需求计划优化
This commit is contained in:
@@ -146,9 +146,8 @@ class SfDemandPlan(models.Model):
|
||||
for line in self:
|
||||
sum_plan_uom_qty = sum(line.line_ids.mapped('plan_uom_qty'))
|
||||
pending_qty = line.product_uom_qty - sum_plan_uom_qty
|
||||
rounding = line.product_id.uom_id.rounding or 0.01
|
||||
if float_compare(pending_qty, 0,
|
||||
precision_rounding=rounding) == -1:
|
||||
precision_rounding=line.product_id.uom_id.rounding) == -1:
|
||||
line.pending_qty = 0
|
||||
else:
|
||||
line.pending_qty = pending_qty
|
||||
|
||||
@@ -28,10 +28,8 @@ class SfProductionDemandPlan(models.Model):
|
||||
], string='状态', default='30', readonly=True)
|
||||
demand_plan_id = fields.Many2one(comodel_name="sf.demand.plan",
|
||||
string="物料需求", readonly=True)
|
||||
sale_order_id = fields.Many2one(comodel_name="sale.order", related='demand_plan_id.sale_order_id',
|
||||
string="销售订单", readonly=True)
|
||||
sale_order_line_id = fields.Many2one(comodel_name="sale.order.line", related='demand_plan_id.sale_order_line_id',
|
||||
string="销售订单明细", readonly=True)
|
||||
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)
|
||||
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',
|
||||
@@ -215,9 +213,8 @@ class SfProductionDemandPlan(models.Model):
|
||||
@api.depends('sale_order_line_id.qty_to_deliver')
|
||||
def _compute_qty_to_deliver(self):
|
||||
for line in self:
|
||||
rounding = line.product_id.uom_id.rounding or 0.01
|
||||
if float_compare(line.sale_order_line_id.qty_to_deliver, 0,
|
||||
precision_rounding=rounding) == -1:
|
||||
precision_rounding=line.product_id.uom_id.rounding) == -1:
|
||||
line.qty_to_deliver = 0
|
||||
else:
|
||||
line.qty_to_deliver = line.sale_order_line_id.qty_to_deliver
|
||||
@@ -287,9 +284,8 @@ class SfProductionDemandPlan(models.Model):
|
||||
if record.mrp_production_ids and record.mrp_production_ids.move_raw_ids:
|
||||
total_reserved_availability = sum(
|
||||
record.mrp_production_ids.mapped('move_raw_ids.reserved_availability'))
|
||||
rounding = record.product_id.uom_id.rounding or 0.01
|
||||
if float_compare(total_reserved_availability, record.plan_uom_qty,
|
||||
precision_rounding=rounding) >= 0:
|
||||
precision_rounding=record.product_id.uom_id.rounding) >= 0:
|
||||
record.material_check = '1' # 已齐套
|
||||
else:
|
||||
record.material_check = '0' # 未齐套
|
||||
|
||||
Reference in New Issue
Block a user