Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/优化sf

# Conflicts:
#	sf_manufacturing/models/__init__.py
#	sf_manufacturing/models/mrp_workcenter.py
#	sf_manufacturing/models/mrp_workorder.py
#	sf_manufacturing/views/mrp_workorder_view.xml
This commit is contained in:
jinling.yang
2023-01-09 20:33:53 +08:00
7 changed files with 210 additions and 20 deletions

View File

@@ -258,9 +258,6 @@ class ResMrpWorkOrder(models.Model):
else:
return True
# def fetchCNCing(self):
# return None
# cnc程序获取
def fetchCNC(self):
try:
@@ -316,14 +313,50 @@ class ResMrpWorkOrder(models.Model):
logging.info('fetchCNC error:%s' % e)
raise UserError(e)
# return {
# 'name': _("工单"),
# 'view_mode': 'form',
# 'res_model': 'mrp.workorder',
# 'res_id': self.id,
# 'type': 'ir.actions.act_window',
# 'target': 'new'
# }
# cnc程序获取
def fetchCNC(self):
cnc = self.env['mrp.workorder'].search(
[('routing_type', '=', 'CNC加工'), ('production_id', '=', self.production_id.id)], limit=1)
if cnc.product_id.upload_model_file:
attachment = cnc.product_id.upload_model_file[0]
base64_data = base64.b64encode(attachment.datas)
base64_datas = base64_data.decode('utf-8')
model_code = hashlib.sha1(base64_datas.encode('utf-8')).hexdigest()
res = {'model_code': '' if not cnc.product_id.upload_model_file else model_code,
'production_no': self.production_id.name,
'machine_tool_code': cnc.workcenter_id.machine_tool_id.code,
'material_code': cnc.env['sf.production.materials'].search(
[('id', '=', cnc.product_id.materials_id.id)]).materials_no,
'material_type_code': cnc.env['sf.materials.model'].search(
[('id', '=', cnc.product_id.materials_type_id.id)]).materials_no,
'machining_processing_panel': cnc.product_id.model_processing_panel,
'machining_precision': cnc.product_id.model_machining_precision,
'embryo_long': cnc.product_id.bom_ids.bom_line_ids.product_id.length,
'embryo_height': cnc.product_id.bom_ids.bom_line_ids.product_id.height,
'embryo_width': cnc.product_id.bom_ids.bom_line_ids.product_id.width,
'order_no': cnc.production_id.origin,
'user': self.env.user.name,
'model_file': '' if not cnc.product_id.model_file else base64.b64encode(
cnc.product_id.model_file).decode('utf-8')
}
logging.info('res:%s' % res)
configsettings = self.env['res.config.settings'].get_values()
config_header = Common.get_headers(self, configsettings['token'], configsettings['sf_secret_key'])
url = '/api/intelligent_programming/create'
config_url = configsettings['sf_url'] + url
# res_str = json.dumps(res)
ret = requests.post(config_url, json={}, data=res, headers=config_header)
ret = ret.json()
if ret['status'] == 1:
self.write({'programming_no': ret['programming_no'], 'programming_state': '编程中', 'work_state': '编程中'})
return {
'name': _("工单"),
'view_mode': 'form',
'res_model': 'mrp.workorder',
'res_id': self.id,
'type': 'ir.actions.act_window',
'target': 'new'
}
def json_workorder_str1(self, k, production, route):
workorders_values_str = [0, '', {
@@ -436,7 +469,7 @@ class CNCprocessing(models.Model):
cnc_workorder.state = 'done'
cnc_workorder.work_state = '已编程'
cnc_workorder.programming_state = '已编程'
cnc_workorder.time_ids.date_end = datetime.now()
# cnc_workorder.time_ids.date_end = datetime.now()
def get_cnc_processing_file(self, folder_name, cnc_processing):
logging.info('folder_name:%s' % folder_name)
@@ -501,6 +534,9 @@ class SfWorkOrderBarcodes(models.Model):
def on_barcode_scanned(self, barcode):
tray_code = self.env['sf.tray'].search([('code', '=', barcode)])
self.tray_code = tray_code.code
# 在这里,用等号赋值只是一次性的,只是一种展示
# self.tray_code = tray_code.code
# 用write方法写入数据库是永久的
self.write({'tray_code': tray_code.code})
workorder = self.env['mrp.workorder'].browse(self.ids)
workorder.gettray_auto(barcode)