From 3bfc3f5ce4dd120dd1b56b4f8eb659be3452063d Mon Sep 17 00:00:00 2001 From: Jorge Che Date: Thu, 20 Oct 2022 17:34:16 +0000 Subject: [PATCH] [IMP] mrp_exception: finalized the changes --- mrp_exception/__init__.py | 1 + mrp_exception/__manifest__.py | 9 ++- .../demo/mrp_production_exception.xml | 9 +-- mrp_exception/models/mrp_production.py | 2 +- mrp_exception/security/ir.model.access.csv | 2 + mrp_exception/views/mrp_production_views.xml | 65 +++++++++++++++++++ mrp_exception/wizard/__init__.py | 1 + .../mrp_production_exception_confirm.py | 26 ++++++++ ...mrp_production_exception_confirm_views.xml | 25 +++++++ 9 files changed, 130 insertions(+), 10 deletions(-) create mode 100644 mrp_exception/views/mrp_production_views.xml create mode 100644 mrp_exception/wizard/__init__.py create mode 100644 mrp_exception/wizard/mrp_production_exception_confirm.py create mode 100644 mrp_exception/wizard/mrp_production_exception_confirm_views.xml diff --git a/mrp_exception/__init__.py b/mrp_exception/__init__.py index 0650744f..9b429614 100644 --- a/mrp_exception/__init__.py +++ b/mrp_exception/__init__.py @@ -1 +1,2 @@ from . import models +from . import wizard diff --git a/mrp_exception/__manifest__.py b/mrp_exception/__manifest__.py index 090c58ef..b28447c9 100644 --- a/mrp_exception/__manifest__.py +++ b/mrp_exception/__manifest__.py @@ -16,13 +16,12 @@ Custom exceptions on journal entries 'mrp', ], 'data': [ - # 'demo/mrp_production_exception.xml', - # 'security/ir.model.access.csv', - # 'views/account_move_views.xml', - # 'wizard/account_move_exception_confirm_views.xml', + 'security/ir.model.access.csv', + 'views/mrp_production_views.xml', + 'wizard/mrp_production_exception_confirm_views.xml', ], 'demo': [ - 'demo/account_exception_demo.xml', + 'demo/mrp_production_exception.xml', ], 'installable': True, 'auto_install': False, diff --git a/mrp_exception/demo/mrp_production_exception.xml b/mrp_exception/demo/mrp_production_exception.xml index 6ad6b426..4b2a9cb9 100644 --- a/mrp_exception/demo/mrp_production_exception.xml +++ b/mrp_exception/demo/mrp_production_exception.xml @@ -1,12 +1,13 @@ - - Wrong Label Type - Please, ensure thet the correct Label Type is confirmed. + + Finished product is not storable + Please, ensure thet the finished product is of Storable type. 50 mrp.production - if production.label_type == 'ORG' and any(production.po_lot_id.order_line.mapped(lambda l: l.organic_status == 'NON-ORG')): failed=True + failed = self.product_id.detailed_type != 'storable' + diff --git a/mrp_exception/models/mrp_production.py b/mrp_exception/models/mrp_production.py index 3857fcc9..f0208268 100644 --- a/mrp_exception/models/mrp_production.py +++ b/mrp_exception/models/mrp_production.py @@ -25,7 +25,7 @@ class MrpProduction(models.Model): @api.model def _get_popup_action(self): - return self.env.ref('omf_mrp.action_mrp_production_exception_confirm') + return self.env.ref('mrp_exception.action_mrp_production_exception_confirm') def action_confirm(self): self.ensure_one() diff --git a/mrp_exception/security/ir.model.access.csv b/mrp_exception/security/ir.model.access.csv index e69de29b..316d86b0 100644 --- a/mrp_exception/security/ir.model.access.csv +++ b/mrp_exception/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +mrp_exception.access_mrp_production_exception_confirm,access_mrp_production_exception_confirm,mrp_exception.model_mrp_production_exception_confirm,base.group_user,1,1,1,1 diff --git a/mrp_exception/views/mrp_production_views.xml b/mrp_exception/views/mrp_production_views.xml new file mode 100644 index 00000000..4e71a258 --- /dev/null +++ b/mrp_exception/views/mrp_production_views.xml @@ -0,0 +1,65 @@ + + + + + Manufacturing Order Exceptions + exception.rule + tree,form + + [('model', '=', 'mrp.production')] + {'active_test': False, 'default_model' : 'mrp.production'} + + + + + + mrp.production.form.inherit.exception + mrp.production + + + + + + + + + + + + + stock.picking.tree.inherit.exception + stock.picking + + + + + + + + + + stock.picking.internal.search.inherit.exception + stock.picking + + + + + + + + + + diff --git a/mrp_exception/wizard/__init__.py b/mrp_exception/wizard/__init__.py new file mode 100644 index 00000000..760a96b8 --- /dev/null +++ b/mrp_exception/wizard/__init__.py @@ -0,0 +1 @@ +from . import mrp_production_exception_confirm diff --git a/mrp_exception/wizard/mrp_production_exception_confirm.py b/mrp_exception/wizard/mrp_production_exception_confirm.py new file mode 100644 index 00000000..8f65dfa7 --- /dev/null +++ b/mrp_exception/wizard/mrp_production_exception_confirm.py @@ -0,0 +1,26 @@ +# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details. + +from odoo import api, fields, models + + +class MrpProductionExceptionConfirm(models.TransientModel): + _name = 'mrp.production.exception.confirm' + _inherit = ['exception.rule.confirm'] + _description = 'Manufacturing Order Confirm Wizard' + + related_model_id = fields.Many2one('mrp.production', 'Manufacturing Order') + + def action_confirm(self): + self.ensure_one() + if self.ignore: + self.related_model_id.ignore_exception = True + res = super().action_confirm() + if self.ignore: + return self.related_model_id.button_validate() + else: + return res + + def _action_ignore(self): + self.related_model_id.ignore_exception = True + super()._action_ignore() + return self.related_model_id.button_validate() diff --git a/mrp_exception/wizard/mrp_production_exception_confirm_views.xml b/mrp_exception/wizard/mrp_production_exception_confirm_views.xml new file mode 100644 index 00000000..ba7a0ff3 --- /dev/null +++ b/mrp_exception/wizard/mrp_production_exception_confirm_views.xml @@ -0,0 +1,25 @@ + + + + + Manufacturing Order Exceptions + mrp.production.exception.confirm + + primary + + +