Debian Codegraph @

addons/mrp_product_expiry/wizard/confirm_expiry.py

raw symbols SCIP
1 # -*- coding: utf-8 -*-
2 # Part of Odoo. See LICENSE file for full copyright and licensing details.
3
4 from odoo import api, fields, models, _
5
6
7 class ExpiryPickingConfirmation(models.TransientModel):
8 _inherit = 'expiry.picking.confirmation'
9
10 production_ids = fields.Many2many('mrp.production', readonly=True)
11 workorder_id = fields.Many2one('mrp.workorder', readonly=True)
12
13 @api.depends('lot_ids')
14 def _compute_descriptive_fields(self):
15 if self.production_ids or self.workorder_id:
16 # Shows expired lots only if we are more than one expired lot.
17 self.show_lots = len(self.lot_ids) > 1
18 if self.show_lots:
19 # For multiple expired lots, they are listed in the wizard view.
20 self.description = _(
21 "You are going to use some expired components."
22 "\nDo you confirm you want to proceed?"
23 )
24 else:
25 # For one expired lot, its name is written in the wizard message.
26 self.description = _(
27 "You are going to use the component %(product_name)s, %(lot_name)s which is expired."
28 "\nDo you confirm you want to proceed?",
29 product_name=self.lot_ids.product_id.display_name,
30 lot_name=self.lot_ids.name,
31 )
32 else:
33 super()._compute_descriptive_fields()
34
35 def confirm_produce(self):
36 ctx = dict(self.env.context, skip_expired=True)
37 ctx.pop('default_lot_ids')
38 return self.production_ids.with_context(ctx).button_mark_done()
39
40 def confirm_workorder(self):
41 ctx = dict(self.env.context, skip_expired=True)
42 ctx.pop('default_lot_ids')
43 return self.workorder_id.with_context(ctx).record_production()