diff --git a/stock_move_purchase_price_update/README.rst b/stock_move_purchase_price_update/README.rst new file mode 100644 index 00000000000..f13e74920c9 --- /dev/null +++ b/stock_move_purchase_price_update/README.rst @@ -0,0 +1,111 @@ +================================ +Stock Move Purchase Price Update +================================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:497c30681d23cee221c7d086b326b8170b871e7021c9f282e679f26b1dd12912 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/18.0/stock_move_purchase_price_update + :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-stock_move_purchase_price_update + :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 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Allow update purchase price from incoming picking operations, picking +detailed operations and picking batch detailed operations if the +purchase order is not invoiced. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +- Go to 'Inventory > Configuration > Operations' Types +- Select Reception operation +- Enable 'Show Detailed Operations' option. +- Go to Reception picking +- Add optional column 'Purchase price' in operations and/or detailed + operations + +Usage +===== + +- Go to Purchase > Products > Products and edit/create one +- Set Product Type as Storable Product +- Go to Purchase > Orders > Requests for Quotation +- Create new RQ with the previous product in the order lines +- Confirm the Purchase Order +- Now you have a new button called 'Receive Products' > Press it +- Add optional column 'Purchase Price' in operations and or detailed + operations +- You can change the price of the purchase order line from here + +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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Tecnativa + +Contributors +------------ + +- `Tecnativa `__: + + - Carlos Dauden + +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-carlosdauden| image:: https://github.com/carlosdauden.png?size=40px + :target: https://github.com/carlosdauden + :alt: carlosdauden + +Current `maintainer `__: + +|maintainer-carlosdauden| + +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/stock_move_purchase_price_update/__init__.py b/stock_move_purchase_price_update/__init__.py new file mode 100644 index 00000000000..31660d6a965 --- /dev/null +++ b/stock_move_purchase_price_update/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import models diff --git a/stock_move_purchase_price_update/__manifest__.py b/stock_move_purchase_price_update/__manifest__.py new file mode 100644 index 00000000000..314a4400690 --- /dev/null +++ b/stock_move_purchase_price_update/__manifest__.py @@ -0,0 +1,21 @@ +# Copyright 2024 Tecnativa - Carlos Dauden +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Stock Move Purchase Price Update", + "summary": "Allow update purchase price from incoming picking operations", + "version": "18.0.1.0.0", + "development_status": "Beta", + "category": "stock", + "website": "https://github.com/OCA/purchase-workflow", + "author": "Tecnativa, Odoo Community Association (OCA)", + "maintainers": ["carlosdauden"], + "license": "AGPL-3", + "application": False, + "installable": True, + "depends": [ + "purchase_stock", + ], + "data": [ + "views/stock_move_views.xml", + ], +} diff --git a/stock_move_purchase_price_update/i18n/es.po b/stock_move_purchase_price_update/i18n/es.po new file mode 100644 index 00000000000..75fe8bd16fc --- /dev/null +++ b/stock_move_purchase_price_update/i18n/es.po @@ -0,0 +1,45 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_move_purchase_price_update +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-09-13 08:27+0000\n" +"PO-Revision-Date: 2024-09-13 10:30+0200\n" +"Last-Translator: Carlos Dauden \n" +"Language-Team: none\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Poedit 3.0.1\n" + +#. module: stock_move_purchase_price_update +#: model:ir.model.fields,field_description:stock_move_purchase_price_update.field_stock_move__is_purchase_price_editable +#: model:ir.model.fields,field_description:stock_move_purchase_price_update.field_stock_move_line__is_purchase_price_editable +msgid "Is Purchase Price Editable" +msgstr "Precio de compra es editable" + +#. module: stock_move_purchase_price_update +#: model:ir.model,name:stock_move_purchase_price_update.model_stock_move_line +msgid "Product Moves (Stock Move Line)" +msgstr "Movimientos de Producto (Stock Move Line)" + +#. module: stock_move_purchase_price_update +#: model:ir.model.fields,field_description:stock_move_purchase_price_update.field_stock_move_line__purchase_line_id +msgid "Purchase Line" +msgstr "Línea de compra" + +#. module: stock_move_purchase_price_update +#: model:ir.model.fields,field_description:stock_move_purchase_price_update.field_stock_move__purchase_price_unit +#: model:ir.model.fields,field_description:stock_move_purchase_price_update.field_stock_move_line__purchase_price_unit +msgid "Purchase price" +msgstr "Precio compra" + +#. module: stock_move_purchase_price_update +#: model:ir.model,name:stock_move_purchase_price_update.model_stock_move +msgid "Stock Move" +msgstr "Movimiento de existencias" diff --git a/stock_move_purchase_price_update/i18n/stock_move_purchase_price_update.pot b/stock_move_purchase_price_update/i18n/stock_move_purchase_price_update.pot new file mode 100644 index 00000000000..f0f75b20991 --- /dev/null +++ b/stock_move_purchase_price_update/i18n/stock_move_purchase_price_update.pot @@ -0,0 +1,41 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_move_purchase_price_update +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.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: stock_move_purchase_price_update +#: model:ir.model.fields,field_description:stock_move_purchase_price_update.field_stock_move__is_purchase_price_editable +#: model:ir.model.fields,field_description:stock_move_purchase_price_update.field_stock_move_line__is_purchase_price_editable +msgid "Is Purchase Price Editable" +msgstr "" + +#. module: stock_move_purchase_price_update +#: model:ir.model,name:stock_move_purchase_price_update.model_stock_move_line +msgid "Product Moves (Stock Move Line)" +msgstr "" + +#. module: stock_move_purchase_price_update +#: model:ir.model.fields,field_description:stock_move_purchase_price_update.field_stock_move_line__purchase_line_id +msgid "Purchase Line" +msgstr "" + +#. module: stock_move_purchase_price_update +#: model:ir.model.fields,field_description:stock_move_purchase_price_update.field_stock_move__purchase_price_unit +#: model:ir.model.fields,field_description:stock_move_purchase_price_update.field_stock_move_line__purchase_price_unit +msgid "Purchase price" +msgstr "" + +#. module: stock_move_purchase_price_update +#: model:ir.model,name:stock_move_purchase_price_update.model_stock_move +msgid "Stock Move" +msgstr "" diff --git a/stock_move_purchase_price_update/models/__init__.py b/stock_move_purchase_price_update/models/__init__.py new file mode 100644 index 00000000000..72a7221c09f --- /dev/null +++ b/stock_move_purchase_price_update/models/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import stock_move +from . import stock_move_line diff --git a/stock_move_purchase_price_update/models/stock_move.py b/stock_move_purchase_price_update/models/stock_move.py new file mode 100644 index 00000000000..7bfe56a12f4 --- /dev/null +++ b/stock_move_purchase_price_update/models/stock_move.py @@ -0,0 +1,29 @@ +# Copyright 2024 Tecnativa - Carlos Dauden +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class StockMove(models.Model): + _inherit = "stock.move" + + purchase_price_unit = fields.Float( + string="Purchase price", + compute="_compute_purchase_fields", + inverse="_inverse_purchase_price_unit", + digits="Product Price", + ) + is_purchase_price_editable = fields.Boolean( + compute="_compute_purchase_fields", + ) + + @api.depends("purchase_line_id.price_unit", "purchase_line_id.qty_invoiced") + def _compute_purchase_fields(self): + for line in self: + line.purchase_price_unit = line.purchase_line_id.price_unit + line.is_purchase_price_editable = line.purchase_line_id.qty_invoiced == 0.0 + + # Use compute with inverse because related field don't save the value + def _inverse_purchase_price_unit(self): + for line in self: + line.purchase_line_id.price_unit = line.purchase_price_unit diff --git a/stock_move_purchase_price_update/models/stock_move_line.py b/stock_move_purchase_price_update/models/stock_move_line.py new file mode 100644 index 00000000000..5bf27ab297d --- /dev/null +++ b/stock_move_purchase_price_update/models/stock_move_line.py @@ -0,0 +1,36 @@ +# Copyright 2024 Tecnativa - Carlos Dauden +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class StockMoveLine(models.Model): + _inherit = "stock.move.line" + + purchase_line_id = fields.Many2one( + comodel_name="purchase.order.line", + compute="_compute_purchase_fields", + ) + purchase_price_unit = fields.Float( + string="Purchase price", + compute="_compute_purchase_fields", + inverse="_inverse_purchase_price_unit", + digits="Product Price", + ) + is_purchase_price_editable = fields.Boolean( + compute="_compute_purchase_fields", + ) + + @api.depends( + "move_id.purchase_line_id.price_unit", "move_id.purchase_line_id.qty_invoiced" + ) + def _compute_purchase_fields(self): + for line in self: + line.purchase_line_id = line.move_id.purchase_line_id + line.purchase_price_unit = line.purchase_line_id.price_unit + line.is_purchase_price_editable = line.purchase_line_id.qty_invoiced == 0.0 + + # Use compute with inverse because related field don't save the value + def _inverse_purchase_price_unit(self): + for line in self: + line.move_id.purchase_line_id.price_unit = line.purchase_price_unit diff --git a/stock_move_purchase_price_update/pyproject.toml b/stock_move_purchase_price_update/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/stock_move_purchase_price_update/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/stock_move_purchase_price_update/readme/CONFIGURE.md b/stock_move_purchase_price_update/readme/CONFIGURE.md new file mode 100644 index 00000000000..9f21fdb04fa --- /dev/null +++ b/stock_move_purchase_price_update/readme/CONFIGURE.md @@ -0,0 +1,5 @@ +- Go to 'Inventory \> Configuration \> Operations' Types +- Select Reception operation +- Enable 'Show Detailed Operations' option. +- Go to Reception picking +- Add optional column 'Purchase price' in operations and/or detailed operations diff --git a/stock_move_purchase_price_update/readme/CONTRIBUTORS.md b/stock_move_purchase_price_update/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..37d0fcf44b6 --- /dev/null +++ b/stock_move_purchase_price_update/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- [Tecnativa](https://www.tecnativa.com): + - Carlos Dauden diff --git a/stock_move_purchase_price_update/readme/DESCRIPTION.md b/stock_move_purchase_price_update/readme/DESCRIPTION.md new file mode 100644 index 00000000000..a3253796b8e --- /dev/null +++ b/stock_move_purchase_price_update/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +Allow update purchase price from incoming picking operations, picking detailed +operations and picking batch detailed operations if the purchase order is not invoiced. diff --git a/stock_move_purchase_price_update/readme/USAGE.md b/stock_move_purchase_price_update/readme/USAGE.md new file mode 100644 index 00000000000..ba66e30feac --- /dev/null +++ b/stock_move_purchase_price_update/readme/USAGE.md @@ -0,0 +1,8 @@ +- Go to Purchase \> Products \> Products and edit/create one +- Set Product Type as Storable Product +- Go to Purchase \> Orders \> Requests for Quotation +- Create new RQ with the previous product in the order lines +- Confirm the Purchase Order +- Now you have a new button called 'Receive Products' \> Press it +- Add optional column 'Purchase Price' in operations and or detailed operations +- You can change the price of the purchase order line from here diff --git a/stock_move_purchase_price_update/static/description/icon.png b/stock_move_purchase_price_update/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/stock_move_purchase_price_update/static/description/icon.png differ diff --git a/stock_move_purchase_price_update/static/description/index.html b/stock_move_purchase_price_update/static/description/index.html new file mode 100644 index 00000000000..eea7333e246 --- /dev/null +++ b/stock_move_purchase_price_update/static/description/index.html @@ -0,0 +1,457 @@ + + + + + +Stock Move Purchase Price Update + + + +
+

