diff --git a/oca_dependencies.txt b/oca_dependencies.txt index d9e0cd6649d..eb3eb63a286 100644 --- a/oca_dependencies.txt +++ b/oca_dependencies.txt @@ -1,3 +1,4 @@ +account-invoicing server-tools product-attribute server-ux diff --git a/purchase_triple_discount/README.rst b/purchase_triple_discount/README.rst new file mode 100644 index 00000000000..3758da6f254 --- /dev/null +++ b/purchase_triple_discount/README.rst @@ -0,0 +1,109 @@ +=============================== +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 +===== + +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 +~~~~~~~~~~~~ + +* `Tecnativa `_: + + * 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 + +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/__init__.py b/purchase_triple_discount/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/purchase_triple_discount/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/purchase_triple_discount/__manifest__.py b/purchase_triple_discount/__manifest__.py new file mode 100644 index 00000000000..3054422fdaa --- /dev/null +++ b/purchase_triple_discount/__manifest__.py @@ -0,0 +1,22 @@ +# 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', + 'category': 'Purchase Management', + 'author': 'Tecnativa, ' + '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', + '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/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..92024bb4572 --- /dev/null +++ b/purchase_triple_discount/i18n/purchase_triple_discount.pot @@ -0,0 +1,95 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_triple_discount +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.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,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 +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/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/models/__init__.py b/purchase_triple_discount/models/__init__.py new file mode 100644 index 00000000000..42194fa4c43 --- /dev/null +++ b/purchase_triple_discount/models/__init__.py @@ -0,0 +1,5 @@ +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 new file mode 100644 index 00000000000..8c2e650addd --- /dev/null +++ b/purchase_triple_discount/models/account_invoice.py @@ -0,0 +1,15 @@ +# 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/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 new file mode 100644 index 00000000000..90fecd8fd1b --- /dev/null +++ b/purchase_triple_discount/models/purchase_order.py @@ -0,0 +1,76 @@ +# 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" + + @api.depends('discount2', 'discount3') + def _compute_amount(self): + super(PurchaseOrderLine, self)._compute_amount() + + discount2 = fields.Float( + 'Disc. 2 (%)', + digits=dp.get_precision('Discount'), + ) + + discount3 = fields.Float( + 'Disc. 3 (%)', + digits=dp.get_precision('Discount'), + ) + + _sql_constraints = [ + ('discount2_limit', 'CHECK (discount2 <= 100.0)', + 'Discount 2 must be lower than 100%.'), + ('discount3_limit', 'CHECK (discount3 <= 100.0)', + 'Discount 3 must be lower than 100%.'), + ] + + 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 + + @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 00000000000..3a0328b516c Binary files /dev/null and b/purchase_triple_discount/static/description/icon.png differ 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 new file mode 100644 index 00000000000..19588b827ca --- /dev/null +++ b/purchase_triple_discount/tests/__init__.py @@ -0,0 +1 @@ +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..ba126d8639f --- /dev/null +++ b/purchase_triple_discount/tests/test_purchase_discount.py @@ -0,0 +1,204 @@ +# Copyright 2017-19 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.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', + }) + cls.product2 = cls.env['product.product'].create({ + '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', + 'type_tax_use': 'purchase', + 'amount': 15.0, + }) + cls.order = cls.env['purchase.order'].create({ + '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({ + '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, + }) + 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 """ + 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) + + 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/purchase_view.xml b/purchase_triple_discount/views/purchase_view.xml new file mode 100644 index 00000000000..58b5a089794 --- /dev/null +++ b/purchase_triple_discount/views/purchase_view.xml @@ -0,0 +1,22 @@ + + + + + purchase.order.triple.discount.form + purchase.order + + + + + + + + + + + + + + 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 + + + + + + + + + + diff --git a/setup/_metapackage/VERSION.txt b/setup/_metapackage/VERSION.txt index 042ea46c3e1..cbf2026c500 100644 --- a/setup/_metapackage/VERSION.txt +++ b/setup/_metapackage/VERSION.txt @@ -1 +1 @@ -11.0.20190716.0 \ No newline at end of file +11.0.20190807.0 \ No newline at end of file diff --git a/setup/_metapackage/setup.py b/setup/_metapackage/setup.py index 28d15c4dcc1..5ef5f382c4c 100644 --- a/setup/_metapackage/setup.py +++ b/setup/_metapackage/setup.py @@ -38,6 +38,7 @@ 'odoo11-addon-purchase_request_tier_validation', 'odoo11-addon-purchase_request_usage_department', 'odoo11-addon-purchase_tier_validation', + 'odoo11-addon-purchase_triple_discount', 'odoo11-addon-stock_landed_cost_company_percentage', 'odoo11-addon-subcontracted_service', ], diff --git a/setup/purchase_triple_discount/odoo/addons/purchase_triple_discount b/setup/purchase_triple_discount/odoo/addons/purchase_triple_discount new file mode 120000 index 00000000000..47eaffc87e0 --- /dev/null +++ b/setup/purchase_triple_discount/odoo/addons/purchase_triple_discount @@ -0,0 +1 @@ +../../../../purchase_triple_discount \ No newline at end of file diff --git a/setup/purchase_triple_discount/setup.cfg b/setup/purchase_triple_discount/setup.cfg new file mode 100644 index 00000000000..3c6e79cf31d --- /dev/null +++ b/setup/purchase_triple_discount/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal=1 diff --git a/setup/purchase_triple_discount/setup.py b/setup/purchase_triple_discount/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/purchase_triple_discount/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)