人工线下加工最后一个工单完工后未记录时间完工时间

This commit is contained in:
guanhuan
2025-06-16 14:35:28 +08:00
parent 2febc369bb
commit 9123aeaee8

View File

@@ -259,7 +259,9 @@ class SfProductionDemandPlan(models.Model):
manufacturing_orders = record.sale_order_id.mrp_production_ids.filtered( manufacturing_orders = record.sale_order_id.mrp_production_ids.filtered(
lambda mo: mo.product_id == record.product_id) lambda mo: mo.product_id == record.product_id)
finished_orders = manufacturing_orders.filtered(lambda mo: mo.state == 'done') finished_orders = manufacturing_orders.filtered(lambda mo: mo.state == 'done')
if len(finished_orders) >= record.product_uom_qty: sum_product_qty = sum(finished_orders.mapped('product_qty'))
if finished_orders and float_compare(sum_product_qty, record.product_uom_qty,
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
for workorder in mo.workorder_ids if workorder.date_finished for workorder in mo.workorder_ids if workorder.date_finished
@@ -361,7 +363,8 @@ class SfProductionDemandPlan(models.Model):
) )
for order in purchase_orders for order in purchase_orders
) )
if total_purchase_quantity < record.product_uom_qty: if float_compare(total_purchase_quantity, record.product_uom_qty,
precision_rounding=record.product_id.uom_id.rounding) == -1:
pr_ids = self.env['purchase.request'].sudo().search( pr_ids = self.env['purchase.request'].sudo().search(
[('line_ids.product_id', 'in', raw_materials.ids), ('state', '!=', 'done')]) [('line_ids.product_id', 'in', raw_materials.ids), ('state', '!=', 'done')])
outsourcing_purchase_request.extend(pr_ids.ids) outsourcing_purchase_request.extend(pr_ids.ids)
@@ -378,7 +381,9 @@ class SfProductionDemandPlan(models.Model):
) )
for order in purchase_orders for order in purchase_orders
) )
if total_purchase_quantity < record.product_uom_qty:
if float_compare(total_purchase_quantity, record.product_uom_qty,
precision_rounding=record.product_id.uom_id.rounding) == -1:
pr_ids = self.env['purchase.request'].sudo().search( pr_ids = self.env['purchase.request'].sudo().search(
[('origin', 'like', record.sale_order_id.name), ('state', '!=', 'done')]) [('origin', 'like', record.sale_order_id.name), ('state', '!=', 'done')])
outsourcing_purchase_request.extend(pr_ids.ids) outsourcing_purchase_request.extend(pr_ids.ids)
@@ -400,7 +405,9 @@ class SfProductionDemandPlan(models.Model):
) )
for order in product_purchase_orders for order in product_purchase_orders
) )
if total_outsourcing_purchase_quantity / total_product_qty < record.product_uom_qty: quantity = total_outsourcing_purchase_quantity / total_product_qty
if float_compare(quantity, record.product_uom_qty,
precision_rounding=record.product_id.uom_id.rounding) == -1:
purchase_request = self.env['purchase.request'].sudo().search( purchase_request = self.env['purchase.request'].sudo().search(
[('line_ids.product_id', 'in', bom_product_ids.ids), [('line_ids.product_id', 'in', bom_product_ids.ids),
('line_ids.purchase_state', 'not in', ('purchase', 'done')), ('state', '!=', 'done')]) ('line_ids.purchase_state', 'not in', ('purchase', 'done')), ('state', '!=', 'done')])