diff --git a/purchase_order_price_recalculation/README.rst b/purchase_order_price_recalculation/README.rst new file mode 100644 index 00000000000..b757c0d5fe4 --- /dev/null +++ b/purchase_order_price_recalculation/README.rst @@ -0,0 +1,101 @@ +======================================= +Price recalculation in purchases orders +======================================= + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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/14.0/purchase_order_price_recalculation + :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-14-0/purchase-workflow-14-0-purchase_order_price_recalculation + :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/14.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds one button on purchase orders (below the lines) that: + +* Recalculates the prices of the order lines that contain a product in them. + +It is launched manually as a button to get the user to decide if he/she wants to +recalculate prices when vendor is changed or after duplicating a purchase order +to update or not purchase information. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +#. Go to *Purchase -> Products > Products* and create some record and set differente prices to vendors in Purchase tab, for example: Vendor 1: 10 and Vendor 2: 20. +#. Go to *Purchase -> Orders > Requests for Quotation* and create some record and set Vendor 1. +#. Add a line with the previously created product. +#. The unit price of the product is 10. +#. Change vendor to Vendor 2. +#. Click on the "Update lines info" button. +#. The unit price of the product is 20. + +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 `_: + + * Víctor Martínez + * Pedro M. Baeza + +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. + +.. |maintainer-victoralmau| image:: https://github.com/victoralmau.png?size=40px + :target: https://github.com/victoralmau + :alt: victoralmau + +Current `maintainer `__: + +|maintainer-victoralmau| + +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_order_price_recalculation/__init__.py b/purchase_order_price_recalculation/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/purchase_order_price_recalculation/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/purchase_order_price_recalculation/__manifest__.py b/purchase_order_price_recalculation/__manifest__.py new file mode 100644 index 00000000000..746b6e42f69 --- /dev/null +++ b/purchase_order_price_recalculation/__manifest__.py @@ -0,0 +1,14 @@ +# Copyright 2022 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Price recalculation in purchases orders", + "version": "14.0.1.0.0", + "category": "Purchase Management", + "website": "https://github.com/OCA/purchase-workflow", + "author": "Tecnativa, Odoo Community Association (OCA)", + "license": "AGPL-3", + "installable": True, + "depends": ["purchase"], + "data": ["views/purchase_order_view.xml"], + "maintainers": ["victoralmau"], +} diff --git a/purchase_order_price_recalculation/i18n/es.po b/purchase_order_price_recalculation/i18n/es.po new file mode 100644 index 00000000000..7770fca2915 --- /dev/null +++ b/purchase_order_price_recalculation/i18n/es.po @@ -0,0 +1,52 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_order_price_recalculation +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2022-05-03 08:04+0000\n" +"PO-Revision-Date: 2022-05-03 10:06+0200\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: \n" +"X-Generator: Poedit 2.3\n" + +#. module: purchase_order_price_recalculation +#: model:ir.model.fields,field_description:purchase_order_price_recalculation.field_purchase_order__display_name +msgid "Display Name" +msgstr "Nombre mostrado" + +#. module: purchase_order_price_recalculation +#: model:ir.model.fields,field_description:purchase_order_price_recalculation.field_purchase_order__id +msgid "ID" +msgstr "ID" + +#. module: purchase_order_price_recalculation +#: model:ir.model.fields,field_description:purchase_order_price_recalculation.field_purchase_order____last_update +msgid "Last Modified on" +msgstr "Última modificación el" + +#. module: purchase_order_price_recalculation +#: model:ir.model,name:purchase_order_price_recalculation.model_purchase_order +msgid "Purchase Order" +msgstr "Pedido de compra" + +#. module: purchase_order_price_recalculation +#: model_terms:ir.ui.view,arch_db:purchase_order_price_recalculation.purchase_order_form +msgid "" +"This will update all the line prices based on the vendor currently set. Do " +"you want to continue?" +msgstr "" +"Esto actualizará todos los precios de la línea según el proveedor " +"establecido actualmente. ¿Quiere continuar?" + +#. module: purchase_order_price_recalculation +#: model_terms:ir.ui.view,arch_db:purchase_order_price_recalculation.purchase_order_form +msgid "Update lines info" +msgstr "Actualizar información de líneas" diff --git a/purchase_order_price_recalculation/i18n/purchase_order_price_recalculation.pot b/purchase_order_price_recalculation/i18n/purchase_order_price_recalculation.pot new file mode 100644 index 00000000000..f09271e2912 --- /dev/null +++ b/purchase_order_price_recalculation/i18n/purchase_order_price_recalculation.pot @@ -0,0 +1,48 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_order_price_recalculation +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2022-05-03 08:04+0000\n" +"PO-Revision-Date: 2022-05-03 08:04+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: \n" + +#. module: purchase_order_price_recalculation +#: model:ir.model.fields,field_description:purchase_order_price_recalculation.field_purchase_order__display_name +msgid "Display Name" +msgstr "" + +#. module: purchase_order_price_recalculation +#: model:ir.model.fields,field_description:purchase_order_price_recalculation.field_purchase_order__id +msgid "ID" +msgstr "" + +#. module: purchase_order_price_recalculation +#: model:ir.model.fields,field_description:purchase_order_price_recalculation.field_purchase_order____last_update +msgid "Last Modified on" +msgstr "" + +#. module: purchase_order_price_recalculation +#: model:ir.model,name:purchase_order_price_recalculation.model_purchase_order +msgid "Purchase Order" +msgstr "" + +#. module: purchase_order_price_recalculation +#: model_terms:ir.ui.view,arch_db:purchase_order_price_recalculation.purchase_order_form +msgid "" +"This will update all the line prices based on the vendor currently set. Do " +"you want to continue?" +msgstr "" + +#. module: purchase_order_price_recalculation +#: model_terms:ir.ui.view,arch_db:purchase_order_price_recalculation.purchase_order_form +msgid "Update lines info" +msgstr "" diff --git a/purchase_order_price_recalculation/models/__init__.py b/purchase_order_price_recalculation/models/__init__.py new file mode 100644 index 00000000000..2eaf7ea0a8b --- /dev/null +++ b/purchase_order_price_recalculation/models/__init__.py @@ -0,0 +1,2 @@ +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html +from . import purchase_order diff --git a/purchase_order_price_recalculation/models/purchase_order.py b/purchase_order_price_recalculation/models/purchase_order.py new file mode 100644 index 00000000000..41a7c3a9ca4 --- /dev/null +++ b/purchase_order_price_recalculation/models/purchase_order.py @@ -0,0 +1,13 @@ +# Copyright 2022 Tecnativa - Víctor Martínez +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html +from odoo import models + + +class PurchaseOrder(models.Model): + _inherit = "purchase.order" + + def update_lines_info(self): + self.ensure_one() + for line in self.order_line: + line._onchange_quantity() + return True diff --git a/purchase_order_price_recalculation/readme/CONTRIBUTORS.rst b/purchase_order_price_recalculation/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..5fb71305308 --- /dev/null +++ b/purchase_order_price_recalculation/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* `Tecnativa `_: + + * Víctor Martínez + * Pedro M. Baeza diff --git a/purchase_order_price_recalculation/readme/DESCRIPTION.rst b/purchase_order_price_recalculation/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..68b30bb5ec5 --- /dev/null +++ b/purchase_order_price_recalculation/readme/DESCRIPTION.rst @@ -0,0 +1,7 @@ +This module adds one button on purchase orders (below the lines) that: + +* Recalculates the prices of the order lines that contain a product in them. + +It is launched manually as a button to get the user to decide if he/she wants to +recalculate prices when vendor is changed or after duplicating a purchase order +to update or not purchase information. diff --git a/purchase_order_price_recalculation/readme/USAGE.rst b/purchase_order_price_recalculation/readme/USAGE.rst new file mode 100644 index 00000000000..a66ad865a42 --- /dev/null +++ b/purchase_order_price_recalculation/readme/USAGE.rst @@ -0,0 +1,7 @@ +#. Go to *Purchase -> Products > Products* and create some record and set differente prices to vendors in Purchase tab, for example: Vendor 1: 10 and Vendor 2: 20. +#. Go to *Purchase -> Orders > Requests for Quotation* and create some record and set Vendor 1. +#. Add a line with the previously created product. +#. The unit price of the product is 10. +#. Change vendor to Vendor 2. +#. Click on the "Update lines info" button. +#. The unit price of the product is 20. diff --git a/purchase_order_price_recalculation/static/description/icon.png b/purchase_order_price_recalculation/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/purchase_order_price_recalculation/static/description/icon.png differ diff --git a/purchase_order_price_recalculation/static/description/index.html b/purchase_order_price_recalculation/static/description/index.html new file mode 100644 index 00000000000..b3ef987f530 --- /dev/null +++ b/purchase_order_price_recalculation/static/description/index.html @@ -0,0 +1,444 @@ + + + + + + +Price recalculation in purchases orders + + + +
+

