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: