需求计划文件打印
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user