29 lines
1.1 KiB
Python
29 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):
|
|
return {
|
|
'res_model': 'quality.check',
|
|
'type': 'ir.actions.act_window',
|
|
'name': '质量检查',
|
|
'domain': [('workorder_id', '=', self.id)],
|
|
'view_mode': 'tree,form',
|
|
}
|