diff --git a/mrp_exception/__init__.py b/mrp_exception/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/mrp_exception/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/mrp_exception/__manifest__.py b/mrp_exception/__manifest__.py new file mode 100644 index 00000000..090c58ef --- /dev/null +++ b/mrp_exception/__manifest__.py @@ -0,0 +1,29 @@ +# 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': [ + # 'demo/mrp_production_exception.xml', + # 'security/ir.model.access.csv', + # 'views/account_move_views.xml', + # 'wizard/account_move_exception_confirm_views.xml', + ], + 'demo': [ + 'demo/account_exception_demo.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..6ad6b426 --- /dev/null +++ b/mrp_exception/demo/mrp_production_exception.xml @@ -0,0 +1,12 @@ + + + + + Wrong Label Type + Please, ensure thet the correct Label Type is confirmed. + 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 + + + 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..3857fcc9 --- /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('omf_mrp.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..e69de29b