修改制造订单的状态字段以及与排程单的交互逻辑,优化一些翻译
This commit is contained in:
@@ -12,14 +12,30 @@ class sf_production_plan(models.Model):
|
||||
_name = 'sf.production.plan'
|
||||
_description = 'sf_production_plan'
|
||||
_inherit = ['mail.thread']
|
||||
_order = 'state desc, write_date desc'
|
||||
# _order = 'state desc, write_date desc'
|
||||
|
||||
state = fields.Selection([
|
||||
('draft', '待排程'),
|
||||
('done', '已排程'),
|
||||
('processing', '已加工'),
|
||||
('processing', '加工中'),
|
||||
('finished', '已完成')
|
||||
], string='工单状态', tracking=True)
|
||||
|
||||
state_order = fields.Integer(compute='_compute_state_order', store=True)
|
||||
|
||||
@api.depends('state')
|
||||
def _compute_state_order(self):
|
||||
order_mapping = {
|
||||
'draft': 1,
|
||||
'done': 2,
|
||||
'processing': 3,
|
||||
'finished': 4
|
||||
}
|
||||
for record in self:
|
||||
record.state_order = order_mapping.get(record.state, 0)
|
||||
|
||||
_order = 'state_order asc, write_date desc'
|
||||
|
||||
name = fields.Char(string='工单编号')
|
||||
active = fields.Boolean(string='已归档', default=True)
|
||||
# selected = fields.Boolean(default=False)
|
||||
@@ -51,6 +67,11 @@ class sf_production_plan(models.Model):
|
||||
sequence = fields.Integer(string='序号', copy=False, readonly=True, index=True)
|
||||
current_operation_name = fields.Char(string='当前工序名称', size=64, default='生产计划')
|
||||
|
||||
@api.onchange('state')
|
||||
def _onchange_state(self):
|
||||
if self.state == 'finished':
|
||||
self.production_id.schedule_state = '已完成'
|
||||
|
||||
# @api.model
|
||||
# def _search(self, args, offset=0, limit=None, order=None, count=False, access_rights_uid=None):
|
||||
# """
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<!-- <button name="do_production_schedule" type="object" string="批量排程"/> -->
|
||||
<button string="批量排程" name="%(sf_plan.action_plan_some)d" type="action" class="btn-primary"/>
|
||||
</header>
|
||||
<field name="state" widget="badge" decoration-warning="state == 'draft'" decoration-success="state == 'done'"/>
|
||||
<field name="state" widget="badge" decoration-warning="state == 'draft'" decoration-success="state == 'done'" decoration-info="state == 'processing'" decoration-danger="state == 'finished'"/>
|
||||
<field name="name"/>
|
||||
<field name="origin"/>
|
||||
<field name="order_deadline"/>
|
||||
|
||||
@@ -34,7 +34,7 @@ class Action_Plan_All_Wizard(models.TransientModel):
|
||||
plan_obj = self.env['sf.production.plan'].browse(plan.id)
|
||||
plan_obj.production_line_id = self.production_line_id.id
|
||||
plan_obj.do_production_schedule()
|
||||
plan_obj.state = 'done'
|
||||
# plan_obj.state = 'done'
|
||||
print('处理计划:', plan.id, '完成')
|
||||
|
||||
# # 获取当前生产线
|
||||
|
||||
Reference in New Issue
Block a user