From b377e946beb241064eb7ab2ac600eb3aa47452d6 Mon Sep 17 00:00:00 2001 From: David Vidal Date: Tue, 18 Jul 2017 20:20:49 +0200 Subject: [PATCH 01/33] [ADD] purchase_triple_discount: New module --- purchase_triple_discount/README.rst | 71 ++++++++++ purchase_triple_discount/__init__.py | 3 + purchase_triple_discount/__manifest__.py | 21 +++ purchase_triple_discount/models/__init__.py | 4 + .../models/account_invoice.py | 16 +++ .../models/purchase_order.py | 42 ++++++ purchase_triple_discount/tests/__init__.py | 3 + .../tests/test_purchase_discount.py | 125 ++++++++++++++++++ .../views/purchase_view.xml | 22 +++ 9 files changed, 307 insertions(+) create mode 100644 purchase_triple_discount/README.rst create mode 100644 purchase_triple_discount/__init__.py create mode 100644 purchase_triple_discount/__manifest__.py create mode 100644 purchase_triple_discount/models/__init__.py create mode 100644 purchase_triple_discount/models/account_invoice.py create mode 100644 purchase_triple_discount/models/purchase_order.py create mode 100644 purchase_triple_discount/tests/__init__.py create mode 100644 purchase_triple_discount/tests/test_purchase_discount.py create mode 100644 purchase_triple_discount/views/purchase_view.xml diff --git a/purchase_triple_discount/README.rst b/purchase_triple_discount/README.rst new file mode 100644 index 00000000000..d72ad7e10e9 --- /dev/null +++ b/purchase_triple_discount/README.rst @@ -0,0 +1,71 @@ +.. 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 + +======================== +Purchase Triple Discount +======================== + +This module allows to have three successive discounts on every purchase order +line. + +Usage +===== + +Create a new purchase 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 charge instead of 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/142/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 +------------ + +* David Vidal + +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/purchase_triple_discount/__init__.py b/purchase_triple_discount/__init__.py new file mode 100644 index 00000000000..cde864bae21 --- /dev/null +++ b/purchase_triple_discount/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import models diff --git a/purchase_triple_discount/__manifest__.py b/purchase_triple_discount/__manifest__.py new file mode 100644 index 00000000000..a6d0ff2ecc1 --- /dev/null +++ b/purchase_triple_discount/__manifest__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 Tecnativa - David Vidal +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +{ + 'name': 'Account Invoice Triple Discount', + 'version': '10.0.1.0.0', + 'category': 'Purchase Management', + 'author': 'Tecnativa, ' + 'Odoo Community Association (OCA)', + 'website': 'https://tecnativa.com', + 'license': 'AGPL-3', + 'summary': 'Manage triple discount on purchase order lines', + 'depends': [ + 'purchase_discount', + 'account_invoice_triple_discount', + ], + 'data': [ + 'views/purchase_view.xml', + ], + 'installable': True, +} diff --git a/purchase_triple_discount/models/__init__.py b/purchase_triple_discount/models/__init__.py new file mode 100644 index 00000000000..c72976ae1ea --- /dev/null +++ b/purchase_triple_discount/models/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- + +from . import account_invoice +from . import purchase_order diff --git a/purchase_triple_discount/models/account_invoice.py b/purchase_triple_discount/models/account_invoice.py new file mode 100644 index 00000000000..18cb43c3a37 --- /dev/null +++ b/purchase_triple_discount/models/account_invoice.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 Tecnativa - David Vidal +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import models + + +class AccountInvoice(models.Model): + _inherit = "account.invoice" + + def _prepare_invoice_line_from_po_line(self, line): + vals = super(AccountInvoice, + self)._prepare_invoice_line_from_po_line(line) + vals['discount2'] = line.discount2 + vals['discount3'] = line.discount3 + return vals diff --git a/purchase_triple_discount/models/purchase_order.py b/purchase_triple_discount/models/purchase_order.py new file mode 100644 index 00000000000..c2b2d363952 --- /dev/null +++ b/purchase_triple_discount/models/purchase_order.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 Tecnativa - David Vidal +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models +from odoo.addons import decimal_precision as dp + + +class PurchaseOrderLine(models.Model): + _inherit = "purchase.order.line" + + @api.depends('discount2', 'discount3') + def _compute_amount(self): + super(PurchaseOrderLine, self)._compute_amount() + + discount2 = fields.Float( + 'Disc. 2 (%)', + digits=dp.get_precision('Discount'), + default=0.0, + ) + + discount3 = fields.Float( + 'Disc. 3 (%)', + digits=dp.get_precision('Discount'), + default=0.0, + ) + + _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%.'), + ] + + def _get_discounted_price_unit(self): + price_unit = super( + PurchaseOrderLine, self)._get_discounted_price_unit() + if self.discount2: + price_unit *= (1 - self.discount2 / 100.0) + if self.discount3: + price_unit *= (1 - self.discount3 / 100.0) + return price_unit diff --git a/purchase_triple_discount/tests/__init__.py b/purchase_triple_discount/tests/__init__.py new file mode 100644 index 00000000000..b8e666681b0 --- /dev/null +++ b/purchase_triple_discount/tests/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import test_purchase_discount diff --git a/purchase_triple_discount/tests/test_purchase_discount.py b/purchase_triple_discount/tests/test_purchase_discount.py new file mode 100644 index 00000000000..ac4f0b3e73d --- /dev/null +++ b/purchase_triple_discount/tests/test_purchase_discount.py @@ -0,0 +1,125 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 Tecnativa - David Vidal +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.tests import common + + +class TestPurchaseOrder(common.SavepointCase): + + @classmethod + def setUpClass(cls): + super(TestPurchaseOrder, cls).setUpClass() + cls.partner = cls.env['res.partner'].create({ + 'name': 'Mr. Odoo', + }) + cls.product1 = cls.env['product.product'].create({ + 'name': 'Test Product 1', + 'purchase_method': 'purchase', + }) + cls.product2 = cls.env['product.product'].create({ + 'name': 'Test Product 2', + 'purchase_method': 'purchase', + }) + cls.tax = cls.env['account.tax'].create({ + 'name': 'TAX 15%', + 'amount_type': 'percent', + 'type_tax_use': 'purchase', + 'amount': 15.0, + }) + cls.order = cls.env['purchase.order'].create({ + 'partner_id': cls.partner.id + }) + po_line = cls.env['purchase.order.line'] + cls.po_line1 = po_line.create({ + 'order_id': cls.order.id, + 'product_id': cls.product1.id, + 'date_planned': '2018-01-19 00:00:00', + 'name': 'Line 1', + 'product_qty': 1.0, + 'product_uom': cls.product1.uom_id.id, + 'taxes_id': [(6, 0, [cls.tax.id])], + 'price_unit': 600.0, + }) + cls.po_line2 = po_line.create({ + 'order_id': cls.order.id, + 'product_id': cls.product2.id, + 'date_planned': '2018-01-19 00:00:00', + 'name': 'Line 2', + 'product_qty': 10.0, + 'product_uom': cls.product2.uom_id.id, + 'taxes_id': [(6, 0, [cls.tax.id])], + 'price_unit': 60.0, + }) + + def test_01_purchase_order_classic_discount(self): + """ Tests with single discount """ + self.po_line1.discount = 50.0 + self.po_line2.discount = 75.0 + self.assertEqual(self.po_line1.price_subtotal, 300.0) + self.assertEqual(self.po_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.po_line1.taxes_id = False + self.assertEqual(self.order.amount_tax, 22.5) + + def test_02_purchase_order_simple_triple_discount(self): + """ Tests on a single line """ + self.po_line2.unlink() + # Divide by two on every discount: + self.po_line1.discount = 50.0 + self.po_line1.discount2 = 50.0 + self.po_line1.discount3 = 50.0 + self.assertEqual(self.po_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.po_line1.discount = 0.0 + self.assertEqual(self.po_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.po_line1.discount2 = -50.0 + self.assertEqual(self.po_line1.price_subtotal, 450.0) + self.assertEqual(self.order.amount_untaxed, 450.0) + self.assertEqual(self.order.amount_tax, 67.5) + + def test_03_purchase_order_complex_triple_discount(self): + """ Tests on multiple lines """ + self.po_line1.discount = 50.0 + self.po_line1.discount2 = 50.0 + self.po_line1.discount3 = 50.0 + self.assertEqual(self.po_line1.price_subtotal, 75.0) + self.assertEqual(self.order.amount_untaxed, 675.0) + self.assertEqual(self.order.amount_tax, 101.25) + self.po_line2.discount3 = 50.0 + self.assertEqual(self.po_line2.price_subtotal, 300.0) + self.assertEqual(self.order.amount_untaxed, 375.0) + self.assertEqual(self.order.amount_tax, 56.25) + + def test_04_purchase_order_triple_discount_invoicing(self): + """ When a confirmed order is invoiced, the resultant invoice + should inherit the discounts """ + self.po_line1.discount = 50.0 + self.po_line1.discount2 = 50.0 + self.po_line1.discount3 = 50.0 + self.po_line2.discount3 = 50.0 + self.order.button_confirm() + self.invoice = self.env['account.invoice'].create({ + 'partner_id': self.partner.id, + 'purchase_id': self.order.id, + 'account_id': self.partner.property_account_payable_id.id, + 'type': 'in_invoice', + }) + self.invoice.purchase_order_change() + self.invoice._onchange_invoice_line_ids() + self.assertEqual(self.po_line1.discount, + self.invoice.invoice_line_ids[0].discount) + self.assertEqual(self.po_line1.discount2, + self.invoice.invoice_line_ids[0].discount2) + self.assertEqual(self.po_line1.discount3, + self.invoice.invoice_line_ids[0].discount3) + self.assertEqual(self.po_line2.discount3, + self.invoice.invoice_line_ids[1].discount3) + self.assertEqual(self.order.amount_total, self.invoice.amount_total) diff --git a/purchase_triple_discount/views/purchase_view.xml b/purchase_triple_discount/views/purchase_view.xml new file mode 100644 index 00000000000..b90a2536721 --- /dev/null +++ b/purchase_triple_discount/views/purchase_view.xml @@ -0,0 +1,22 @@ + + + + + purchase.order.triple.discount.form + purchase.order + + + + + + + + + + + + + + From 4afbe9b485f1a13f34aadacec7bce5b9e07f90d8 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Wed, 11 Oct 2017 15:32:41 +0200 Subject: [PATCH 02/33] [FIX] purchase_triple_discount: Correct view inheritance --- purchase_triple_discount/README.rst | 5 ++ purchase_triple_discount/__manifest__.py | 2 +- purchase_triple_discount/i18n/de.po | 49 ++++++++++++++++++ purchase_triple_discount/i18n/es.po | 49 ++++++++++++++++++ purchase_triple_discount/i18n/es_MX.po | 50 +++++++++++++++++++ purchase_triple_discount/i18n/es_PE.po | 50 +++++++++++++++++++ purchase_triple_discount/i18n/fi.po | 49 ++++++++++++++++++ purchase_triple_discount/i18n/fr.po | 50 +++++++++++++++++++ purchase_triple_discount/i18n/hr.po | 50 +++++++++++++++++++ purchase_triple_discount/i18n/it.po | 49 ++++++++++++++++++ purchase_triple_discount/i18n/nl_NL.po | 50 +++++++++++++++++++ purchase_triple_discount/i18n/pt_BR.po | 50 +++++++++++++++++++ purchase_triple_discount/i18n/pt_PT.po | 50 +++++++++++++++++++ .../i18n/purchase_triple_discount.pot | 45 +++++++++++++++++ purchase_triple_discount/i18n/ro.po | 50 +++++++++++++++++++ purchase_triple_discount/i18n/sl.po | 50 +++++++++++++++++++ .../views/purchase_view.xml | 2 +- 17 files changed, 698 insertions(+), 2 deletions(-) create mode 100644 purchase_triple_discount/i18n/de.po create mode 100644 purchase_triple_discount/i18n/es.po create mode 100644 purchase_triple_discount/i18n/es_MX.po create mode 100644 purchase_triple_discount/i18n/es_PE.po create mode 100644 purchase_triple_discount/i18n/fi.po create mode 100644 purchase_triple_discount/i18n/fr.po create mode 100644 purchase_triple_discount/i18n/hr.po create mode 100644 purchase_triple_discount/i18n/it.po create mode 100644 purchase_triple_discount/i18n/nl_NL.po create mode 100644 purchase_triple_discount/i18n/pt_BR.po create mode 100644 purchase_triple_discount/i18n/pt_PT.po create mode 100644 purchase_triple_discount/i18n/purchase_triple_discount.pot create mode 100644 purchase_triple_discount/i18n/ro.po create mode 100644 purchase_triple_discount/i18n/sl.po diff --git a/purchase_triple_discount/README.rst b/purchase_triple_discount/README.rst index d72ad7e10e9..4f88069330e 100644 --- a/purchase_triple_discount/README.rst +++ b/purchase_triple_discount/README.rst @@ -42,6 +42,11 @@ Bugs are tracked on `GitHub Issues check there if your issue has already been reported. If you spotted it first, help us smash it by providing detailed and welcomed feedback. +Known issues / Roadmap +====================== + +* Include second and third discount in purchase order report. + Credits ======= diff --git a/purchase_triple_discount/__manifest__.py b/purchase_triple_discount/__manifest__.py index a6d0ff2ecc1..7736ff5f17d 100644 --- a/purchase_triple_discount/__manifest__.py +++ b/purchase_triple_discount/__manifest__.py @@ -3,7 +3,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { 'name': 'Account Invoice Triple Discount', - 'version': '10.0.1.0.0', + 'version': '10.0.1.1.0', 'category': 'Purchase Management', 'author': 'Tecnativa, ' 'Odoo Community Association (OCA)', diff --git a/purchase_triple_discount/i18n/de.po b/purchase_triple_discount/i18n/de.po new file mode 100644 index 00000000000..60c985cba07 --- /dev/null +++ b/purchase_triple_discount/i18n/de.po @@ -0,0 +1,49 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_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-24 07:53+0000\n" +"PO-Revision-Date: 2017-11-24 07:53+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: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line_discount2 +msgid "Disc. 2 (%)" +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line_discount3 +msgid "Disc. 3 (%)" +msgstr "" + +#. module: purchase_triple_discount +#: sql_constraint:purchase.order.line:0 +msgid "Discount 2 must be lower than 100%." +msgstr "" + +#. module: purchase_triple_discount +#: sql_constraint:purchase.order.line:0 +msgid "Discount 3 must be lower than 100%." +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_account_invoice +msgid "Invoice" +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_purchase_order_line +msgid "Purchase Order Line" +msgstr "Bestellposition" diff --git a/purchase_triple_discount/i18n/es.po b/purchase_triple_discount/i18n/es.po new file mode 100644 index 00000000000..1d7431079f9 --- /dev/null +++ b/purchase_triple_discount/i18n/es.po @@ -0,0 +1,49 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_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-24 07:53+0000\n" +"PO-Revision-Date: 2017-11-24 07:53+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" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line_discount2 +msgid "Disc. 2 (%)" +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line_discount3 +msgid "Disc. 3 (%)" +msgstr "" + +#. module: purchase_triple_discount +#: sql_constraint:purchase.order.line:0 +msgid "Discount 2 must be lower than 100%." +msgstr "" + +#. module: purchase_triple_discount +#: sql_constraint:purchase.order.line:0 +msgid "Discount 3 must be lower than 100%." +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_account_invoice +msgid "Invoice" +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_purchase_order_line +msgid "Purchase Order Line" +msgstr "Línea orden de compra" diff --git a/purchase_triple_discount/i18n/es_MX.po b/purchase_triple_discount/i18n/es_MX.po new file mode 100644 index 00000000000..d0fcb8a2b30 --- /dev/null +++ b/purchase_triple_discount/i18n/es_MX.po @@ -0,0 +1,50 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_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-24 07:53+0000\n" +"PO-Revision-Date: 2017-11-24 07:53+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Spanish (Mexico) (https://www.transifex.com/oca/teams/23907/" +"es_MX/)\n" +"Language: es_MX\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: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line_discount2 +msgid "Disc. 2 (%)" +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line_discount3 +msgid "Disc. 3 (%)" +msgstr "" + +#. module: purchase_triple_discount +#: sql_constraint:purchase.order.line:0 +msgid "Discount 2 must be lower than 100%." +msgstr "" + +#. module: purchase_triple_discount +#: sql_constraint:purchase.order.line:0 +msgid "Discount 3 must be lower than 100%." +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_account_invoice +msgid "Invoice" +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_purchase_order_line +msgid "Purchase Order Line" +msgstr "Línea de orden de compra" diff --git a/purchase_triple_discount/i18n/es_PE.po b/purchase_triple_discount/i18n/es_PE.po new file mode 100644 index 00000000000..4862e8824e8 --- /dev/null +++ b/purchase_triple_discount/i18n/es_PE.po @@ -0,0 +1,50 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_triple_discount +# +# Translators: +# Henry Garcia , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-11-24 07:53+0000\n" +"PO-Revision-Date: 2017-11-24 07:53+0000\n" +"Last-Translator: Henry Garcia , 2017\n" +"Language-Team: Spanish (Peru) (https://www.transifex.com/oca/teams/23907/" +"es_PE/)\n" +"Language: es_PE\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: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line_discount2 +msgid "Disc. 2 (%)" +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line_discount3 +msgid "Disc. 3 (%)" +msgstr "" + +#. module: purchase_triple_discount +#: sql_constraint:purchase.order.line:0 +msgid "Discount 2 must be lower than 100%." +msgstr "" + +#. module: purchase_triple_discount +#: sql_constraint:purchase.order.line:0 +msgid "Discount 3 must be lower than 100%." +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_account_invoice +msgid "Invoice" +msgstr "Factura" + +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_purchase_order_line +msgid "Purchase Order Line" +msgstr "Linea de orden de compra" diff --git a/purchase_triple_discount/i18n/fi.po b/purchase_triple_discount/i18n/fi.po new file mode 100644 index 00000000000..e4411b598ca --- /dev/null +++ b/purchase_triple_discount/i18n/fi.po @@ -0,0 +1,49 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_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-24 07:53+0000\n" +"PO-Revision-Date: 2017-11-24 07:53+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Finnish (https://www.transifex.com/oca/teams/23907/fi/)\n" +"Language: fi\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: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line_discount2 +msgid "Disc. 2 (%)" +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line_discount3 +msgid "Disc. 3 (%)" +msgstr "" + +#. module: purchase_triple_discount +#: sql_constraint:purchase.order.line:0 +msgid "Discount 2 must be lower than 100%." +msgstr "" + +#. module: purchase_triple_discount +#: sql_constraint:purchase.order.line:0 +msgid "Discount 3 must be lower than 100%." +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_account_invoice +msgid "Invoice" +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_purchase_order_line +msgid "Purchase Order Line" +msgstr "Ostotilausrivi" diff --git a/purchase_triple_discount/i18n/fr.po b/purchase_triple_discount/i18n/fr.po new file mode 100644 index 00000000000..b0e6eb62746 --- /dev/null +++ b/purchase_triple_discount/i18n/fr.po @@ -0,0 +1,50 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_triple_discount +# +# Translators: +# OCA Transbot , 2017 +# Quentin THEURET , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-11-25 08:26+0000\n" +"PO-Revision-Date: 2017-11-25 08:26+0000\n" +"Last-Translator: Quentin THEURET , 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: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line_discount2 +msgid "Disc. 2 (%)" +msgstr "Rem. 2 (%)" + +#. module: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line_discount3 +msgid "Disc. 3 (%)" +msgstr "Rem. 3 (%)" + +#. module: purchase_triple_discount +#: sql_constraint:purchase.order.line:0 +msgid "Discount 2 must be lower than 100%." +msgstr "La remise 2 doit être inférieure à 100%." + +#. module: purchase_triple_discount +#: sql_constraint:purchase.order.line:0 +msgid "Discount 3 must be lower than 100%." +msgstr "La remise 3 doit être inférieure à 100%." + +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_account_invoice +msgid "Invoice" +msgstr "Facture" + +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_purchase_order_line +msgid "Purchase Order Line" +msgstr "Ligne de commande d'achat" diff --git a/purchase_triple_discount/i18n/hr.po b/purchase_triple_discount/i18n/hr.po new file mode 100644 index 00000000000..f0fb4c19f1b --- /dev/null +++ b/purchase_triple_discount/i18n/hr.po @@ -0,0 +1,50 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_triple_discount +# +# Translators: +# Bole , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-03-03 03:48+0000\n" +"PO-Revision-Date: 2018-03-03 03:48+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: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line_discount2 +msgid "Disc. 2 (%)" +msgstr "Pop. 2 (%)" + +#. module: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line_discount3 +msgid "Disc. 3 (%)" +msgstr "Pop. 3(%)" + +#. module: purchase_triple_discount +#: sql_constraint:purchase.order.line:0 +msgid "Discount 2 must be lower than 100%." +msgstr "Popust 2 mora biti manje od 100%." + +#. module: purchase_triple_discount +#: sql_constraint:purchase.order.line:0 +msgid "Discount 3 must be lower than 100%." +msgstr "Popust 3 mora biti manje od 100%." + +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_account_invoice +msgid "Invoice" +msgstr "Račun" + +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_purchase_order_line +msgid "Purchase Order Line" +msgstr "Stavka naloga za nabavu" diff --git a/purchase_triple_discount/i18n/it.po b/purchase_triple_discount/i18n/it.po new file mode 100644 index 00000000000..cfcc9dd2aea --- /dev/null +++ b/purchase_triple_discount/i18n/it.po @@ -0,0 +1,49 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_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-24 07:53+0000\n" +"PO-Revision-Date: 2017-11-24 07:53+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: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line_discount2 +msgid "Disc. 2 (%)" +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line_discount3 +msgid "Disc. 3 (%)" +msgstr "" + +#. module: purchase_triple_discount +#: sql_constraint:purchase.order.line:0 +msgid "Discount 2 must be lower than 100%." +msgstr "" + +#. module: purchase_triple_discount +#: sql_constraint:purchase.order.line:0 +msgid "Discount 3 must be lower than 100%." +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_account_invoice +msgid "Invoice" +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_purchase_order_line +msgid "Purchase Order Line" +msgstr "Riga Ordine d'Acquisto" diff --git a/purchase_triple_discount/i18n/nl_NL.po b/purchase_triple_discount/i18n/nl_NL.po new file mode 100644 index 00000000000..b7d3bf6368c --- /dev/null +++ b/purchase_triple_discount/i18n/nl_NL.po @@ -0,0 +1,50 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_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-24 07:53+0000\n" +"PO-Revision-Date: 2017-11-24 07:53+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: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line_discount2 +msgid "Disc. 2 (%)" +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line_discount3 +msgid "Disc. 3 (%)" +msgstr "" + +#. module: purchase_triple_discount +#: sql_constraint:purchase.order.line:0 +msgid "Discount 2 must be lower than 100%." +msgstr "" + +#. module: purchase_triple_discount +#: sql_constraint:purchase.order.line:0 +msgid "Discount 3 must be lower than 100%." +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_account_invoice +msgid "Invoice" +msgstr "Factuur" + +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_purchase_order_line +msgid "Purchase Order Line" +msgstr "Inkooporderregel" diff --git a/purchase_triple_discount/i18n/pt_BR.po b/purchase_triple_discount/i18n/pt_BR.po new file mode 100644 index 00000000000..8781de26599 --- /dev/null +++ b/purchase_triple_discount/i18n/pt_BR.po @@ -0,0 +1,50 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_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-24 07:53+0000\n" +"PO-Revision-Date: 2017-11-24 07:53+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: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line_discount2 +msgid "Disc. 2 (%)" +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line_discount3 +msgid "Disc. 3 (%)" +msgstr "" + +#. module: purchase_triple_discount +#: sql_constraint:purchase.order.line:0 +msgid "Discount 2 must be lower than 100%." +msgstr "" + +#. module: purchase_triple_discount +#: sql_constraint:purchase.order.line:0 +msgid "Discount 3 must be lower than 100%." +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_account_invoice +msgid "Invoice" +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_purchase_order_line +msgid "Purchase Order Line" +msgstr "Linha da Ordem de Compra" diff --git a/purchase_triple_discount/i18n/pt_PT.po b/purchase_triple_discount/i18n/pt_PT.po new file mode 100644 index 00000000000..7050082db2a --- /dev/null +++ b/purchase_triple_discount/i18n/pt_PT.po @@ -0,0 +1,50 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_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-24 07:53+0000\n" +"PO-Revision-Date: 2017-11-24 07:53+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Portuguese (Portugal) (https://www.transifex.com/oca/" +"teams/23907/pt_PT/)\n" +"Language: pt_PT\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: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line_discount2 +msgid "Disc. 2 (%)" +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line_discount3 +msgid "Disc. 3 (%)" +msgstr "" + +#. module: purchase_triple_discount +#: sql_constraint:purchase.order.line:0 +msgid "Discount 2 must be lower than 100%." +msgstr "" + +#. module: purchase_triple_discount +#: sql_constraint:purchase.order.line:0 +msgid "Discount 3 must be lower than 100%." +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_account_invoice +msgid "Invoice" +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_purchase_order_line +msgid "Purchase Order Line" +msgstr "Linha de Encomenda de Compra" diff --git a/purchase_triple_discount/i18n/purchase_triple_discount.pot b/purchase_triple_discount/i18n/purchase_triple_discount.pot new file mode 100644 index 00000000000..1ae5dc0cc5d --- /dev/null +++ b/purchase_triple_discount/i18n/purchase_triple_discount.pot @@ -0,0 +1,45 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_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: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line_discount2 +msgid "Disc. 2 (%)" +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line_discount3 +msgid "Disc. 3 (%)" +msgstr "" + +#. module: purchase_triple_discount +#: sql_constraint:purchase.order.line:0 +msgid "Discount 2 must be lower than 100%." +msgstr "" + +#. module: purchase_triple_discount +#: sql_constraint:purchase.order.line:0 +msgid "Discount 3 must be lower than 100%." +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_account_invoice +msgid "Invoice" +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_purchase_order_line +msgid "Purchase Order Line" +msgstr "" + diff --git a/purchase_triple_discount/i18n/ro.po b/purchase_triple_discount/i18n/ro.po new file mode 100644 index 00000000000..fb4bd8aeaad --- /dev/null +++ b/purchase_triple_discount/i18n/ro.po @@ -0,0 +1,50 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_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-24 07:53+0000\n" +"PO-Revision-Date: 2017-11-24 07:53+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: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line_discount2 +msgid "Disc. 2 (%)" +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line_discount3 +msgid "Disc. 3 (%)" +msgstr "" + +#. module: purchase_triple_discount +#: sql_constraint:purchase.order.line:0 +msgid "Discount 2 must be lower than 100%." +msgstr "" + +#. module: purchase_triple_discount +#: sql_constraint:purchase.order.line:0 +msgid "Discount 3 must be lower than 100%." +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_account_invoice +msgid "Invoice" +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_purchase_order_line +msgid "Purchase Order Line" +msgstr "Linie comandă achiziție" diff --git a/purchase_triple_discount/i18n/sl.po b/purchase_triple_discount/i18n/sl.po new file mode 100644 index 00000000000..9eb0faffa56 --- /dev/null +++ b/purchase_triple_discount/i18n/sl.po @@ -0,0 +1,50 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_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-24 07:53+0000\n" +"PO-Revision-Date: 2017-11-24 07:53+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: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line_discount2 +msgid "Disc. 2 (%)" +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line_discount3 +msgid "Disc. 3 (%)" +msgstr "" + +#. module: purchase_triple_discount +#: sql_constraint:purchase.order.line:0 +msgid "Discount 2 must be lower than 100%." +msgstr "" + +#. module: purchase_triple_discount +#: sql_constraint:purchase.order.line:0 +msgid "Discount 3 must be lower than 100%." +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_account_invoice +msgid "Invoice" +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_purchase_order_line +msgid "Purchase Order Line" +msgstr "Postavka nabavnega naloga" diff --git a/purchase_triple_discount/views/purchase_view.xml b/purchase_triple_discount/views/purchase_view.xml index b90a2536721..58b5a089794 100644 --- a/purchase_triple_discount/views/purchase_view.xml +++ b/purchase_triple_discount/views/purchase_view.xml @@ -4,7 +4,7 @@ purchase.order.triple.discount.form purchase.order - + From 8348441d97dc63b4fa2a933a0f36a8c3268129e1 Mon Sep 17 00:00:00 2001 From: David Date: Mon, 5 Aug 2019 11:08:44 +0200 Subject: [PATCH 03/33] [MIG] purchase_triple_discount: Migration to 11.0 --- purchase_triple_discount/README.rst | 89 ++-- purchase_triple_discount/__init__.py | 2 - purchase_triple_discount/__manifest__.py | 9 +- .../i18n/purchase_triple_discount.pot | 52 +- purchase_triple_discount/models/__init__.py | 5 +- .../models/account_invoice.py | 1 - .../models/procurement_rule.py | 25 + .../models/product_supplierinfo.py | 43 ++ .../models/purchase_order.py | 44 +- .../models/res_partner.py | 21 + .../readme/CONTRIBUTORS.rst | 3 + .../readme/DESCRIPTION.rst | 2 + purchase_triple_discount/readme/ROADMAP.rst | 1 + purchase_triple_discount/readme/USAGE.rst | 24 + .../static/description/icon.png | Bin 0 -> 9455 bytes .../static/description/index.html | 465 ++++++++++++++++++ purchase_triple_discount/tests/__init__.py | 2 - .../tests/test_purchase_discount.py | 85 +++- .../views/product_supplierinfo_view.xml | 25 + .../views/res_partner_view.xml | 16 + 20 files changed, 866 insertions(+), 48 deletions(-) create mode 100644 purchase_triple_discount/models/procurement_rule.py create mode 100644 purchase_triple_discount/models/product_supplierinfo.py create mode 100644 purchase_triple_discount/models/res_partner.py create mode 100644 purchase_triple_discount/readme/CONTRIBUTORS.rst create mode 100644 purchase_triple_discount/readme/DESCRIPTION.rst create mode 100644 purchase_triple_discount/readme/ROADMAP.rst create mode 100644 purchase_triple_discount/readme/USAGE.rst create mode 100644 purchase_triple_discount/static/description/icon.png create mode 100644 purchase_triple_discount/static/description/index.html create mode 100644 purchase_triple_discount/views/product_supplierinfo_view.xml create mode 100644 purchase_triple_discount/views/res_partner_view.xml diff --git a/purchase_triple_discount/README.rst b/purchase_triple_discount/README.rst index 4f88069330e..3758da6f254 100644 --- a/purchase_triple_discount/README.rst +++ b/purchase_triple_discount/README.rst @@ -1,14 +1,38 @@ -.. 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 - -======================== -Purchase Triple Discount -======================== +=============================== +Account Invoice Triple Discount +=============================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github + :target: https://github.com/OCA/purchase-workflow/tree/11.0/purchase_triple_discount + :alt: OCA/purchase-workflow +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/purchase-workflow-11-0/purchase-workflow-11-0-purchase_triple_discount + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/142/11.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| This module allows to have three successive discounts on every purchase order line. +**Table of contents** + +.. contents:: + :local: + Usage ===== @@ -30,47 +54,56 @@ 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/142/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. +* When the purchase order is validated, the discounts will be added to the + corresponding vendor pricelist. +* Vendor pricelists can be edited as well with their corresponding new second + and third discounts. +* A default second or third discount can be set in every vendor + *Sale & Purchases* tab. Known issues / Roadmap ====================== * Include second and third discount in purchase order report. +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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + Credits ======= -Images ------- +Authors +~~~~~~~ -* Odoo Community Association: `Icon `_. +* Tecnativa Contributors ------------- +~~~~~~~~~~~~ -* David Vidal +* `Tecnativa `_: -Maintainer ----------- + * David Vidal + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. .. 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. +This module is part of the `OCA/purchase-workflow `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/purchase_triple_discount/__init__.py b/purchase_triple_discount/__init__.py index cde864bae21..0650744f6bc 100644 --- a/purchase_triple_discount/__init__.py +++ b/purchase_triple_discount/__init__.py @@ -1,3 +1 @@ -# -*- coding: utf-8 -*- - from . import models diff --git a/purchase_triple_discount/__manifest__.py b/purchase_triple_discount/__manifest__.py index 7736ff5f17d..3054422fdaa 100644 --- a/purchase_triple_discount/__manifest__.py +++ b/purchase_triple_discount/__manifest__.py @@ -1,21 +1,22 @@ -# -*- coding: utf-8 -*- # Copyright 2017 Tecnativa - David Vidal # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { 'name': 'Account Invoice Triple Discount', - 'version': '10.0.1.1.0', + 'version': '11.0.1.0.0', 'category': 'Purchase Management', 'author': 'Tecnativa, ' 'Odoo Community Association (OCA)', - 'website': 'https://tecnativa.com', + 'website': 'https://github.com/OCA/purchase-workflow', 'license': 'AGPL-3', 'summary': 'Manage triple discount on purchase order lines', 'depends': [ - 'purchase_discount', + 'product_supplierinfo_discount', 'account_invoice_triple_discount', ], 'data': [ + 'views/product_supplierinfo_view.xml', 'views/purchase_view.xml', + 'views/res_partner_view.xml', ], 'installable': True, } diff --git a/purchase_triple_discount/i18n/purchase_triple_discount.pot b/purchase_triple_discount/i18n/purchase_triple_discount.pot index 1ae5dc0cc5d..92024bb4572 100644 --- a/purchase_triple_discount/i18n/purchase_triple_discount.pot +++ b/purchase_triple_discount/i18n/purchase_triple_discount.pot @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 10.0\n" +"Project-Id-Version: Odoo Server 11.0\n" "Report-Msgid-Bugs-To: \n" "Last-Translator: <>\n" "Language-Team: \n" @@ -13,6 +13,23 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: \n" +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_res_partner +msgid "Contact" +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_res_partner_default_supplierinfo_discount2 +#: model:ir.model.fields,field_description:purchase_triple_discount.field_res_users_default_supplierinfo_discount2 +msgid "Default Supplier Discount 2 (%)" +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_res_partner_default_supplierinfo_discount3 +#: model:ir.model.fields,field_description:purchase_triple_discount.field_res_users_default_supplierinfo_discount3 +msgid "Default Supplier Discount 3 (%)" +msgstr "" + #. module: purchase_triple_discount #: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line_discount2 msgid "Disc. 2 (%)" @@ -23,23 +40,56 @@ msgstr "" msgid "Disc. 3 (%)" msgstr "" +#. module: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_product_supplierinfo_discount2 +msgid "Discount 2 (%)" +msgstr "" + #. module: purchase_triple_discount #: sql_constraint:purchase.order.line:0 msgid "Discount 2 must be lower than 100%." msgstr "" +#. module: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_product_supplierinfo_discount3 +msgid "Discount 3 (%)" +msgstr "" + #. module: purchase_triple_discount #: sql_constraint:purchase.order.line:0 msgid "Discount 3 must be lower than 100%." msgstr "" +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_product_supplierinfo +msgid "Information about a product vendor" +msgstr "" + #. module: purchase_triple_discount #: model:ir.model,name:purchase_triple_discount.model_account_invoice msgid "Invoice" msgstr "" +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_procurement_rule +msgid "Procurement Rule" +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_purchase_order +msgid "Purchase Order" +msgstr "" + #. module: purchase_triple_discount #: model:ir.model,name:purchase_triple_discount.model_purchase_order_line msgid "Purchase Order Line" msgstr "" +#. module: purchase_triple_discount +#: model:ir.model.fields,help:purchase_triple_discount.field_res_partner_default_supplierinfo_discount2 +#: model:ir.model.fields,help:purchase_triple_discount.field_res_partner_default_supplierinfo_discount3 +#: model:ir.model.fields,help:purchase_triple_discount.field_res_users_default_supplierinfo_discount2 +#: model:ir.model.fields,help:purchase_triple_discount.field_res_users_default_supplierinfo_discount3 +msgid "This value will be used as the default one, for each new supplierinfo line depending on that supplier." +msgstr "" + diff --git a/purchase_triple_discount/models/__init__.py b/purchase_triple_discount/models/__init__.py index c72976ae1ea..42194fa4c43 100644 --- a/purchase_triple_discount/models/__init__.py +++ b/purchase_triple_discount/models/__init__.py @@ -1,4 +1,5 @@ -# -*- coding: utf-8 -*- - from . import account_invoice +from . import procurement_rule +from . import product_supplierinfo from . import purchase_order +from . import res_partner diff --git a/purchase_triple_discount/models/account_invoice.py b/purchase_triple_discount/models/account_invoice.py index 18cb43c3a37..8c2e650addd 100644 --- a/purchase_triple_discount/models/account_invoice.py +++ b/purchase_triple_discount/models/account_invoice.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2017 Tecnativa - David Vidal # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). diff --git a/purchase_triple_discount/models/procurement_rule.py b/purchase_triple_discount/models/procurement_rule.py new file mode 100644 index 00000000000..75ef03cada9 --- /dev/null +++ b/purchase_triple_discount/models/procurement_rule.py @@ -0,0 +1,25 @@ +# Copyright 2019 Tecnativa - David Vidal +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import fields, models + + +class ProcurementRule(models.Model): + _inherit = 'procurement.rule' + + def _prepare_purchase_order_line(self, product_id, product_qty, + product_uom, values, po, supplier): + """Apply the discount to the created purchase order""" + res = super(ProcurementRule, self)._prepare_purchase_order_line( + product_id, product_qty, product_uom, values, po, supplier) + date = None + if po.date_order: + date = fields.Date.to_string( + fields.Date.from_string(po.date_order)) + seller = product_id._select_seller( + partner_id=supplier.name, + quantity=product_qty, + date=date, uom_id=product_uom) + if seller: + res['discount2'] = seller.discount2 + res['discount3'] = seller.discount3 + return res diff --git a/purchase_triple_discount/models/product_supplierinfo.py b/purchase_triple_discount/models/product_supplierinfo.py new file mode 100644 index 00000000000..353007eea5b --- /dev/null +++ b/purchase_triple_discount/models/product_supplierinfo.py @@ -0,0 +1,43 @@ +# Copyright 2019 Tecnativa - David Vidal +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import models, fields, api +import odoo.addons.decimal_precision as dp + + +class ProductSupplierInfo(models.Model): + _inherit = 'product.supplierinfo' + + discount2 = fields.Float( + string='Discount 2 (%)', + digits=dp.get_precision('Discount'), + ) + discount3 = fields.Float( + string='Discount 3 (%)', + digits=dp.get_precision('Discount'), + ) + + @api.onchange('name') + def onchange_name(self): + """Apply the default supplier discounts of the selected supplier""" + for supplierinfo in self.filtered('name'): + supplierinfo.discount2 = ( + supplierinfo.name.default_supplierinfo_discount2) + supplierinfo.discount3 = ( + supplierinfo.name.default_supplierinfo_discount3) + return super().onchange_name() + + @api.model + def create(self, vals): + """Insert discounts 2 and 3 from context from purchase.order's + _add_supplier_to_product method""" + if ('discount2_map' in self.env.context and + not vals.get('discount2') and + vals['product_tmpl_id'] in self.env.context['discount2_map']): + vals['discount2'] = self.env.context['discount2_map'][ + vals['product_tmpl_id']] + if ('discount3_map' in self.env.context and + not vals.get('discount3') and + vals['product_tmpl_id'] in self.env.context['discount3_map']): + vals['discount3'] = self.env.context['discount3_map'][ + vals['product_tmpl_id']] + return super(ProductSupplierInfo, self).create(vals) diff --git a/purchase_triple_discount/models/purchase_order.py b/purchase_triple_discount/models/purchase_order.py index c2b2d363952..90fecd8fd1b 100644 --- a/purchase_triple_discount/models/purchase_order.py +++ b/purchase_triple_discount/models/purchase_order.py @@ -1,11 +1,27 @@ -# -*- coding: utf-8 -*- -# Copyright 2017 Tecnativa - David Vidal +# Copyright 2017-19 Tecnativa - David Vidal # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - from odoo import api, fields, models from odoo.addons import decimal_precision as dp +class PurchaseOrder(models.Model): + _inherit = 'purchase.order' + + def _add_supplier_to_product(self): + """Insert a mapping of products to discounts to be picked up + in supplierinfo's create()""" + self.ensure_one() + discount2_map = dict( + [(line.product_id.product_tmpl_id.id, line.discount2) + for line in self.order_line.filtered('discount2')]) + discount3_map = dict( + [(line.product_id.product_tmpl_id.id, line.discount3) + for line in self.order_line.filtered('discount3')]) + return super(PurchaseOrder, self.with_context( + discount2_map=discount2_map, discount3_map=discount3_map) + )._add_supplier_to_product() + + class PurchaseOrderLine(models.Model): _inherit = "purchase.order.line" @@ -16,13 +32,11 @@ def _compute_amount(self): discount2 = fields.Float( 'Disc. 2 (%)', digits=dp.get_precision('Discount'), - default=0.0, ) discount3 = fields.Float( 'Disc. 3 (%)', digits=dp.get_precision('Discount'), - default=0.0, ) _sql_constraints = [ @@ -40,3 +54,23 @@ def _get_discounted_price_unit(self): if self.discount3: price_unit *= (1 - self.discount3 / 100.0) return price_unit + + @api.onchange('product_qty', 'product_uom') + def _onchange_quantity(self): + """ + Check if a discount is defined into the supplier info and if so then + apply it to the current purchase order line + """ + res = super(PurchaseOrderLine, self)._onchange_quantity() + if self.product_id: + date = None + if self.order_id.date_order: + date = fields.Date.to_string( + fields.Date.from_string(self.order_id.date_order)) + product_supplierinfo = self.product_id._select_seller( + partner_id=self.partner_id, quantity=self.product_qty, + date=date, uom_id=self.product_uom) + if product_supplierinfo: + self.discount2 = product_supplierinfo.discount2 + self.discount3 = product_supplierinfo.discount3 + return res diff --git a/purchase_triple_discount/models/res_partner.py b/purchase_triple_discount/models/res_partner.py new file mode 100644 index 00000000000..6e64e7977f2 --- /dev/null +++ b/purchase_triple_discount/models/res_partner.py @@ -0,0 +1,21 @@ +# Copyright 2019 Tecnativa - David Vidal +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import models, fields +from odoo.addons import decimal_precision as dp + + +class ResPartner(models.Model): + _inherit = "res.partner" + + default_supplierinfo_discount2 = fields.Float( + string='Default Supplier Discount 2 (%)', + digits=dp.get_precision('Discount'), + help="This value will be used as the default one, for each new " + "supplierinfo line depending on that supplier.", + ) + default_supplierinfo_discount3 = fields.Float( + string='Default Supplier Discount 3 (%)', + digits=dp.get_precision('Discount'), + help="This value will be used as the default one, for each new " + "supplierinfo line depending on that supplier.", + ) diff --git a/purchase_triple_discount/readme/CONTRIBUTORS.rst b/purchase_triple_discount/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..0ff1feb5358 --- /dev/null +++ b/purchase_triple_discount/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Tecnativa `_: + + * David Vidal diff --git a/purchase_triple_discount/readme/DESCRIPTION.rst b/purchase_triple_discount/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..1e65e34ddb3 --- /dev/null +++ b/purchase_triple_discount/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This module allows to have three successive discounts on every purchase order +line. diff --git a/purchase_triple_discount/readme/ROADMAP.rst b/purchase_triple_discount/readme/ROADMAP.rst new file mode 100644 index 00000000000..9747b4c7b17 --- /dev/null +++ b/purchase_triple_discount/readme/ROADMAP.rst @@ -0,0 +1 @@ +* Include second and third discount in purchase order report. diff --git a/purchase_triple_discount/readme/USAGE.rst b/purchase_triple_discount/readme/USAGE.rst new file mode 100644 index 00000000000..00e0f487d7f --- /dev/null +++ b/purchase_triple_discount/readme/USAGE.rst @@ -0,0 +1,24 @@ +Create a new purchase 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 charge instead of discount: + +Unit price: 600.00 -> + + - Disc. 1 = 50% -> Amount = 300.00 + - Disc. 2 = -5% -> Amount = 315.00 + +* When the purchase order is validated, the discounts will be added to the + corresponding vendor pricelist. +* Vendor pricelists can be edited as well with their corresponding new second + and third discounts. +* A default second or third discount can be set in every vendor + *Sale & Purchases* tab. diff --git a/purchase_triple_discount/static/description/icon.png b/purchase_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/purchase_triple_discount/static/description/index.html b/purchase_triple_discount/static/description/index.html new file mode 100644 index 00000000000..89a4587d6c1 --- /dev/null +++ b/purchase_triple_discount/static/description/index.html @@ -0,0 +1,465 @@ + + + + + + +Account Invoice Triple Discount + + + +
+

