From cf19ea93c0a5ebb687bdbe9efde15a29107ad511 Mon Sep 17 00:00:00 2001 From: alfredoavanzosc Date: Thu, 13 Oct 2016 15:07:29 +0200 Subject: [PATCH] [IMP] mrp_operations_rejected_quantity: Show warning if producto to produce is greather than planified quantity. --- mrp_operations_rejected_quantity/i18n/es.po | 12 ++++++++++++ .../wizard/mrp_work_order_produce.py | 11 ++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/mrp_operations_rejected_quantity/i18n/es.po b/mrp_operations_rejected_quantity/i18n/es.po index 144b56fc..17a7933b 100644 --- a/mrp_operations_rejected_quantity/i18n/es.po +++ b/mrp_operations_rejected_quantity/i18n/es.po @@ -230,6 +230,18 @@ msgstr "o" msgid "pause" msgstr "pausa" +#. module: mrp_operations_rejected_quantity +#: code:addons/mrp_operations_rejected_quantity/wizard/mrp_work_order_produce.py:88 +#, python-format +msgid "Product to produce" +msgstr "Producto a producir" + +#. module: mrp_operations_rejected_quantity +#: code:addons/mrp_operations_rejected_quantity/wizard/mrp_work_order_produce.py:89 +#, python-format +msgid "Quantity to produce greater than planned" +msgstr "Cantidad a producir mayor que la cantidad a producir planificada en OF" + #. module: mrp_operations_rejected_quantity #: view:mrp.work.order.produce:mrp_operations_rejected_quantity.view_mrp_product_consume_wizard_inh_rejectedquantity #: view:mrp.work.order.produce:mrp_operations_rejected_quantity.view_mrp_product_produce_wizard_inh_rejectedquantity diff --git a/mrp_operations_rejected_quantity/wizard/mrp_work_order_produce.py b/mrp_operations_rejected_quantity/wizard/mrp_work_order_produce.py index 6ba63021..4084cbf5 100644 --- a/mrp_operations_rejected_quantity/wizard/mrp_work_order_produce.py +++ b/mrp_operations_rejected_quantity/wizard/mrp_work_order_produce.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # (c) 2016 Alfredo de la Fuente - AvanzOSC # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html -from openerp import models, fields, api +from openerp import models, fields, api, _ class MrpWorkOrderProduce(models.TransientModel): @@ -62,12 +62,12 @@ def on_change_qty(self, product_qty, consume_lines): operation_obj = self.env['mrp.production.workcenter.line'] planned_product_obj = self.env['mrp.production.product.line'] operation = operation_obj.browse(self.env.context.get('active_id')) - accepted_amount = sum( + processed_accepted_amount = sum( x.accepted_amount for x in operation.operation_time_lines.filtered( lambda r: r.state == 'processed')) res = super(MrpWorkOrderProduce, self).on_change_qty( - operation.production_id.product_qty - accepted_amount, + operation.production_id.product_qty - processed_accepted_amount, consume_lines) accepted_amount = sum( x.accepted_amount for x in @@ -77,6 +77,11 @@ def on_change_qty(self, product_qty, consume_lines): x.rejected_amount for x in operation.operation_time_lines.filtered( lambda r: r.state == 'pending')) + if (product_qty + processed_accepted_amount > + operation.production_id.product_qty): + res['warning'] = { + 'title': _('Product to produce'), + 'message': _('Quantity to produce greater than planned')} for line in res['value']['consume_lines']: cond = [('work_order', '=', operation.id), ('product_id', '=', line[2].get('product_id'))]