[ADD] mrp_exception: initial work

H11147
This commit is contained in:
Jorge Che
2022-10-18 23:59:57 +00:00
parent 3fc96fc203
commit 6e20862af2
6 changed files with 77 additions and 0 deletions

View File

@@ -0,0 +1 @@
from . import models

View File

@@ -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,
}

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="excep_wrong_label_type" model="exception.rule">
<field name="name">Wrong Label Type</field>
<field name="description">Please, ensure thet the correct Label Type is confirmed.</field>
<field name="sequence">50</field>
<field name="model">mrp.production</field>
<field name="code">if production.label_type == 'ORG' and any(production.po_lot_id.order_line.mapped(lambda l: l.organic_status == 'NON-ORG')): failed=True</field>
</record>
</odoo>

View File

@@ -0,0 +1 @@
from . import mrp_production

View File

@@ -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()