Account Invoice Triple Discount

+ + +

Beta License: AGPL-3 OCA/purchase-workflow Translate me on Weblate Try me on Runbot

+

This module allows to have three successive discounts on every purchase order +line.

+

Table of contents

+ +
+

Usage

+

Create a new purchase 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 charge instead of discount:

+

Unit price: 600.00 ->

+
+
    +
  • Disc. 1 = 50% -> Amount = 300.00
  • +
  • Disc. 2 = -5% -> Amount = 315.00
  • +
+
+
    +
  • When the purchase order is validated, the discounts will be added to the +corresponding vendor pricelist.
  • +
  • Vendor pricelists can be edited as well with their corresponding new second +and third discounts.
  • +
  • A default second or third discount can be set in every vendor +Sale & Purchases tab.
  • +
+
+
+

Known issues / Roadmap

+
    +
  • Include second and third discount in purchase order report.
  • +
+
+
+

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 smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

This module is part of the OCA/purchase-workflow project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/purchase_triple_discount/tests/__init__.py b/purchase_triple_discount/tests/__init__.py index b8e666681b0..19588b827ca 100644 --- a/purchase_triple_discount/tests/__init__.py +++ b/purchase_triple_discount/tests/__init__.py @@ -1,3 +1 @@ -# -*- coding: utf-8 -*- - from . import test_purchase_discount diff --git a/purchase_triple_discount/tests/test_purchase_discount.py b/purchase_triple_discount/tests/test_purchase_discount.py index ac4f0b3e73d..ba126d8639f 100644 --- a/purchase_triple_discount/tests/test_purchase_discount.py +++ b/purchase_triple_discount/tests/test_purchase_discount.py @@ -1,5 +1,4 @@ -# -*- coding: utf-8 -*- -# Copyright 2017 Tecnativa - David Vidal +# Copyright 2017-19 Tecnativa - David Vidal # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo.tests import common @@ -10,9 +9,13 @@ class TestPurchaseOrder(common.SavepointCase): @classmethod def setUpClass(cls): super(TestPurchaseOrder, cls).setUpClass() + cls.supplierinfo_obj = cls.env['product.supplierinfo'] cls.partner = cls.env['res.partner'].create({ 'name': 'Mr. Odoo', }) + cls.partner2 = cls.env['res.partner'].create({ + 'name': 'Mrs. Odoo', + }) cls.product1 = cls.env['product.product'].create({ 'name': 'Test Product 1', 'purchase_method': 'purchase', @@ -21,6 +24,20 @@ def setUpClass(cls): 'name': 'Test Product 2', 'purchase_method': 'purchase', }) + cls.supplierinfo = cls.supplierinfo_obj.create({ + 'min_qty': 0.0, + 'name': cls.partner2.id, + 'product_tmpl_id': cls.product1.product_tmpl_id.id, + 'discount': 10, + 'discount2': 20, + 'discount3': 30, + }) + cls.supplierinfo2 = cls.supplierinfo_obj.create({ + 'min_qty': 10.0, + 'name': cls.partner2.id, + 'product_tmpl_id': cls.product1.product_tmpl_id.id, + 'discount3': 50, + }) cls.tax = cls.env['account.tax'].create({ 'name': 'TAX 15%', 'amount_type': 'percent', @@ -28,7 +45,10 @@ def setUpClass(cls): 'amount': 15.0, }) cls.order = cls.env['purchase.order'].create({ - 'partner_id': cls.partner.id + 'partner_id': cls.partner.id, + }) + cls.order2 = cls.env['purchase.order'].create({ + 'partner_id': cls.partner2.id, }) po_line = cls.env['purchase.order.line'] cls.po_line1 = po_line.create({ @@ -51,6 +71,16 @@ def setUpClass(cls): 'taxes_id': [(6, 0, [cls.tax.id])], 'price_unit': 60.0, }) + cls.po_line3 = po_line.create({ + 'order_id': cls.order2.id, + 'product_id': cls.product1.id, + 'date_planned': '2020-01-01 00:00:00', + 'name': 'Line 1', + 'product_qty': 1.0, + 'product_uom': cls.product1.uom_id.id, + 'taxes_id': [(6, 0, [cls.tax.id])], + 'price_unit': 600.0, + }) def test_01_purchase_order_classic_discount(self): """ Tests with single discount """ @@ -123,3 +153,52 @@ def test_04_purchase_order_triple_discount_invoicing(self): self.assertEqual(self.po_line2.discount3, self.invoice.invoice_line_ids[1].discount3) self.assertEqual(self.order.amount_total, self.invoice.amount_total) + + def test_05_purchase_order_default_discounts(self): + self.po_line3._onchange_quantity() + self.assertEquals(self.po_line3.discount, 10) + self.assertEquals(self.po_line3.discount2, 20) + self.assertEquals(self.po_line3.discount3, 30) + self.po_line3.product_qty = 10 + self.po_line3._onchange_quantity() + self.assertFalse(self.po_line3.discount) + self.assertFalse(self.po_line3.discount2) + self.assertEquals(self.po_line3.discount3, 50) + + def test_06_default_supplier_discounts(self): + self.partner2.default_supplierinfo_discount = 11 + self.partner2.default_supplierinfo_discount2 = 22 + self.partner2.default_supplierinfo_discount3 = 33 + supplierinfo = self.supplierinfo_obj.new({ + 'min_qty': 0.0, + 'name': self.partner2.id, + 'product_tmpl_id': self.product1.product_tmpl_id.id, + 'discount': 10, + }) + supplierinfo.onchange_name() + self.assertEquals(supplierinfo.discount, 11) + self.assertEquals(supplierinfo.discount2, 22) + self.assertEquals(supplierinfo.discount3, 33) + + def test_07_supplierinfo_from_purchaseorder(self): + self.order2.order_line.create({ + 'order_id': self.order2.id, + 'product_id': self.product2.id, + 'date_planned': '2020-01-01 00:00:00', + 'name': 'Line 2', + 'product_qty': 1.0, + 'product_uom': self.product2.uom_id.id, + 'taxes_id': [(6, 0, [self.tax.id])], + 'price_unit': 999.0, + 'discount': 11.11, + 'discount2': 22.22, + 'discount3': 33.33, + }) + self.order2.button_confirm() + seller = self.supplierinfo_obj.search([ + ('name', '=', self.partner2.id), + ('product_tmpl_id', '=', self.product2.product_tmpl_id.id)]) + self.assertTrue(seller) + self.assertEqual(seller.discount, 11.11) + self.assertEqual(seller.discount2, 22.22) + self.assertEqual(seller.discount3, 33.33) diff --git a/purchase_triple_discount/views/product_supplierinfo_view.xml b/purchase_triple_discount/views/product_supplierinfo_view.xml new file mode 100644 index 00000000000..d831be29771 --- /dev/null +++ b/purchase_triple_discount/views/product_supplierinfo_view.xml @@ -0,0 +1,25 @@ + + + + product.supplierinfo + + + + + + + + + + + product.supplierinfo + + + + + + + + + + diff --git a/purchase_triple_discount/views/res_partner_view.xml b/purchase_triple_discount/views/res_partner_view.xml new file mode 100644 index 00000000000..4e5c08b40f4 --- /dev/null +++ b/purchase_triple_discount/views/res_partner_view.xml @@ -0,0 +1,16 @@ + + + + res.partner + + + + + + + + + + From f66a70652ed494503d8e247184ce85379040f461 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Thu, 8 Aug 2019 09:44:41 +0200 Subject: [PATCH 04/33] [MIG] purchase_triple_discount - remove dependency to obsolete module product_supplierinfo_discount - rename procurement.rule into stock.rule - Use new hook introduced in purchase_discount V12 to add discount2 and discount3 - Introduce discount2 and discount3 in purchase.report model --- purchase_triple_discount/README.rst | 24 +++--- purchase_triple_discount/__init__.py | 1 + purchase_triple_discount/__manifest__.py | 9 ++- purchase_triple_discount/i18n/fr.po | 73 +++++++++++++++---- purchase_triple_discount/models/__init__.py | 2 +- .../models/account_invoice.py | 3 +- .../models/procurement_rule.py | 25 ------- .../models/product_supplierinfo.py | 2 +- .../models/purchase_order.py | 34 +++------ purchase_triple_discount/models/stock_rule.py | 19 +++++ .../readme/CONTRIBUTORS.rst | 2 + purchase_triple_discount/readme/ROADMAP.rst | 1 - purchase_triple_discount/report/__init__.py | 1 + .../report/purchase_report.py | 42 +++++++++++ .../static/description/index.html | 44 +++++------ .../views/product_supplierinfo_view.xml | 18 +++-- .../views/res_partner_view.xml | 2 +- 17 files changed, 188 insertions(+), 114 deletions(-) delete mode 100644 purchase_triple_discount/models/procurement_rule.py create mode 100644 purchase_triple_discount/models/stock_rule.py delete mode 100644 purchase_triple_discount/readme/ROADMAP.rst create mode 100644 purchase_triple_discount/report/__init__.py create mode 100644 purchase_triple_discount/report/purchase_report.py diff --git a/purchase_triple_discount/README.rst b/purchase_triple_discount/README.rst index 3758da6f254..a266f030424 100644 --- a/purchase_triple_discount/README.rst +++ b/purchase_triple_discount/README.rst @@ -1,6 +1,6 @@ -=============================== -Account Invoice Triple Discount -=============================== +============================== +Purchase Order Triple Discount +============================== .. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! This file is generated by oca-gen-addon-readme !! @@ -14,13 +14,13 @@ Account Invoice Triple Discount :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github - :target: https://github.com/OCA/purchase-workflow/tree/11.0/purchase_triple_discount + :target: https://github.com/OCA/purchase-workflow/tree/12.0/purchase_triple_discount :alt: OCA/purchase-workflow .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/purchase-workflow-11-0/purchase-workflow-11-0-purchase_triple_discount + :target: https://translation.odoo-community.org/projects/purchase-workflow-12-0/purchase-workflow-12-0-purchase_triple_discount :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/142/11.0 + :target: https://runbot.odoo-community.org/runbot/142/12.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -61,18 +61,13 @@ Unit price: 600.00 -> * A default second or third discount can be set in every vendor *Sale & Purchases* tab. -Known issues / Roadmap -====================== - -* Include second and third discount in purchase order report. - 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 smashing it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -83,6 +78,7 @@ Authors ~~~~~~~ * Tecnativa +* GRAP Contributors ~~~~~~~~~~~~ @@ -91,6 +87,8 @@ Contributors * David Vidal +* Sylvain LE GAL (https://twitter.com/legalsylvain) + Maintainers ~~~~~~~~~~~ @@ -104,6 +102,6 @@ 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. -This module is part of the `OCA/purchase-workflow `_ project on GitHub. +This module is part of the `OCA/purchase-workflow `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/purchase_triple_discount/__init__.py b/purchase_triple_discount/__init__.py index 0650744f6bc..bf588bc8b80 100644 --- a/purchase_triple_discount/__init__.py +++ b/purchase_triple_discount/__init__.py @@ -1 +1,2 @@ from . import models +from . import report diff --git a/purchase_triple_discount/__manifest__.py b/purchase_triple_discount/__manifest__.py index 3054422fdaa..485c03fbfb9 100644 --- a/purchase_triple_discount/__manifest__.py +++ b/purchase_triple_discount/__manifest__.py @@ -1,16 +1,17 @@ # Copyright 2017 Tecnativa - David Vidal # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { - 'name': 'Account Invoice Triple Discount', - 'version': '11.0.1.0.0', + 'name': 'Purchase Order Triple Discount', + 'version': '12.0.1.0.0', 'category': 'Purchase Management', - 'author': 'Tecnativa, ' + 'author': 'Tecnativa,' + 'GRAP,' 'Odoo Community Association (OCA)', 'website': 'https://github.com/OCA/purchase-workflow', 'license': 'AGPL-3', 'summary': 'Manage triple discount on purchase order lines', 'depends': [ - 'product_supplierinfo_discount', + 'purchase_discount', 'account_invoice_triple_discount', ], 'data': [ diff --git a/purchase_triple_discount/i18n/fr.po b/purchase_triple_discount/i18n/fr.po index b0e6eb62746..858d34e6b9f 100644 --- a/purchase_triple_discount/i18n/fr.po +++ b/purchase_triple_discount/i18n/fr.po @@ -1,39 +1,62 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * purchase_triple_discount +# * purchase_triple_discount # -# Translators: -# OCA Transbot , 2017 -# Quentin THEURET , 2017 msgid "" msgstr "" -"Project-Id-Version: Odoo Server 10.0\n" +"Project-Id-Version: Odoo Server 12.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-11-25 08:26+0000\n" -"PO-Revision-Date: 2017-11-25 08:26+0000\n" -"Last-Translator: Quentin THEURET , 2017\n" -"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" -"Language: fr\n" +"POT-Creation-Date: 2019-08-08 08:11+0000\n" +"PO-Revision-Date: 2019-08-08 08:11+0000\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: nplurals=2; plural=(n > 1);\n" +"Plural-Forms: \n" #. module: purchase_triple_discount -#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line_discount2 +#: model:ir.model,name:purchase_triple_discount.model_res_partner +msgid "Contact" +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_res_partner__default_supplierinfo_discount2 +#: model:ir.model.fields,field_description:purchase_triple_discount.field_res_users__default_supplierinfo_discount2 +msgid "Default Supplier Discount 2 (%)" +msgstr "Remise par défaut n°2 (%)" + +#. module: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_res_partner__default_supplierinfo_discount3 +#: model:ir.model.fields,field_description:purchase_triple_discount.field_res_users__default_supplierinfo_discount3 +msgid "Default Supplier Discount 3 (%)" +msgstr "Remise par défaut n°3 (%)" + +#. module: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line__discount2 msgid "Disc. 2 (%)" msgstr "Rem. 2 (%)" #. module: purchase_triple_discount -#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line_discount3 +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line__discount3 msgid "Disc. 3 (%)" msgstr "Rem. 3 (%)" +#. module: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_product_supplierinfo__discount2 +msgid "Discount 2 (%)" +msgstr "Remise 2 (%)" + #. module: purchase_triple_discount #: sql_constraint:purchase.order.line:0 msgid "Discount 2 must be lower than 100%." msgstr "La remise 2 doit être inférieure à 100%." +#. module: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_product_supplierinfo__discount3 +msgid "Discount 3 (%)" +msgstr "Remise 3 (%)" + #. module: purchase_triple_discount #: sql_constraint:purchase.order.line:0 msgid "Discount 3 must be lower than 100%." @@ -44,7 +67,31 @@ msgstr "La remise 3 doit être inférieure à 100%." msgid "Invoice" msgstr "Facture" +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_purchase_order +msgid "Purchase Order" +msgstr "Commande fournisseur" + #. module: purchase_triple_discount #: model:ir.model,name:purchase_triple_discount.model_purchase_order_line msgid "Purchase Order Line" msgstr "Ligne de commande d'achat" + +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_stock_rule +msgid "Stock Rule" +msgstr "Règle de stock minimum" + +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_product_supplierinfo +msgid "Supplier Pricelist" +msgstr "Liste de prix du fournisseur" + +#. module: purchase_triple_discount +#: model:ir.model.fields,help:purchase_triple_discount.field_res_partner__default_supplierinfo_discount2 +#: model:ir.model.fields,help:purchase_triple_discount.field_res_partner__default_supplierinfo_discount3 +#: model:ir.model.fields,help:purchase_triple_discount.field_res_users__default_supplierinfo_discount2 +#: model:ir.model.fields,help:purchase_triple_discount.field_res_users__default_supplierinfo_discount3 +msgid "This value will be used as the default one, for each new supplierinfo line depending on that supplier." +msgstr "" + diff --git a/purchase_triple_discount/models/__init__.py b/purchase_triple_discount/models/__init__.py index 42194fa4c43..3a82c1cac29 100644 --- a/purchase_triple_discount/models/__init__.py +++ b/purchase_triple_discount/models/__init__.py @@ -1,5 +1,5 @@ from . import account_invoice -from . import procurement_rule +from . import stock_rule from . import product_supplierinfo from . import purchase_order from . import res_partner diff --git a/purchase_triple_discount/models/account_invoice.py b/purchase_triple_discount/models/account_invoice.py index 8c2e650addd..596ee20e85a 100644 --- a/purchase_triple_discount/models/account_invoice.py +++ b/purchase_triple_discount/models/account_invoice.py @@ -8,8 +8,7 @@ class AccountInvoice(models.Model): _inherit = "account.invoice" def _prepare_invoice_line_from_po_line(self, line): - vals = super(AccountInvoice, - self)._prepare_invoice_line_from_po_line(line) + vals = super()._prepare_invoice_line_from_po_line(line) vals['discount2'] = line.discount2 vals['discount3'] = line.discount3 return vals diff --git a/purchase_triple_discount/models/procurement_rule.py b/purchase_triple_discount/models/procurement_rule.py deleted file mode 100644 index 75ef03cada9..00000000000 --- a/purchase_triple_discount/models/procurement_rule.py +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2019 Tecnativa - David Vidal -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import fields, models - - -class ProcurementRule(models.Model): - _inherit = 'procurement.rule' - - def _prepare_purchase_order_line(self, product_id, product_qty, - product_uom, values, po, supplier): - """Apply the discount to the created purchase order""" - res = super(ProcurementRule, self)._prepare_purchase_order_line( - product_id, product_qty, product_uom, values, po, supplier) - date = None - if po.date_order: - date = fields.Date.to_string( - fields.Date.from_string(po.date_order)) - seller = product_id._select_seller( - partner_id=supplier.name, - quantity=product_qty, - date=date, uom_id=product_uom) - if seller: - res['discount2'] = seller.discount2 - res['discount3'] = seller.discount3 - return res diff --git a/purchase_triple_discount/models/product_supplierinfo.py b/purchase_triple_discount/models/product_supplierinfo.py index 353007eea5b..e01afe179ae 100644 --- a/purchase_triple_discount/models/product_supplierinfo.py +++ b/purchase_triple_discount/models/product_supplierinfo.py @@ -40,4 +40,4 @@ def create(self, vals): vals['product_tmpl_id'] in self.env.context['discount3_map']): vals['discount3'] = self.env.context['discount3_map'][ vals['product_tmpl_id']] - return super(ProductSupplierInfo, self).create(vals) + return super().create(vals) diff --git a/purchase_triple_discount/models/purchase_order.py b/purchase_triple_discount/models/purchase_order.py index 90fecd8fd1b..d0b3f7e061c 100644 --- a/purchase_triple_discount/models/purchase_order.py +++ b/purchase_triple_discount/models/purchase_order.py @@ -19,15 +19,16 @@ def _add_supplier_to_product(self): for line in self.order_line.filtered('discount3')]) return super(PurchaseOrder, self.with_context( discount2_map=discount2_map, discount3_map=discount3_map) - )._add_supplier_to_product() + )._add_supplier_to_product() class PurchaseOrderLine(models.Model): _inherit = "purchase.order.line" + # adding discount2 and discount3 to depends @api.depends('discount2', 'discount3') def _compute_amount(self): - super(PurchaseOrderLine, self)._compute_amount() + super()._compute_amount() discount2 = fields.Float( 'Disc. 2 (%)', @@ -47,30 +48,17 @@ def _compute_amount(self): ] def _get_discounted_price_unit(self): - price_unit = super( - PurchaseOrderLine, self)._get_discounted_price_unit() + price_unit = super()._get_discounted_price_unit() if self.discount2: price_unit *= (1 - self.discount2 / 100.0) if self.discount3: price_unit *= (1 - self.discount3 / 100.0) return price_unit - @api.onchange('product_qty', 'product_uom') - def _onchange_quantity(self): - """ - Check if a discount is defined into the supplier info and if so then - apply it to the current purchase order line - """ - res = super(PurchaseOrderLine, self)._onchange_quantity() - if self.product_id: - date = None - if self.order_id.date_order: - date = fields.Date.to_string( - fields.Date.from_string(self.order_id.date_order)) - product_supplierinfo = self.product_id._select_seller( - partner_id=self.partner_id, quantity=self.product_qty, - date=date, uom_id=self.product_uom) - if product_supplierinfo: - self.discount2 = product_supplierinfo.discount2 - self.discount3 = product_supplierinfo.discount3 - return res + @api.model + def _apply_value_from_seller(self, seller): + super()._apply_value_from_seller(seller) + if not seller: + return + self.discount2 = seller.discount2 + self.discount3 = seller.discount3 diff --git a/purchase_triple_discount/models/stock_rule.py b/purchase_triple_discount/models/stock_rule.py new file mode 100644 index 00000000000..c75e5f08f20 --- /dev/null +++ b/purchase_triple_discount/models/stock_rule.py @@ -0,0 +1,19 @@ +# Copyright 2019 GRAP (http://www.grap.coop) +# Sylvain LE GAL (https://twitter.com/legalsylvain) +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from odoo import api, models + + +class StockRule(models.Model): + _inherit = 'stock.rule' + + @api.model + def _prepare_purchase_order_line_from_seller(self, seller): + res = super()._prepare_purchase_order_line_from_seller(seller) + if not res: + return res + res.update({ + 'discount2': seller.discount2, + 'discount3': seller.discount3, + }) diff --git a/purchase_triple_discount/readme/CONTRIBUTORS.rst b/purchase_triple_discount/readme/CONTRIBUTORS.rst index 0ff1feb5358..2e2c0737e7c 100644 --- a/purchase_triple_discount/readme/CONTRIBUTORS.rst +++ b/purchase_triple_discount/readme/CONTRIBUTORS.rst @@ -1,3 +1,5 @@ * `Tecnativa `_: * David Vidal + +* Sylvain LE GAL (https://twitter.com/legalsylvain) diff --git a/purchase_triple_discount/readme/ROADMAP.rst b/purchase_triple_discount/readme/ROADMAP.rst deleted file mode 100644 index 9747b4c7b17..00000000000 --- a/purchase_triple_discount/readme/ROADMAP.rst +++ /dev/null @@ -1 +0,0 @@ -* Include second and third discount in purchase order report. diff --git a/purchase_triple_discount/report/__init__.py b/purchase_triple_discount/report/__init__.py new file mode 100644 index 00000000000..84b6eef84ac --- /dev/null +++ b/purchase_triple_discount/report/__init__.py @@ -0,0 +1 @@ +from . import purchase_report diff --git a/purchase_triple_discount/report/purchase_report.py b/purchase_triple_discount/report/purchase_report.py new file mode 100644 index 00000000000..1e05406e934 --- /dev/null +++ b/purchase_triple_discount/report/purchase_report.py @@ -0,0 +1,42 @@ +# Copyright 2019 GRAP (http://www.grap.coop) +# Sylvain LE GAL (https://twitter.com/legalsylvain) +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from odoo import fields, models +import odoo.addons.decimal_precision as dp + + +class PurchaseReport(models.Model): + _inherit = "purchase.report" + + discount2 = fields.Float( + string='Discount 2 (%)', digits=dp.get_precision('Discount'), + group_operator="avg", + ) + + discount3 = fields.Float( + string='Discount 3 (%)', digits=dp.get_precision('Discount'), + group_operator="avg", + ) + + def _select(self): + res = super()._select() + res += ", l.discount2 AS discount2, l.discount3 AS discount3" + return res + + def _group_by(self): + res = super()._group_by() + res += ", l.discount2, l.discount3" + return res + + def _get_discounted_price_unit_exp(self): + """Inheritable method for getting the SQL expression used for + calculating the unit price with discount(s). + + :rtype: str + :return: SQL expression for discounted unit price. + """ + return """ + (1.0 - COALESCE(l.discount, 0.0) / 100.0) * + (1.0 - COALESCE(l.discount2, 0.0) / 100.0) * + (1.0 - COALESCE(l.discount3, 0.0) / 100.0) * l.price_unit """ diff --git a/purchase_triple_discount/static/description/index.html b/purchase_triple_discount/static/description/index.html index 89a4587d6c1..22b6bdd661b 100644 --- a/purchase_triple_discount/static/description/index.html +++ b/purchase_triple_discount/static/description/index.html @@ -3,8 +3,8 @@ - -Account Invoice Triple Discount + +Purchase Order Triple Discount -
-

