diff --git a/sf_demand_plan/models/sf_production_demand_plan.py b/sf_demand_plan/models/sf_production_demand_plan.py
index 0b83b685..df1e2990 100644
--- a/sf_demand_plan/models/sf_production_demand_plan.py
+++ b/sf_demand_plan/models/sf_production_demand_plan.py
@@ -14,7 +14,6 @@ class SfProductionDemandPlan(models.Model):
def _get_machining_precision(self):
machinings = self.env['sf.machining.accuracy'].sudo().search([])
-
list = [(m.sync_id, m.name) for m in machinings]
return list
@@ -35,7 +34,8 @@ class SfProductionDemandPlan(models.Model):
sale_order_id = fields.Many2one(comodel_name="sale.order",
string="销售订单", readonly=True)
sale_order_line_id = fields.Many2one(comodel_name="sale.order.line",
- string="销售订单行", readonly=True)
+ string="销售订单明细", readonly=True)
+ sale_order_line_number = fields.Char(string='销售订单行', compute='_compute_sale_order_line_number', store=True)
company_id = fields.Many2one(
related='sale_order_id.company_id',
store=True, index=True, precompute=True)
@@ -91,7 +91,7 @@ class SfProductionDemandPlan(models.Model):
route_id = fields.Many2one('stock.route', string='路线', related='sale_order_line_id.route_id', store=True)
contract_date = fields.Date('合同日期', related='sale_order_id.contract_date')
date_order = fields.Datetime('下单日期', related='sale_order_id.date_order')
- contract_code = fields.Char('合同号', related='sale_order_id.contract_code')
+ contract_code = fields.Char('合同号', related='sale_order_id.contract_code', store=True)
plan_remark = fields.Text("计划备注")
material_check = fields.Selection([
('0', "未齐套"),
@@ -160,13 +160,23 @@ class SfProductionDemandPlan(models.Model):
if pending_productions:
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 record.sale_order_id.mrp_production_ids:
+ product_productions = record.sale_order_id.mrp_production_ids.filtered(
+ lambda p: p.product_id.id == record.product_id.id
+ )
+ if product_productions and all(order.schedule_state != '未排' for order in product_productions):
+ record.status = '60' # 已下达
if sale_order_state == 'cancel' or not record.sale_order_line_id:
record.status = '100' # 取消
+ @api.depends('sale_order_line_id.product_id.name')
+ def _compute_sale_order_line_number(self):
+ for line in self:
+ if line.product_id:
+ line.sale_order_line_number = line.sale_order_line_id.product_id.name[-1]
+ else:
+ line.sale_order_line_number = None
+
@api.depends('product_id.part_number', 'product_id.model_name')
def _compute_part_number(self):
for line in self:
@@ -191,7 +201,7 @@ class SfProductionDemandPlan(models.Model):
def _compute_materials_id(self):
for line in self:
if line.product_id:
- line.materials_id = f"{line.product_id.materials_id.name}*{line.product_id.materials_type_id.name}"
+ line.materials_id = f"{line.product_id.materials_id.name}/{line.product_id.materials_type_id.name}"
else:
line.materials_id = None
@@ -450,7 +460,9 @@ class SfProductionDemandPlan(models.Model):
record.hide_action_stock_picking = False
record.hide_action_outsourcing_stock_picking = False
if record.supply_method in ('automation', 'manual'):
- manufacturing_orders = record.sale_order_id.mrp_production_ids
+ manufacturing_orders = record.sale_order_id.mrp_production_ids.filtered(
+ lambda p: p.product_id.id == record.product_id.id
+ )
record.hide_action_stock_picking = bool(manufacturing_orders.mapped('picking_ids').filtered(
lambda p: p.state == 'assigned'))
elif record.supply_method in ('purchase', 'outsourcing'):
diff --git a/sf_demand_plan/views/demand_plan.xml b/sf_demand_plan/views/demand_plan.xml
index e68a46f6..f78e5cf6 100644
--- a/sf_demand_plan/views/demand_plan.xml
+++ b/sf_demand_plan/views/demand_plan.xml
@@ -3,7 +3,7 @@
sf.production.demand.plan.tree
sf.production.demand.plan
-
-
+
@@ -42,7 +42,7 @@
-
+
@@ -85,6 +85,7 @@
+
@@ -97,6 +98,8 @@
context="{'group_by': 'deadline_of_delivery'}"/>
+