From 5388306bb969cdcefb9468e76c65ab4edf6cd8cd Mon Sep 17 00:00:00 2001 From: Aungkokolin1997 Date: Fri, 9 Feb 2024 11:52:43 +0630 Subject: [PATCH] [ADD] purchase_stock_price_unit_sync --- purchase_stock_price_unit_sync/__init__.py | 1 + purchase_stock_price_unit_sync/__manifest__.py | 12 ++++++++++++ .../models/__init__.py | 1 + .../models/purchase_order.py | 17 +++++++++++++++++ .../readme/DESCRIPTION.rst | 3 +++ 5 files changed, 34 insertions(+) create mode 100644 purchase_stock_price_unit_sync/__init__.py create mode 100644 purchase_stock_price_unit_sync/__manifest__.py create mode 100644 purchase_stock_price_unit_sync/models/__init__.py create mode 100644 purchase_stock_price_unit_sync/models/purchase_order.py create mode 100644 purchase_stock_price_unit_sync/readme/DESCRIPTION.rst diff --git a/purchase_stock_price_unit_sync/__init__.py b/purchase_stock_price_unit_sync/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/purchase_stock_price_unit_sync/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/purchase_stock_price_unit_sync/__manifest__.py b/purchase_stock_price_unit_sync/__manifest__.py new file mode 100644 index 00000000..db229472 --- /dev/null +++ b/purchase_stock_price_unit_sync/__manifest__.py @@ -0,0 +1,12 @@ +# Copyright 2024 Quartile Limited +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + 'name': 'Showing actual received quantity of Purchase Order', + 'version': '10.0.1.0.0', + 'author': 'Quartile Limited', + 'website': 'https://www.quartile.co', + 'category': 'Purchase', + 'license': "AGPL-3", + 'depends': ['purchase_stock'], + 'installable': True, +} diff --git a/purchase_stock_price_unit_sync/models/__init__.py b/purchase_stock_price_unit_sync/models/__init__.py new file mode 100644 index 00000000..9f035306 --- /dev/null +++ b/purchase_stock_price_unit_sync/models/__init__.py @@ -0,0 +1 @@ +from . import purchase_order diff --git a/purchase_stock_price_unit_sync/models/purchase_order.py b/purchase_stock_price_unit_sync/models/purchase_order.py new file mode 100644 index 00000000..a73e7818 --- /dev/null +++ b/purchase_stock_price_unit_sync/models/purchase_order.py @@ -0,0 +1,17 @@ +# Copyright 2024 Quartile Limited +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api,models + + +class PurchaseOrderLine(models.Model): + _inhert = "purchase.order.line" + + @api.multi + def write(self, values): + res = super(PurchaseOrderLine, self).write(values) + lines = self.filtered(lambda l: l.order_id.state == 'purchase') + if 'price_unit' in values: + for line in lines: + moves = line.move_ids.filtered(lambda s: s.state not in ('cancel', 'done') and s.product_id == line.product_id) + moves.write({'price_unit': line._get_stock_move_price_unit()}) diff --git a/purchase_stock_price_unit_sync/readme/DESCRIPTION.rst b/purchase_stock_price_unit_sync/readme/DESCRIPTION.rst new file mode 100644 index 00000000..91fce2db --- /dev/null +++ b/purchase_stock_price_unit_sync/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +This module updates the price_unit field of the stock move to match the price_unit +of the purchase order line when the price_unit is modified after the purchase order +has been confirmed.