From 95b5c862428567700e50f30a33521e5e1897f490 Mon Sep 17 00:00:00 2001 From: guanhuan Date: Mon, 16 Jun 2025 17:42:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=95=E6=96=99=E9=BD=90=E5=A5=97=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_demand_plan/models/sf_production_demand_plan.py | 9 +++------ sf_demand_plan/wizard/sf_demand_plan_print_wizard.py | 6 ++++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/sf_demand_plan/models/sf_production_demand_plan.py b/sf_demand_plan/models/sf_production_demand_plan.py index de2c1203..4eb8d449 100644 --- a/sf_demand_plan/models/sf_production_demand_plan.py +++ b/sf_demand_plan/models/sf_production_demand_plan.py @@ -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: diff --git a/sf_demand_plan/wizard/sf_demand_plan_print_wizard.py b/sf_demand_plan/wizard/sf_demand_plan_print_wizard.py index ddd154e6..8fe70302 100644 --- a/sf_demand_plan/wizard/sf_demand_plan_print_wizard.py +++ b/sf_demand_plan/wizard/sf_demand_plan_print_wizard.py @@ -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: