diff --git a/sf_message/__manifest__.py b/sf_message/__manifest__.py
index cdfef4bd..0f032a6d 100644
--- a/sf_message/__manifest__.py
+++ b/sf_message/__manifest__.py
@@ -11,7 +11,7 @@
""",
'category': 'sf',
'website': 'https://www.sf.jikimo.com',
- 'depends': ['sale', 'purchase', 'sf_plan', 'jikimo_message_notify'],
+ 'depends': ['sale', 'purchase', 'sf_plan', 'jikimo_message_notify','stock'],
'data': [
'data/bussiness_node.xml'
],
diff --git a/sf_message/data/bussiness_node.xml b/sf_message/data/bussiness_node.xml
index eeb7cbe7..a9c3dc62 100644
--- a/sf_message/data/bussiness_node.xml
+++ b/sf_message/data/bussiness_node.xml
@@ -10,5 +10,17 @@
确认接单
sale.order
+
+ 调拨入库
+ stock.picking
+
+
+ 功能刀具组装
+ sf.functional.tool.assembly
+
+
+ 功能刀具寿命到期
+ sf.functional.tool.dismantle
+
\ No newline at end of file
diff --git a/sf_message/models/__init__.py b/sf_message/models/__init__.py
index b0c058fc..e84a0acd 100644
--- a/sf_message/models/__init__.py
+++ b/sf_message/models/__init__.py
@@ -6,3 +6,4 @@ from . import sf_message_cam_program
from . import sf_message_functional_tool_assembly
from . import sf_message_purchase
from . import sf_message_workorder
+from . import sf_message_functional_tool_dismantle
\ No newline at end of file
diff --git a/sf_message/models/sf_message_functional_tool_assembly.py b/sf_message/models/sf_message_functional_tool_assembly.py
index 251af2cc..d4e05fc0 100644
--- a/sf_message/models/sf_message_functional_tool_assembly.py
+++ b/sf_message/models/sf_message_functional_tool_assembly.py
@@ -3,4 +3,16 @@ from odoo import models, fields, api, _
class SFMessagefunctionalToolAssembly(models.Model):
_name = 'sf.functional.tool.assembly'
+ _description = "刀具组装单"
_inherit = ['sf.functional.tool.assembly', 'jikimo.message.dispatch']
+
+ @api.model_create_multi
+ def create(self, vals):
+ result = super(SFMessagefunctionalToolAssembly, self).create(vals)
+ is_cam = False
+ for obj in result:
+ if obj.loading_task_source == '0' and obj.assemble_status == '0':
+ is_cam = True
+ if is_cam:
+ self.add_queue('功能刀具组装')
+ return result
diff --git a/sf_message/models/sf_message_functional_tool_dismantle.py b/sf_message/models/sf_message_functional_tool_dismantle.py
new file mode 100644
index 00000000..dac3db28
--- /dev/null
+++ b/sf_message/models/sf_message_functional_tool_dismantle.py
@@ -0,0 +1,18 @@
+from odoo import models, api
+
+
+class SFMessagefunctionalToolDismantle(models.Model):
+ _name = 'sf.functional.tool.dismantle'
+ _description = "刀具拆解单"
+ _inherit = ['sf.functional.tool.dismantle', 'jikimo.message.dispatch']
+
+ @api.model
+ def create(self, vals):
+ result = super(SFMessagefunctionalToolDismantle, self).create(vals)
+ is_dismantle = False
+ for obj in result:
+ if obj.dismantle_cause in ['寿命到期报废', '崩刀报废']and obj.state=='待拆解':
+ is_dismantle = True
+ if is_dismantle:
+ self.add_queue('功能刀具寿命到期')
+ return result
diff --git a/sf_message/models/sf_message_stock_picking.py b/sf_message/models/sf_message_stock_picking.py
index b090549e..d66008f9 100644
--- a/sf_message/models/sf_message_stock_picking.py
+++ b/sf_message/models/sf_message_stock_picking.py
@@ -3,4 +3,11 @@ from odoo import models, fields, api, _
class SFMessageStockPicking(models.Model):
_name = 'stock.picking'
+ _description = "库存调拨"
_inherit = ['stock.picking', 'jikimo.message.dispatch']
+
+ def button_validate(self):
+ res = super(SFMessageStockPicking, self).button_validate()
+ if self.location_id.name == '进货' and self.location_dest_id.name == '刀具房':
+ self.add_queue('调拨入库')
+ return res
diff --git a/sf_message/models/sf_message_template.py b/sf_message/models/sf_message_template.py
index 7380fbe6..5a37513c 100644
--- a/sf_message/models/sf_message_template.py
+++ b/sf_message/models/sf_message_template.py
@@ -9,4 +9,7 @@ class SfMessageTemplate(models.Model):
def _get_message_model(self):
res = super(SfMessageTemplate, self)._get_message_model()
res.append("sale.order")
+ res.append("stock.picking")
+ res.append('sf.functional.tool.assembly')
+ res.append('sf.functional.tool.dismantle')
return res
diff --git a/sf_mrs_connect/controllers/controllers.py b/sf_mrs_connect/controllers/controllers.py
index c5d1cd10..25736199 100644
--- a/sf_mrs_connect/controllers/controllers.py
+++ b/sf_mrs_connect/controllers/controllers.py
@@ -31,67 +31,67 @@ class Sf_Mrs_Connect(http.Controller):
request.env.ref("base.user_admin")).search(domain)
if productions:
# 拉取所有加工面的程序文件
- for r in ret['processing_panel'].split(','):
- program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', r)
- if os.path.exists(program_path_tmp_r):
- files_r = os.listdir(program_path_tmp_r)
- if files_r:
- for file_name in files_r:
- file_path = os.path.join(program_path_tmp_r, file_name)
- os.remove(file_path)
- download_state = request.env['sf.cnc.processing'].with_user(
- request.env.ref("base.user_admin")).download_file_tmp(
- ret['folder_name'], r)
- if download_state is False:
- res['status'] = -2
- res['message'] = '编程单号为%s的CNC程序文件从FTP拉取失败' % (ret['programming_no'])
- return json.JSONEncoder().encode(res)
+ # for r in ret['processing_panel'].split(','):
+ # program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', r)
+ # if os.path.exists(program_path_tmp_r):
+ # files_r = os.listdir(program_path_tmp_r)
+ # if files_r:
+ # for file_name in files_r:
+ # file_path = os.path.join(program_path_tmp_r, file_name)
+ # os.remove(file_path)
+ # download_state = request.env['sf.cnc.processing'].with_user(
+ # request.env.ref("base.user_admin")).download_file_tmp(
+ # ret['folder_name'], r)
+ # if download_state is False:
+ # res['status'] = -2
+ # res['message'] = '编程单号为%s的CNC程序文件从FTP拉取失败' % (ret['programming_no'])
+ # return json.JSONEncoder().encode(res)
for production in productions:
if not production.workorder_ids:
production.product_id.model_processing_panel = ret['processing_panel']
production._create_workorder(ret)
productions.process_range_time()
- else:
- for panel in ret['processing_panel'].split(','):
- # 查询状态为进行中且工序类型为CNC加工的工单
- cnc_workorder_has = production.workorder_ids.filtered(
- lambda ach: ach.routing_type == 'CNC加工' and ach.state not in ['progress', 'done',
- 'rework',
- 'cancel'] and ach.processing_panel == panel)
- if cnc_workorder_has:
- if cnc_workorder_has.cnc_ids:
- cnc_workorder_has.cmm_ids.sudo().unlink()
- cnc_workorder_has.cnc_ids.sudo().unlink()
- request.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan(
- production)
- cnc_workorder_has.write(
- {'cnc_ids': cnc_workorder_has.cnc_ids.sudo()._json_cnc_processing(panel, ret),
- 'cmm_ids': cnc_workorder_has.cmm_ids.sudo()._json_cmm_program(panel, ret)})
- for panel in ret['processing_panel'].split(','):
- # 查询状态为进行中且工序类型为CNC加工的工单
- cnc_workorder = productions.workorder_ids.filtered(
- lambda ac: ac.routing_type == 'CNC加工' and ac.state not in ['progress', 'done', 'rework'
- 'cancel'] and ac.processing_panel == panel)
- if cnc_workorder:
- # program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test',
- # panel)
- program_path_tmp_panel = os.path.join('/tmp', ret['folder_name'], 'return', panel)
- logging.info('program_path_tmp_panel:%s' % program_path_tmp_panel)
- files_panel = os.listdir(program_path_tmp_panel)
- if files_panel:
- for file in files_panel:
- file_extension = os.path.splitext(file)[1]
- logging.info('file_extension:%s' % file_extension)
- if file_extension.lower() == '.pdf':
- panel_file_path = os.path.join(program_path_tmp_panel, file)
- logging.info('panel_file_path:%s' % panel_file_path)
- cnc_workorder.write({'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())})
- pre_workorder = productions.workorder_ids.filtered(
- lambda ap: ap.routing_type == '装夹预调' and ap.state not in ['done', 'rework'
- 'cancel'] and ap.processing_panel == panel)
- if pre_workorder:
- pre_workorder.write(
- {'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())})
+ # else:
+ # for panel in ret['processing_panel'].split(','):
+ # # 查询状态为进行中且工序类型为CNC加工的工单
+ # cnc_workorder_has = production.workorder_ids.filtered(
+ # lambda ach: ach.routing_type == 'CNC加工' and ach.state not in ['progress', 'done',
+ # 'rework',
+ # 'cancel'] and ach.processing_panel == panel)
+ # if cnc_workorder_has:
+ # if cnc_workorder_has.cnc_ids:
+ # cnc_workorder_has.cmm_ids.sudo().unlink()
+ # cnc_workorder_has.cnc_ids.sudo().unlink()
+ # request.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan(
+ # production)
+ # cnc_workorder_has.write(
+ # {'cnc_ids': cnc_workorder_has.cnc_ids.sudo()._json_cnc_processing(panel, ret),
+ # 'cmm_ids': cnc_workorder_has.cmm_ids.sudo()._json_cmm_program(panel, ret)})
+ # for panel in ret['processing_panel'].split(','):
+ # # 查询状态为进行中且工序类型为CNC加工的工单
+ # cnc_workorder = productions.workorder_ids.filtered(
+ # lambda ac: ac.routing_type == 'CNC加工' and ac.state not in ['progress', 'done', 'rework'
+ # 'cancel'] and ac.processing_panel == panel)
+ # if cnc_workorder:
+ # # program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test',
+ # # panel)
+ # program_path_tmp_panel = os.path.join('/tmp', ret['folder_name'], 'return', panel)
+ # logging.info('program_path_tmp_panel:%s' % program_path_tmp_panel)
+ # files_panel = os.listdir(program_path_tmp_panel)
+ # if files_panel:
+ # for file in files_panel:
+ # file_extension = os.path.splitext(file)[1]
+ # logging.info('file_extension:%s' % file_extension)
+ # if file_extension.lower() == '.pdf':
+ # panel_file_path = os.path.join(program_path_tmp_panel, file)
+ # logging.info('panel_file_path:%s' % panel_file_path)
+ # cnc_workorder.write({'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())})
+ # pre_workorder = productions.workorder_ids.filtered(
+ # lambda ap: ap.routing_type == '装夹预调' and ap.state not in ['done', 'rework'
+ # 'cancel'] and ap.processing_panel == panel)
+ # if pre_workorder:
+ # pre_workorder.write(
+ # {'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())})
productions.write({'programming_state': '已编程', 'work_state': '已编程'})
return json.JSONEncoder().encode(res)
else: