diff --git a/mrp_exception/__init__.py b/mrp_exception/__init__.py new file mode 100644 index 00000000..9b429614 --- /dev/null +++ b/mrp_exception/__init__.py @@ -0,0 +1,2 @@ +from . import models +from . import wizard diff --git a/mrp_exception/__manifest__.py b/mrp_exception/__manifest__.py new file mode 100644 index 00000000..b28447c9 --- /dev/null +++ b/mrp_exception/__manifest__.py @@ -0,0 +1,28 @@ +# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details. + +{ + 'name': 'Manufaturing Order Exception', + 'version': '15.0.1.0.0', + 'author': 'Hibou Corp.', + 'license': 'OPL-1', + 'category': 'Generic Modules', + 'summary': 'Custom exceptions on Manufacturing Orders', + 'description': """ +Custom exceptions on journal entries +""", + 'website': 'https://hibou.io/', + 'depends': [ + 'base_exception_user', + 'mrp', + ], + 'data': [ + 'security/ir.model.access.csv', + 'views/mrp_production_views.xml', + 'wizard/mrp_production_exception_confirm_views.xml', + ], + 'demo': [ + '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 new file mode 100644 index 00000000..d694d9e4 --- /dev/null +++ b/mrp_exception/demo/mrp_production_exception.xml @@ -0,0 +1,13 @@ + + + + + Finished product is not storable + Please, ensure thet the finished product is of Storable type. + 50 + mrp.production + failed = self.product_id.detailed_type != 'product' + + + + diff --git a/mrp_exception/models/__init__.py b/mrp_exception/models/__init__.py new file mode 100644 index 00000000..a9e5f13e --- /dev/null +++ b/mrp_exception/models/__init__.py @@ -0,0 +1 @@ +from . import mrp_production diff --git a/mrp_exception/models/mrp_production.py b/mrp_exception/models/mrp_production.py new file mode 100644 index 00000000..f0208268 --- /dev/null +++ b/mrp_exception/models/mrp_production.py @@ -0,0 +1,34 @@ +from odoo import api, fields, models + + +class ExceptionRule(models.Model): + _inherit = 'exception.rule' + + model = fields.Selection( + selection_add=[ + ('mrp.production', 'Production'), + ], + ondelete={ + 'mrp.production': 'cascade', + }, + ) + production_ids = fields.Many2many('mrp.production', string="Productions") + + +class MrpProduction(models.Model): + _inherit = ['mrp.production', 'base.exception'] + _name = 'mrp.production' + + @api.model + def _reverse_field(self): + return 'production_ids' + + @api.model + def _get_popup_action(self): + return self.env.ref('mrp_exception.action_mrp_production_exception_confirm') + + def action_confirm(self): + self.ensure_one() + if self.detect_exceptions(): + return self._popup_exceptions() + return super().action_confirm() diff --git a/mrp_exception/security/ir.model.access.csv b/mrp_exception/security/ir.model.access.csv new file mode 100644 index 00000000..316d86b0 --- /dev/null +++ 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 + + + + + There are exceptions blocking the confirmation of this Delivery Order: + + + + + + + + + + + + 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 + + + + + + + + + Blocked due to exceptions + ir.actions.act_window + mrp.production.exception.confirm + form + + new + + +
There are exceptions blocking the confirmation of this Delivery Order: