From e6cf13ad80a2278b9dd7b7276db64442aea7fabc Mon Sep 17 00:00:00 2001 From: Oihane Crucelaegui Date: Thu, 18 Jul 2019 14:12:55 +0200 Subject: [PATCH 1/3] [FIX] mrp_operations_extension: update qty erases operations --- mrp_operations_extension/wizard/__init__.py | 1 + .../wizard/change_production_qty.py | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 mrp_operations_extension/wizard/change_production_qty.py diff --git a/mrp_operations_extension/wizard/__init__.py b/mrp_operations_extension/wizard/__init__.py index b04550b49..b67aea37b 100644 --- a/mrp_operations_extension/wizard/__init__.py +++ b/mrp_operations_extension/wizard/__init__.py @@ -2,5 +2,6 @@ ############################################################################## # For copyright and license notices, see __openerp__.py file in root directory ############################################################################## +from . import change_production_qty from . import mrp_work_order_produce from . import workcenter_line_finish diff --git a/mrp_operations_extension/wizard/change_production_qty.py b/mrp_operations_extension/wizard/change_production_qty.py new file mode 100644 index 000000000..4f2242322 --- /dev/null +++ b/mrp_operations_extension/wizard/change_production_qty.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +# Copyright 2019 Oihane Crucelaegui - AvanzOSC +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from openerp import _, api, models + + +class ChangeProductionQty(models.TransientModel): + _inherit = 'change.production.qty' + + @api.multi + def change_prod_qty(self): + """ + Changes the Quantity of Product. + """ + record_id = self.env.context.get('active_id', False) + assert record_id, _('Active Id not found') + prod_obj = self.env['mrp.production'] + bom_line_obj = self.env['mrp.bom.line'] + uom_obj = self.env['product.uom'] + res = super(ChangeProductionQty, self).change_prod_qty() + for wiz_qty in self: + prod = prod_obj.browse(record_id) + for move in prod.move_lines: + bom_point = prod.bom_id + factor = uom_obj._compute_qty(prod.product_uom.id, + prod.product_qty, + bom_point.product_uom.id) + product_details, workcenter_details = ( + bom_point._bom_explode(prod.product_id, + factor / bom_point.product_qty, [])) + for r in product_details: + bom_line = bom_line_obj.browse(r['bom_line']) + workorder = prod.workcenter_lines.filtered( + lambda x: (x.routing_wc_line == bom_line.operation)) + if workorder: + move.work_order = workorder + return res From d13c7e8cd7a1425eb118f747625d81d1cd971955 Mon Sep 17 00:00:00 2001 From: oca-travis Date: Wed, 24 Jul 2019 14:43:37 +0000 Subject: [PATCH 2/3] [UPD] Update mrp_operations_extension.pot --- .../i18n/mrp_operations_extension.pot | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mrp_operations_extension/i18n/mrp_operations_extension.pot b/mrp_operations_extension/i18n/mrp_operations_extension.pot index 53ceb630b..a48f723e6 100644 --- a/mrp_operations_extension/i18n/mrp_operations_extension.pot +++ b/mrp_operations_extension/i18n/mrp_operations_extension.pot @@ -24,6 +24,12 @@ msgstr "" msgid "# operators" msgstr "" +#. module: mrp_operations_extension +#: code:addons/mrp_operations_extension/wizard/change_production_qty.py:17 +#, python-format +msgid "Active Id not found" +msgstr "" + #. module: mrp_operations_extension #: view:mrp.production:mrp_operations_extension.mrp_production_form_view_inh #: view:mrp.production.workcenter.line:mrp_operations_extension.workcenter_line_inh_form_view @@ -73,6 +79,11 @@ msgstr "" msgid "Capacity per cycle" msgstr "" +#. module: mrp_operations_extension +#: model:ir.model,name:mrp_operations_extension.model_change_production_qty +msgid "Change Quantity of Products" +msgstr "" + #. module: mrp_operations_extension #: code:addons/mrp_operations_extension/models/mrp_bom.py:55 #, python-format From d753873e195c13fe35a4c2cd79fa5a75ffad2614 Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Wed, 24 Jul 2019 15:57:45 +0000 Subject: [PATCH 3/3] mrp_operations_extension 8.0.2.0.1 --- mrp_operations_extension/__openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mrp_operations_extension/__openerp__.py b/mrp_operations_extension/__openerp__.py index 98cef199d..1368598eb 100644 --- a/mrp_operations_extension/__openerp__.py +++ b/mrp_operations_extension/__openerp__.py @@ -6,7 +6,7 @@ { "name": "Manufacturing Operations Extension", - "version": "8.0.2.0.0", + "version": "8.0.2.0.1", "category": "Manufacturing", "license": "AGPL-3", "author": "OdooMRP team, "