待下达生产状态修改

This commit is contained in:
guanhuan
2025-05-29 17:05:19 +08:00
parent 007f39f137
commit 1bdb81f5f7
2 changed files with 27 additions and 9 deletions

View File

@@ -25,8 +25,8 @@ class sf_production_plan(models.Model):
('10', '草稿'), ('10', '草稿'),
('20', '待确认'), ('20', '待确认'),
('30', '需求确认'), ('30', '需求确认'),
('40', '待下达生产'), ('50', '待下达生产'),
('50', '已下达'), ('60', '已下达'),
('100', '取消'), ('100', '取消'),
], string='状态', compute='_compute_status', store=True) ], string='状态', compute='_compute_status', store=True)
sale_order_id = fields.Many2one(comodel_name="sale.order", sale_order_id = fields.Many2one(comodel_name="sale.order",
@@ -100,7 +100,8 @@ class sf_production_plan(models.Model):
sequence = fields.Integer('序号') 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): def _compute_status(self):
for record in self: for record in self:
if record.sale_order_id: 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 ( if record.supply_method in ('purchase', 'outsourcing') and sale_order_state in (
'sale', 'processing', 'physical_distribution', 'delivered', 'sale', 'processing', 'physical_distribution', 'delivered',
'done') and sale_order_state != 'cancel': 'done') and sale_order_state != 'cancel':
record.status = '50' # 已下达 record.status = '60' # 已下达
if record.supply_method in ('automation', 'manual'): if record.supply_method in ('automation', 'manual'):
if sale_order_state in ( if sale_order_state in (
'sale', 'processing', 'physical_distribution', 'delivered', 'sale', 'processing', 'physical_distribution', 'delivered',
'done') and sale_order_state != 'cancel': 'done') and sale_order_state != 'cancel':
record.status = '30' # 需求确认 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 if record.sale_order_id.mrp_production_ids and all(
record.sale_order_id.mrp_production_ids): order.product_id == record.product_id and order.schedule_state != '未排' for order in
record.status = '50' # 已下达 record.sale_order_id.mrp_production_ids):
record.status = '60' # 已下达
if sale_order_state == 'cancel' or not record.sale_order_line_id: if sale_order_state == 'cancel' or not record.sale_order_line_id:
record.status = '100' # 取消 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']], 'views': [[self.env.ref('sf_demand_plan.action_plan_print_tree').id, 'list']],
'target': 'new', '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',
}

View File

@@ -37,8 +37,10 @@
<field name="route_id" optional="hide"/> <field name="route_id" optional="hide"/>
<field name="date_order"/> <field name="date_order"/>
<field name="plan_remark"/> <field name="plan_remark"/>
<field name="material_check"/>
<field name="processing_time"/> <field name="processing_time"/>
<field name="material_check"/>
<button name="action_open_sale_order" type="object" string="供货方式待确认" class="btn-primary"
attrs="{'invisible': [('supply_method', '!=', False)]}"/>
<field name="planned_start_date"/> <field name="planned_start_date"/>
<field name="actual_start_date"/> <field name="actual_start_date"/>
<field name="actual_end_date"/> <field name="actual_end_date"/>
@@ -48,7 +50,7 @@
<field name="write_uid" optional="hide" string="更新人"/> <field name="write_uid" optional="hide" string="更新人"/>
<field name="print_count"/> <field name="print_count"/>
<button name="release_production_order" type="object" string="下达生产" class="btn-primary" <button name="release_production_order" type="object" string="下达生产" class="btn-primary"
attrs="{'invisible': ['|',('status', '!=', '30'), ('supply_method', 'not in', ['automation', 'manual'])]}"/> attrs="{'invisible': ['|',('status', '!=', '50'), ('supply_method', 'not in', ['automation', 'manual'])]}"/>
</tree> </tree>
</field> </field>
</record> </record>