需求计划下达计划
This commit is contained in:
@@ -230,33 +230,26 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
else:
|
else:
|
||||||
line.model_long = None
|
line.model_long = None
|
||||||
|
|
||||||
@api.depends('sale_order_id.mrp_production_ids.workorder_ids.date_start')
|
@api.depends('mrp_production_ids.workorder_ids.date_start')
|
||||||
def _compute_actual_start_date(self):
|
def _compute_actual_start_date(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
if record.sale_order_id and record.sale_order_id.mrp_production_ids:
|
if record.mrp_production_ids:
|
||||||
manufacturing_orders = record.sale_order_id.mrp_production_ids.filtered(
|
start_dates = [
|
||||||
lambda mo: mo.product_id == record.product_id)
|
workorder.date_start for mo in record.mrp_production_ids
|
||||||
if manufacturing_orders:
|
for workorder in mo.workorder_ids if workorder.date_start
|
||||||
start_dates = [
|
]
|
||||||
workorder.date_start for mo in manufacturing_orders
|
record.actual_start_date = min(start_dates) if start_dates else None
|
||||||
for workorder in mo.workorder_ids if workorder.date_start
|
|
||||||
]
|
|
||||||
record.actual_start_date = min(start_dates) if start_dates else None
|
|
||||||
else:
|
|
||||||
record.actual_start_date = None
|
|
||||||
else:
|
else:
|
||||||
record.actual_start_date = None
|
record.actual_start_date = None
|
||||||
|
|
||||||
@api.depends('sale_order_id.mrp_production_ids.workorder_ids.state',
|
@api.depends('mrp_production_ids.workorder_ids.state',
|
||||||
'sale_order_id.mrp_production_ids.workorder_ids.date_finished')
|
'mrp_production_ids.workorder_ids.date_finished')
|
||||||
def _compute_actual_end_date(self):
|
def _compute_actual_end_date(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
if record.sale_order_id and record.sale_order_id.mrp_production_ids:
|
if record.mrp_production_ids:
|
||||||
manufacturing_orders = record.sale_order_id.mrp_production_ids.filtered(
|
finished_orders = record.mrp_production_ids.filtered(lambda mo: mo.state == 'done')
|
||||||
lambda mo: mo.product_id == record.product_id)
|
|
||||||
finished_orders = manufacturing_orders.filtered(lambda mo: mo.state == 'done')
|
|
||||||
sum_product_qty = sum(finished_orders.mapped('product_qty'))
|
sum_product_qty = sum(finished_orders.mapped('product_qty'))
|
||||||
if finished_orders and float_compare(sum_product_qty, record.product_uom_qty,
|
if finished_orders and float_compare(sum_product_qty, record.plan_uom_qty,
|
||||||
precision_rounding=record.product_id.uom_id.rounding) >= 0:
|
precision_rounding=record.product_id.uom_id.rounding) >= 0:
|
||||||
end_dates = [
|
end_dates = [
|
||||||
workorder.date_finished for mo in finished_orders
|
workorder.date_finished for mo in finished_orders
|
||||||
@@ -268,27 +261,17 @@ class SfProductionDemandPlan(models.Model):
|
|||||||
else:
|
else:
|
||||||
record.actual_end_date = None
|
record.actual_end_date = None
|
||||||
|
|
||||||
@api.depends('sale_order_id.mrp_production_ids.move_raw_ids.reserved_availability')
|
@api.depends('mrp_production_ids.move_raw_ids.reserved_availability')
|
||||||
def _compute_material_check(self):
|
def _compute_material_check(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
if record.sale_order_id and record.sale_order_id.mrp_production_ids:
|
if record.mrp_production_ids and record.mrp_production_ids.move_raw_ids:
|
||||||
manufacturing_orders = record.sale_order_id.mrp_production_ids.filtered(
|
total_reserved_availability = sum(
|
||||||
lambda mo: mo.product_id == record.product_id)
|
record.mrp_production_ids.mapped('move_raw_ids.reserved_availability'))
|
||||||
|
if float_compare(total_reserved_availability, record.plan_uom_qty,
|
||||||
if manufacturing_orders and manufacturing_orders.move_raw_ids:
|
precision_rounding=record.product_id.uom_id.rounding) >= 0:
|
||||||
# 获取完成的制造订单
|
record.material_check = '1' # 已齐套
|
||||||
done_manufacturing = manufacturing_orders.filtered(lambda mo: mo.state == 'done')
|
|
||||||
product_qty = sum(done_manufacturing.mapped('product_qty'))
|
|
||||||
# 需求数量-完成数量
|
|
||||||
product_uom_qty = record.product_uom_qty - product_qty
|
|
||||||
total_reserved_availability = sum(manufacturing_orders.mapped('move_raw_ids.reserved_availability'))
|
|
||||||
if float_compare(total_reserved_availability, product_uom_qty,
|
|
||||||
precision_rounding=record.product_id.uom_id.rounding) >= 0:
|
|
||||||
record.material_check = '1' # 已齐套
|
|
||||||
else:
|
|
||||||
record.material_check = '0' # 未齐套
|
|
||||||
else:
|
else:
|
||||||
record.material_check = None
|
record.material_check = '0' # 未齐套
|
||||||
else:
|
else:
|
||||||
record.material_check = None
|
record.material_check = None
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user