Account Invoice Triple Discount

+
+

Purchase Order Triple Discount

-

Beta License: AGPL-3 OCA/purchase-workflow Translate me on Weblate Try me on Runbot

+

Beta License: AGPL-3 OCA/purchase-workflow Translate me on Weblate Try me on Runbot

This module allows to have three successive discounts on every purchase order line.

Table of contents

-
-

Known issues / Roadmap

-
    -
  • Include second and third discount in purchase order report.
  • -
-
-

Bug Tracker

+

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 smashing it by providing a detailed and welcomed -feedback.

+feedback.

Do not contact contributors directly about support or help with technical issues.

-

Credits

+

Credits

-

Authors

+

Authors

  • Tecnativa
  • +
  • GRAP
-

Maintainers

+

Maintainers

This module is maintained by the OCA.

Odoo Community Association

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.

-

This module is part of the OCA/purchase-workflow project on GitHub.

+

This module is part of the OCA/purchase-workflow project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/purchase_triple_discount/views/product_supplierinfo_view.xml b/purchase_triple_discount/views/product_supplierinfo_view.xml index d831be29771..0d03390111b 100644 --- a/purchase_triple_discount/views/product_supplierinfo_view.xml +++ b/purchase_triple_discount/views/product_supplierinfo_view.xml @@ -2,18 +2,24 @@ product.supplierinfo - + - - - - + + product.supplierinfo - + diff --git a/purchase_triple_discount/views/res_partner_view.xml b/purchase_triple_discount/views/res_partner_view.xml index 4e5c08b40f4..429492e10bc 100644 --- a/purchase_triple_discount/views/res_partner_view.xml +++ b/purchase_triple_discount/views/res_partner_view.xml @@ -2,7 +2,7 @@ res.partner - + Date: Fri, 9 Aug 2019 11:15:30 +0200 Subject: [PATCH 05/33] [IMP] inheritance between purchase_discount and purchase_triple_discount, adding hook --- .../models/product_supplierinfo.py | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/purchase_triple_discount/models/product_supplierinfo.py b/purchase_triple_discount/models/product_supplierinfo.py index e01afe179ae..b864dd6849a 100644 --- a/purchase_triple_discount/models/product_supplierinfo.py +++ b/purchase_triple_discount/models/product_supplierinfo.py @@ -27,17 +27,7 @@ def onchange_name(self): return super().onchange_name() @api.model - def create(self, vals): - """Insert discounts 2 and 3 from context from purchase.order's - _add_supplier_to_product method""" - if ('discount2_map' in self.env.context and - not vals.get('discount2') and - vals['product_tmpl_id'] in self.env.context['discount2_map']): - vals['discount2'] = self.env.context['discount2_map'][ - vals['product_tmpl_id']] - if ('discount3_map' in self.env.context and - not vals.get('discount3') and - vals['product_tmpl_id'] in self.env.context['discount3_map']): - vals['discount3'] = self.env.context['discount3_map'][ - vals['product_tmpl_id']] - return super().create(vals) + def _discount_mapping_fields(self): + res = super()._discount_mapping_fields() + res += ['discount2', 'discount3'] + return res From d73229a99a5292a6d048d2bd6e2d88d9f186dc1e Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Fri, 9 Aug 2019 18:05:11 +0200 Subject: [PATCH 06/33] [IMP] purchase*_discount: Several improvements: * Lighter algorithm when synchronizing PO line info to product.supplierinfo. * Use new create multi method for performance. * Better SQL expresion in purchase report for decreasing the number of operations. * Add test for purchase report. --- purchase_triple_discount/README.rst | 1 + purchase_triple_discount/__manifest__.py | 2 +- purchase_triple_discount/i18n/de.po | 60 ++++++++++++++++++- purchase_triple_discount/i18n/es.po | 60 ++++++++++++++++++- .../i18n/purchase_triple_discount.pot | 48 ++++++++------- .../models/product_supplierinfo.py | 5 +- .../models/purchase_order.py | 18 ------ .../readme/CONTRIBUTORS.rst | 1 + .../report/purchase_report.py | 8 +-- .../static/description/index.html | 3 +- .../tests/test_purchase_discount.py | 14 +++++ 11 files changed, 167 insertions(+), 53 deletions(-) diff --git a/purchase_triple_discount/README.rst b/purchase_triple_discount/README.rst index a266f030424..547a111204e 100644 --- a/purchase_triple_discount/README.rst +++ b/purchase_triple_discount/README.rst @@ -86,6 +86,7 @@ Contributors * `Tecnativa `_: * David Vidal + * Pedro M. Baeza * Sylvain LE GAL (https://twitter.com/legalsylvain) diff --git a/purchase_triple_discount/__manifest__.py b/purchase_triple_discount/__manifest__.py index 485c03fbfb9..a554b5a6e75 100644 --- a/purchase_triple_discount/__manifest__.py +++ b/purchase_triple_discount/__manifest__.py @@ -2,7 +2,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { 'name': 'Purchase Order Triple Discount', - 'version': '12.0.1.0.0', + 'version': '12.0.1.0.1', 'category': 'Purchase Management', 'author': 'Tecnativa,' 'GRAP,' diff --git a/purchase_triple_discount/i18n/de.po b/purchase_triple_discount/i18n/de.po index 60c985cba07..76cc2fa85dc 100644 --- a/purchase_triple_discount/i18n/de.po +++ b/purchase_triple_discount/i18n/de.po @@ -19,20 +19,49 @@ msgstr "" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #. module: purchase_triple_discount -#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line_discount2 +#: model:ir.model,name:purchase_triple_discount.model_res_partner +msgid "Contact" +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_res_partner__default_supplierinfo_discount2 +#: model:ir.model.fields,field_description:purchase_triple_discount.field_res_users__default_supplierinfo_discount2 +msgid "Default Supplier Discount 2 (%)" +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_res_partner__default_supplierinfo_discount3 +#: model:ir.model.fields,field_description:purchase_triple_discount.field_res_users__default_supplierinfo_discount3 +msgid "Default Supplier Discount 3 (%)" +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line__discount2 msgid "Disc. 2 (%)" msgstr "" #. module: purchase_triple_discount -#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line_discount3 +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line__discount3 msgid "Disc. 3 (%)" msgstr "" +#. module: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_product_supplierinfo__discount2 +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_report__discount2 +msgid "Discount 2 (%)" +msgstr "" + #. module: purchase_triple_discount #: sql_constraint:purchase.order.line:0 msgid "Discount 2 must be lower than 100%." msgstr "" +#. module: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_product_supplierinfo__discount3 +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_report__discount3 +msgid "Discount 3 (%)" +msgstr "" + #. module: purchase_triple_discount #: sql_constraint:purchase.order.line:0 msgid "Discount 3 must be lower than 100%." @@ -47,3 +76,30 @@ msgstr "" #: model:ir.model,name:purchase_triple_discount.model_purchase_order_line msgid "Purchase Order Line" msgstr "Bestellposition" + +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_purchase_report +#, fuzzy +#| msgid "Purchase Order Line" +msgid "Purchase Report" +msgstr "Bestellposition" + +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_stock_rule +msgid "Stock Rule" +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_product_supplierinfo +msgid "Supplier Pricelist" +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model.fields,help:purchase_triple_discount.field_res_partner__default_supplierinfo_discount2 +#: model:ir.model.fields,help:purchase_triple_discount.field_res_partner__default_supplierinfo_discount3 +#: model:ir.model.fields,help:purchase_triple_discount.field_res_users__default_supplierinfo_discount2 +#: model:ir.model.fields,help:purchase_triple_discount.field_res_users__default_supplierinfo_discount3 +msgid "" +"This value will be used as the default one, for each new supplierinfo line " +"depending on that supplier." +msgstr "" diff --git a/purchase_triple_discount/i18n/es.po b/purchase_triple_discount/i18n/es.po index 1d7431079f9..e020d860637 100644 --- a/purchase_triple_discount/i18n/es.po +++ b/purchase_triple_discount/i18n/es.po @@ -19,20 +19,49 @@ msgstr "" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #. module: purchase_triple_discount -#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line_discount2 +#: model:ir.model,name:purchase_triple_discount.model_res_partner +msgid "Contact" +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_res_partner__default_supplierinfo_discount2 +#: model:ir.model.fields,field_description:purchase_triple_discount.field_res_users__default_supplierinfo_discount2 +msgid "Default Supplier Discount 2 (%)" +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_res_partner__default_supplierinfo_discount3 +#: model:ir.model.fields,field_description:purchase_triple_discount.field_res_users__default_supplierinfo_discount3 +msgid "Default Supplier Discount 3 (%)" +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line__discount2 msgid "Disc. 2 (%)" msgstr "" #. module: purchase_triple_discount -#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line_discount3 +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line__discount3 msgid "Disc. 3 (%)" msgstr "" +#. module: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_product_supplierinfo__discount2 +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_report__discount2 +msgid "Discount 2 (%)" +msgstr "" + #. module: purchase_triple_discount #: sql_constraint:purchase.order.line:0 msgid "Discount 2 must be lower than 100%." msgstr "" +#. module: purchase_triple_discount +#: model:ir.model.fields,field_description:purchase_triple_discount.field_product_supplierinfo__discount3 +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_report__discount3 +msgid "Discount 3 (%)" +msgstr "" + #. module: purchase_triple_discount #: sql_constraint:purchase.order.line:0 msgid "Discount 3 must be lower than 100%." @@ -47,3 +76,30 @@ msgstr "" #: model:ir.model,name:purchase_triple_discount.model_purchase_order_line msgid "Purchase Order Line" msgstr "Línea orden de compra" + +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_purchase_report +#, fuzzy +#| msgid "Purchase Order Line" +msgid "Purchase Report" +msgstr "Línea orden de compra" + +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_stock_rule +msgid "Stock Rule" +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model,name:purchase_triple_discount.model_product_supplierinfo +msgid "Supplier Pricelist" +msgstr "" + +#. module: purchase_triple_discount +#: model:ir.model.fields,help:purchase_triple_discount.field_res_partner__default_supplierinfo_discount2 +#: model:ir.model.fields,help:purchase_triple_discount.field_res_partner__default_supplierinfo_discount3 +#: model:ir.model.fields,help:purchase_triple_discount.field_res_users__default_supplierinfo_discount2 +#: model:ir.model.fields,help:purchase_triple_discount.field_res_users__default_supplierinfo_discount3 +msgid "" +"This value will be used as the default one, for each new supplierinfo line " +"depending on that supplier." +msgstr "" diff --git a/purchase_triple_discount/i18n/purchase_triple_discount.pot b/purchase_triple_discount/i18n/purchase_triple_discount.pot index 92024bb4572..72432669654 100644 --- a/purchase_triple_discount/i18n/purchase_triple_discount.pot +++ b/purchase_triple_discount/i18n/purchase_triple_discount.pot @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 11.0\n" +"Project-Id-Version: Odoo Server 12.0\n" "Report-Msgid-Bugs-To: \n" "Last-Translator: <>\n" "Language-Team: \n" @@ -19,29 +19,30 @@ msgid "Contact" msgstr "" #. module: purchase_triple_discount -#: model:ir.model.fields,field_description:purchase_triple_discount.field_res_partner_default_supplierinfo_discount2 -#: model:ir.model.fields,field_description:purchase_triple_discount.field_res_users_default_supplierinfo_discount2 +#: model:ir.model.fields,field_description:purchase_triple_discount.field_res_partner__default_supplierinfo_discount2 +#: model:ir.model.fields,field_description:purchase_triple_discount.field_res_users__default_supplierinfo_discount2 msgid "Default Supplier Discount 2 (%)" msgstr "" #. module: purchase_triple_discount -#: model:ir.model.fields,field_description:purchase_triple_discount.field_res_partner_default_supplierinfo_discount3 -#: model:ir.model.fields,field_description:purchase_triple_discount.field_res_users_default_supplierinfo_discount3 +#: model:ir.model.fields,field_description:purchase_triple_discount.field_res_partner__default_supplierinfo_discount3 +#: model:ir.model.fields,field_description:purchase_triple_discount.field_res_users__default_supplierinfo_discount3 msgid "Default Supplier Discount 3 (%)" msgstr "" #. module: purchase_triple_discount -#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line_discount2 +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line__discount2 msgid "Disc. 2 (%)" msgstr "" #. module: purchase_triple_discount -#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line_discount3 +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_order_line__discount3 msgid "Disc. 3 (%)" msgstr "" #. module: purchase_triple_discount -#: model:ir.model.fields,field_description:purchase_triple_discount.field_product_supplierinfo_discount2 +#: model:ir.model.fields,field_description:purchase_triple_discount.field_product_supplierinfo__discount2 +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_report__discount2 msgid "Discount 2 (%)" msgstr "" @@ -51,7 +52,8 @@ msgid "Discount 2 must be lower than 100%." msgstr "" #. module: purchase_triple_discount -#: model:ir.model.fields,field_description:purchase_triple_discount.field_product_supplierinfo_discount3 +#: model:ir.model.fields,field_description:purchase_triple_discount.field_product_supplierinfo__discount3 +#: model:ir.model.fields,field_description:purchase_triple_discount.field_purchase_report__discount3 msgid "Discount 3 (%)" msgstr "" @@ -61,35 +63,35 @@ msgid "Discount 3 must be lower than 100%." msgstr "" #. module: purchase_triple_discount -#: model:ir.model,name:purchase_triple_discount.model_product_supplierinfo -msgid "Information about a product vendor" +#: model:ir.model,name:purchase_triple_discount.model_account_invoice +msgid "Invoice" msgstr "" #. module: purchase_triple_discount -#: model:ir.model,name:purchase_triple_discount.model_account_invoice -msgid "Invoice" +#: model:ir.model,name:purchase_triple_discount.model_purchase_order_line +msgid "Purchase Order Line" msgstr "" #. module: purchase_triple_discount -#: model:ir.model,name:purchase_triple_discount.model_procurement_rule -msgid "Procurement Rule" +#: model:ir.model,name:purchase_triple_discount.model_purchase_report +msgid "Purchase Report" msgstr "" #. module: purchase_triple_discount -#: model:ir.model,name:purchase_triple_discount.model_purchase_order -msgid "Purchase Order" +#: model:ir.model,name:purchase_triple_discount.model_stock_rule +msgid "Stock Rule" msgstr "" #. module: purchase_triple_discount -#: model:ir.model,name:purchase_triple_discount.model_purchase_order_line -msgid "Purchase Order Line" +#: model:ir.model,name:purchase_triple_discount.model_product_supplierinfo +msgid "Supplier Pricelist" msgstr "" #. module: purchase_triple_discount -#: model:ir.model.fields,help:purchase_triple_discount.field_res_partner_default_supplierinfo_discount2 -#: model:ir.model.fields,help:purchase_triple_discount.field_res_partner_default_supplierinfo_discount3 -#: model:ir.model.fields,help:purchase_triple_discount.field_res_users_default_supplierinfo_discount2 -#: model:ir.model.fields,help:purchase_triple_discount.field_res_users_default_supplierinfo_discount3 +#: model:ir.model.fields,help:purchase_triple_discount.field_res_partner__default_supplierinfo_discount2 +#: model:ir.model.fields,help:purchase_triple_discount.field_res_partner__default_supplierinfo_discount3 +#: model:ir.model.fields,help:purchase_triple_discount.field_res_users__default_supplierinfo_discount2 +#: model:ir.model.fields,help:purchase_triple_discount.field_res_users__default_supplierinfo_discount3 msgid "This value will be used as the default one, for each new supplierinfo line depending on that supplier." msgstr "" diff --git a/purchase_triple_discount/models/product_supplierinfo.py b/purchase_triple_discount/models/product_supplierinfo.py index b864dd6849a..81e0ec40135 100644 --- a/purchase_triple_discount/models/product_supplierinfo.py +++ b/purchase_triple_discount/models/product_supplierinfo.py @@ -1,4 +1,5 @@ # Copyright 2019 Tecnativa - David Vidal +# Copyright 2019 Tecnativa - Pedro M. Baeza # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import models, fields, api import odoo.addons.decimal_precision as dp @@ -27,7 +28,7 @@ def onchange_name(self): return super().onchange_name() @api.model - def _discount_mapping_fields(self): - res = super()._discount_mapping_fields() + def _get_po_to_supplierinfo_synced_fields(self): + res = super()._get_po_to_supplierinfo_synced_fields() res += ['discount2', 'discount3'] return res diff --git a/purchase_triple_discount/models/purchase_order.py b/purchase_triple_discount/models/purchase_order.py index d0b3f7e061c..e8296f37686 100644 --- a/purchase_triple_discount/models/purchase_order.py +++ b/purchase_triple_discount/models/purchase_order.py @@ -4,24 +4,6 @@ from odoo.addons import decimal_precision as dp -class PurchaseOrder(models.Model): - _inherit = 'purchase.order' - - def _add_supplier_to_product(self): - """Insert a mapping of products to discounts to be picked up - in supplierinfo's create()""" - self.ensure_one() - discount2_map = dict( - [(line.product_id.product_tmpl_id.id, line.discount2) - for line in self.order_line.filtered('discount2')]) - discount3_map = dict( - [(line.product_id.product_tmpl_id.id, line.discount3) - for line in self.order_line.filtered('discount3')]) - return super(PurchaseOrder, self.with_context( - discount2_map=discount2_map, discount3_map=discount3_map) - )._add_supplier_to_product() - - class PurchaseOrderLine(models.Model): _inherit = "purchase.order.line" diff --git a/purchase_triple_discount/readme/CONTRIBUTORS.rst b/purchase_triple_discount/readme/CONTRIBUTORS.rst index 2e2c0737e7c..a065e01607d 100644 --- a/purchase_triple_discount/readme/CONTRIBUTORS.rst +++ b/purchase_triple_discount/readme/CONTRIBUTORS.rst @@ -1,5 +1,6 @@ * `Tecnativa `_: * David Vidal + * Pedro M. Baeza * Sylvain LE GAL (https://twitter.com/legalsylvain) diff --git a/purchase_triple_discount/report/purchase_report.py b/purchase_triple_discount/report/purchase_report.py index 1e05406e934..7bcc2d4daa5 100644 --- a/purchase_triple_discount/report/purchase_report.py +++ b/purchase_triple_discount/report/purchase_report.py @@ -1,5 +1,6 @@ # Copyright 2019 GRAP (http://www.grap.coop) # Sylvain LE GAL (https://twitter.com/legalsylvain) +# Copyright 2019 Tecnativa - Pedro M. Baeza # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html from odoo import fields, models @@ -13,7 +14,6 @@ class PurchaseReport(models.Model): string='Discount 2 (%)', digits=dp.get_precision('Discount'), group_operator="avg", ) - discount3 = fields.Float( string='Discount 3 (%)', digits=dp.get_precision('Discount'), group_operator="avg", @@ -37,6 +37,6 @@ def _get_discounted_price_unit_exp(self): :return: SQL expression for discounted unit price. """ return """ - (1.0 - COALESCE(l.discount, 0.0) / 100.0) * - (1.0 - COALESCE(l.discount2, 0.0) / 100.0) * - (1.0 - COALESCE(l.discount3, 0.0) / 100.0) * l.price_unit """ + ((100 - COALESCE(l.discount, 0.0)) * + (100 - COALESCE(l.discount2, 0.0)) * + (100 - COALESCE(l.discount3, 0.0))) / 1000000 * l.price_unit""" diff --git a/purchase_triple_discount/static/description/index.html b/purchase_triple_discount/static/description/index.html index 22b6bdd661b..baba262bd52 100644 --- a/purchase_triple_discount/static/description/index.html +++ b/purchase_triple_discount/static/description/index.html @@ -3,7 +3,7 @@ - + Purchase Order Triple Discount -
-

Purchase Order Triple Discount

+
+ + +Odoo Community Association + +
+

Purchase Order Triple Discount

-

Beta License: AGPL-3 OCA/purchase-workflow Translate me on Weblate Try me on Runboat

+

Beta License: AGPL-3 OCA/purchase-workflow Translate me on Weblate Try me on Runboat

This module allows to have three successive discounts on every purchase order line.

Table of contents

@@ -386,7 +391,7 @@

Purchase Order Triple Discount

-

Usage

+

Usage

Create a new purchase 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 @@ -417,7 +422,7 @@

Usage

-

Bug Tracker

+

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 to smash it by providing a detailed and welcomed @@ -425,16 +430,16 @@

Bug Tracker

Do not contact contributors directly about support or help with technical issues.

-

Credits

+

Credits

-

Authors

+

Authors

  • Tecnativa
  • GRAP
-

Maintainers

+

Maintainers

This module is maintained by the OCA.

Odoo Community Association @@ -467,5 +472,6 @@

Maintainers

+
From 85f8c0d082ef70b44b83cb79aef87ee4aa79c3a2 Mon Sep 17 00:00:00 2001 From: Vicent-S73 Date: Wed, 28 Jan 2026 12:20:40 +0100 Subject: [PATCH 31/33] [IMP] purchase_triple_discount: pre-commit auto fixes --- purchase_triple_discount/README.rst | 10 +++++----- purchase_triple_discount/static/description/index.html | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/purchase_triple_discount/README.rst b/purchase_triple_discount/README.rst index 4166895312b..32a5f4a3bec 100644 --- a/purchase_triple_discount/README.rst +++ b/purchase_triple_discount/README.rst @@ -21,13 +21,13 @@ Purchase Order Triple Discount :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github - :target: https://github.com/OCA/purchase-workflow/tree/18.0/purchase_triple_discount + :target: https://github.com/OCA/purchase-workflow/tree/19.0/purchase_triple_discount :alt: OCA/purchase-workflow .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/purchase-workflow-18-0/purchase-workflow-18-0-purchase_triple_discount + :target: https://translation.odoo-community.org/projects/purchase-workflow-19-0/purchase-workflow-19-0-purchase_triple_discount :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png - :target: https://runboat.odoo-community.org/builds?repo=OCA/purchase-workflow&target_branch=18.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/purchase-workflow&target_branch=19.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| @@ -74,7 +74,7 @@ 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 to smash it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -114,6 +114,6 @@ 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. -This module is part of the `OCA/purchase-workflow `_ project on GitHub. +This module is part of the `OCA/purchase-workflow `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/purchase_triple_discount/static/description/index.html b/purchase_triple_discount/static/description/index.html index 8b725afca28..1867c546488 100644 --- a/purchase_triple_discount/static/description/index.html +++ b/purchase_triple_discount/static/description/index.html @@ -374,7 +374,7 @@

Purchase Order Triple Discount

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:fb4779564a8b987350b0ed4d4e6d8035eddc9a8fd341f3e32703640e8e8bd359 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/purchase-workflow Translate me on Weblate Try me on Runboat

+

Beta License: AGPL-3 OCA/purchase-workflow Translate me on Weblate Try me on Runboat

This module allows to have three successive discounts on every purchase order line.

Table of contents

@@ -426,7 +426,7 @@

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 to smash it by providing a detailed and welcomed -feedback.

+feedback.

Do not contact contributors directly about support or help with technical issues.

@@ -467,7 +467,7 @@

Maintainers

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.

-

This module is part of the OCA/purchase-workflow project on GitHub.

+

This module is part of the OCA/purchase-workflow project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

From 6448becfb5d8f2279266974b186b6ecb83ddc4b0 Mon Sep 17 00:00:00 2001 From: Vicent-S73 Date: Wed, 28 Jan 2026 12:22:28 +0100 Subject: [PATCH 32/33] [MIG] purchase_triple_discount: Migration to 19.0 --- purchase_triple_discount/README.rst | 4 ++ purchase_triple_discount/__manifest__.py | 4 +- .../models/purchase_order_line.py | 15 ++++---- .../models/purchase_triple_discount_mixin.py | 30 +++++++-------- .../readme/CONTRIBUTORS.md | 2 + .../static/description/index.html | 5 +++ .../tests/test_purchase_discount.py | 38 ++++++++++++++----- 7 files changed, 62 insertions(+), 36 deletions(-) diff --git a/purchase_triple_discount/README.rst b/purchase_triple_discount/README.rst index 32a5f4a3bec..eb46d0ec9ae 100644 --- a/purchase_triple_discount/README.rst +++ b/purchase_triple_discount/README.rst @@ -101,6 +101,10 @@ Contributors - Christopher Ormaza +- `Studio73 S.L. `__: + + - Vicent Castells + Maintainers ----------- diff --git a/purchase_triple_discount/__manifest__.py b/purchase_triple_discount/__manifest__.py index 0eb72d2aae3..e7d83a3b63a 100644 --- a/purchase_triple_discount/__manifest__.py +++ b/purchase_triple_discount/__manifest__.py @@ -2,9 +2,9 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { "name": "Purchase Order Triple Discount", - "version": "18.0.1.0.0", + "version": "19.0.1.0.0", "category": "Purchase Management", - "author": "Tecnativa," "GRAP," "Odoo Community Association (OCA)", + "author": "Tecnativa,GRAP,Odoo Community Association (OCA)", "website": "https://github.com/OCA/purchase-workflow", "license": "AGPL-3", "summary": "Manage triple discount on purchase order lines", diff --git a/purchase_triple_discount/models/purchase_order_line.py b/purchase_triple_discount/models/purchase_order_line.py index 7c15cb95105..b0791283068 100644 --- a/purchase_triple_discount/models/purchase_order_line.py +++ b/purchase_triple_discount/models/purchase_order_line.py @@ -8,7 +8,7 @@ class PurchaseOrderLine(models.Model): _name = "purchase.order.line" _inherit = ["purchase.triple.discount.mixin", "purchase.order.line"] - @api.depends("product_qty", "product_uom", "company_id") + @api.depends("product_qty", "product_uom_id", "company_id") def _compute_price_unit_and_date_planned_and_name(self): res = super()._compute_price_unit_and_date_planned_and_name() self._compute_discounts() @@ -25,7 +25,7 @@ def _compute_discounts(self): date=line.order_id.date_order and line.order_id.date_order.date() or fields.Date.context_today(line), - uom_id=line.product_uom, + uom_id=line.product_uom_id, params=params, ) if not seller: @@ -50,21 +50,20 @@ def _prepare_account_move_line(self, move=False): @api.model def _prepare_purchase_order_line( - self, product_id, product_qty, product_uom, company_id, supplier, po + self, product_id, product_qty, product_uom_id, company_id, partner, po ): res = super()._prepare_purchase_order_line( - product_id, product_qty, product_uom, company_id, supplier, po + product_id, product_qty, product_uom_id, company_id, partner, po ) today = fields.Date.today() - partner = supplier.partner_id - uom_po_qty = product_uom._compute_quantity( - product_qty, product_id.uom_po_id, rounding_method="HALF-UP" + uom_po_qty = product_uom_id._compute_quantity( + product_qty, product_id.uom_id, rounding_method="HALF-UP" ) seller = product_id.with_company(company_id)._select_seller( partner_id=partner, quantity=uom_po_qty, date=po.date_order and max(po.date_order.date(), today) or today, - uom_id=product_id.uom_po_id, + uom_id=product_id.uom_id, ) res.update( dict( diff --git a/purchase_triple_discount/models/purchase_triple_discount_mixin.py b/purchase_triple_discount/models/purchase_triple_discount_mixin.py index 78f034f3da9..a2aafef3242 100644 --- a/purchase_triple_discount/models/purchase_triple_discount_mixin.py +++ b/purchase_triple_discount/models/purchase_triple_discount_mixin.py @@ -30,23 +30,19 @@ class TripleDiscountMixin(models.AbstractModel): readonly=False, ) - _sql_constraints = [ - ( - "discount1_limit", - "CHECK (discount1 <= 100.0)", - "Discount 1 must be lower than 100%.", - ), - ( - "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%.", - ), - ] + _discount1_constraint = models.Constraint( + "CHECK (discount1 <= 100.0)", + "Discount 1 must be lower than 100%.", + ) + + _discount2_constraint = models.Constraint( + "CHECK (discount2 <= 100.0)", + "Discount 2 must be lower than 100%.", + ) + _discount3_constraint = models.Constraint( + "CHECK (discount3 <= 100.0)", + "Discount 3 must be lower than 100%.", + ) @api.depends(lambda self: self._get_multiple_discount_field_names()) def _compute_discount(self): diff --git a/purchase_triple_discount/readme/CONTRIBUTORS.md b/purchase_triple_discount/readme/CONTRIBUTORS.md index 4a66425a19a..2601e596994 100644 --- a/purchase_triple_discount/readme/CONTRIBUTORS.md +++ b/purchase_triple_discount/readme/CONTRIBUTORS.md @@ -7,3 +7,5 @@ - [ForgeFlow S.L.](https://www.forgeflow.com): - Christopher Ormaza \<\> +- [Studio73 S.L.](https://www.studio73.es): + - Vicent Castells \<\> diff --git a/purchase_triple_discount/static/description/index.html b/purchase_triple_discount/static/description/index.html index 1867c546488..bc044355257 100644 --- a/purchase_triple_discount/static/description/index.html +++ b/purchase_triple_discount/static/description/index.html @@ -456,6 +456,11 @@

Contributors

  • Christopher Ormaza <chris.ormaza@forgeflow.com>
  • +
  • Studio73 S.L.:

    + +
  • diff --git a/purchase_triple_discount/tests/test_purchase_discount.py b/purchase_triple_discount/tests/test_purchase_discount.py index e5dd8c1ba6f..3b64f7c4590 100644 --- a/purchase_triple_discount/tests/test_purchase_discount.py +++ b/purchase_triple_discount/tests/test_purchase_discount.py @@ -2,6 +2,7 @@ # Copyright 2019 Tecnativa - Pedro M. Baeza # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import Command from odoo.tests import Form, common @@ -79,8 +80,8 @@ def setUpClass(cls): "date_planned": "2018-01-19 00:00:00", "name": "Line 1", "product_qty": 1.0, - "product_uom": cls.product1.uom_id.id, - "taxes_id": [(6, 0, [cls.tax.id])], + "product_uom_id": cls.product1.uom_id.id, + "tax_ids": [Command.set([cls.tax.id])], "price_unit": 600.0, } ) @@ -91,8 +92,8 @@ def setUpClass(cls): "date_planned": "2018-01-19 00:00:00", "name": "Line 2", "product_qty": 10.0, - "product_uom": cls.product2.uom_id.id, - "taxes_id": [(6, 0, [cls.tax.id])], + "product_uom_id": cls.product2.uom_id.id, + "tax_ids": [Command.set([cls.tax.id])], "price_unit": 60.0, } ) @@ -103,8 +104,8 @@ def setUpClass(cls): "date_planned": "2020-01-01 00:00:00", "name": "Line 1", "product_qty": 1.0, - "product_uom": cls.product1.uom_id.id, - "taxes_id": [(6, 0, [cls.tax.id])], + "product_uom_id": cls.product1.uom_id.id, + "tax_ids": [Command.set([cls.tax.id])], "price_unit": 600.0, } ) @@ -118,7 +119,7 @@ def test_01_purchase_order_classic_discount(self): self.assertEqual(self.order.amount_untaxed, 450.0) self.assertEqual(self.order.amount_tax, 67.5) # Mix taxed and untaxed: - self.po_line1.taxes_id = False + self.po_line1.tax_ids = False self.assertEqual(self.order.amount_tax, 22.5) def test_02_purchase_order_simple_triple_discount(self): @@ -205,8 +206,8 @@ def test_06_supplierinfo_from_purchaseorder(self): "date_planned": "2020-01-01 00:00:00", "name": "Line 2", "product_qty": 1.0, - "product_uom": self.product2.uom_id.id, - "taxes_id": [(6, 0, [self.tax.id])], + "product_uom_id": self.product2.uom_id.id, + "tax_ids": [Command.set([self.tax.id])], "price_unit": 999.0, "discount1": 11.11, "discount2": 22.22, @@ -224,3 +225,22 @@ def test_06_supplierinfo_from_purchaseorder(self): self.assertEqual(seller.discount1, 11.11) self.assertEqual(seller.discount2, 22.22) self.assertEqual(seller.discount3, 33.33) + + def test_07_prepare_purchase_order_line_coverage(self): + from unittest.mock import patch + + with patch( + "odoo.addons.purchase.models.purchase_order_line.PurchaseOrderLine._prepare_purchase_order_line", + return_value={"price_unit": 100.0}, + ): + res = self.env["purchase.order.line"]._prepare_purchase_order_line( + self.product1, + 1.0, + self.product1.uom_id, + self.env.company, + self.supplierinfo, + self.order2, + ) + self.assertEqual(res.get("discount1"), 10.0) + self.assertEqual(res.get("discount2"), 20.0) + self.assertEqual(res.get("discount3"), 30.0) From e0b132858bff2ed299c7279751472cc55728de95 Mon Sep 17 00:00:00 2001 From: Vicent-S73 Date: Wed, 28 Jan 2026 12:33:12 +0100 Subject: [PATCH 33/33] [DON'T MERGE] test-requirements.txt --- test-requirements.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 test-requirements.txt diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 00000000000..f7f832a2880 --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1 @@ +odoo-addon-account_invoice_triple_discount @ git+https://github.com/OCA/account-invoicing.git@refs/pull/2144/head#subdirectory=account_invoice_triple_discount