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