diff --git a/sf_demand_plan/__init__.py b/sf_demand_plan/__init__.py
index cde864ba..35e7c960 100644
--- a/sf_demand_plan/__init__.py
+++ b/sf_demand_plan/__init__.py
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from . import models
+from . import wizard
diff --git a/sf_demand_plan/__manifest__.py b/sf_demand_plan/__manifest__.py
index fba85e4c..0f4f2311 100644
--- a/sf_demand_plan/__manifest__.py
+++ b/sf_demand_plan/__manifest__.py
@@ -14,6 +14,7 @@
'data': [
'security/ir.model.access.csv',
'views/demand_plan.xml',
+ 'wizard/sf_demand_plan_print_wizard_view.xml',
],
'demo': [
],
diff --git a/sf_demand_plan/models/sale_order.py b/sf_demand_plan/models/sale_order.py
index 80499fcf..e1168115 100644
--- a/sf_demand_plan/models/sale_order.py
+++ b/sf_demand_plan/models/sale_order.py
@@ -10,5 +10,14 @@ class ReSaleOrder(models.Model):
'sale_order_id': ret.order_id.id,
'sale_order_line_id': ret.id,
}
- self.env['sf.production.demand.plan'].sudo().create(vals)
+ demand_plan = self.env['sf.production.demand.plan'].sudo().create(vals)
+ if demand_plan.product_id.machining_drawings_name:
+ filename_url = demand_plan.product_id.machining_drawings_name.rsplit('.', 1)[0]
+ wizard_vals = {
+ 'demand_plan_id': demand_plan.id,
+ 'model_id': demand_plan.model_id,
+ 'filename_url': filename_url,
+ 'type': '1',
+ }
+ self.env['sf.demand.plan.print.wizard'].sudo().create(wizard_vals)
return ret
diff --git a/sf_demand_plan/models/sf_production_demand_plan.py b/sf_demand_plan/models/sf_production_demand_plan.py
index d1f29bc3..6678354c 100644
--- a/sf_demand_plan/models/sf_production_demand_plan.py
+++ b/sf_demand_plan/models/sf_production_demand_plan.py
@@ -303,3 +303,13 @@ class sf_production_plan(models.Model):
pro_plan_list.date_planned_start = date_planned_start
for pro_plan in pro_plan_list:
pro_plan.do_production_schedule()
+
+ def button_action_print(self):
+ return {
+ 'res_model': 'sf.demand.plan.print.wizard',
+ 'type': 'ir.actions.act_window',
+ 'name': _("打印"),
+ 'domain': [('demand_plan_id', 'in', self.ids)],
+ 'views': [[self.env.ref('sf_demand_plan.action_plan_print_tree').id, 'list']],
+ 'target': 'new',
+ }
diff --git a/sf_demand_plan/security/ir.model.access.csv b/sf_demand_plan/security/ir.model.access.csv
index cb2af3fc..56e8e247 100644
--- a/sf_demand_plan/security/ir.model.access.csv
+++ b/sf_demand_plan/security/ir.model.access.csv
@@ -1,3 +1,6 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_sf_production_demand_plan,sf.production.demand.plan,model_sf_production_demand_plan,base.group_user,1,0,0,0
access_sf_production_demand_plan_for_dispatch,sf.production.demand.plan for dispatch,model_sf_production_demand_plan,sf_base.group_plan_dispatch,1,1,0,0
+
+access_sf_demand_plan_print_wizard,sf.demand.plan.print.wizard,model_sf_demand_plan_print_wizard,base.group_user,1,0,0,0
+access_sf_demand_plan_print_wizard_for_dispatch,sf.demand.plan.print.wizard for dispatch,model_sf_demand_plan_print_wizard,sf_base.group_plan_dispatch,1,1,0,0
diff --git a/sf_demand_plan/views/demand_plan.xml b/sf_demand_plan/views/demand_plan.xml
index 94d81fea..0a89a9c1 100644
--- a/sf_demand_plan/views/demand_plan.xml
+++ b/sf_demand_plan/views/demand_plan.xml
@@ -4,6 +4,10 @@
sf.production.demand.plan
+
diff --git a/sf_demand_plan/wizard/__init__.py b/sf_demand_plan/wizard/__init__.py
new file mode 100644
index 00000000..170f9e85
--- /dev/null
+++ b/sf_demand_plan/wizard/__init__.py
@@ -0,0 +1 @@
+from . import sf_demand_plan_print_wizard
diff --git a/sf_demand_plan/wizard/sf_demand_plan_print_wizard.py b/sf_demand_plan/wizard/sf_demand_plan_print_wizard.py
new file mode 100644
index 00000000..6d322995
--- /dev/null
+++ b/sf_demand_plan/wizard/sf_demand_plan_print_wizard.py
@@ -0,0 +1,57 @@
+# -*- coding: utf-8 -*-
+
+from odoo import models, fields, api, _
+
+
+class Sf_Demand_Plan_Print_Wizard(models.TransientModel):
+ _name = 'sf.demand.plan.print.wizard'
+ _description = u'打印向导'
+
+ demand_plan_id = fields.Many2one('sf.production.demand.plan', string='需求计划ID')
+ product_id = fields.Many2one(
+ comodel_name='product.product',
+ related='demand_plan_id.product_id',
+ string='产品', store=True, index=True)
+ model_id = fields.Char('模型ID')
+ filename_url = fields.Char('文件名/URL')
+ type = fields.Selection([
+ ('1', '图纸'),
+ ('2', '程序单'),
+ ], string='类型')
+ status = fields.Selection([
+ ('not_start', '未开始'),
+ ('success', '成功'),
+ ('fail', '失败'),
+ ], string='状态', default='not_start')
+ machining_drawings = fields.Binary('2D加工图纸', related='product_id.machining_drawings', store=True)
+
+ workorder_id = fields.Many2one('mrp.workorder', string='工单')
+ cnc_worksheet = fields.Binary('程序单')
+
+
+class MrpWorkorder(models.Model):
+ _inherit = 'mrp.workorder'
+
+ def write(self, vals):
+ res = super(MrpWorkorder, self).write(vals)
+ for record in self:
+ if 'cnc_worksheet' in vals:
+ demand_plan_print = self.env['sf.demand.plan.print.wizard'].sudo().search(
+ [('workorder_id', '=', record.id)])
+ if demand_plan_print:
+ self.env['sf.demand.plan.print.wizard'].sudo().write(
+ {'cnc_worksheet': res.cnc_worksheet, 'filename_url': record.cnc_worksheet_name})
+ else:
+ demand_plan = self.env['sf.production.demand.plan'].sudo().search(
+ [('product_id', '=', record.product_id.id)])
+ if demand_plan:
+ wizard_vals = {
+ 'demand_plan_id': demand_plan.id,
+ 'model_id': demand_plan.model_id,
+ 'type': '2',
+ 'workorder_id': record.id,
+ 'cnc_worksheet': record.cnc_worksheet,
+ 'filename_url': record.cnc_worksheet_name
+ }
+ self.env['sf.demand.plan.print.wizard'].sudo().create(wizard_vals)
+ return res
diff --git a/sf_demand_plan/wizard/sf_demand_plan_print_wizard_view.xml b/sf_demand_plan/wizard/sf_demand_plan_print_wizard_view.xml
new file mode 100644
index 00000000..311e3ae8
--- /dev/null
+++ b/sf_demand_plan/wizard/sf_demand_plan_print_wizard_view.xml
@@ -0,0 +1,17 @@
+
+
+
+ sf.demand.plan.print.wizard.tree
+ sf.demand.plan.print.wizard
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py
index 4cc1dae6..7f0060bf 100644
--- a/sf_manufacturing/models/mrp_workorder.py
+++ b/sf_manufacturing/models/mrp_workorder.py
@@ -326,6 +326,7 @@ class ResMrpWorkOrder(models.Model):
tag_type = fields.Selection([("重新加工", "重新加工")], string="标签", tracking=True)
technology_design_id = fields.Many2one('sf.technology.design')
+ cnc_worksheet_name = fields.Char('工作指令文件名', readonly=True)
def _compute_default_construction_period_status(self):
need_list = ['pending', 'waiting', 'ready', 'progress', 'to be detected', 'done']
diff --git a/sf_mrs_connect/controllers/controllers.py b/sf_mrs_connect/controllers/controllers.py
index 9ca50188..97eabe94 100644
--- a/sf_mrs_connect/controllers/controllers.py
+++ b/sf_mrs_connect/controllers/controllers.py
@@ -91,12 +91,15 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController):
program_path_tmp_panel = os.path.join('/tmp', ret['folder_name'], 'return', panel)
files_panel = os.listdir(program_path_tmp_panel)
panel_file_path = ''
+ panel_file_name = ''
if files_panel:
for file in files_panel:
file_extension = os.path.splitext(file)[1]
if file_extension.lower() == '.pdf':
panel_file_path = os.path.join(program_path_tmp_panel, file)
+ panel_file_name = os.path.splitext(file)[0]
logging.info('panel_file_path:%s' % panel_file_path)
+ logging.info('panel_file_name:%s' % panel_file_name)
# 向编程单中添加二维码
request.env['printing.utils'].add_qr_code_to_pdf(
@@ -105,7 +108,8 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController):
"模型ID:%s" % model_id,
"零件图号:%s" % part_number if part_number else None
)
- cnc_workorder.write({'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())})
+ cnc_workorder.write({'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read()),
+ 'cnc_worksheet_name': panel_file_name})
pre_workorder = productions.workorder_ids.filtered(
lambda ap: ap.routing_type in ['装夹预调', '人工线下加工'] and ap.state not in ['done', 'rework'
'cancel'] and ap.processing_panel == panel)