Merge branch 'feature/修复快速订单' into develop
This commit is contained in:
@@ -135,7 +135,8 @@ class MrpProduction(models.Model):
|
|||||||
# cnc程序获取
|
# cnc程序获取
|
||||||
def fetchCNC(self):
|
def fetchCNC(self):
|
||||||
cnc = self.env['mrp.production'].search([('id', '=', self.id)])
|
cnc = self.env['mrp.production'].search([('id', '=', self.id)])
|
||||||
quick_order = self.env['quick.easy.order'].search([('id', '=', cnc.product_id.id)])
|
quick_order = self.env['quick.easy.order'].search(
|
||||||
|
[('name', '=', cnc.product_id.default_code.rsplit('-', 1)[0])])
|
||||||
programme_way = False
|
programme_way = False
|
||||||
if cnc.manual_quotation is True:
|
if cnc.manual_quotation is True:
|
||||||
programme_way = 'manual operation'
|
programme_way = 'manual operation'
|
||||||
@@ -157,7 +158,6 @@ class MrpProduction(models.Model):
|
|||||||
'embryo_height': cnc.product_id.bom_ids.bom_line_ids.product_id.height,
|
'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,
|
'embryo_width': cnc.product_id.bom_ids.bom_line_ids.product_id.width,
|
||||||
'order_no': cnc.origin,
|
'order_no': cnc.origin,
|
||||||
'quick_order_no': quick_order.name if quick_order else False,
|
|
||||||
'model_order_no': cnc.product_id.default_code,
|
'model_order_no': cnc.product_id.default_code,
|
||||||
'user': cnc.env.user.name,
|
'user': cnc.env.user.name,
|
||||||
'programme_way': programme_way,
|
'programme_way': programme_way,
|
||||||
|
|||||||
@@ -652,47 +652,6 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
else:
|
else:
|
||||||
self.results = '合格'
|
self.results = '合格'
|
||||||
|
|
||||||
# cnc程序获取
|
|
||||||
def fetchCNC(self):
|
|
||||||
try:
|
|
||||||
cnc = self.env['mrp.workorder'].search(
|
|
||||||
[('routing_type', '=', 'CNC加工'), ('production_id', '=', self.production_id.id)], limit=1)
|
|
||||||
res = {'model_code': '' if not cnc.product_id.model_code else cnc.product_id.model_code,
|
|
||||||
'production_no': self.production_id.name,
|
|
||||||
'machine_tool_code': cnc.workcenter_id.equipment_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,
|
|
||||||
'model_order_no': cnc.product_id.default_code.rsplit(' -', 1)[0],
|
|
||||||
'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()
|
|
||||||
logging.info('fetchCNC-ret:%s' % ret)
|
|
||||||
if ret['status'] == 1:
|
|
||||||
self.write(
|
|
||||||
{'programming_no': ret['programming_no'], 'programming_state': '编程中', 'work_state': '编程中'})
|
|
||||||
else:
|
|
||||||
raise UserError(ret['message'])
|
|
||||||
except Exception as e:
|
|
||||||
logging.info('fetchCNC error:%s' % e)
|
|
||||||
raise UserError("cnc程序获取编程单失败,请联系管理员")
|
|
||||||
|
|
||||||
def json_workorder_str1(self, k, production, route):
|
def json_workorder_str1(self, k, production, route):
|
||||||
workorders_values_str = [0, '', {
|
workorders_values_str = [0, '', {
|
||||||
'product_uom_id': production.product_uom_id.id,
|
'product_uom_id': production.product_uom_id.id,
|
||||||
|
|||||||
@@ -210,12 +210,12 @@
|
|||||||
<field name="programming_state" readonly="1"
|
<field name="programming_state" readonly="1"
|
||||||
attrs='{"invisible": [("programming_no","=",False)]}'/>
|
attrs='{"invisible": [("programming_no","=",False)]}'/>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<!-- <group>-->
|
||||||
<div class="col-12 col-lg-6 o_setting_box" style="white-space: nowrap">
|
<!-- <div class="col-12 col-lg-6 o_setting_box" style="white-space: nowrap">-->
|
||||||
<button type="object" class="oe_highlight" name="fetchCNC" string="获取CNC程序代码"
|
<!-- <button type="object" class="oe_highlight" name="fetchCNC" string="获取CNC程序代码"-->
|
||||||
/>
|
<!-- />-->
|
||||||
</div>
|
<!-- </div>-->
|
||||||
</group>
|
<!-- </group>-->
|
||||||
</page>
|
</page>
|
||||||
</xpath>
|
</xpath>
|
||||||
<!-- <page string="Components" name="components">-->
|
<!-- <page string="Components" name="components">-->
|
||||||
|
|||||||
@@ -128,18 +128,18 @@ class QuickEasyOrder(models.Model):
|
|||||||
# # print(volume)
|
# # print(volume)
|
||||||
# item.model_volume = volume
|
# item.model_volume = volume
|
||||||
# # 长宽高/体积
|
# # 长宽高/体积
|
||||||
# output_file = os.path.join('C:/Users/43484/Desktop/机企猫工作文档', str(library_of_models.code) + '.stl')
|
# output_file = os.path.join('C:/Users/43484/Desktop/机企猫工作文档', str(model_code) + '.stl')
|
||||||
output_file = os.path.join('/tmp', str(model_code) + '.stl')
|
output_file = os.path.join('/tmp', str(model_code) + '.stl')
|
||||||
your_mesh = mesh.Mesh.from_file(output_file)
|
# your_mesh = mesh.Mesh.from_file(output_file)
|
||||||
volume, cog, inertia = your_mesh.get_mass_properties()
|
# volume, cog, inertia = your_mesh.get_mass_properties()
|
||||||
xyz = (your_mesh.max_ - your_mesh.min_)
|
# xyz = (your_mesh.max_ - your_mesh.min_)
|
||||||
item.model_length = xyz[0] # 长 单位mm
|
# item.model_length = xyz[0] # 长 单位mm
|
||||||
item.model_width = xyz[1] # 宽
|
# item.model_width = xyz[1] # 宽
|
||||||
item.model_height = xyz[2] # 高
|
# item.model_height = xyz[2] # 高
|
||||||
item.model_volume = volume
|
# item.model_volume = volume
|
||||||
write_stl_file(shapes, output_file, 'binary', 0.03, 0.5)
|
write_stl_file(shapes, output_file, 'binary', 0.03, 0.5)
|
||||||
# 转化为glb
|
# 转化为glb
|
||||||
# output_glb_file = os.path.join('C:/Users/43484/Desktop/机企猫工作文档', str(library_of_models.code) + '.glb')
|
# output_glb_file = os.path.join('C:/Users/43484/Desktop/机企猫工作文档', str(model_code) + '.glb')
|
||||||
output_glb_file = os.path.join('/tmp', str(model_code) + '.glb')
|
output_glb_file = os.path.join('/tmp', str(model_code) + '.glb')
|
||||||
util_path = get_resource_path('sf_base', 'static/util')
|
util_path = get_resource_path('sf_base', 'static/util')
|
||||||
cmd = 'python3 %s/stl2gltf.py %s %s -b' % (util_path, output_file, output_glb_file)
|
cmd = 'python3 %s/stl2gltf.py %s %s -b' % (util_path, output_file, output_glb_file)
|
||||||
@@ -189,6 +189,7 @@ class QuickEasyOrder(models.Model):
|
|||||||
'number': item.quantity,
|
'number': item.quantity,
|
||||||
'total_amount': item.price,
|
'total_amount': item.price,
|
||||||
'remark': '',
|
'remark': '',
|
||||||
|
'manual_quotation': True,
|
||||||
'barcode': barcode
|
'barcode': barcode
|
||||||
})
|
})
|
||||||
# res['bfm_process_order_list'] = json.dumps(res['bfm_process_order_list'])
|
# res['bfm_process_order_list'] = json.dumps(res['bfm_process_order_list'])
|
||||||
@@ -292,7 +293,7 @@ class QuickEasyOrder(models.Model):
|
|||||||
'model_height': order.model_height,
|
'model_height': order.model_height,
|
||||||
'model_volume': order.model_volume,
|
'model_volume': order.model_volume,
|
||||||
'color_model_path': '/tmp/' + str(model_code) + ".step",
|
'color_model_path': '/tmp/' + str(model_code) + ".step",
|
||||||
'model_order_no': order.name,
|
'model_order_no': '%s-%s' % (order.name, 1),
|
||||||
'remark': '订单号:%s 客户:%s' % (order.name, order.customer_id.name)
|
'remark': '订单号:%s 客户:%s' % (order.name, order.customer_id.name)
|
||||||
}
|
}
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user