Price recalculation in purchases orders

+ + +

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

+

This module adds one button on purchase orders (below the lines) that:

+
    +
  • Recalculates the prices of the order lines that contain a product in them.
  • +
+

It is launched manually as a button to get the user to decide if he/she wants to +recalculate prices when vendor is changed or after duplicating a purchase order +to update or not purchase information.

+

Table of contents

+ +
+

Usage

+
    +
  1. Go to Purchase -> Products > Products and create some record and set differente prices to vendors in Purchase tab, for example: Vendor 1: 10 and Vendor 2: 20.
  2. +
  3. Go to Purchase -> Orders > Requests for Quotation and create some record and set Vendor 1.
  4. +
  5. Add a line with the previously created product.
  6. +
  7. The unit price of the product is 10.
  8. +
  9. Change vendor to Vendor 2.
  10. +
  11. Click on the “Update lines info” button.
  12. +
  13. The unit price of the product is 20.
  14. +
+
+
+

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:
      +
    • Víctor Martínez
    • +
    • Pedro M. Baeza
    • +
    +
  • +
+
+
+

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.

+

Current maintainer:

+

victoralmau

+

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_order_price_recalculation/tests/__init__.py b/purchase_order_price_recalculation/tests/__init__.py new file mode 100644 index 00000000000..3f6b4227301 --- /dev/null +++ b/purchase_order_price_recalculation/tests/__init__.py @@ -0,0 +1,2 @@ +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html +from . import test_purchase_order_price_recalculation diff --git a/purchase_order_price_recalculation/tests/test_purchase_order_price_recalculation.py b/purchase_order_price_recalculation/tests/test_purchase_order_price_recalculation.py new file mode 100644 index 00000000000..93f37ac5a54 --- /dev/null +++ b/purchase_order_price_recalculation/tests/test_purchase_order_price_recalculation.py @@ -0,0 +1,42 @@ +# Copyright 2022 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) + +from odoo.tests import Form, common + + +class TestPurchaseOrderPriceRecalculation(common.SavepointCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.partner_a = cls.env["res.partner"].create({"name": "Test partner A"}) + cls.partner_b = cls.env["res.partner"].create({"name": "Test partner B"}) + cls.product = cls.env["product.product"].create( + { + "name": "Test product", + "seller_ids": [ + (0, 0, {"name": cls.partner_a.id, "price": 10}), + (0, 0, {"name": cls.partner_b.id, "price": 20}), + ], + } + ) + cls.order = cls._create_order(cls, cls.partner_a) + + def _create_order(self, partner): + order_form = Form(self.env["purchase.order"]) + order_form.partner_id = partner + with order_form.order_line.new() as line_form: + line_form.product_id = self.product + line_form.product_qty = 1 + return order_form.save() + + def test_order_update_lines_info(self): + product_line = self.order.order_line + self.assertEqual(product_line.price_unit, 10) + # Test form + order_form = Form(self.order) + order_form.partner_id = self.partner_b + # Update partner + self.order.partner_id = self.partner_b + self.assertEqual(product_line.price_unit, 10) + self.order.update_lines_info() + self.assertEqual(product_line.price_unit, 20) diff --git a/purchase_order_price_recalculation/views/purchase_order_view.xml b/purchase_order_price_recalculation/views/purchase_order_view.xml new file mode 100644 index 00000000000..b310c841b05 --- /dev/null +++ b/purchase_order_price_recalculation/views/purchase_order_view.xml @@ -0,0 +1,19 @@ + + + + purchase.order + + + + + + diff --git a/setup/purchase_order_price_recalculation/odoo/addons/purchase_order_price_recalculation b/setup/purchase_order_price_recalculation/odoo/addons/purchase_order_price_recalculation new file mode 120000 index 00000000000..8fca4d0bf27 --- /dev/null +++ b/setup/purchase_order_price_recalculation/odoo/addons/purchase_order_price_recalculation @@ -0,0 +1 @@ +../../../../purchase_order_price_recalculation \ No newline at end of file diff --git a/setup/purchase_order_price_recalculation/setup.py b/setup/purchase_order_price_recalculation/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/purchase_order_price_recalculation/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)