From 914c41147ea9281ff1736d8e39f9945434285e58 Mon Sep 17 00:00:00 2001 From: Alex Comba Date: Mon, 27 Mar 2017 17:55:56 +0200 Subject: [PATCH 01/44] [ADD] sale_triple_discount --- sale_triple_discount/README.rst | 60 +++++++++ sale_triple_discount/__init__.py | 1 + sale_triple_discount/__manifest__.py | 25 ++++ sale_triple_discount/i18n/es.po | 48 ++++++++ sale_triple_discount/i18n/it.po | 66 ++++++++++ sale_triple_discount/models/__init__.py | 3 + .../models/account_invoice_line.py | 69 +++++++++++ sale_triple_discount/models/res_partner.py | 13 ++ .../models/sale_order_line.py | 94 ++++++++++++++ .../static/description/icon.png | Bin 0 -> 9455 bytes sale_triple_discount/tests/__init__.py | 1 + .../tests/test_sale_triple_discount.py | 116 ++++++++++++++++++ .../views/account_invoice_view.xml | 36 ++++++ .../views/res_partner_view.xml | 17 +++ .../views/sale_order_view.xml | 28 +++++ 15 files changed, 577 insertions(+) create mode 100644 sale_triple_discount/README.rst create mode 100644 sale_triple_discount/__init__.py create mode 100644 sale_triple_discount/__manifest__.py create mode 100644 sale_triple_discount/i18n/es.po create mode 100644 sale_triple_discount/i18n/it.po create mode 100644 sale_triple_discount/models/__init__.py create mode 100644 sale_triple_discount/models/account_invoice_line.py create mode 100644 sale_triple_discount/models/res_partner.py create mode 100644 sale_triple_discount/models/sale_order_line.py create mode 100644 sale_triple_discount/static/description/icon.png create mode 100644 sale_triple_discount/tests/__init__.py create mode 100644 sale_triple_discount/tests/test_sale_triple_discount.py create mode 100755 sale_triple_discount/views/account_invoice_view.xml create mode 100755 sale_triple_discount/views/res_partner_view.xml create mode 100755 sale_triple_discount/views/sale_order_view.xml diff --git a/sale_triple_discount/README.rst b/sale_triple_discount/README.rst new file mode 100644 index 00000000000..45c978156f0 --- /dev/null +++ b/sale_triple_discount/README.rst @@ -0,0 +1,60 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +==================== +Sale Triple Discount +==================== + +This module allows to manage triple discount on sale order line and on account invoice line. +Three discounts have a default can be defined at partner level. + +Configuration +============= + +To configure this module, you need to: + +* set **Discount on lines** group to be able to see discounts on the lines + +Usage +===== + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/167/10.0 + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smash it by providing detailed and welcomed feedback. + +Credits +======= + +Images +------ + +* Odoo Community Association: `Icon `_. + +Contributors +------------ + +* Alex Comba + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit https://odoo-community.org. diff --git a/sale_triple_discount/__init__.py b/sale_triple_discount/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/sale_triple_discount/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/sale_triple_discount/__manifest__.py b/sale_triple_discount/__manifest__.py new file mode 100644 index 00000000000..f53d973cd9c --- /dev/null +++ b/sale_triple_discount/__manifest__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Copyright 2015 ADHOC SA (http://www.adhoc.com.ar) +# Copyright 2017 Alex Comba - Agile Business Group +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +{ + 'name': 'Sale Triple Discount', + 'version': '10.0.1.0.0', + 'category': 'Sales Management', + 'author': 'ADHOC SA, Agile Business Group, ' + 'Odoo Community Association (OCA)', + 'website': 'www.adhoc.com.ar', + 'license': 'AGPL-3', + 'summary': 'Manage triple discount on sale order lines ' + 'and on invoice lines', + 'depends': [ + 'sale', + 'account' + ], + 'data': [ + 'views/sale_order_view.xml', + 'views/account_invoice_view.xml', + 'views/res_partner_view.xml', + ], + 'installable': True, +} diff --git a/sale_triple_discount/i18n/es.po b/sale_triple_discount/i18n/es.po new file mode 100644 index 00000000000..a9f6d4a6fa8 --- /dev/null +++ b/sale_triple_discount/i18n/es.po @@ -0,0 +1,48 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_three_discounts +# +# Translators: +# Javier Diez , 2016 +# Juan José Scarafía , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-11-11 16:37+0000\n" +"PO-Revision-Date: 2016-11-11 16:37+0000\n" +"Last-Translator: Juan José Scarafía , 2016\n" +"Language-Team: Spanish (https://www.transifex.com/adhoc/teams/46451/es/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: es\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_account_invoice_line_discount1 +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount1 +msgid "Discount 1 (%)" +msgstr "Descuento 1 (%)" + +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_account_invoice_line_discount2 +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount2 +msgid "Discount 2 (%)" +msgstr "Descuento 2 (%)" + +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_account_invoice_line_discount3 +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount3 +msgid "Discount 3 (%)" +msgstr "Descuento 3 (%)" + +#. module: sale_triple_discount +#: model:ir.model,name:sale_triple_discount.model_account_invoice_line +msgid "Invoice Line" +msgstr "Línea de Factura" + +#. module: sale_triple_discount +#: model:ir.model,name:sale_triple_discount.model_sale_order_line +msgid "Sales Order Line" +msgstr "Línea de pedido de venta" diff --git a/sale_triple_discount/i18n/it.po b/sale_triple_discount/i18n/it.po new file mode 100644 index 00000000000..553ba47ee15 --- /dev/null +++ b/sale_triple_discount/i18n/it.po @@ -0,0 +1,66 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_triple_discount +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-03-28 15:17+0000\n" +"PO-Revision-Date: 2017-03-28 17:25+0200\n" +"Last-Translator: Alex Comba \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: \n" +"Language: it\n" +"X-Generator: Poedit 1.8.9\n" + +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_res_partner_default_discount1 +msgid "Default Discount 1 (%)" +msgstr "Default Sc.1 (%)" + +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_res_partner_default_discount2 +msgid "Default Discount 2 (%)" +msgstr "Default Sc.2 (%)" + +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_res_partner_default_discount3 +msgid "Default Discount 3 (%)" +msgstr "Default Sc.3 (%)" + +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_account_invoice_line_discount1 +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount1 +msgid "Discount 1 (%)" +msgstr "Sc.1 (%)" + +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_account_invoice_line_discount2 +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount2 +msgid "Discount 2 (%)" +msgstr "Sc.2 (%)" + +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_account_invoice_line_discount3 +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount3 +msgid "Discount 3 (%)" +msgstr "Sc.3 (%)" + +#. module: sale_triple_discount +#: model:ir.model,name:sale_triple_discount.model_account_invoice_line +msgid "Invoice Line" +msgstr "Riga Fattura" + +#. module: sale_triple_discount +#: model:ir.model,name:sale_triple_discount.model_res_partner +msgid "Partner" +msgstr "Partner" + +#. module: sale_triple_discount +#: model:ir.model,name:sale_triple_discount.model_sale_order_line +msgid "Sales Order Line" +msgstr "Riga d'Ordine di Vendita" diff --git a/sale_triple_discount/models/__init__.py b/sale_triple_discount/models/__init__.py new file mode 100644 index 00000000000..ebc3f2706ee --- /dev/null +++ b/sale_triple_discount/models/__init__.py @@ -0,0 +1,3 @@ +from . import sale_order_line +from . import account_invoice_line +from . import res_partner diff --git a/sale_triple_discount/models/account_invoice_line.py b/sale_triple_discount/models/account_invoice_line.py new file mode 100644 index 00000000000..dd1108de357 --- /dev/null +++ b/sale_triple_discount/models/account_invoice_line.py @@ -0,0 +1,69 @@ +# -*- coding: utf-8 -*- +# Copyright 2015 ADHOC SA (http://www.adhoc.com.ar) +# Copyright 2017 Alex Comba - Agile Business Group +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models +import openerp.addons.decimal_precision as dp + + +class AccountInvoiceLine(models.Model): + _inherit = "account.invoice.line" + + @api.model + def _default_discount1(self): + default_discount1 = 0.0 + partner_id = self.env.context.get('partner_id', False) + if partner_id: + partner = self.env['res.partner'].browse(partner_id) + default_discount1 = partner.default_discount1 + return default_discount1 + + @api.model + def _default_discount2(self): + default_discount2 = 0.0 + partner_id = self.env.context.get('partner_id', False) + if partner_id: + partner = self.env['res.partner'].browse(partner_id) + default_discount2 = partner.default_discount2 + return default_discount2 + + @api.model + def _default_discount3(self): + default_discount3 = 0.0 + partner_id = self.env.context.get('partner_id', False) + if partner_id: + partner = self.env['res.partner'].browse(partner_id) + default_discount3 = partner.default_discount3 + return default_discount3 + + discount1 = fields.Float( + 'Discount 1 (%)', + digits=dp.get_precision('Discount'), + default=_default_discount1, + ) + discount2 = fields.Float( + 'Discount 2 (%)', + digits=dp.get_precision('Discount'), + default=_default_discount2, + ) + discount3 = fields.Float( + 'Discount 3 (%)', + digits=dp.get_precision('Discount'), + default=_default_discount3, + ) + discount = fields.Float( + compute='get_discount', + store=True, + readonly=True, + ) + + @api.multi + @api.depends('discount1', 'discount2', 'discount3') + def get_discount(self): + for line in self: + discount_factor = 1.0 + for discount in [line.discount1, line.discount2, line.discount3]: + discount_factor = ( + discount_factor * ((100.0 - discount) / 100.0)) + line.discount = 100.0 - (discount_factor * 100.0) diff --git a/sale_triple_discount/models/res_partner.py b/sale_triple_discount/models/res_partner.py new file mode 100644 index 00000000000..d962d199d02 --- /dev/null +++ b/sale_triple_discount/models/res_partner.py @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 Alex Comba - Agile Business Group +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class ResPartner(models.Model): + _inherit = "res.partner" + + default_discount1 = fields.Float('Default Discount 1 (%)') + default_discount2 = fields.Float('Default Discount 2 (%)') + default_discount3 = fields.Float('Default Discount 3 (%)') diff --git a/sale_triple_discount/models/sale_order_line.py b/sale_triple_discount/models/sale_order_line.py new file mode 100644 index 00000000000..6767f3ae0f0 --- /dev/null +++ b/sale_triple_discount/models/sale_order_line.py @@ -0,0 +1,94 @@ +# -*- coding: utf-8 -*- +# Copyright 2015 ADHOC SA (http://www.adhoc.com.ar) +# Copyright 2017 Alex Comba - Agile Business Group +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models +import openerp.addons.decimal_precision as dp + + +class SaleOrderLine(models.Model): + _inherit = "sale.order.line" + + @api.model + def _default_discount1(self): + default_discount1 = 0.0 + partner_id = self.env.context.get('partner_id', False) + if partner_id: + partner = self.env['res.partner'].browse(partner_id) + default_discount1 = partner.default_discount1 + return default_discount1 + + @api.model + def _default_discount2(self): + default_discount2 = 0.0 + partner_id = self.env.context.get('partner_id', False) + if partner_id: + partner = self.env['res.partner'].browse(partner_id) + default_discount2 = partner.default_discount2 + return default_discount2 + + @api.model + def _default_discount3(self): + default_discount3 = 0.0 + partner_id = self.env.context.get('partner_id', False) + if partner_id: + partner = self.env['res.partner'].browse(partner_id) + default_discount3 = partner.default_discount3 + return default_discount3 + + discount1 = fields.Float( + 'Discount 1 (%)', + digits=dp.get_precision('Discount'), + readonly=True, + default=_default_discount1, + states={'draft': [('readonly', False)], 'sent': [('readonly', False)]} + ) + discount2 = fields.Float( + 'Discount 2 (%)', + digits=dp.get_precision('Discount'), + readonly=True, + default=_default_discount2, + states={'draft': [('readonly', False)], 'sent': [('readonly', False)]} + ) + discount3 = fields.Float( + 'Discount 3 (%)', + digits=dp.get_precision('Discount'), + readonly=True, + default=_default_discount3, + states={'draft': [('readonly', False)], 'sent': [('readonly', False)]} + ) + discount = fields.Float(compute='get_discount', store=True) + + @api.multi + @api.depends('discount1', 'discount2', 'discount3') + def get_discount(self): + for line in self: + discount_factor = 1.0 + for discount in [line.discount1, line.discount2, line.discount3]: + discount_factor = ( + discount_factor * ((100.0 - discount) / 100.0)) + line.discount = 100.0 - (discount_factor * 100.0) + + @api.onchange( + 'product_id', 'price_unit', 'product_uom', 'product_uom_qty', 'tax_id') + def _onchange_discount(self): + super(SaleOrderLine, self)._onchange_discount() + if self.discount != 0: + # to keep discount value calculated by pricelist + self.discount1 = self.discount + self.discount2 = 0 + self.discount3 = 0 + else: + # to recalculate discount value based on three discounts + # when these latter are filled by their default + self.get_discount() + + @api.multi + def _prepare_invoice_line(self, qty): + res = super(SaleOrderLine, self)._prepare_invoice_line(qty) + res.update({ + 'discount1': self.discount1, + 'discount2': self.discount2, + 'discount3': self.discount3}) + return res diff --git a/sale_triple_discount/static/description/icon.png b/sale_triple_discount/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..3a0328b516c4980e8e44cdb63fd945757ddd132d GIT binary patch literal 9455 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 z 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 Xviia!U7SGha1wx#SCgwmn*{w2TRX*I literal 0 HcmV?d00001 diff --git a/sale_triple_discount/tests/__init__.py b/sale_triple_discount/tests/__init__.py new file mode 100644 index 00000000000..8bbc8f82f0a --- /dev/null +++ b/sale_triple_discount/tests/__init__.py @@ -0,0 +1 @@ +from . import test_sale_triple_discount diff --git a/sale_triple_discount/tests/test_sale_triple_discount.py b/sale_triple_discount/tests/test_sale_triple_discount.py new file mode 100644 index 00000000000..2f1a2c6ab0c --- /dev/null +++ b/sale_triple_discount/tests/test_sale_triple_discount.py @@ -0,0 +1,116 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 Alex Comba - Agile Business Group +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.tests.common import TransactionCase + + +class TestSaleTripleDiscount(TransactionCase): + + def create_sale_order(self): + self.so_model = self.env['sale.order'] + self.so_line_model = self.env['sale.order.line'] + self.so = self.so_model.create({ + 'partner_id': self.customer.id}) + # pass customer by context + self.so_line = self.so_line_model.with_context( + partner_id=self.customer.id).create({ + 'name': '/', + 'order_id': self.so.id, + 'product_id': self.product.id}) + + def create_invoice(self): + self.inv_model = self.env['account.invoice'] + self.inv_line_model = self.env['account.invoice.line'] + inv = self.inv_model.create({ + 'name': "Test Customer Invoice", + 'journal_id': self.env['account.journal'].search( + [('type', '=', 'sale')])[0].id, + 'partner_id': self.customer.id, + 'account_id': self.env['account.account'].search( + [('user_type_id', '=', self.env.ref( + 'account.data_account_type_receivable').id)], + limit=1).id, + }) + # pass customer by context + self.inv_line_model.with_context( + partner_id=self.customer.id).create({ + 'name': '/', + 'invoice_id': inv.id, + 'product_id': self.product.id, + 'quantity': 1.0, + 'account_id': self.env['account.account'].search( + [('user_type_id', '=', self.env.ref( + 'account.data_account_type_revenue').id)], + limit=1).id, + 'price_unit': 450.00, + }) + return inv + + def setUp(self): + super(TestSaleTripleDiscount, self).setUp() + self.inv_model = self.env['account.invoice'] + self.inv_line_model = self.env['account.invoice.line'] + self.customer = self.env.ref('base.res_partner_2') + self.product = self.env.ref('product.product_product_3') + self.product.invoice_policy = 'order' + self.customer.default_discount1 = 20.0 + self.customer.default_discount2 = 10.0 + self.customer.default_discount3 = 5.0 + + def test_so_line_default_discount(self): + self.create_sale_order() + self.assertEqual( + self.so_line.discount1, self.customer.default_discount1) + self.assertEqual( + self.so_line.discount2, self.customer.default_discount2) + self.assertEqual( + self.so_line.discount3, self.customer.default_discount3) + + def test_so_line_get_discount(self): + self.create_sale_order() + self.assertEqual(self.so_line.discount, 31.6) + + def test_so_line_onchange_discount(self): + self.create_sale_order() + self.so_line.discount1 = 10.0 + self.so_line.discount2 = 5.0 + self.so_line.discount1 = 2.0 + self.so_line._onchange_discount() + self.assertEqual(self.so_line.discount, 11.56) + + def test_so_line_prepare_invoice_line(self): + self.create_sale_order() + self.so.action_confirm() + inv_id = self.so.action_invoice_create() + self.assertEqual( + self.so.invoice_status, + 'invoiced', + 'SO invoice_status should be "invoiced" instead of "%s" ' + 'after invoicing' % self.so.invoice_status) + self.assertEqual(len(inv_id), 1) + inv = self.env['account.invoice'].browse(inv_id) + self.assertEqual(len(inv.invoice_line_ids), 1) + inv_line = inv.invoice_line_ids[0] + self.assertEqual( + inv_line.discount1, self.so_line.discount1) + self.assertEqual( + inv_line.discount2, self.so_line.discount2) + self.assertEqual( + inv_line.discount3, self.so_line.discount3) + self.assertEqual(inv_line.discount, 31.6) + + def test_inv_line_default_discount(self): + inv = self.create_invoice() + inv_line = inv.invoice_line_ids[0] + self.assertEqual( + inv_line.discount1, self.customer.default_discount1) + self.assertEqual( + inv_line.discount2, self.customer.default_discount2) + self.assertEqual( + inv_line.discount3, self.customer.default_discount3) + + def test_inv_line_get_discount(self): + inv = self.create_invoice() + inv_line = inv.invoice_line_ids[0] + self.assertEqual(inv_line.discount, 31.6) diff --git a/sale_triple_discount/views/account_invoice_view.xml b/sale_triple_discount/views/account_invoice_view.xml new file mode 100755 index 00000000000..e3cd835f0de --- /dev/null +++ b/sale_triple_discount/views/account_invoice_view.xml @@ -0,0 +1,36 @@ + + + + + account.invoice.triple.discount.form + account.invoice + + + + {'partner_id': partner_id} + + + True + + + + + + + + + + + account.invoice.line.triple.discount.form + account.invoice.line + + + + + + + + + + + diff --git a/sale_triple_discount/views/res_partner_view.xml b/sale_triple_discount/views/res_partner_view.xml new file mode 100755 index 00000000000..da5fde5c7b1 --- /dev/null +++ b/sale_triple_discount/views/res_partner_view.xml @@ -0,0 +1,17 @@ + + + + + partner.triple.discount.form + res.partner + + + + + + + + + + + diff --git a/sale_triple_discount/views/sale_order_view.xml b/sale_triple_discount/views/sale_order_view.xml new file mode 100755 index 00000000000..92f28b242e8 --- /dev/null +++ b/sale_triple_discount/views/sale_order_view.xml @@ -0,0 +1,28 @@ + + + + + sale.order.triple.discount.form + sale.order + + + + {'partner_id': partner_id} + + + True + + + + + + + + + + + + + + + From beb7025ebee0e12b273957936a49ebc863c5b677 Mon Sep 17 00:00:00 2001 From: David Vidal Date: Thu, 7 Sep 2017 11:44:55 +0200 Subject: [PATCH 02/44] [MIG] sale_triple_discount: Migration to 10.0 OCA Transbot updated translations from Transifex [UPD] Update sale_triple_discount.pot --- sale_triple_discount/README.rst | 25 ++- sale_triple_discount/__init__.py | 2 + sale_triple_discount/__manifest__.py | 15 +- sale_triple_discount/i18n/ca.po | 44 ++++ sale_triple_discount/i18n/de.po | 44 ++++ sale_triple_discount/i18n/es.po | 46 ++-- sale_triple_discount/i18n/es_VE.po | 45 ++++ sale_triple_discount/i18n/fr.po | 44 ++++ sale_triple_discount/i18n/hr.po | 45 ++++ sale_triple_discount/i18n/it.po | 64 ++---- sale_triple_discount/i18n/nl_NL.po | 45 ++++ sale_triple_discount/i18n/pt_BR.po | 45 ++++ sale_triple_discount/i18n/ro.po | 45 ++++ .../i18n/sale_triple_discount.pot | 40 ++++ sale_triple_discount/i18n/sl.po | 45 ++++ sale_triple_discount/i18n/tr.po | 44 ++++ sale_triple_discount/i18n/tr_TR.po | 45 ++++ sale_triple_discount/models/__init__.py | 4 +- .../models/account_invoice_line.py | 69 ------ sale_triple_discount/models/res_partner.py | 13 -- .../models/sale_order_line.py | 109 ++++----- sale_triple_discount/tests/__init__.py | 2 + .../tests/test_sale_triple_discount.py | 207 +++++++++--------- .../views/account_invoice_view.xml | 36 --- .../views/res_partner_view.xml | 17 -- .../views/sale_order_view.xml | 30 +-- 26 files changed, 768 insertions(+), 402 deletions(-) create mode 100644 sale_triple_discount/i18n/ca.po create mode 100644 sale_triple_discount/i18n/de.po create mode 100644 sale_triple_discount/i18n/es_VE.po create mode 100644 sale_triple_discount/i18n/fr.po create mode 100644 sale_triple_discount/i18n/hr.po create mode 100644 sale_triple_discount/i18n/nl_NL.po create mode 100644 sale_triple_discount/i18n/pt_BR.po create mode 100644 sale_triple_discount/i18n/ro.po create mode 100644 sale_triple_discount/i18n/sale_triple_discount.pot create mode 100644 sale_triple_discount/i18n/sl.po create mode 100644 sale_triple_discount/i18n/tr.po create mode 100644 sale_triple_discount/i18n/tr_TR.po delete mode 100644 sale_triple_discount/models/account_invoice_line.py delete mode 100644 sale_triple_discount/models/res_partner.py delete mode 100755 sale_triple_discount/views/account_invoice_view.xml delete mode 100755 sale_triple_discount/views/res_partner_view.xml diff --git a/sale_triple_discount/README.rst b/sale_triple_discount/README.rst index 45c978156f0..8e91cb180d6 100644 --- a/sale_triple_discount/README.rst +++ b/sale_triple_discount/README.rst @@ -6,8 +6,8 @@ Sale Triple Discount ==================== -This module allows to manage triple discount on sale order line and on account invoice line. -Three discounts have a default can be defined at partner level. +This module allows to have three successive discounts on every sale order +line. Configuration ============= @@ -19,6 +19,24 @@ To configure this module, you need to: Usage ===== +Create a new sale order and add discounts in any of the three discount +fields given. They go in order of precedence so discount 2 will be calculated +over discount 1 and discount 3 over the result of discount 2. For example, +let's divide by two on every discount: + +Unit price: 600.00 -> + + - Disc. 1 = 50% -> Amount = 300.00 + - Disc. 2 = 50% -> Amount = 150.00 + - Disc. 3 = 50% -> Amount = 75.00 + +You can also use negative values to make a charge instead of a discount: + +Unit price: 600.00 -> + + - Disc. 1 = 50% -> Amount = 300.00 + - Disc. 2 = -5% -> Amount = 315.00 + .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot :target: https://runbot.odoo-community.org/runbot/167/10.0 @@ -42,7 +60,10 @@ Images Contributors ------------ +* Nicolas Mac Rouillon <@nicomacr> +* Juan José Scarafía * Alex Comba +* David Vidal Maintainer ---------- diff --git a/sale_triple_discount/__init__.py b/sale_triple_discount/__init__.py index 0650744f6bc..cde864bae21 100644 --- a/sale_triple_discount/__init__.py +++ b/sale_triple_discount/__init__.py @@ -1 +1,3 @@ +# -*- coding: utf-8 -*- + from . import models diff --git a/sale_triple_discount/__manifest__.py b/sale_triple_discount/__manifest__.py index f53d973cd9c..b787e00b0f9 100644 --- a/sale_triple_discount/__manifest__.py +++ b/sale_triple_discount/__manifest__.py @@ -1,25 +1,26 @@ # -*- coding: utf-8 -*- # Copyright 2015 ADHOC SA (http://www.adhoc.com.ar) # Copyright 2017 Alex Comba - Agile Business Group +# Copyright 2017 Tecnativa - David Vidal # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + { 'name': 'Sale Triple Discount', 'version': '10.0.1.0.0', 'category': 'Sales Management', - 'author': 'ADHOC SA, Agile Business Group, ' + 'author': 'ADHOC SA, ' + 'Agile Business Group, ' + 'Tecnativa, ' 'Odoo Community Association (OCA)', - 'website': 'www.adhoc.com.ar', + 'website': 'https://odoo-community.org', 'license': 'AGPL-3', - 'summary': 'Manage triple discount on sale order lines ' - 'and on invoice lines', + 'summary': 'Manage triple discount on sale order lines', 'depends': [ 'sale', - 'account' + 'account_invoice_triple_discount', ], 'data': [ 'views/sale_order_view.xml', - 'views/account_invoice_view.xml', - 'views/res_partner_view.xml', ], 'installable': True, } diff --git a/sale_triple_discount/i18n/ca.po b/sale_triple_discount/i18n/ca.po new file mode 100644 index 00000000000..7b228777745 --- /dev/null +++ b/sale_triple_discount/i18n/ca.po @@ -0,0 +1,44 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_triple_discount +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-11-23 01:52+0000\n" +"PO-Revision-Date: 2017-11-23 01:52+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Catalan (https://www.transifex.com/oca/teams/23907/ca/)\n" +"Language: ca\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount2 +msgid "Disc. 2 (%)" +msgstr "" + +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount3 +msgid "Disc. 3 (%)" +msgstr "" + +#. module: sale_triple_discount +#: sql_constraint:sale.order.line:0 +msgid "Discount 2 must be lower than 100%." +msgstr "" + +#. module: sale_triple_discount +#: sql_constraint:sale.order.line:0 +msgid "Discount 3 must be lower than 100%." +msgstr "" + +#. module: sale_triple_discount +#: model:ir.model,name:sale_triple_discount.model_sale_order_line +msgid "Sales Order Line" +msgstr "Línia de comanda de vendes" diff --git a/sale_triple_discount/i18n/de.po b/sale_triple_discount/i18n/de.po new file mode 100644 index 00000000000..7f5c6422e0e --- /dev/null +++ b/sale_triple_discount/i18n/de.po @@ -0,0 +1,44 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_triple_discount +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-11-23 01:52+0000\n" +"PO-Revision-Date: 2017-11-23 01:52+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: German (https://www.transifex.com/oca/teams/23907/de/)\n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount2 +msgid "Disc. 2 (%)" +msgstr "" + +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount3 +msgid "Disc. 3 (%)" +msgstr "" + +#. module: sale_triple_discount +#: sql_constraint:sale.order.line:0 +msgid "Discount 2 must be lower than 100%." +msgstr "" + +#. module: sale_triple_discount +#: sql_constraint:sale.order.line:0 +msgid "Discount 3 must be lower than 100%." +msgstr "" + +#. module: sale_triple_discount +#: model:ir.model,name:sale_triple_discount.model_sale_order_line +msgid "Sales Order Line" +msgstr "Auftragsposition" diff --git a/sale_triple_discount/i18n/es.po b/sale_triple_discount/i18n/es.po index a9f6d4a6fa8..f78a5e41094 100644 --- a/sale_triple_discount/i18n/es.po +++ b/sale_triple_discount/i18n/es.po @@ -1,46 +1,42 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * sale_three_discounts -# +# * sale_triple_discount +# # Translators: -# Javier Diez , 2016 -# Juan José Scarafía , 2016 +# OCA Transbot , 2017 msgid "" msgstr "" -"Project-Id-Version: Odoo Server 9.0c\n" +"Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-11-11 16:37+0000\n" -"PO-Revision-Date: 2016-11-11 16:37+0000\n" -"Last-Translator: Juan José Scarafía , 2016\n" -"Language-Team: Spanish (https://www.transifex.com/adhoc/teams/46451/es/)\n" +"POT-Creation-Date: 2017-11-23 01:52+0000\n" +"PO-Revision-Date: 2017-11-23 01:52+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n" +"Language: es\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Language: es\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #. module: sale_triple_discount -#: model:ir.model.fields,field_description:sale_triple_discount.field_account_invoice_line_discount1 -#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount1 -msgid "Discount 1 (%)" -msgstr "Descuento 1 (%)" - -#. module: sale_triple_discount -#: model:ir.model.fields,field_description:sale_triple_discount.field_account_invoice_line_discount2 #: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount2 -msgid "Discount 2 (%)" -msgstr "Descuento 2 (%)" +msgid "Disc. 2 (%)" +msgstr "" #. module: sale_triple_discount -#: model:ir.model.fields,field_description:sale_triple_discount.field_account_invoice_line_discount3 #: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount3 -msgid "Discount 3 (%)" -msgstr "Descuento 3 (%)" +msgid "Disc. 3 (%)" +msgstr "" #. module: sale_triple_discount -#: model:ir.model,name:sale_triple_discount.model_account_invoice_line -msgid "Invoice Line" -msgstr "Línea de Factura" +#: sql_constraint:sale.order.line:0 +msgid "Discount 2 must be lower than 100%." +msgstr "" + +#. module: sale_triple_discount +#: sql_constraint:sale.order.line:0 +msgid "Discount 3 must be lower than 100%." +msgstr "" #. module: sale_triple_discount #: model:ir.model,name:sale_triple_discount.model_sale_order_line diff --git a/sale_triple_discount/i18n/es_VE.po b/sale_triple_discount/i18n/es_VE.po new file mode 100644 index 00000000000..52221356365 --- /dev/null +++ b/sale_triple_discount/i18n/es_VE.po @@ -0,0 +1,45 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_triple_discount +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-11-23 01:52+0000\n" +"PO-Revision-Date: 2017-11-23 01:52+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Spanish (Venezuela) (https://www.transifex.com/oca/" +"teams/23907/es_VE/)\n" +"Language: es_VE\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount2 +msgid "Disc. 2 (%)" +msgstr "" + +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount3 +msgid "Disc. 3 (%)" +msgstr "" + +#. module: sale_triple_discount +#: sql_constraint:sale.order.line:0 +msgid "Discount 2 must be lower than 100%." +msgstr "" + +#. module: sale_triple_discount +#: sql_constraint:sale.order.line:0 +msgid "Discount 3 must be lower than 100%." +msgstr "" + +#. module: sale_triple_discount +#: model:ir.model,name:sale_triple_discount.model_sale_order_line +msgid "Sales Order Line" +msgstr "Línea de pedido de venta" diff --git a/sale_triple_discount/i18n/fr.po b/sale_triple_discount/i18n/fr.po new file mode 100644 index 00000000000..7b881fc7c1f --- /dev/null +++ b/sale_triple_discount/i18n/fr.po @@ -0,0 +1,44 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_triple_discount +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-11-23 01:52+0000\n" +"PO-Revision-Date: 2017-11-23 01:52+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount2 +msgid "Disc. 2 (%)" +msgstr "" + +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount3 +msgid "Disc. 3 (%)" +msgstr "" + +#. module: sale_triple_discount +#: sql_constraint:sale.order.line:0 +msgid "Discount 2 must be lower than 100%." +msgstr "" + +#. module: sale_triple_discount +#: sql_constraint:sale.order.line:0 +msgid "Discount 3 must be lower than 100%." +msgstr "" + +#. module: sale_triple_discount +#: model:ir.model,name:sale_triple_discount.model_sale_order_line +msgid "Sales Order Line" +msgstr "Sales Order Line" diff --git a/sale_triple_discount/i18n/hr.po b/sale_triple_discount/i18n/hr.po new file mode 100644 index 00000000000..dd0b22d32d8 --- /dev/null +++ b/sale_triple_discount/i18n/hr.po @@ -0,0 +1,45 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_triple_discount +# +# Translators: +# Bole , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-11-23 01:52+0000\n" +"PO-Revision-Date: 2017-11-23 01:52+0000\n" +"Last-Translator: Bole , 2017\n" +"Language-Team: Croatian (https://www.transifex.com/oca/teams/23907/hr/)\n" +"Language: hr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" +"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" + +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount2 +msgid "Disc. 2 (%)" +msgstr "" + +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount3 +msgid "Disc. 3 (%)" +msgstr "" + +#. module: sale_triple_discount +#: sql_constraint:sale.order.line:0 +msgid "Discount 2 must be lower than 100%." +msgstr "" + +#. module: sale_triple_discount +#: sql_constraint:sale.order.line:0 +msgid "Discount 3 must be lower than 100%." +msgstr "" + +#. module: sale_triple_discount +#: model:ir.model,name:sale_triple_discount.model_sale_order_line +msgid "Sales Order Line" +msgstr "Stavka ponude" diff --git a/sale_triple_discount/i18n/it.po b/sale_triple_discount/i18n/it.po index 553ba47ee15..13f57de3f0b 100644 --- a/sale_triple_discount/i18n/it.po +++ b/sale_triple_discount/i18n/it.po @@ -1,66 +1,44 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * sale_triple_discount +# * sale_triple_discount # +# Translators: +# OCA Transbot , 2017 msgid "" msgstr "" "Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-03-28 15:17+0000\n" -"PO-Revision-Date: 2017-03-28 17:25+0200\n" -"Last-Translator: Alex Comba \n" -"Language-Team: \n" +"POT-Creation-Date: 2017-11-23 01:52+0000\n" +"PO-Revision-Date: 2017-11-23 01:52+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Italian (https://www.transifex.com/oca/teams/23907/it/)\n" +"Language: it\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: \n" -"Language: it\n" -"X-Generator: Poedit 1.8.9\n" - -#. module: sale_triple_discount -#: model:ir.model.fields,field_description:sale_triple_discount.field_res_partner_default_discount1 -msgid "Default Discount 1 (%)" -msgstr "Default Sc.1 (%)" - -#. module: sale_triple_discount -#: model:ir.model.fields,field_description:sale_triple_discount.field_res_partner_default_discount2 -msgid "Default Discount 2 (%)" -msgstr "Default Sc.2 (%)" - -#. module: sale_triple_discount -#: model:ir.model.fields,field_description:sale_triple_discount.field_res_partner_default_discount3 -msgid "Default Discount 3 (%)" -msgstr "Default Sc.3 (%)" - -#. module: sale_triple_discount -#: model:ir.model.fields,field_description:sale_triple_discount.field_account_invoice_line_discount1 -#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount1 -msgid "Discount 1 (%)" -msgstr "Sc.1 (%)" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" #. module: sale_triple_discount -#: model:ir.model.fields,field_description:sale_triple_discount.field_account_invoice_line_discount2 #: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount2 -msgid "Discount 2 (%)" -msgstr "Sc.2 (%)" +msgid "Disc. 2 (%)" +msgstr "" #. module: sale_triple_discount -#: model:ir.model.fields,field_description:sale_triple_discount.field_account_invoice_line_discount3 #: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount3 -msgid "Discount 3 (%)" -msgstr "Sc.3 (%)" +msgid "Disc. 3 (%)" +msgstr "" #. module: sale_triple_discount -#: model:ir.model,name:sale_triple_discount.model_account_invoice_line -msgid "Invoice Line" -msgstr "Riga Fattura" +#: sql_constraint:sale.order.line:0 +msgid "Discount 2 must be lower than 100%." +msgstr "" #. module: sale_triple_discount -#: model:ir.model,name:sale_triple_discount.model_res_partner -msgid "Partner" -msgstr "Partner" +#: sql_constraint:sale.order.line:0 +msgid "Discount 3 must be lower than 100%." +msgstr "" #. module: sale_triple_discount #: model:ir.model,name:sale_triple_discount.model_sale_order_line msgid "Sales Order Line" -msgstr "Riga d'Ordine di Vendita" +msgstr "Linea d'ordine di vendita" diff --git a/sale_triple_discount/i18n/nl_NL.po b/sale_triple_discount/i18n/nl_NL.po new file mode 100644 index 00000000000..427d4b818fc --- /dev/null +++ b/sale_triple_discount/i18n/nl_NL.po @@ -0,0 +1,45 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_triple_discount +# +# Translators: +# Peter Hageman , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-11-23 01:52+0000\n" +"PO-Revision-Date: 2017-11-23 01:52+0000\n" +"Last-Translator: Peter Hageman , 2017\n" +"Language-Team: Dutch (Netherlands) (https://www.transifex.com/oca/" +"teams/23907/nl_NL/)\n" +"Language: nl_NL\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount2 +msgid "Disc. 2 (%)" +msgstr "" + +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount3 +msgid "Disc. 3 (%)" +msgstr "" + +#. module: sale_triple_discount +#: sql_constraint:sale.order.line:0 +msgid "Discount 2 must be lower than 100%." +msgstr "" + +#. module: sale_triple_discount +#: sql_constraint:sale.order.line:0 +msgid "Discount 3 must be lower than 100%." +msgstr "" + +#. module: sale_triple_discount +#: model:ir.model,name:sale_triple_discount.model_sale_order_line +msgid "Sales Order Line" +msgstr "Verkooporderregel" diff --git a/sale_triple_discount/i18n/pt_BR.po b/sale_triple_discount/i18n/pt_BR.po new file mode 100644 index 00000000000..31d471c3f1e --- /dev/null +++ b/sale_triple_discount/i18n/pt_BR.po @@ -0,0 +1,45 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_triple_discount +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-11-23 01:52+0000\n" +"PO-Revision-Date: 2017-11-23 01:52+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Portuguese (Brazil) (https://www.transifex.com/oca/" +"teams/23907/pt_BR/)\n" +"Language: pt_BR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount2 +msgid "Disc. 2 (%)" +msgstr "" + +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount3 +msgid "Disc. 3 (%)" +msgstr "" + +#. module: sale_triple_discount +#: sql_constraint:sale.order.line:0 +msgid "Discount 2 must be lower than 100%." +msgstr "" + +#. module: sale_triple_discount +#: sql_constraint:sale.order.line:0 +msgid "Discount 3 must be lower than 100%." +msgstr "" + +#. module: sale_triple_discount +#: model:ir.model,name:sale_triple_discount.model_sale_order_line +msgid "Sales Order Line" +msgstr "Linha Pedido de Venda" diff --git a/sale_triple_discount/i18n/ro.po b/sale_triple_discount/i18n/ro.po new file mode 100644 index 00000000000..263d4f38191 --- /dev/null +++ b/sale_triple_discount/i18n/ro.po @@ -0,0 +1,45 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_triple_discount +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-11-23 01:52+0000\n" +"PO-Revision-Date: 2017-11-23 01:52+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Romanian (https://www.transifex.com/oca/teams/23907/ro/)\n" +"Language: ro\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=3; plural=(n==1?0:(((n%100>19)||((n%100==0)&&(n!=0)))?" +"2:1));\n" + +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount2 +msgid "Disc. 2 (%)" +msgstr "" + +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount3 +msgid "Disc. 3 (%)" +msgstr "" + +#. module: sale_triple_discount +#: sql_constraint:sale.order.line:0 +msgid "Discount 2 must be lower than 100%." +msgstr "" + +#. module: sale_triple_discount +#: sql_constraint:sale.order.line:0 +msgid "Discount 3 must be lower than 100%." +msgstr "" + +#. module: sale_triple_discount +#: model:ir.model,name:sale_triple_discount.model_sale_order_line +msgid "Sales Order Line" +msgstr "Linie comandă vânzare" diff --git a/sale_triple_discount/i18n/sale_triple_discount.pot b/sale_triple_discount/i18n/sale_triple_discount.pot new file mode 100644 index 00000000000..0fe744d4291 --- /dev/null +++ b/sale_triple_discount/i18n/sale_triple_discount.pot @@ -0,0 +1,40 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_triple_discount +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount2 +msgid "Disc. 2 (%)" +msgstr "" + +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount3 +msgid "Disc. 3 (%)" +msgstr "" + +#. module: sale_triple_discount +#: sql_constraint:sale.order.line:0 +msgid "Discount 2 must be lower than 100%." +msgstr "" + +#. module: sale_triple_discount +#: sql_constraint:sale.order.line:0 +msgid "Discount 3 must be lower than 100%." +msgstr "" + +#. module: sale_triple_discount +#: model:ir.model,name:sale_triple_discount.model_sale_order_line +msgid "Sales Order Line" +msgstr "" + diff --git a/sale_triple_discount/i18n/sl.po b/sale_triple_discount/i18n/sl.po new file mode 100644 index 00000000000..730742ac9a6 --- /dev/null +++ b/sale_triple_discount/i18n/sl.po @@ -0,0 +1,45 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_triple_discount +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-11-23 01:52+0000\n" +"PO-Revision-Date: 2017-11-23 01:52+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Slovenian (https://www.transifex.com/oca/teams/23907/sl/)\n" +"Language: sl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n" +"%100==4 ? 2 : 3);\n" + +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount2 +msgid "Disc. 2 (%)" +msgstr "" + +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount3 +msgid "Disc. 3 (%)" +msgstr "" + +#. module: sale_triple_discount +#: sql_constraint:sale.order.line:0 +msgid "Discount 2 must be lower than 100%." +msgstr "" + +#. module: sale_triple_discount +#: sql_constraint:sale.order.line:0 +msgid "Discount 3 must be lower than 100%." +msgstr "" + +#. module: sale_triple_discount +#: model:ir.model,name:sale_triple_discount.model_sale_order_line +msgid "Sales Order Line" +msgstr "Postavka prodajnega naloga" diff --git a/sale_triple_discount/i18n/tr.po b/sale_triple_discount/i18n/tr.po new file mode 100644 index 00000000000..14aa7c17ffa --- /dev/null +++ b/sale_triple_discount/i18n/tr.po @@ -0,0 +1,44 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_triple_discount +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-11-23 01:52+0000\n" +"PO-Revision-Date: 2017-11-23 01:52+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Turkish (https://www.transifex.com/oca/teams/23907/tr/)\n" +"Language: tr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount2 +msgid "Disc. 2 (%)" +msgstr "" + +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount3 +msgid "Disc. 3 (%)" +msgstr "" + +#. module: sale_triple_discount +#: sql_constraint:sale.order.line:0 +msgid "Discount 2 must be lower than 100%." +msgstr "" + +#. module: sale_triple_discount +#: sql_constraint:sale.order.line:0 +msgid "Discount 3 must be lower than 100%." +msgstr "" + +#. module: sale_triple_discount +#: model:ir.model,name:sale_triple_discount.model_sale_order_line +msgid "Sales Order Line" +msgstr "Satış Siparişi Hattı" diff --git a/sale_triple_discount/i18n/tr_TR.po b/sale_triple_discount/i18n/tr_TR.po new file mode 100644 index 00000000000..3094ab85008 --- /dev/null +++ b/sale_triple_discount/i18n/tr_TR.po @@ -0,0 +1,45 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_triple_discount +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-11-23 01:52+0000\n" +"PO-Revision-Date: 2017-11-23 01:52+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Turkish (Turkey) (https://www.transifex.com/oca/teams/23907/" +"tr_TR/)\n" +"Language: tr_TR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=1; plural=0;\n" + +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount2 +msgid "Disc. 2 (%)" +msgstr "" + +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount3 +msgid "Disc. 3 (%)" +msgstr "" + +#. module: sale_triple_discount +#: sql_constraint:sale.order.line:0 +msgid "Discount 2 must be lower than 100%." +msgstr "" + +#. module: sale_triple_discount +#: sql_constraint:sale.order.line:0 +msgid "Discount 3 must be lower than 100%." +msgstr "" + +#. module: sale_triple_discount +#: model:ir.model,name:sale_triple_discount.model_sale_order_line +msgid "Sales Order Line" +msgstr "Sipariş emri satırı " diff --git a/sale_triple_discount/models/__init__.py b/sale_triple_discount/models/__init__.py index ebc3f2706ee..5be03b1fe1b 100644 --- a/sale_triple_discount/models/__init__.py +++ b/sale_triple_discount/models/__init__.py @@ -1,3 +1,3 @@ +# -*- coding: utf-8 -*- + from . import sale_order_line -from . import account_invoice_line -from . import res_partner diff --git a/sale_triple_discount/models/account_invoice_line.py b/sale_triple_discount/models/account_invoice_line.py deleted file mode 100644 index dd1108de357..00000000000 --- a/sale_triple_discount/models/account_invoice_line.py +++ /dev/null @@ -1,69 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2015 ADHOC SA (http://www.adhoc.com.ar) -# Copyright 2017 Alex Comba - Agile Business Group -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -from odoo import api, fields, models -import openerp.addons.decimal_precision as dp - - -class AccountInvoiceLine(models.Model): - _inherit = "account.invoice.line" - - @api.model - def _default_discount1(self): - default_discount1 = 0.0 - partner_id = self.env.context.get('partner_id', False) - if partner_id: - partner = self.env['res.partner'].browse(partner_id) - default_discount1 = partner.default_discount1 - return default_discount1 - - @api.model - def _default_discount2(self): - default_discount2 = 0.0 - partner_id = self.env.context.get('partner_id', False) - if partner_id: - partner = self.env['res.partner'].browse(partner_id) - default_discount2 = partner.default_discount2 - return default_discount2 - - @api.model - def _default_discount3(self): - default_discount3 = 0.0 - partner_id = self.env.context.get('partner_id', False) - if partner_id: - partner = self.env['res.partner'].browse(partner_id) - default_discount3 = partner.default_discount3 - return default_discount3 - - discount1 = fields.Float( - 'Discount 1 (%)', - digits=dp.get_precision('Discount'), - default=_default_discount1, - ) - discount2 = fields.Float( - 'Discount 2 (%)', - digits=dp.get_precision('Discount'), - default=_default_discount2, - ) - discount3 = fields.Float( - 'Discount 3 (%)', - digits=dp.get_precision('Discount'), - default=_default_discount3, - ) - discount = fields.Float( - compute='get_discount', - store=True, - readonly=True, - ) - - @api.multi - @api.depends('discount1', 'discount2', 'discount3') - def get_discount(self): - for line in self: - discount_factor = 1.0 - for discount in [line.discount1, line.discount2, line.discount3]: - discount_factor = ( - discount_factor * ((100.0 - discount) / 100.0)) - line.discount = 100.0 - (discount_factor * 100.0) diff --git a/sale_triple_discount/models/res_partner.py b/sale_triple_discount/models/res_partner.py deleted file mode 100644 index d962d199d02..00000000000 --- a/sale_triple_discount/models/res_partner.py +++ /dev/null @@ -1,13 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2017 Alex Comba - Agile Business Group -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -from odoo import fields, models - - -class ResPartner(models.Model): - _inherit = "res.partner" - - default_discount1 = fields.Float('Default Discount 1 (%)') - default_discount2 = fields.Float('Default Discount 2 (%)') - default_discount3 = fields.Float('Default Discount 3 (%)') diff --git a/sale_triple_discount/models/sale_order_line.py b/sale_triple_discount/models/sale_order_line.py index 6767f3ae0f0..9f1e4d6a023 100644 --- a/sale_triple_discount/models/sale_order_line.py +++ b/sale_triple_discount/models/sale_order_line.py @@ -1,94 +1,65 @@ # -*- coding: utf-8 -*- # Copyright 2015 ADHOC SA (http://www.adhoc.com.ar) # Copyright 2017 Alex Comba - Agile Business Group +# Copyright 2017 Tecnativa - David Vidal # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import api, fields, models -import openerp.addons.decimal_precision as dp +import odoo.addons.decimal_precision as dp class SaleOrderLine(models.Model): _inherit = "sale.order.line" - @api.model - def _default_discount1(self): - default_discount1 = 0.0 - partner_id = self.env.context.get('partner_id', False) - if partner_id: - partner = self.env['res.partner'].browse(partner_id) - default_discount1 = partner.default_discount1 - return default_discount1 - - @api.model - def _default_discount2(self): - default_discount2 = 0.0 - partner_id = self.env.context.get('partner_id', False) - if partner_id: - partner = self.env['res.partner'].browse(partner_id) - default_discount2 = partner.default_discount2 - return default_discount2 - - @api.model - def _default_discount3(self): - default_discount3 = 0.0 - partner_id = self.env.context.get('partner_id', False) - if partner_id: - partner = self.env['res.partner'].browse(partner_id) - default_discount3 = partner.default_discount3 - return default_discount3 + @api.depends('discount2', 'discount3') + def _compute_amount(self): + for line in self: + prev_price_unit = line.price_unit + prev_discount = line.discount + price_unit = line.price_unit * (1 - (line.discount or 0.0) / 100.0) + price_unit *= (1 - (line.discount2 or 0.0) / 100.0) + price_unit *= (1 - (line.discount3 or 0.0) / 100.0) + line.update({ + 'price_unit': price_unit, + 'discount': 0.0, + }) + super(SaleOrderLine, line)._compute_amount() + line.update({ + 'price_unit': prev_price_unit, + 'discount': prev_discount, + }) - discount1 = fields.Float( - 'Discount 1 (%)', - digits=dp.get_precision('Discount'), - readonly=True, - default=_default_discount1, - states={'draft': [('readonly', False)], 'sent': [('readonly', False)]} - ) discount2 = fields.Float( - 'Discount 2 (%)', + 'Disc. 2 (%)', digits=dp.get_precision('Discount'), - readonly=True, - default=_default_discount2, - states={'draft': [('readonly', False)], 'sent': [('readonly', False)]} + default=0.0, ) discount3 = fields.Float( - 'Discount 3 (%)', + 'Disc. 3 (%)', digits=dp.get_precision('Discount'), - readonly=True, - default=_default_discount3, - states={'draft': [('readonly', False)], 'sent': [('readonly', False)]} + default=0.0, ) - discount = fields.Float(compute='get_discount', store=True) - @api.multi - @api.depends('discount1', 'discount2', 'discount3') - def get_discount(self): - for line in self: - discount_factor = 1.0 - for discount in [line.discount1, line.discount2, line.discount3]: - discount_factor = ( - discount_factor * ((100.0 - discount) / 100.0)) - line.discount = 100.0 - (discount_factor * 100.0) - - @api.onchange( - 'product_id', 'price_unit', 'product_uom', 'product_uom_qty', 'tax_id') - def _onchange_discount(self): - super(SaleOrderLine, self)._onchange_discount() - if self.discount != 0: - # to keep discount value calculated by pricelist - self.discount1 = self.discount - self.discount2 = 0 - self.discount3 = 0 - else: - # to recalculate discount value based on three discounts - # when these latter are filled by their default - self.get_discount() + _sql_constraints = [ + ('discount2_limit', 'CHECK (discount2 <= 100.0)', + 'Discount 2 must be lower than 100%.'), + ('discount3_limit', 'CHECK (discount3 <= 100.0)', + 'Discount 3 must be lower than 100%.'), + ] - @api.multi def _prepare_invoice_line(self, qty): res = super(SaleOrderLine, self)._prepare_invoice_line(qty) res.update({ - 'discount1': self.discount1, 'discount2': self.discount2, - 'discount3': self.discount3}) + 'discount3': self.discount3, + }) return res + + @api.depends('discount2', 'discount3') + def _get_price_reduce(self): + for line in self: + super(SaleOrderLine, line)._get_price_reduce() + if line.discount2: + line.price_reduce *= (1 - line.discount2 / 100) + if line.discount3: + line.price_reduce *= (1 - line.discount3 / 100) diff --git a/sale_triple_discount/tests/__init__.py b/sale_triple_discount/tests/__init__.py index 8bbc8f82f0a..8c6f65621b2 100644 --- a/sale_triple_discount/tests/__init__.py +++ b/sale_triple_discount/tests/__init__.py @@ -1 +1,3 @@ +# -*- coding: utf-8 -*- + from . import test_sale_triple_discount diff --git a/sale_triple_discount/tests/test_sale_triple_discount.py b/sale_triple_discount/tests/test_sale_triple_discount.py index 2f1a2c6ab0c..64d1399cb8c 100644 --- a/sale_triple_discount/tests/test_sale_triple_discount.py +++ b/sale_triple_discount/tests/test_sale_triple_discount.py @@ -1,116 +1,113 @@ # -*- coding: utf-8 -*- -# Copyright 2017 Alex Comba - Agile Business Group +# Copyright 2017 Tecnativa - David Vidal # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo.tests.common import TransactionCase +from odoo.tests import common -class TestSaleTripleDiscount(TransactionCase): +class TestSaleOrder(common.SavepointCase): - def create_sale_order(self): - self.so_model = self.env['sale.order'] - self.so_line_model = self.env['sale.order.line'] - self.so = self.so_model.create({ - 'partner_id': self.customer.id}) - # pass customer by context - self.so_line = self.so_line_model.with_context( - partner_id=self.customer.id).create({ - 'name': '/', - 'order_id': self.so.id, - 'product_id': self.product.id}) - - def create_invoice(self): - self.inv_model = self.env['account.invoice'] - self.inv_line_model = self.env['account.invoice.line'] - inv = self.inv_model.create({ - 'name': "Test Customer Invoice", - 'journal_id': self.env['account.journal'].search( - [('type', '=', 'sale')])[0].id, - 'partner_id': self.customer.id, - 'account_id': self.env['account.account'].search( - [('user_type_id', '=', self.env.ref( - 'account.data_account_type_receivable').id)], - limit=1).id, + @classmethod + def setUpClass(cls): + super(TestSaleOrder, cls).setUpClass() + cls.partner = cls.env['res.partner'].create({ + 'name': 'Mr. Odoo', + }) + cls.product1 = cls.env['product.product'].create({ + 'name': 'Test Product 1', + }) + cls.product2 = cls.env['product.product'].create({ + 'name': 'Test Product 2', + }) + cls.tax = cls.env['account.tax'].create({ + 'name': 'TAX 15%', + 'amount_type': 'percent', + 'type_tax_use': 'sale', + 'amount': 15.0, + }) + cls.order = cls.env['sale.order'].create({ + 'partner_id': cls.partner.id + }) + so_line = cls.env['sale.order.line'] + cls.so_line1 = so_line.create({ + 'order_id': cls.order.id, + 'product_id': cls.product1.id, + 'name': 'Line 1', + 'product_uom_qty': 1.0, + 'tax_id': [(6, 0, [cls.tax.id])], + 'price_unit': 600.0, + }) + cls.so_line2 = so_line.create({ + 'order_id': cls.order.id, + 'product_id': cls.product2.id, + 'name': 'Line 2', + 'product_uom_qty': 10.0, + 'tax_id': [(6, 0, [cls.tax.id])], + 'price_unit': 60.0, }) - # pass customer by context - self.inv_line_model.with_context( - partner_id=self.customer.id).create({ - 'name': '/', - 'invoice_id': inv.id, - 'product_id': self.product.id, - 'quantity': 1.0, - 'account_id': self.env['account.account'].search( - [('user_type_id', '=', self.env.ref( - 'account.data_account_type_revenue').id)], - limit=1).id, - 'price_unit': 450.00, - }) - return inv - - def setUp(self): - super(TestSaleTripleDiscount, self).setUp() - self.inv_model = self.env['account.invoice'] - self.inv_line_model = self.env['account.invoice.line'] - self.customer = self.env.ref('base.res_partner_2') - self.product = self.env.ref('product.product_product_3') - self.product.invoice_policy = 'order' - self.customer.default_discount1 = 20.0 - self.customer.default_discount2 = 10.0 - self.customer.default_discount3 = 5.0 - - def test_so_line_default_discount(self): - self.create_sale_order() - self.assertEqual( - self.so_line.discount1, self.customer.default_discount1) - self.assertEqual( - self.so_line.discount2, self.customer.default_discount2) - self.assertEqual( - self.so_line.discount3, self.customer.default_discount3) - - def test_so_line_get_discount(self): - self.create_sale_order() - self.assertEqual(self.so_line.discount, 31.6) - def test_so_line_onchange_discount(self): - self.create_sale_order() - self.so_line.discount1 = 10.0 - self.so_line.discount2 = 5.0 - self.so_line.discount1 = 2.0 - self.so_line._onchange_discount() - self.assertEqual(self.so_line.discount, 11.56) + def test_01_sale_order_classic_discount(self): + """ Tests with single discount """ + self.so_line1.discount = 50.0 + self.so_line2.discount = 75.0 + self.assertEqual(self.so_line1.price_subtotal, 300.0) + self.assertEqual(self.so_line2.price_subtotal, 150.0) + self.assertEqual(self.order.amount_untaxed, 450.0) + self.assertEqual(self.order.amount_tax, 67.5) + # Mix taxed and untaxed: + self.so_line1.tax_id = False + self.assertEqual(self.order.amount_tax, 22.5) - def test_so_line_prepare_invoice_line(self): - self.create_sale_order() - self.so.action_confirm() - inv_id = self.so.action_invoice_create() - self.assertEqual( - self.so.invoice_status, - 'invoiced', - 'SO invoice_status should be "invoiced" instead of "%s" ' - 'after invoicing' % self.so.invoice_status) - self.assertEqual(len(inv_id), 1) - inv = self.env['account.invoice'].browse(inv_id) - self.assertEqual(len(inv.invoice_line_ids), 1) - inv_line = inv.invoice_line_ids[0] - self.assertEqual( - inv_line.discount1, self.so_line.discount1) - self.assertEqual( - inv_line.discount2, self.so_line.discount2) - self.assertEqual( - inv_line.discount3, self.so_line.discount3) - self.assertEqual(inv_line.discount, 31.6) + def test_02_sale_order_simple_triple_discount(self): + """ Tests on a single line """ + self.so_line2.unlink() + # Divide by two on every discount: + self.so_line1.discount = 50.0 + self.so_line1.discount2 = 50.0 + self.so_line1.discount3 = 50.0 + self.assertEqual(self.so_line1.price_subtotal, 75.0) + self.assertEqual(self.order.amount_untaxed, 75.0) + self.assertEqual(self.order.amount_tax, 11.25) + # Unset first discount: + self.so_line1.discount = 0.0 + self.assertEqual(self.so_line1.price_subtotal, 150.0) + self.assertEqual(self.order.amount_untaxed, 150.0) + self.assertEqual(self.order.amount_tax, 22.5) + # Set a charge instead: + self.so_line1.discount2 = -50.0 + self.assertEqual(self.so_line1.price_subtotal, 450.0) + self.assertEqual(self.order.amount_untaxed, 450.0) + self.assertEqual(self.order.amount_tax, 67.5) - def test_inv_line_default_discount(self): - inv = self.create_invoice() - inv_line = inv.invoice_line_ids[0] - self.assertEqual( - inv_line.discount1, self.customer.default_discount1) - self.assertEqual( - inv_line.discount2, self.customer.default_discount2) - self.assertEqual( - inv_line.discount3, self.customer.default_discount3) + def test_03_sale_order_complex_triple_discount(self): + """ Tests on multiple lines """ + self.so_line1.discount = 50.0 + self.so_line1.discount2 = 50.0 + self.so_line1.discount3 = 50.0 + self.assertEqual(self.so_line1.price_subtotal, 75.0) + self.assertEqual(self.order.amount_untaxed, 675.0) + self.assertEqual(self.order.amount_tax, 101.25) + self.so_line2.discount3 = 50.0 + self.assertEqual(self.so_line2.price_subtotal, 300.0) + self.assertEqual(self.order.amount_untaxed, 375.0) + self.assertEqual(self.order.amount_tax, 56.25) - def test_inv_line_get_discount(self): - inv = self.create_invoice() - inv_line = inv.invoice_line_ids[0] - self.assertEqual(inv_line.discount, 31.6) + def test_04_sale_order_triple_discount_invoicing(self): + """ When a confirmed order is invoiced, the resultant invoice + should inherit the discounts """ + self.so_line1.discount = 50.0 + self.so_line1.discount2 = 50.0 + self.so_line1.discount3 = 50.0 + self.so_line2.discount3 = 50.0 + self.order.action_confirm() + self.order.action_invoice_create() + invoice = self.order.invoice_ids[0] + self.assertEqual(self.so_line1.discount, + invoice.invoice_line_ids[0].discount) + self.assertEqual(self.so_line1.discount2, + invoice.invoice_line_ids[0].discount2) + self.assertEqual(self.so_line1.discount3, + invoice.invoice_line_ids[0].discount3) + self.assertEqual(self.so_line2.discount3, + invoice.invoice_line_ids[1].discount3) + self.assertEqual(self.order.amount_total, invoice.amount_total) diff --git a/sale_triple_discount/views/account_invoice_view.xml b/sale_triple_discount/views/account_invoice_view.xml deleted file mode 100755 index e3cd835f0de..00000000000 --- a/sale_triple_discount/views/account_invoice_view.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - account.invoice.triple.discount.form - account.invoice - - - - {'partner_id': partner_id} - - - True - - - - - - - - - - - account.invoice.line.triple.discount.form - account.invoice.line - - - - - - - - - - - diff --git a/sale_triple_discount/views/res_partner_view.xml b/sale_triple_discount/views/res_partner_view.xml deleted file mode 100755 index da5fde5c7b1..00000000000 --- a/sale_triple_discount/views/res_partner_view.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - partner.triple.discount.form - res.partner - - - - - - - - - - - diff --git a/sale_triple_discount/views/sale_order_view.xml b/sale_triple_discount/views/sale_order_view.xml index 92f28b242e8..a52618a5df2 100755 --- a/sale_triple_discount/views/sale_order_view.xml +++ b/sale_triple_discount/views/sale_order_view.xml @@ -6,21 +6,23 @@ sale.order - - {'partner_id': partner_id} + + + - - True - - - - - - - - - - + + From 77a4cae73af78ef49e3b44b458ef40e458bd0b2f Mon Sep 17 00:00:00 2001 From: Thomas Pot Date: Thu, 21 Jun 2018 16:49:41 +0000 Subject: [PATCH 03/44] Translated using Weblate (Nederlands (nl_NL)) Currently translated at 100,0% (5 of 5 strings) Translation: sale-workflow-10.0/sale-workflow-10.0-sale_triple_discount Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-10-0/sale-workflow-10-0-sale_triple_discount/nl_NL/ --- sale_triple_discount/i18n/nl_NL.po | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/sale_triple_discount/i18n/nl_NL.po b/sale_triple_discount/i18n/nl_NL.po index 427d4b818fc..b83354d29b7 100644 --- a/sale_triple_discount/i18n/nl_NL.po +++ b/sale_triple_discount/i18n/nl_NL.po @@ -9,35 +9,36 @@ msgstr "" "Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2017-11-23 01:52+0000\n" -"PO-Revision-Date: 2017-11-23 01:52+0000\n" -"Last-Translator: Peter Hageman , 2017\n" -"Language-Team: Dutch (Netherlands) (https://www.transifex.com/oca/" -"teams/23907/nl_NL/)\n" +"PO-Revision-Date: 2018-06-21 16:50+0000\n" +"Last-Translator: Thomas Pot \n" +"Language-Team: Dutch (Netherlands) (https://www.transifex.com/oca/teams/" +"23907/nl_NL/)\n" "Language: nl_NL\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 3.0.1\n" #. module: sale_triple_discount #: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount2 msgid "Disc. 2 (%)" -msgstr "" +msgstr "Korting 2 (%)" #. module: sale_triple_discount #: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount3 msgid "Disc. 3 (%)" -msgstr "" +msgstr "Korting 3 (%)" #. module: sale_triple_discount #: sql_constraint:sale.order.line:0 msgid "Discount 2 must be lower than 100%." -msgstr "" +msgstr "Korting 2 moet lager zijn dan 100%" #. module: sale_triple_discount #: sql_constraint:sale.order.line:0 msgid "Discount 3 must be lower than 100%." -msgstr "" +msgstr "Korting 3 moet lager zijn dan 100%" #. module: sale_triple_discount #: model:ir.model,name:sale_triple_discount.model_sale_order_line From 58b4fc7fc9c188f6e5052e1ac11b9fb8352f82d5 Mon Sep 17 00:00:00 2001 From: Thomas Pot Date: Thu, 21 Jun 2018 16:50:51 +0000 Subject: [PATCH 04/44] Translated using Weblate (Dutch (nl_NL)) Currently translated at 100.0% (5 of 5 strings) Translation: sale-workflow-10.0/sale-workflow-10.0-sale_triple_discount Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-10-0/sale-workflow-10-0-sale_triple_discount/nl_NL/ --- sale_triple_discount/i18n/nl_NL.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sale_triple_discount/i18n/nl_NL.po b/sale_triple_discount/i18n/nl_NL.po index b83354d29b7..1646bdc43bd 100644 --- a/sale_triple_discount/i18n/nl_NL.po +++ b/sale_triple_discount/i18n/nl_NL.po @@ -9,7 +9,7 @@ msgstr "" "Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2017-11-23 01:52+0000\n" -"PO-Revision-Date: 2018-06-21 16:50+0000\n" +"PO-Revision-Date: 2018-06-22 17:01+0000\n" "Last-Translator: Thomas Pot \n" "Language-Team: Dutch (Netherlands) (https://www.transifex.com/oca/teams/" "23907/nl_NL/)\n" @@ -33,12 +33,12 @@ msgstr "Korting 3 (%)" #. module: sale_triple_discount #: sql_constraint:sale.order.line:0 msgid "Discount 2 must be lower than 100%." -msgstr "Korting 2 moet lager zijn dan 100%" +msgstr "Korting 2 moet lager zijn dan 100%." #. module: sale_triple_discount #: sql_constraint:sale.order.line:0 msgid "Discount 3 must be lower than 100%." -msgstr "Korting 3 moet lager zijn dan 100%" +msgstr "Korting 3 moet lager zijn dan 100%." #. module: sale_triple_discount #: model:ir.model,name:sale_triple_discount.model_sale_order_line From d327702d8b8e2cbee7a5ec56f6baf831a62a5b66 Mon Sep 17 00:00:00 2001 From: SimoRubi Date: Wed, 19 Dec 2018 17:22:56 +0100 Subject: [PATCH 05/44] [FIX] sale_triple_discount: Correctly compute taxes with round_globally configuration --- sale_triple_discount/README.rst | 1 + sale_triple_discount/__manifest__.py | 2 +- sale_triple_discount/models/__init__.py | 1 + sale_triple_discount/models/sale_order.py | 32 ++++++++++ .../models/sale_order_line.py | 60 ++++++++++++------- .../tests/test_sale_triple_discount.py | 16 +++++ 6 files changed, 91 insertions(+), 21 deletions(-) create mode 100644 sale_triple_discount/models/sale_order.py diff --git a/sale_triple_discount/README.rst b/sale_triple_discount/README.rst index 8e91cb180d6..8b3def3b5f2 100644 --- a/sale_triple_discount/README.rst +++ b/sale_triple_discount/README.rst @@ -64,6 +64,7 @@ Contributors * Juan José Scarafía * Alex Comba * David Vidal +* Simone Rubino Maintainer ---------- diff --git a/sale_triple_discount/__manifest__.py b/sale_triple_discount/__manifest__.py index b787e00b0f9..1e99688ba12 100644 --- a/sale_triple_discount/__manifest__.py +++ b/sale_triple_discount/__manifest__.py @@ -6,7 +6,7 @@ { 'name': 'Sale Triple Discount', - 'version': '10.0.1.0.0', + 'version': '10.0.1.0.1', 'category': 'Sales Management', 'author': 'ADHOC SA, ' 'Agile Business Group, ' diff --git a/sale_triple_discount/models/__init__.py b/sale_triple_discount/models/__init__.py index 5be03b1fe1b..7cb0685491f 100644 --- a/sale_triple_discount/models/__init__.py +++ b/sale_triple_discount/models/__init__.py @@ -1,3 +1,4 @@ # -*- coding: utf-8 -*- +from . import sale_order from . import sale_order_line diff --git a/sale_triple_discount/models/sale_order.py b/sale_triple_discount/models/sale_order.py new file mode 100644 index 00000000000..350d7554e01 --- /dev/null +++ b/sale_triple_discount/models/sale_order.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +# Copyright 2018 Simone Rubino - Agile Business Group +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import api, models + + +class SaleOrder(models.Model): + _inherit = 'sale.order' + + @api.depends('order_line.price_total') + def _amount_all(self): + prev_values = dict() + for order in self: + for line in order.order_line: + prev_values[line] = dict( + discount=line.discount, + discount2=line.discount2, + discount3=line.discount3, + ) + # Update, for some reason, does not work + line.write({ + 'discount': line._get_triple_discount(), + 'discount2': 0.0, + 'discount3': 0.0 + }) + super(SaleOrder, self)._amount_all() + + # Restore previous values + for line, prev_vals_dict in prev_values.items(): + # Update, for some reason, does not work + line.write(prev_vals_dict) diff --git a/sale_triple_discount/models/sale_order_line.py b/sale_triple_discount/models/sale_order_line.py index 9f1e4d6a023..26918803338 100644 --- a/sale_triple_discount/models/sale_order_line.py +++ b/sale_triple_discount/models/sale_order_line.py @@ -2,6 +2,7 @@ # Copyright 2015 ADHOC SA (http://www.adhoc.com.ar) # Copyright 2017 Alex Comba - Agile Business Group # Copyright 2017 Tecnativa - David Vidal +# Copyright 2018 Simone Rubino - Agile Business Group # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import api, fields, models @@ -13,21 +14,9 @@ class SaleOrderLine(models.Model): @api.depends('discount2', 'discount3') def _compute_amount(self): - for line in self: - prev_price_unit = line.price_unit - prev_discount = line.discount - price_unit = line.price_unit * (1 - (line.discount or 0.0) / 100.0) - price_unit *= (1 - (line.discount2 or 0.0) / 100.0) - price_unit *= (1 - (line.discount3 or 0.0) / 100.0) - line.update({ - 'price_unit': price_unit, - 'discount': 0.0, - }) - super(SaleOrderLine, line)._compute_amount() - line.update({ - 'price_unit': prev_price_unit, - 'discount': prev_discount, - }) + prev_values = self.triple_discount_preprocess() + super(SaleOrderLine, self)._compute_amount() + self.triple_discount_postprocess(prev_values) discount2 = fields.Float( 'Disc. 2 (%)', @@ -47,6 +36,14 @@ def _compute_amount(self): 'Discount 3 must be lower than 100%.'), ] + def _get_triple_discount(self): + """Get the discount that is equivalent to the subsequent application + of discount, discount2 and discount3""" + discount_factor = 1.0 + for discount in [self.discount, self.discount2, self.discount3]: + discount_factor *= (100.0 - discount) / 100.0 + return 100.0 - (discount_factor * 100.0) + def _prepare_invoice_line(self, qty): res = super(SaleOrderLine, self)._prepare_invoice_line(qty) res.update({ @@ -57,9 +54,32 @@ def _prepare_invoice_line(self, qty): @api.depends('discount2', 'discount3') def _get_price_reduce(self): + prev_values = self.triple_discount_preprocess() + super(SaleOrderLine, self)._get_price_reduce() + self.triple_discount_postprocess(prev_values) + + @api.multi + def triple_discount_preprocess(self): + """Save the values of the discounts in a dictionary, + to be restored in postprocess. + Resetting discount2 and discount3 to 0.0 avoids issues if + this method is called multiple times.""" + prev_values = dict() for line in self: - super(SaleOrderLine, line)._get_price_reduce() - if line.discount2: - line.price_reduce *= (1 - line.discount2 / 100) - if line.discount3: - line.price_reduce *= (1 - line.discount3 / 100) + prev_values[line] = dict( + discount=line.discount, + discount2=line.discount2, + discount3=line.discount3, + ) + line.update({ + 'discount': line._get_triple_discount(), + 'discount2': 0.0, + 'discount3': 0.0 + }) + return prev_values + + @api.model + def triple_discount_postprocess(self, prev_values): + """Restore the discounts of the lines in the dictionary prev_values""" + for line, prev_vals_dict in prev_values.items(): + line.update(prev_vals_dict) diff --git a/sale_triple_discount/tests/test_sale_triple_discount.py b/sale_triple_discount/tests/test_sale_triple_discount.py index 64d1399cb8c..0c73d0943d3 100644 --- a/sale_triple_discount/tests/test_sale_triple_discount.py +++ b/sale_triple_discount/tests/test_sale_triple_discount.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # Copyright 2017 Tecnativa - David Vidal +# Copyright 2018 Simone Rubino - Agile Business Group # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo.tests import common @@ -111,3 +112,18 @@ def test_04_sale_order_triple_discount_invoicing(self): self.assertEqual(self.so_line2.discount3, invoice.invoice_line_ids[1].discount3) self.assertEqual(self.order.amount_total, invoice.amount_total) + + def test_05_round_globally(self): + """ Tests on multiple lines when 'round_globally' is active""" + self.env.user.company_id. \ + tax_calculation_rounding_method = 'round_globally' + self.so_line1.discount = 50.0 + self.so_line1.discount2 = 50.0 + self.so_line1.discount3 = 50.0 + self.assertEqual(self.so_line1.price_subtotal, 75.0) + self.assertEqual(self.order.amount_untaxed, 675.0) + self.assertEqual(self.order.amount_tax, 101.25) + self.so_line2.discount3 = 50.0 + self.assertEqual(self.so_line2.price_subtotal, 300.0) + self.assertEqual(self.order.amount_untaxed, 375.0) + self.assertEqual(self.order.amount_tax, 56.25) From b7ba17124319912aa397e52db91e504c9321869b Mon Sep 17 00:00:00 2001 From: SimoRubi Date: Fri, 21 Dec 2018 10:52:52 +0100 Subject: [PATCH 06/44] [FIX] sale_triple_discount: Store values in cache for recomputation consistency [FIX] sale_triple_discount: Invalidating the cache of specific records before recomputing price and discount [UPD] Update sale_triple_discount.pot Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: sale-workflow-10.0/sale-workflow-10.0-sale_triple_discount Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-10-0/sale-workflow-10-0-sale_triple_discount/ --- sale_triple_discount/i18n/ca.po | 36 +++++++++++++++++ sale_triple_discount/i18n/de.po | 36 +++++++++++++++++ sale_triple_discount/i18n/es.po | 36 +++++++++++++++++ sale_triple_discount/i18n/es_VE.po | 36 +++++++++++++++++ sale_triple_discount/i18n/fr.po | 36 +++++++++++++++++ sale_triple_discount/i18n/hr.po | 36 +++++++++++++++++ sale_triple_discount/i18n/it.po | 36 +++++++++++++++++ sale_triple_discount/i18n/nl_NL.po | 40 ++++++++++++++++++- sale_triple_discount/i18n/pt_BR.po | 36 +++++++++++++++++ sale_triple_discount/i18n/ro.po | 36 +++++++++++++++++ .../i18n/sale_triple_discount.pot | 5 +++ sale_triple_discount/i18n/sl.po | 36 +++++++++++++++++ sale_triple_discount/i18n/tr.po | 36 +++++++++++++++++ sale_triple_discount/i18n/tr_TR.po | 36 +++++++++++++++++ sale_triple_discount/models/sale_order.py | 19 +-------- .../models/sale_order_line.py | 16 ++++++-- 16 files changed, 489 insertions(+), 23 deletions(-) diff --git a/sale_triple_discount/i18n/ca.po b/sale_triple_discount/i18n/ca.po index 7b228777745..57374520295 100644 --- a/sale_triple_discount/i18n/ca.po +++ b/sale_triple_discount/i18n/ca.po @@ -18,6 +18,11 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" +#. module: sale_triple_discount +#: selection:sale.order.line,discounting_type:0 +msgid "Additive" +msgstr "" + #. module: sale_triple_discount #: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount2 msgid "Disc. 2 (%)" @@ -38,7 +43,38 @@ msgstr "" msgid "Discount 3 must be lower than 100%." msgstr "" +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discounting_type +msgid "Discounting type" +msgstr "" + +#. module: sale_triple_discount +#: selection:sale.order.line,discounting_type:0 +msgid "Multiplicative" +msgstr "" + +#. module: sale_triple_discount +#: code:addons/sale_triple_discount/models/sale_order_line.py:23 +#, python-format +msgid "Sale order line %s has unknown discounting type %s" +msgstr "" + +#. module: sale_triple_discount +#: model:ir.model,name:sale_triple_discount.model_sale_order +#, fuzzy +msgid "Sales Order" +msgstr "Línia de comanda de vendes" + #. module: sale_triple_discount #: model:ir.model,name:sale_triple_discount.model_sale_order_line msgid "Sales Order Line" msgstr "Línia de comanda de vendes" + +#. module: sale_triple_discount +#: model:ir.model.fields,help:sale_triple_discount.field_sale_order_line_discounting_type +msgid "" +"Specifies whether discounts should be additive or multiplicative.\n" +"Additive discounts are summed first and then applied.\n" +"Multiplicative discounts are applied sequentially.\n" +"Multiplicative discounts are default" +msgstr "" diff --git a/sale_triple_discount/i18n/de.po b/sale_triple_discount/i18n/de.po index 7f5c6422e0e..7d888cd04ca 100644 --- a/sale_triple_discount/i18n/de.po +++ b/sale_triple_discount/i18n/de.po @@ -18,6 +18,11 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" +#. module: sale_triple_discount +#: selection:sale.order.line,discounting_type:0 +msgid "Additive" +msgstr "" + #. module: sale_triple_discount #: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount2 msgid "Disc. 2 (%)" @@ -38,7 +43,38 @@ msgstr "" msgid "Discount 3 must be lower than 100%." msgstr "" +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discounting_type +msgid "Discounting type" +msgstr "" + +#. module: sale_triple_discount +#: selection:sale.order.line,discounting_type:0 +msgid "Multiplicative" +msgstr "" + +#. module: sale_triple_discount +#: code:addons/sale_triple_discount/models/sale_order_line.py:23 +#, python-format +msgid "Sale order line %s has unknown discounting type %s" +msgstr "" + +#. module: sale_triple_discount +#: model:ir.model,name:sale_triple_discount.model_sale_order +#, fuzzy +msgid "Sales Order" +msgstr "Auftragsposition" + #. module: sale_triple_discount #: model:ir.model,name:sale_triple_discount.model_sale_order_line msgid "Sales Order Line" msgstr "Auftragsposition" + +#. module: sale_triple_discount +#: model:ir.model.fields,help:sale_triple_discount.field_sale_order_line_discounting_type +msgid "" +"Specifies whether discounts should be additive or multiplicative.\n" +"Additive discounts are summed first and then applied.\n" +"Multiplicative discounts are applied sequentially.\n" +"Multiplicative discounts are default" +msgstr "" diff --git a/sale_triple_discount/i18n/es.po b/sale_triple_discount/i18n/es.po index f78a5e41094..c9f093449a2 100644 --- a/sale_triple_discount/i18n/es.po +++ b/sale_triple_discount/i18n/es.po @@ -18,6 +18,11 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" +#. module: sale_triple_discount +#: selection:sale.order.line,discounting_type:0 +msgid "Additive" +msgstr "" + #. module: sale_triple_discount #: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount2 msgid "Disc. 2 (%)" @@ -38,7 +43,38 @@ msgstr "" msgid "Discount 3 must be lower than 100%." msgstr "" +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discounting_type +msgid "Discounting type" +msgstr "" + +#. module: sale_triple_discount +#: selection:sale.order.line,discounting_type:0 +msgid "Multiplicative" +msgstr "" + +#. module: sale_triple_discount +#: code:addons/sale_triple_discount/models/sale_order_line.py:23 +#, python-format +msgid "Sale order line %s has unknown discounting type %s" +msgstr "" + +#. module: sale_triple_discount +#: model:ir.model,name:sale_triple_discount.model_sale_order +#, fuzzy +msgid "Sales Order" +msgstr "Línea de pedido de venta" + #. module: sale_triple_discount #: model:ir.model,name:sale_triple_discount.model_sale_order_line msgid "Sales Order Line" msgstr "Línea de pedido de venta" + +#. module: sale_triple_discount +#: model:ir.model.fields,help:sale_triple_discount.field_sale_order_line_discounting_type +msgid "" +"Specifies whether discounts should be additive or multiplicative.\n" +"Additive discounts are summed first and then applied.\n" +"Multiplicative discounts are applied sequentially.\n" +"Multiplicative discounts are default" +msgstr "" diff --git a/sale_triple_discount/i18n/es_VE.po b/sale_triple_discount/i18n/es_VE.po index 52221356365..d4fb93c041e 100644 --- a/sale_triple_discount/i18n/es_VE.po +++ b/sale_triple_discount/i18n/es_VE.po @@ -19,6 +19,11 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" +#. module: sale_triple_discount +#: selection:sale.order.line,discounting_type:0 +msgid "Additive" +msgstr "" + #. module: sale_triple_discount #: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount2 msgid "Disc. 2 (%)" @@ -39,7 +44,38 @@ msgstr "" msgid "Discount 3 must be lower than 100%." msgstr "" +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discounting_type +msgid "Discounting type" +msgstr "" + +#. module: sale_triple_discount +#: selection:sale.order.line,discounting_type:0 +msgid "Multiplicative" +msgstr "" + +#. module: sale_triple_discount +#: code:addons/sale_triple_discount/models/sale_order_line.py:23 +#, python-format +msgid "Sale order line %s has unknown discounting type %s" +msgstr "" + +#. module: sale_triple_discount +#: model:ir.model,name:sale_triple_discount.model_sale_order +#, fuzzy +msgid "Sales Order" +msgstr "Línea de pedido de venta" + #. module: sale_triple_discount #: model:ir.model,name:sale_triple_discount.model_sale_order_line msgid "Sales Order Line" msgstr "Línea de pedido de venta" + +#. module: sale_triple_discount +#: model:ir.model.fields,help:sale_triple_discount.field_sale_order_line_discounting_type +msgid "" +"Specifies whether discounts should be additive or multiplicative.\n" +"Additive discounts are summed first and then applied.\n" +"Multiplicative discounts are applied sequentially.\n" +"Multiplicative discounts are default" +msgstr "" diff --git a/sale_triple_discount/i18n/fr.po b/sale_triple_discount/i18n/fr.po index 7b881fc7c1f..5504d0a861c 100644 --- a/sale_triple_discount/i18n/fr.po +++ b/sale_triple_discount/i18n/fr.po @@ -18,6 +18,11 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" +#. module: sale_triple_discount +#: selection:sale.order.line,discounting_type:0 +msgid "Additive" +msgstr "" + #. module: sale_triple_discount #: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount2 msgid "Disc. 2 (%)" @@ -38,7 +43,38 @@ msgstr "" msgid "Discount 3 must be lower than 100%." msgstr "" +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discounting_type +msgid "Discounting type" +msgstr "" + +#. module: sale_triple_discount +#: selection:sale.order.line,discounting_type:0 +msgid "Multiplicative" +msgstr "" + +#. module: sale_triple_discount +#: code:addons/sale_triple_discount/models/sale_order_line.py:23 +#, python-format +msgid "Sale order line %s has unknown discounting type %s" +msgstr "" + +#. module: sale_triple_discount +#: model:ir.model,name:sale_triple_discount.model_sale_order +#, fuzzy +msgid "Sales Order" +msgstr "Sales Order Line" + #. module: sale_triple_discount #: model:ir.model,name:sale_triple_discount.model_sale_order_line msgid "Sales Order Line" msgstr "Sales Order Line" + +#. module: sale_triple_discount +#: model:ir.model.fields,help:sale_triple_discount.field_sale_order_line_discounting_type +msgid "" +"Specifies whether discounts should be additive or multiplicative.\n" +"Additive discounts are summed first and then applied.\n" +"Multiplicative discounts are applied sequentially.\n" +"Multiplicative discounts are default" +msgstr "" diff --git a/sale_triple_discount/i18n/hr.po b/sale_triple_discount/i18n/hr.po index dd0b22d32d8..93646cabd1d 100644 --- a/sale_triple_discount/i18n/hr.po +++ b/sale_triple_discount/i18n/hr.po @@ -19,6 +19,11 @@ msgstr "" "Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" "%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" +#. module: sale_triple_discount +#: selection:sale.order.line,discounting_type:0 +msgid "Additive" +msgstr "" + #. module: sale_triple_discount #: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount2 msgid "Disc. 2 (%)" @@ -39,7 +44,38 @@ msgstr "" msgid "Discount 3 must be lower than 100%." msgstr "" +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discounting_type +msgid "Discounting type" +msgstr "" + +#. module: sale_triple_discount +#: selection:sale.order.line,discounting_type:0 +msgid "Multiplicative" +msgstr "" + +#. module: sale_triple_discount +#: code:addons/sale_triple_discount/models/sale_order_line.py:23 +#, python-format +msgid "Sale order line %s has unknown discounting type %s" +msgstr "" + +#. module: sale_triple_discount +#: model:ir.model,name:sale_triple_discount.model_sale_order +#, fuzzy +msgid "Sales Order" +msgstr "Stavka ponude" + #. module: sale_triple_discount #: model:ir.model,name:sale_triple_discount.model_sale_order_line msgid "Sales Order Line" msgstr "Stavka ponude" + +#. module: sale_triple_discount +#: model:ir.model.fields,help:sale_triple_discount.field_sale_order_line_discounting_type +msgid "" +"Specifies whether discounts should be additive or multiplicative.\n" +"Additive discounts are summed first and then applied.\n" +"Multiplicative discounts are applied sequentially.\n" +"Multiplicative discounts are default" +msgstr "" diff --git a/sale_triple_discount/i18n/it.po b/sale_triple_discount/i18n/it.po index 13f57de3f0b..9179cf03a90 100644 --- a/sale_triple_discount/i18n/it.po +++ b/sale_triple_discount/i18n/it.po @@ -18,6 +18,11 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" +#. module: sale_triple_discount +#: selection:sale.order.line,discounting_type:0 +msgid "Additive" +msgstr "" + #. module: sale_triple_discount #: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount2 msgid "Disc. 2 (%)" @@ -38,7 +43,38 @@ msgstr "" msgid "Discount 3 must be lower than 100%." msgstr "" +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discounting_type +msgid "Discounting type" +msgstr "" + +#. module: sale_triple_discount +#: selection:sale.order.line,discounting_type:0 +msgid "Multiplicative" +msgstr "" + +#. module: sale_triple_discount +#: code:addons/sale_triple_discount/models/sale_order_line.py:23 +#, python-format +msgid "Sale order line %s has unknown discounting type %s" +msgstr "" + +#. module: sale_triple_discount +#: model:ir.model,name:sale_triple_discount.model_sale_order +#, fuzzy +msgid "Sales Order" +msgstr "Linea d'ordine di vendita" + #. module: sale_triple_discount #: model:ir.model,name:sale_triple_discount.model_sale_order_line msgid "Sales Order Line" msgstr "Linea d'ordine di vendita" + +#. module: sale_triple_discount +#: model:ir.model.fields,help:sale_triple_discount.field_sale_order_line_discounting_type +msgid "" +"Specifies whether discounts should be additive or multiplicative.\n" +"Additive discounts are summed first and then applied.\n" +"Multiplicative discounts are applied sequentially.\n" +"Multiplicative discounts are default" +msgstr "" diff --git a/sale_triple_discount/i18n/nl_NL.po b/sale_triple_discount/i18n/nl_NL.po index 1646bdc43bd..c1a24863f9f 100644 --- a/sale_triple_discount/i18n/nl_NL.po +++ b/sale_triple_discount/i18n/nl_NL.po @@ -11,8 +11,8 @@ msgstr "" "POT-Creation-Date: 2017-11-23 01:52+0000\n" "PO-Revision-Date: 2018-06-22 17:01+0000\n" "Last-Translator: Thomas Pot \n" -"Language-Team: Dutch (Netherlands) (https://www.transifex.com/oca/teams/" -"23907/nl_NL/)\n" +"Language-Team: Dutch (Netherlands) (https://www.transifex.com/oca/" +"teams/23907/nl_NL/)\n" "Language: nl_NL\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -20,6 +20,11 @@ msgstr "" "Plural-Forms: nplurals=2; plural=n != 1;\n" "X-Generator: Weblate 3.0.1\n" +#. module: sale_triple_discount +#: selection:sale.order.line,discounting_type:0 +msgid "Additive" +msgstr "" + #. module: sale_triple_discount #: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount2 msgid "Disc. 2 (%)" @@ -40,7 +45,38 @@ msgstr "Korting 2 moet lager zijn dan 100%." msgid "Discount 3 must be lower than 100%." msgstr "Korting 3 moet lager zijn dan 100%." +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discounting_type +msgid "Discounting type" +msgstr "" + +#. module: sale_triple_discount +#: selection:sale.order.line,discounting_type:0 +msgid "Multiplicative" +msgstr "" + +#. module: sale_triple_discount +#: code:addons/sale_triple_discount/models/sale_order_line.py:23 +#, python-format +msgid "Sale order line %s has unknown discounting type %s" +msgstr "" + +#. module: sale_triple_discount +#: model:ir.model,name:sale_triple_discount.model_sale_order +#, fuzzy +msgid "Sales Order" +msgstr "Verkooporderregel" + #. module: sale_triple_discount #: model:ir.model,name:sale_triple_discount.model_sale_order_line msgid "Sales Order Line" msgstr "Verkooporderregel" + +#. module: sale_triple_discount +#: model:ir.model.fields,help:sale_triple_discount.field_sale_order_line_discounting_type +msgid "" +"Specifies whether discounts should be additive or multiplicative.\n" +"Additive discounts are summed first and then applied.\n" +"Multiplicative discounts are applied sequentially.\n" +"Multiplicative discounts are default" +msgstr "" diff --git a/sale_triple_discount/i18n/pt_BR.po b/sale_triple_discount/i18n/pt_BR.po index 31d471c3f1e..f5defcb37b8 100644 --- a/sale_triple_discount/i18n/pt_BR.po +++ b/sale_triple_discount/i18n/pt_BR.po @@ -19,6 +19,11 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" +#. module: sale_triple_discount +#: selection:sale.order.line,discounting_type:0 +msgid "Additive" +msgstr "" + #. module: sale_triple_discount #: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount2 msgid "Disc. 2 (%)" @@ -39,7 +44,38 @@ msgstr "" msgid "Discount 3 must be lower than 100%." msgstr "" +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discounting_type +msgid "Discounting type" +msgstr "" + +#. module: sale_triple_discount +#: selection:sale.order.line,discounting_type:0 +msgid "Multiplicative" +msgstr "" + +#. module: sale_triple_discount +#: code:addons/sale_triple_discount/models/sale_order_line.py:23 +#, python-format +msgid "Sale order line %s has unknown discounting type %s" +msgstr "" + +#. module: sale_triple_discount +#: model:ir.model,name:sale_triple_discount.model_sale_order +#, fuzzy +msgid "Sales Order" +msgstr "Linha Pedido de Venda" + #. module: sale_triple_discount #: model:ir.model,name:sale_triple_discount.model_sale_order_line msgid "Sales Order Line" msgstr "Linha Pedido de Venda" + +#. module: sale_triple_discount +#: model:ir.model.fields,help:sale_triple_discount.field_sale_order_line_discounting_type +msgid "" +"Specifies whether discounts should be additive or multiplicative.\n" +"Additive discounts are summed first and then applied.\n" +"Multiplicative discounts are applied sequentially.\n" +"Multiplicative discounts are default" +msgstr "" diff --git a/sale_triple_discount/i18n/ro.po b/sale_triple_discount/i18n/ro.po index 263d4f38191..7e456abd8c4 100644 --- a/sale_triple_discount/i18n/ro.po +++ b/sale_triple_discount/i18n/ro.po @@ -19,6 +19,11 @@ msgstr "" "Plural-Forms: nplurals=3; plural=(n==1?0:(((n%100>19)||((n%100==0)&&(n!=0)))?" "2:1));\n" +#. module: sale_triple_discount +#: selection:sale.order.line,discounting_type:0 +msgid "Additive" +msgstr "" + #. module: sale_triple_discount #: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount2 msgid "Disc. 2 (%)" @@ -39,7 +44,38 @@ msgstr "" msgid "Discount 3 must be lower than 100%." msgstr "" +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discounting_type +msgid "Discounting type" +msgstr "" + +#. module: sale_triple_discount +#: selection:sale.order.line,discounting_type:0 +msgid "Multiplicative" +msgstr "" + +#. module: sale_triple_discount +#: code:addons/sale_triple_discount/models/sale_order_line.py:23 +#, python-format +msgid "Sale order line %s has unknown discounting type %s" +msgstr "" + +#. module: sale_triple_discount +#: model:ir.model,name:sale_triple_discount.model_sale_order +#, fuzzy +msgid "Sales Order" +msgstr "Linie comandă vânzare" + #. module: sale_triple_discount #: model:ir.model,name:sale_triple_discount.model_sale_order_line msgid "Sales Order Line" msgstr "Linie comandă vânzare" + +#. module: sale_triple_discount +#: model:ir.model.fields,help:sale_triple_discount.field_sale_order_line_discounting_type +msgid "" +"Specifies whether discounts should be additive or multiplicative.\n" +"Additive discounts are summed first and then applied.\n" +"Multiplicative discounts are applied sequentially.\n" +"Multiplicative discounts are default" +msgstr "" diff --git a/sale_triple_discount/i18n/sale_triple_discount.pot b/sale_triple_discount/i18n/sale_triple_discount.pot index 0fe744d4291..860623dbcd1 100644 --- a/sale_triple_discount/i18n/sale_triple_discount.pot +++ b/sale_triple_discount/i18n/sale_triple_discount.pot @@ -33,6 +33,11 @@ msgstr "" msgid "Discount 3 must be lower than 100%." msgstr "" +#. module: sale_triple_discount +#: model:ir.model,name:sale_triple_discount.model_sale_order +msgid "Sales Order" +msgstr "" + #. module: sale_triple_discount #: model:ir.model,name:sale_triple_discount.model_sale_order_line msgid "Sales Order Line" diff --git a/sale_triple_discount/i18n/sl.po b/sale_triple_discount/i18n/sl.po index 730742ac9a6..8151fb6305b 100644 --- a/sale_triple_discount/i18n/sl.po +++ b/sale_triple_discount/i18n/sl.po @@ -19,6 +19,11 @@ msgstr "" "Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n" "%100==4 ? 2 : 3);\n" +#. module: sale_triple_discount +#: selection:sale.order.line,discounting_type:0 +msgid "Additive" +msgstr "" + #. module: sale_triple_discount #: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount2 msgid "Disc. 2 (%)" @@ -39,7 +44,38 @@ msgstr "" msgid "Discount 3 must be lower than 100%." msgstr "" +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discounting_type +msgid "Discounting type" +msgstr "" + +#. module: sale_triple_discount +#: selection:sale.order.line,discounting_type:0 +msgid "Multiplicative" +msgstr "" + +#. module: sale_triple_discount +#: code:addons/sale_triple_discount/models/sale_order_line.py:23 +#, python-format +msgid "Sale order line %s has unknown discounting type %s" +msgstr "" + +#. module: sale_triple_discount +#: model:ir.model,name:sale_triple_discount.model_sale_order +#, fuzzy +msgid "Sales Order" +msgstr "Postavka prodajnega naloga" + #. module: sale_triple_discount #: model:ir.model,name:sale_triple_discount.model_sale_order_line msgid "Sales Order Line" msgstr "Postavka prodajnega naloga" + +#. module: sale_triple_discount +#: model:ir.model.fields,help:sale_triple_discount.field_sale_order_line_discounting_type +msgid "" +"Specifies whether discounts should be additive or multiplicative.\n" +"Additive discounts are summed first and then applied.\n" +"Multiplicative discounts are applied sequentially.\n" +"Multiplicative discounts are default" +msgstr "" diff --git a/sale_triple_discount/i18n/tr.po b/sale_triple_discount/i18n/tr.po index 14aa7c17ffa..6666f6aca28 100644 --- a/sale_triple_discount/i18n/tr.po +++ b/sale_triple_discount/i18n/tr.po @@ -18,6 +18,11 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" +#. module: sale_triple_discount +#: selection:sale.order.line,discounting_type:0 +msgid "Additive" +msgstr "" + #. module: sale_triple_discount #: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount2 msgid "Disc. 2 (%)" @@ -38,7 +43,38 @@ msgstr "" msgid "Discount 3 must be lower than 100%." msgstr "" +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discounting_type +msgid "Discounting type" +msgstr "" + +#. module: sale_triple_discount +#: selection:sale.order.line,discounting_type:0 +msgid "Multiplicative" +msgstr "" + +#. module: sale_triple_discount +#: code:addons/sale_triple_discount/models/sale_order_line.py:23 +#, python-format +msgid "Sale order line %s has unknown discounting type %s" +msgstr "" + +#. module: sale_triple_discount +#: model:ir.model,name:sale_triple_discount.model_sale_order +#, fuzzy +msgid "Sales Order" +msgstr "Satış Siparişi Hattı" + #. module: sale_triple_discount #: model:ir.model,name:sale_triple_discount.model_sale_order_line msgid "Sales Order Line" msgstr "Satış Siparişi Hattı" + +#. module: sale_triple_discount +#: model:ir.model.fields,help:sale_triple_discount.field_sale_order_line_discounting_type +msgid "" +"Specifies whether discounts should be additive or multiplicative.\n" +"Additive discounts are summed first and then applied.\n" +"Multiplicative discounts are applied sequentially.\n" +"Multiplicative discounts are default" +msgstr "" diff --git a/sale_triple_discount/i18n/tr_TR.po b/sale_triple_discount/i18n/tr_TR.po index 3094ab85008..957f8cc5f3e 100644 --- a/sale_triple_discount/i18n/tr_TR.po +++ b/sale_triple_discount/i18n/tr_TR.po @@ -19,6 +19,11 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: nplurals=1; plural=0;\n" +#. module: sale_triple_discount +#: selection:sale.order.line,discounting_type:0 +msgid "Additive" +msgstr "" + #. module: sale_triple_discount #: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount2 msgid "Disc. 2 (%)" @@ -39,7 +44,38 @@ msgstr "" msgid "Discount 3 must be lower than 100%." msgstr "" +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discounting_type +msgid "Discounting type" +msgstr "" + +#. module: sale_triple_discount +#: selection:sale.order.line,discounting_type:0 +msgid "Multiplicative" +msgstr "" + +#. module: sale_triple_discount +#: code:addons/sale_triple_discount/models/sale_order_line.py:23 +#, python-format +msgid "Sale order line %s has unknown discounting type %s" +msgstr "" + +#. module: sale_triple_discount +#: model:ir.model,name:sale_triple_discount.model_sale_order +#, fuzzy +msgid "Sales Order" +msgstr "Sipariş emri satırı " + #. module: sale_triple_discount #: model:ir.model,name:sale_triple_discount.model_sale_order_line msgid "Sales Order Line" msgstr "Sipariş emri satırı " + +#. module: sale_triple_discount +#: model:ir.model.fields,help:sale_triple_discount.field_sale_order_line_discounting_type +msgid "" +"Specifies whether discounts should be additive or multiplicative.\n" +"Additive discounts are summed first and then applied.\n" +"Multiplicative discounts are applied sequentially.\n" +"Multiplicative discounts are default" +msgstr "" diff --git a/sale_triple_discount/models/sale_order.py b/sale_triple_discount/models/sale_order.py index 350d7554e01..631a9f8d624 100644 --- a/sale_triple_discount/models/sale_order.py +++ b/sale_triple_discount/models/sale_order.py @@ -12,21 +12,6 @@ class SaleOrder(models.Model): def _amount_all(self): prev_values = dict() for order in self: - for line in order.order_line: - prev_values[line] = dict( - discount=line.discount, - discount2=line.discount2, - discount3=line.discount3, - ) - # Update, for some reason, does not work - line.write({ - 'discount': line._get_triple_discount(), - 'discount2': 0.0, - 'discount3': 0.0 - }) + prev_values.update(order.order_line.triple_discount_preprocess()) super(SaleOrder, self)._amount_all() - - # Restore previous values - for line, prev_vals_dict in prev_values.items(): - # Update, for some reason, does not work - line.write(prev_vals_dict) + self.env['sale.order.line'].triple_discount_postprocess(prev_values) diff --git a/sale_triple_discount/models/sale_order_line.py b/sale_triple_discount/models/sale_order_line.py index 26918803338..7c1675949c9 100644 --- a/sale_triple_discount/models/sale_order_line.py +++ b/sale_triple_discount/models/sale_order_line.py @@ -63,15 +63,19 @@ def triple_discount_preprocess(self): """Save the values of the discounts in a dictionary, to be restored in postprocess. Resetting discount2 and discount3 to 0.0 avoids issues if - this method is called multiple times.""" + this method is called multiple times. + Updating the cache provides consistency through recomputations.""" prev_values = dict() + self.invalidate_cache( + fnames=['discount', 'discount2', 'discount3'], + ids=self.ids) for line in self: prev_values[line] = dict( discount=line.discount, discount2=line.discount2, discount3=line.discount3, ) - line.update({ + line._cache.update({ 'discount': line._get_triple_discount(), 'discount2': 0.0, 'discount3': 0.0 @@ -80,6 +84,10 @@ def triple_discount_preprocess(self): @api.model def triple_discount_postprocess(self, prev_values): - """Restore the discounts of the lines in the dictionary prev_values""" + """Restore the discounts of the lines in the dictionary prev_values. + Updating the cache provides consistency through recomputations.""" + self.invalidate_cache( + fnames=['discount', 'discount2', 'discount3'], + ids=[l.id for l in prev_values.keys()]) for line, prev_vals_dict in prev_values.items(): - line.update(prev_vals_dict) + line._cache.update(prev_vals_dict) From b36dfe773bc24eed4f89deb6f4e4a1c5a5adc1d6 Mon Sep 17 00:00:00 2001 From: Jacques-Etienne Baudoux Date: Wed, 21 Nov 2018 16:32:19 +0100 Subject: [PATCH 07/44] sale_triple_discount: Fix tax total on report: include the discount2/3 in the computation --- sale_triple_discount/README.rst | 1 + sale_triple_discount/__manifest__.py | 1 + sale_triple_discount/models/sale_order.py | 25 ++++++++++++++++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/sale_triple_discount/README.rst b/sale_triple_discount/README.rst index 8b3def3b5f2..e73f9cbf512 100644 --- a/sale_triple_discount/README.rst +++ b/sale_triple_discount/README.rst @@ -65,6 +65,7 @@ Contributors * Alex Comba * David Vidal * Simone Rubino +* Jacques-Etienne Baudoux (BCIM sprl) Maintainer ---------- diff --git a/sale_triple_discount/__manifest__.py b/sale_triple_discount/__manifest__.py index 1e99688ba12..96ab9ec9a7a 100644 --- a/sale_triple_discount/__manifest__.py +++ b/sale_triple_discount/__manifest__.py @@ -2,6 +2,7 @@ # Copyright 2015 ADHOC SA (http://www.adhoc.com.ar) # Copyright 2017 Alex Comba - Agile Business Group # Copyright 2017 Tecnativa - David Vidal +# Copyright 2018 Jacques-Etienne Baudoux (BCIM sprl) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { diff --git a/sale_triple_discount/models/sale_order.py b/sale_triple_discount/models/sale_order.py index 631a9f8d624..a586532724c 100644 --- a/sale_triple_discount/models/sale_order.py +++ b/sale_triple_discount/models/sale_order.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # Copyright 2018 Simone Rubino - Agile Business Group -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +# Copyright 2018 Jacques-Etienne Baudoux (BCIM sprl) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import api, models @@ -15,3 +16,25 @@ def _amount_all(self): prev_values.update(order.order_line.triple_discount_preprocess()) super(SaleOrder, self)._amount_all() self.env['sale.order.line'].triple_discount_postprocess(prev_values) + + @api.multi + def _get_tax_amount_by_group(self): + # Copy/paste from standard method in sale + self.ensure_one() + res = {} + for line in self.order_line: + price_reduce = line.price_reduce # changed + taxes = line.tax_id.compute_all( + price_reduce, quantity=line.product_uom_qty, + product=line.product_id, + partner=self.partner_shipping_id)['taxes'] + for tax in line.tax_id: + group = tax.tax_group_id + res.setdefault(group, 0.0) + for t in taxes: + if (t['id'] == tax.id or + t['id'] in tax.children_tax_ids.ids): + res[group] += t['amount'] + res = sorted(res.items(), key=lambda l: l[0].sequence) + res = map(lambda l: (l[0].name, l[1]), res) + return res From c4c40cb0aa392324490d565e298574ef61d3e706 Mon Sep 17 00:00:00 2001 From: mpanarin Date: Fri, 13 Jul 2018 15:43:11 +0300 Subject: [PATCH 08/44] [IMP] 10.0 sale_triple_discount: rework discount computation --- sale_triple_discount/README.rst | 22 +++++- .../models/sale_order_line.py | 54 ++++++++++++- .../tests/test_sale_triple_discount.py | 78 ++++++++++++------- .../views/sale_order_view.xml | 2 + 4 files changed, 120 insertions(+), 36 deletions(-) diff --git a/sale_triple_discount/README.rst b/sale_triple_discount/README.rst index e73f9cbf512..a9e14cf9e28 100644 --- a/sale_triple_discount/README.rst +++ b/sale_triple_discount/README.rst @@ -6,7 +6,7 @@ Sale Triple Discount ==================== -This module allows to have three successive discounts on every sale order +This module allows to have three discounts on every sale order line. Configuration @@ -20,9 +20,11 @@ Usage ===== Create a new sale order and add discounts in any of the three discount -fields given. They go in order of precedence so discount 2 will be calculated -over discount 1 and discount 3 over the result of discount 2. For example, -let's divide by two on every discount: +fields given. + +For multiplicative discounts they go in order of precedence so discount 2 will +be calculated over discount 1 and discount 3 over the result of discount 2. For +example, let's divide by two on every discount: Unit price: 600.00 -> @@ -30,6 +32,15 @@ Unit price: 600.00 -> - Disc. 2 = 50% -> Amount = 150.00 - Disc. 3 = 50% -> Amount = 75.00 +For additive discounts they will be summed first and then applied. For +example, let's have a three 20% discounts: + +Unit price: 600.00 -> + + - Disc. 1, 2, 3 = 20% + 20% + 20% -> 60% + - Disc. final = 60% -> Amount = 240.00 + + You can also use negative values to make a charge instead of a discount: Unit price: 600.00 -> @@ -37,6 +48,9 @@ Unit price: 600.00 -> - Disc. 1 = 50% -> Amount = 300.00 - Disc. 2 = -5% -> Amount = 315.00 +Module allows defining additional discount fields and applying them with +other by adding them to the `_discount_fields` method. + .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot :target: https://runbot.odoo-community.org/runbot/167/10.0 diff --git a/sale_triple_discount/models/sale_order_line.py b/sale_triple_discount/models/sale_order_line.py index 7c1675949c9..a8c13aa5c99 100644 --- a/sale_triple_discount/models/sale_order_line.py +++ b/sale_triple_discount/models/sale_order_line.py @@ -5,14 +5,49 @@ # Copyright 2018 Simone Rubino - Agile Business Group # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import api, fields, models +from odoo import _, api, fields, models +from odoo.exceptions import ValidationError import odoo.addons.decimal_precision as dp class SaleOrderLine(models.Model): _inherit = "sale.order.line" - @api.depends('discount2', 'discount3') + def _get_final_discount(self): + self.ensure_one() + if self.discounting_type == "additive": + return self._additive_discount() + elif self.discounting_type == "multiplicative": + return self._multiplicative_discount() + else: + raise ValidationError(_( + "Sale order line %s has unknown discounting type %s" + ) % (self.name, self.discounting_type)) + + def _additive_discount(self): + self.ensure_one() + discount = sum( + [getattr(self, x) or 0.0 for x in self._discount_fields()] + ) + if discount <= 0: + return 0 + elif discount >= 100: + return 100 + return discount + + def _multiplicative_discount(self): + self.ensure_one() + discounts = [1 - (self[x] or 0.0) / 100 + for x in self._discount_fields()] + final_discount = 1 + for discount in discounts: + final_discount *= discount + return 100 - final_discount * 100 + + def _discount_fields(self): + return ['discount', 'discount2', 'discount3'] + + @api.depends('discount2', 'discount3', 'discounting_type') def _compute_amount(self): prev_values = self.triple_discount_preprocess() super(SaleOrderLine, self)._compute_amount() @@ -28,6 +63,19 @@ def _compute_amount(self): digits=dp.get_precision('Discount'), default=0.0, ) + discounting_type = fields.Selection( + string="Discounting type", + selection=[ + ('additive', 'Additive'), + ('multiplicative', 'Multiplicative'), + ], + default="multiplicative", + required=True, + help="Specifies whether discounts should be additive " + "or multiplicative.\nAdditive discounts are summed first and " + "then applied.\nMultiplicative discounts are applied sequentially.\n" + "Multiplicative discounts are default", + ) _sql_constraints = [ ('discount2_limit', 'CHECK (discount2 <= 100.0)', @@ -76,7 +124,7 @@ def triple_discount_preprocess(self): discount3=line.discount3, ) line._cache.update({ - 'discount': line._get_triple_discount(), + 'discount': line._get_final_discount(), 'discount2': 0.0, 'discount3': 0.0 }) diff --git a/sale_triple_discount/tests/test_sale_triple_discount.py b/sale_triple_discount/tests/test_sale_triple_discount.py index 0c73d0943d3..bdb730b2bba 100644 --- a/sale_triple_discount/tests/test_sale_triple_discount.py +++ b/sale_triple_discount/tests/test_sale_triple_discount.py @@ -51,13 +51,13 @@ def test_01_sale_order_classic_discount(self): """ Tests with single discount """ self.so_line1.discount = 50.0 self.so_line2.discount = 75.0 - self.assertEqual(self.so_line1.price_subtotal, 300.0) - self.assertEqual(self.so_line2.price_subtotal, 150.0) - self.assertEqual(self.order.amount_untaxed, 450.0) - self.assertEqual(self.order.amount_tax, 67.5) + self.assertAlmostEqual(self.so_line1.price_subtotal, 300.0) + self.assertAlmostEqual(self.so_line2.price_subtotal, 150.0) + self.assertAlmostEqual(self.order.amount_untaxed, 450.0) + self.assertAlmostEqual(self.order.amount_tax, 67.5) # Mix taxed and untaxed: self.so_line1.tax_id = False - self.assertEqual(self.order.amount_tax, 22.5) + self.assertAlmostEqual(self.order.amount_tax, 22.5) def test_02_sale_order_simple_triple_discount(self): """ Tests on a single line """ @@ -66,32 +66,52 @@ def test_02_sale_order_simple_triple_discount(self): self.so_line1.discount = 50.0 self.so_line1.discount2 = 50.0 self.so_line1.discount3 = 50.0 - self.assertEqual(self.so_line1.price_subtotal, 75.0) - self.assertEqual(self.order.amount_untaxed, 75.0) - self.assertEqual(self.order.amount_tax, 11.25) + self.assertAlmostEqual(self.so_line1.price_subtotal, 75.0) + self.assertAlmostEqual(self.order.amount_untaxed, 75.0) + self.assertAlmostEqual(self.order.amount_tax, 11.25) # Unset first discount: self.so_line1.discount = 0.0 - self.assertEqual(self.so_line1.price_subtotal, 150.0) - self.assertEqual(self.order.amount_untaxed, 150.0) - self.assertEqual(self.order.amount_tax, 22.5) + self.assertAlmostEqual(self.so_line1.price_subtotal, 150.0) + self.assertAlmostEqual(self.order.amount_untaxed, 150.0) + self.assertAlmostEqual(self.order.amount_tax, 22.5) # Set a charge instead: self.so_line1.discount2 = -50.0 - self.assertEqual(self.so_line1.price_subtotal, 450.0) - self.assertEqual(self.order.amount_untaxed, 450.0) - self.assertEqual(self.order.amount_tax, 67.5) + self.assertAlmostEqual(self.so_line1.price_subtotal, 450.0) + self.assertAlmostEqual(self.order.amount_untaxed, 450.0) + self.assertAlmostEqual(self.order.amount_tax, 67.5) + # set discount_type to additive + self.so_line1.discount = 10.0 + self.so_line1.discount2 = 10.0 + self.so_line1.discount3 = 10.0 + self.so_line1.discounting_type = "additive" + self.assertAlmostEqual(self.so_line1.price_subtotal, 420.0) + self.assertAlmostEqual(self.order.amount_untaxed, 420.0) + self.assertAlmostEqual(self.order.amount_tax, 63.0) + # set discount over 100% + self.so_line1.discount = 30.0 + self.so_line1.discount2 = 70.0 + self.so_line1.discount3 = 50.0 + self.assertAlmostEqual(self.so_line1.price_subtotal, 0.0) + self.assertAlmostEqual(self.order.amount_untaxed, 0.0) + self.assertAlmostEqual(self.order.amount_tax, 0.0) def test_03_sale_order_complex_triple_discount(self): """ Tests on multiple lines """ self.so_line1.discount = 50.0 self.so_line1.discount2 = 50.0 self.so_line1.discount3 = 50.0 - self.assertEqual(self.so_line1.price_subtotal, 75.0) - self.assertEqual(self.order.amount_untaxed, 675.0) - self.assertEqual(self.order.amount_tax, 101.25) + self.assertAlmostEqual(self.so_line1.price_subtotal, 75.0) + self.assertAlmostEqual(self.order.amount_untaxed, 675.0) + self.assertAlmostEqual(self.order.amount_tax, 101.25) self.so_line2.discount3 = 50.0 - self.assertEqual(self.so_line2.price_subtotal, 300.0) - self.assertEqual(self.order.amount_untaxed, 375.0) - self.assertEqual(self.order.amount_tax, 56.25) + self.assertAlmostEqual(self.so_line2.price_subtotal, 300.0) + self.assertAlmostEqual(self.order.amount_untaxed, 375.0) + self.assertAlmostEqual(self.order.amount_tax, 56.25) + self.so_line2.discounting_type = "additive" + self.so_line2.discount2 = 10.0 + self.assertAlmostEqual(self.so_line2.price_subtotal, 240.0) + self.assertAlmostEqual(self.order.amount_untaxed, 315.0) + self.assertAlmostEqual(self.order.amount_tax, 47.25) def test_04_sale_order_triple_discount_invoicing(self): """ When a confirmed order is invoiced, the resultant invoice @@ -103,15 +123,15 @@ def test_04_sale_order_triple_discount_invoicing(self): self.order.action_confirm() self.order.action_invoice_create() invoice = self.order.invoice_ids[0] - self.assertEqual(self.so_line1.discount, - invoice.invoice_line_ids[0].discount) - self.assertEqual(self.so_line1.discount2, - invoice.invoice_line_ids[0].discount2) - self.assertEqual(self.so_line1.discount3, - invoice.invoice_line_ids[0].discount3) - self.assertEqual(self.so_line2.discount3, - invoice.invoice_line_ids[1].discount3) - self.assertEqual(self.order.amount_total, invoice.amount_total) + self.assertAlmostEqual(self.so_line1.discount, + invoice.invoice_line_ids[0].discount) + self.assertAlmostEqual(self.so_line1.discount2, + invoice.invoice_line_ids[0].discount2) + self.assertAlmostEqual(self.so_line1.discount3, + invoice.invoice_line_ids[0].discount3) + self.assertAlmostEqual(self.so_line2.discount3, + invoice.invoice_line_ids[1].discount3) + self.assertAlmostEqual(self.order.amount_total, invoice.amount_total) def test_05_round_globally(self): """ Tests on multiple lines when 'round_globally' is active""" diff --git a/sale_triple_discount/views/sale_order_view.xml b/sale_triple_discount/views/sale_order_view.xml index a52618a5df2..f9e02167b27 100755 --- a/sale_triple_discount/views/sale_order_view.xml +++ b/sale_triple_discount/views/sale_order_view.xml @@ -12,6 +12,8 @@ groups="sale.group_discount_per_so_line"/> + From c6cb619e085affc4dfcdc98b973254af13058d90 Mon Sep 17 00:00:00 2001 From: Akim Juillerat Date: Thu, 4 Jul 2019 12:02:37 +0200 Subject: [PATCH 09/44] Play onchange after invoice creation to ensure discounts are applied --- sale_triple_discount/models/sale_order.py | 10 ++++++++++ .../tests/test_sale_triple_discount.py | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/sale_triple_discount/models/sale_order.py b/sale_triple_discount/models/sale_order.py index a586532724c..1ef42c7de00 100644 --- a/sale_triple_discount/models/sale_order.py +++ b/sale_triple_discount/models/sale_order.py @@ -38,3 +38,13 @@ def _get_tax_amount_by_group(self): res = sorted(res.items(), key=lambda l: l[0].sequence) res = map(lambda l: (l[0].name, l[1]), res) return res + + @api.multi + def action_invoice_create(self, grouped=False, final=False): + invoice_ids = super(SaleOrder, self).action_invoice_create( + grouped=grouped, final=final + ) + invoices = self.env['account.invoice'].browse(invoice_ids) + for inv in invoices: + inv._onchange_invoice_line_ids() + return invoice_ids diff --git a/sale_triple_discount/tests/test_sale_triple_discount.py b/sale_triple_discount/tests/test_sale_triple_discount.py index bdb730b2bba..6f115fe9b86 100644 --- a/sale_triple_discount/tests/test_sale_triple_discount.py +++ b/sale_triple_discount/tests/test_sale_triple_discount.py @@ -129,8 +129,12 @@ def test_04_sale_order_triple_discount_invoicing(self): invoice.invoice_line_ids[0].discount2) self.assertAlmostEqual(self.so_line1.discount3, invoice.invoice_line_ids[0].discount3) + self.assertAlmostEqual(self.so_line1.price_subtotal, + invoice.invoice_line_ids[0].price_subtotal) self.assertAlmostEqual(self.so_line2.discount3, invoice.invoice_line_ids[1].discount3) + self.assertAlmostEqual(self.so_line2.price_subtotal, + invoice.invoice_line_ids[1].price_subtotal) self.assertAlmostEqual(self.order.amount_total, invoice.amount_total) def test_05_round_globally(self): From 079bd02f9395da29e70adf2afd657b56fa02343b Mon Sep 17 00:00:00 2001 From: Akim Juillerat Date: Thu, 4 Jul 2019 15:04:10 +0200 Subject: [PATCH 10/44] Fix groups on sale.order view [UPD] Update sale_triple_discount.pot --- .../i18n/sale_triple_discount.pot | 29 +++++++++++++++++++ .../views/sale_order_view.xml | 23 ++++++++------- 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/sale_triple_discount/i18n/sale_triple_discount.pot b/sale_triple_discount/i18n/sale_triple_discount.pot index 860623dbcd1..2de17124d07 100644 --- a/sale_triple_discount/i18n/sale_triple_discount.pot +++ b/sale_triple_discount/i18n/sale_triple_discount.pot @@ -13,6 +13,11 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: \n" +#. module: sale_triple_discount +#: selection:sale.order.line,discounting_type:0 +msgid "Additive" +msgstr "" + #. module: sale_triple_discount #: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discount2 msgid "Disc. 2 (%)" @@ -33,6 +38,22 @@ msgstr "" msgid "Discount 3 must be lower than 100%." msgstr "" +#. module: sale_triple_discount +#: model:ir.model.fields,field_description:sale_triple_discount.field_sale_order_line_discounting_type +msgid "Discounting type" +msgstr "" + +#. module: sale_triple_discount +#: selection:sale.order.line,discounting_type:0 +msgid "Multiplicative" +msgstr "" + +#. module: sale_triple_discount +#: code:addons/sale_triple_discount/models/sale_order_line.py:23 +#, python-format +msgid "Sale order line %s has unknown discounting type %s" +msgstr "" + #. module: sale_triple_discount #: model:ir.model,name:sale_triple_discount.model_sale_order msgid "Sales Order" @@ -43,3 +64,11 @@ msgstr "" msgid "Sales Order Line" msgstr "" +#. module: sale_triple_discount +#: model:ir.model.fields,help:sale_triple_discount.field_sale_order_line_discounting_type +msgid "Specifies whether discounts should be additive or multiplicative.\n" +"Additive discounts are summed first and then applied.\n" +"Multiplicative discounts are applied sequentially.\n" +"Multiplicative discounts are default" +msgstr "" + diff --git a/sale_triple_discount/views/sale_order_view.xml b/sale_triple_discount/views/sale_order_view.xml index f9e02167b27..e5d9c2dd97e 100755 --- a/sale_triple_discount/views/sale_order_view.xml +++ b/sale_triple_discount/views/sale_order_view.xml @@ -5,26 +5,29 @@ sale.order.triple.discount.form sale.order + - - - + + + -