26 lines
1.1 KiB
Python
26 lines
1.1 KiB
Python
from odoo import api, fields, models
|
|
|
|
|
|
class ResMrpWorkOrder(models.Model):
|
|
_inherit = 'mrp.workorder'
|
|
|
|
check_ids_state = fields.Selection([('none', '待处理'), ('pass', '通过的'), ('fail', '失败的')], store=True,
|
|
compute='_compute_check_ids_state')
|
|
|
|
@api.depends('check_ids.quality_state')
|
|
def _compute_check_ids_state(self):
|
|
for mw in self:
|
|
if mw.check_ids:
|
|
if all(check_id.quality_state == 'pass' for check_id in mw.check_ids):
|
|
mw.check_ids_state = 'pass'
|
|
elif any(check_id.quality_state == 'fail' for check_id in mw.check_ids):
|
|
mw.check_ids_state = 'fail'
|
|
else:
|
|
mw.check_ids_state = 'none'
|
|
|
|
def action_open_quality_check_work_sf(self):
|
|
action = self.env["ir.actions.actions"]._for_xml_id("quality_control.quality_check_action_picking")
|
|
action['context'] = self.env.context.copy()
|
|
action['domain'] = [('workorder_id', '=', self.id)]
|
|
return action
|