优化产量部分

This commit is contained in:
mgw
2024-09-11 08:51:01 +08:00
parent 44a2604dbd
commit f6a9c97e7f
2 changed files with 40 additions and 14 deletions

View File

@@ -18,7 +18,8 @@ class sf_production_plan(models.Model):
('draft', '待排程'),
('done', '已排程'),
('processing', '加工中'),
('finished', '已完成')
('finished', '已完成'),
('cancel', '已取消')
], string='状态', tracking=True)
state_order = fields.Integer(compute='_compute_state_order', store=True)
@@ -37,7 +38,7 @@ class sf_production_plan(models.Model):
_order = 'state_order asc, write_date desc'
name = fields.Char(string='制造订单')
# active = fields.Boolean(string='已归档', default=True)
active = fields.Boolean(string='已归档', default=True)
# selected = fields.Boolean(default=False)
# order_number = fields.Char(string='订单号')
order_deadline = fields.Datetime(string='订单交期')
@@ -385,3 +386,23 @@ class machine_work_schedule(models.Model):
_description = '机台作业计划'
name = fields.Char(string='机台名')
class MrpProductionInheritForPlan(models.Model):
_inherit = 'mrp.production'
def button_cancel(self):
# 调用父类的取消操作
res = super(MrpProductionInheritForPlan, self).button_cancel()
# 更新 sf.production.plan 模型的 state 为 'cancel'
self.env['sf.production.plan'].search([('production_id', '=', self.id)]).write({'state': 'cancel'})
return res
def toggle_active(self):
# 调用父类方法切换 active 状态
res = super(MrpProductionInheritForPlan, self).toggle_active()
self.env['sf.production.plan'].search(
[('production_id', '=', self.id), '|', ('active', '=', False), ('active', '=', True)]).write(
{'active': self.active})
return res