Debian Codegraph @

addons/mrp_repair/models/production.py

raw symbols SCIP
1 # Part of Odoo. See LICENSE file for full copyright and licensing details.
2
3 from odoo import api, fields, models, _
4
5
6 class MrpProduction(models.Model):
7 _inherit = 'mrp.production'
8
9 repair_count = fields.Integer(
10 string='Count of source repairs',
11 compute='_compute_repair_count',
12 groups='stock.group_stock_user',
13 )
14
15 @api.depends('move_dest_ids.repair_id')
16 def _compute_repair_count(self):
17 for production in self:
18 production.repair_count = len(production.move_dest_ids.repair_id)
19
20 def action_view_repair_orders(self):
21 self.ensure_one()
22 repair_ids = self.move_dest_ids.repair_id
23 action = {
24 'type': 'ir.actions.act_window',
25 'res_model': 'repair.order',
26 'views': [[False, 'form']],
27 }
28 if self.repair_count == 1:
29 action['res_id'] = repair_ids.id
30 elif self.repair_count > 1:
31 action['name'] = _("Repair Source of %s", self.name)
32 action['views'] = [[False, 'list']]
33 action['domain'] = [('id', 'in', repair_ids.ids)]
34 return action