Skip to content
Permalink
Browse files

WIP [ADD] mrp_product_produce: blabla wip

Blabla bla.

Task #1938656
  • Loading branch information...
svs-odoo committed Oct 9, 2019
1 parent 1d8d740 commit 51553e467824d04cdfb619a21e44bdf6fe482a72
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from . import wizard
@@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

{
'name': 'Manufacturing Expiry',
'version': '1.0',
'category': 'Manufacturing/Manufacturing',
'summary': 'Manufacturing Expiry',
'description': """
Technical module.
""",
'depends': ['product_expiry', 'mrp'],
'installable': True,
'application': False,
}
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from . import mrp_product_produce
@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo import api, fields, models, _


class ConfirmExpiry(models.TransientModel):
inherit = 'expiry.picking.confirmation'

production_id = fields.Many2one('mrp.production', readonly=True)

@api.depends('lot_ids')
def _compute_description(self):
if len(self.lot_ids) == 1:
self.description = _(
"You are going to deliver the product %s, %s which is expired."
"\nDo you confirm you want to proceed ?" % (
self.lot_ids.product_id.display_name,
self.lot_ids.name,
)
)
else:
self.description = _(
"You are going to deliver some product expired lots."
"\nDo you confirm you want to proceed ?"
)

def confirm_production(self):
return self.production_id._button_validate()
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="confirm_expiry_view_mrp_inherit" model="ir.ui.view">
<field name="name">Confirm</field>
<field name="model">expiry.picking.confirmation</field>
<field name="inherit_id" ref="product_expiry.confirm_expiry_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='description']" position="after">
<field name="picking_id" invisible="1"/>
<field name="production_id" invisible="1"/>
</xpath>
<xpath expr="//button[@name='confirm_picking']" position="attributes">
<attribute name="attrs">{'invisible': [('picking_id', '=', False)]}</attribute>
</xpath>
<xpath expr="//button[@name='confirm_picking']" position="after">
<button name="confirm_production"
string="Confirm"
type="object"
attrs="{'invisible: [('production_id', '=', False)]'}"
class="btn-primary"/>
</xpath>
</field>
</record>
</odoo>
@@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo import api, fields, models, _
from odoo.exceptions import UserError


class MrpProductProduce(models.TransientModel):
_inherit = "mrp.product.produce"

def do_produce(self):
# Checks no component is expired
res = super(MrpProductProduce, self).do_produce()
if any(move.lot_id.product_expiry_alert for move in self.move_raw_ids.move_line_ids):
raise UserError(_('Hello, I\'m a strange error message... Fear me !'))
return res

0 comments on commit 51553e4

Please sign in to comment.
You can’t perform that action at this time.