投料齐套检查修改

This commit is contained in:
guanhuan
2025-06-16 17:42:05 +08:00
parent dbe8c95558
commit 95b5c86242
2 changed files with 7 additions and 8 deletions

View File

@@ -272,18 +272,15 @@ class SfProductionDemandPlan(models.Model):
else:
record.actual_end_date = None
@api.depends('sale_order_id.mrp_production_ids.move_raw_ids.forecast_availability',
'sale_order_id.mrp_production_ids.move_raw_ids.quantity_done')
@api.depends('sale_order_id.mrp_production_ids.move_raw_ids.reserved_availability')
def _compute_material_check(self):
for record in self:
if record.sale_order_id and record.sale_order_id.mrp_production_ids:
manufacturing_orders = record.sale_order_id.mrp_production_ids.filtered(
lambda mo: mo.product_id == record.product_id)
if manufacturing_orders and manufacturing_orders.move_raw_ids:
total_forecast_availability = sum(manufacturing_orders.mapped('move_raw_ids.forecast_availability'))
total_quantity_done = sum(manufacturing_orders.mapped('move_raw_ids.quantity_done'))
total_sum = total_forecast_availability + total_quantity_done
if float_compare(total_sum, record.product_uom_qty,
total_reserved_availability = sum(manufacturing_orders.mapped('move_raw_ids.reserved_availability'))
if float_compare(total_reserved_availability, record.product_uom_qty,
precision_rounding=record.product_id.uom_id.rounding) >= 0:
record.material_check = '1' # 已齐套
else:

View File

@@ -30,8 +30,10 @@ class SfDemandPlanPrintWizard(models.TransientModel):
workorder_id = fields.Many2one('mrp.workorder', string='工单')
cnc_worksheet = fields.Binary('程序单')
def demand_plan_print(self):
for record in self:
def demand_plan_print(self, print_ids):
plan_print_ids = self.env['sf.demand.plan.print.wizard'].sudo().search(
[('id', 'in', print_ids)])
for record in plan_print_ids:
pdf_data = record.machining_drawings if record.type == '1' else record.cnc_worksheet
if pdf_data:
try: