From 1926375d5850bad006fcfc94a7e3d794c1f86219 Mon Sep 17 00:00:00 2001 From: guanhuan Date: Mon, 9 Jun 2025 10:30:12 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9C=80=E6=B1=82=E8=AE=A1=E5=88=92=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_demand_plan/__manifest__.py | 2 +- .../models/sf_production_demand_plan.py | 2 +- .../wizard/sf_demand_plan_print_wizard.py | 24 ++++++++++++++++++- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/sf_demand_plan/__manifest__.py b/sf_demand_plan/__manifest__.py index 0f4f2311..932685e0 100644 --- a/sf_demand_plan/__manifest__.py +++ b/sf_demand_plan/__manifest__.py @@ -10,7 +10,7 @@ """, 'category': 'sf', 'website': 'https://www.sf.jikimo.com', - 'depends': ['sf_plan'], + 'depends': ['sf_plan', 'jikimo_printing'], 'data': [ 'security/ir.model.access.csv', 'views/demand_plan.xml', diff --git a/sf_demand_plan/models/sf_production_demand_plan.py b/sf_demand_plan/models/sf_production_demand_plan.py index b1b9f9d5..692769cf 100644 --- a/sf_demand_plan/models/sf_production_demand_plan.py +++ b/sf_demand_plan/models/sf_production_demand_plan.py @@ -373,7 +373,7 @@ class sf_production_plan(models.Model): def _compute_hide_action_purchase_orders(self): for record in self: record.hide_action_purchase_orders = False - outsourcing_purchase_request = [] + outsourcing_purchase_request = [] if record.supply_method in ('automation', 'manual') and record.material_check == '0' and not record.sale_order_line_id.is_incoming_material: mrp_production = record.sale_order_id.mrp_production_ids.filtered( 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 6d322995..59bb44ae 100644 --- a/sf_demand_plan/wizard/sf_demand_plan_print_wizard.py +++ b/sf_demand_plan/wizard/sf_demand_plan_print_wizard.py @@ -1,7 +1,9 @@ # -*- coding: utf-8 -*- - +import logging from odoo import models, fields, api, _ +_logger = logging.getLogger(__name__) + class Sf_Demand_Plan_Print_Wizard(models.TransientModel): _name = 'sf.demand.plan.print.wizard' @@ -28,6 +30,26 @@ class Sf_Demand_Plan_Print_Wizard(models.TransientModel): workorder_id = fields.Many2one('mrp.workorder', string='工单') cnc_worksheet = fields.Binary('程序单') + def demand_plan_print(self): + for record in self: + pdf_data = record.machining_drawings if record.type == '1' else record.cnc_worksheet + if pdf_data: + try: + # 执行打印 + self.env['jikimo.printing'].sudo().print_pdf(pdf_data) + record.status = 'success' + t_part, c_part = record.demand_plan_id.print_count.split('C') + t_num = int(t_part[1:]) + c_num = int(c_part) + if record.type == '1': + t_num += 1 + elif record.type == '2': + c_num += 1 + record.demand_plan_id.print_count = f"T{t_num}C{c_num}" + except Exception as e: + record.status = 'fail' + _logger.error(f"文件{record.filename_url}打印失败: {str(e)}") + class MrpWorkorder(models.Model): _inherit = 'mrp.workorder'