打印方法修改
This commit is contained in:
@@ -30,9 +30,14 @@ class SfDemandPlanPrintWizard(models.TransientModel):
|
|||||||
workorder_id = fields.Many2one('mrp.workorder', string='工单')
|
workorder_id = fields.Many2one('mrp.workorder', string='工单')
|
||||||
cnc_worksheet = fields.Binary('程序单')
|
cnc_worksheet = fields.Binary('程序单')
|
||||||
|
|
||||||
|
@api.model
|
||||||
def demand_plan_print(self, print_ids):
|
def demand_plan_print(self, print_ids):
|
||||||
plan_print_ids = self.env['sf.demand.plan.print.wizard'].sudo().search(
|
plan_print_ids = self.env['sf.demand.plan.print.wizard'].sudo().search(
|
||||||
[('id', 'in', print_ids)])
|
[('id', 'in', print_ids)])
|
||||||
|
if not plan_print_ids:
|
||||||
|
return {'message': '记录不存在'}
|
||||||
|
success_records = []
|
||||||
|
failed_records = []
|
||||||
for record in plan_print_ids:
|
for record in plan_print_ids:
|
||||||
pdf_data = record.machining_drawings if record.type == '1' else record.cnc_worksheet
|
pdf_data = record.machining_drawings if record.type == '1' else record.cnc_worksheet
|
||||||
if pdf_data:
|
if pdf_data:
|
||||||
@@ -48,9 +53,20 @@ class SfDemandPlanPrintWizard(models.TransientModel):
|
|||||||
elif record.type == '2':
|
elif record.type == '2':
|
||||||
c_num += 1
|
c_num += 1
|
||||||
record.demand_plan_id.print_count = f"T{t_num}C{c_num}"
|
record.demand_plan_id.print_count = f"T{t_num}C{c_num}"
|
||||||
|
success_records.append({
|
||||||
|
'filename_url': record.filename_url,
|
||||||
|
})
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
record.status = 'fail'
|
record.status = 'fail'
|
||||||
_logger.error(f"文件{record.filename_url}打印失败: {str(e)}")
|
_logger.error(f"文件{record.filename_url}打印失败: {str(e)}")
|
||||||
|
failed_records.append({
|
||||||
|
'filename_url': record.filename_url,
|
||||||
|
})
|
||||||
|
if failed_records:
|
||||||
|
message = f"成功打印 {len(success_records)} 个文件,失败 {len(failed_records)} 个"
|
||||||
|
else:
|
||||||
|
message = f"所有 {len(success_records)} 个文件打印成功"
|
||||||
|
return {'message': message}
|
||||||
|
|
||||||
|
|
||||||
class MrpWorkorder(models.Model):
|
class MrpWorkorder(models.Model):
|
||||||
|
|||||||
Reference in New Issue
Block a user