待下达生产状态修改
This commit is contained in:
@@ -25,8 +25,8 @@ class sf_production_plan(models.Model):
|
||||
('10', '草稿'),
|
||||
('20', '待确认'),
|
||||
('30', '需求确认'),
|
||||
('40', '待下达生产'),
|
||||
('50', '已下达'),
|
||||
('50', '待下达生产'),
|
||||
('60', '已下达'),
|
||||
('100', '取消'),
|
||||
], string='状态', compute='_compute_status', store=True)
|
||||
sale_order_id = fields.Many2one(comodel_name="sale.order",
|
||||
@@ -100,7 +100,8 @@ class sf_production_plan(models.Model):
|
||||
|
||||
sequence = fields.Integer('序号')
|
||||
|
||||
@api.depends('sale_order_id.state', 'sale_order_id.mrp_production_ids.schedule_state', 'sale_order_id.order_line')
|
||||
@api.depends('sale_order_id.state', 'sale_order_id.mrp_production_ids.schedule_state', 'sale_order_id.order_line',
|
||||
'sale_order_id.mrp_production_ids.state')
|
||||
def _compute_status(self):
|
||||
for record in self:
|
||||
if record.sale_order_id:
|
||||
@@ -110,16 +111,23 @@ class sf_production_plan(models.Model):
|
||||
if record.supply_method in ('purchase', 'outsourcing') and sale_order_state in (
|
||||
'sale', 'processing', 'physical_distribution', 'delivered',
|
||||
'done') and sale_order_state != 'cancel':
|
||||
record.status = '50' # 已下达
|
||||
record.status = '60' # 已下达
|
||||
if record.supply_method in ('automation', 'manual'):
|
||||
if sale_order_state in (
|
||||
'sale', 'processing', 'physical_distribution', 'delivered',
|
||||
'done') and sale_order_state != 'cancel':
|
||||
record.status = '30' # 需求确认
|
||||
# 检查所有制造订单的排程单状态,有一个为待排程状态,就为待下达生产
|
||||
pending_productions = record.sale_order_id.mrp_production_ids.filtered(
|
||||
lambda p: p.state == 'confirmed' and p.product_id.id == record.product_id.id
|
||||
)
|
||||
if pending_productions:
|
||||
record.status = '50' # 待下达生产
|
||||
# 检查所有制造订单的排程单状态
|
||||
if all(order.product_id == record.product_id and order.schedule_state != '未排' for order in
|
||||
record.sale_order_id.mrp_production_ids):
|
||||
record.status = '50' # 已下达
|
||||
if record.sale_order_id.mrp_production_ids and all(
|
||||
order.product_id == record.product_id and order.schedule_state != '未排' for order in
|
||||
record.sale_order_id.mrp_production_ids):
|
||||
record.status = '60' # 已下达
|
||||
if sale_order_state == 'cancel' or not record.sale_order_line_id:
|
||||
record.status = '100' # 取消
|
||||
|
||||
@@ -313,3 +321,11 @@ class sf_production_plan(models.Model):
|
||||
'views': [[self.env.ref('sf_demand_plan.action_plan_print_tree').id, 'list']],
|
||||
'target': 'new',
|
||||
}
|
||||
|
||||
def action_open_sale_order(self):
|
||||
return {
|
||||
'type': 'ir.actions.act_window',
|
||||
'res_model': 'sale.order',
|
||||
'res_id': self.sale_order_id.id,
|
||||
'view_mode': 'form',
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user