Stock Move Purchase Price Update

+ + +

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

+

Allow update purchase price from incoming picking operations, picking +detailed operations and picking batch detailed operations if the +purchase order is not invoiced.

+

Table of contents

+ +
+

Configuration

+
    +
  • Go to ‘Inventory > Configuration > Operations’ Types
  • +
  • Select Reception operation
  • +
  • Enable ‘Show Detailed Operations’ option.
  • +
  • Go to Reception picking
  • +
  • Add optional column ‘Purchase price’ in operations and/or detailed +operations
  • +
+
+
+

Usage

+
    +
  • Go to Purchase > Products > Products and edit/create one
  • +
  • Set Product Type as Storable Product
  • +
  • Go to Purchase > Orders > Requests for Quotation
  • +
  • Create new RQ with the previous product in the order lines
  • +
  • Confirm the Purchase Order
  • +
  • Now you have a new button called ‘Receive Products’ > Press it
  • +
  • Add optional column ‘Purchase Price’ in operations and or detailed +operations
  • +
  • You can change the price of the purchase order line from here
  • +
+
+
+

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.

+

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.

+

Current maintainer:

+

carlosdauden

+

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/stock_move_purchase_price_update/tests/__init__.py b/stock_move_purchase_price_update/tests/__init__.py new file mode 100644 index 00000000000..11b1fd472c3 --- /dev/null +++ b/stock_move_purchase_price_update/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import test_stock_move_purchase_price_update diff --git a/stock_move_purchase_price_update/tests/test_stock_move_purchase_price_update.py b/stock_move_purchase_price_update/tests/test_stock_move_purchase_price_update.py new file mode 100644 index 00000000000..e7eef7d4991 --- /dev/null +++ b/stock_move_purchase_price_update/tests/test_stock_move_purchase_price_update.py @@ -0,0 +1,54 @@ +# Copyright 2024 Tecnativa - Carlos Dauden +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.addons.base.tests.common import BaseCommon + + +class TestStockMovePurchasePriceUpdate(BaseCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.company = cls.env.ref("base.main_company") + cls.warehouse = cls.env.ref("stock.warehouse0") + cls.product = cls.env["product.product"].create( + {"name": "Product Test", "type": "consu", "is_storable": True} + ) + cls.vendor = cls.env["res.partner"].create( + { + "name": "Partner Test", + } + ) + cls.purchase_order = cls.env["purchase.order"].create( + { + "partner_id": cls.vendor.id, + "order_line": [ + ( + 0, + 0, + { + "name": cls.product.name, + "product_id": cls.product.id, + "product_uom_qty": 3, + "product_uom": cls.product.uom_id.id, + "price_unit": 100.00, + }, + ), + ], + } + ) + cls.purchase_order.onchange_partner_id() + cls.purchase_order_line = cls.purchase_order.order_line[0] + cls.purchase_order.button_confirm() + cls.picking = cls.purchase_order.picking_ids + + def test_stock_move_purchase_price(self): + moves = self.picking.move_ids + self.assertEqual(moves[0].purchase_price_unit, 100.0) + moves[0].write({"purchase_price_unit": 123.0}) + self.assertEqual(self.purchase_order_line.price_unit, 123.0) + + def test_stock_move_line_purchase_price(self): + move_lines = self.picking.move_line_ids + self.assertEqual(move_lines[0].purchase_price_unit, 100.0) + move_lines[0].write({"purchase_price_unit": 123.0}) + self.assertEqual(self.purchase_order_line.price_unit, 123.0) diff --git a/stock_move_purchase_price_update/views/stock_move_views.xml b/stock_move_purchase_price_update/views/stock_move_views.xml new file mode 100644 index 00000000000..ad2405f3cac --- /dev/null +++ b/stock_move_purchase_price_update/views/stock_move_views.xml @@ -0,0 +1,64 @@ + + + + + stock.picking + + + + + + + + + + + + + stock.move.line + + + + + + + + + +