优化快读订单
This commit is contained in:
@@ -54,8 +54,9 @@ class MrpProduction(models.Model):
|
|||||||
glb_file = fields.Binary("glb模型文件")
|
glb_file = fields.Binary("glb模型文件")
|
||||||
production_line_id = fields.Many2one('sf.production.line', string='生产线')
|
production_line_id = fields.Many2one('sf.production.line', string='生产线')
|
||||||
plan_start_processing_time = fields.Datetime('计划开始加工时间')
|
plan_start_processing_time = fields.Datetime('计划开始加工时间')
|
||||||
production_line_state = fields.Selection([('待上产线', '待上产线'), ('已上产线', '已上产线'), ('已下产线', '已下产线')],
|
production_line_state = fields.Selection(
|
||||||
string='上/下产线', default='待上产线')
|
[('待上产线', '待上产线'), ('已上产线', '已上产线'), ('已下产线', '已下产线')],
|
||||||
|
string='上/下产线', default='待上产线')
|
||||||
|
|
||||||
manual_quotation = fields.Boolean('人工编程', default=False, readonly=True)
|
manual_quotation = fields.Boolean('人工编程', default=False, readonly=True)
|
||||||
|
|
||||||
@@ -156,6 +157,7 @@ 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,
|
||||||
|
|||||||
@@ -1186,7 +1186,7 @@ class WorkPieceDelivery(models.Model):
|
|||||||
logging.info('config-e:%s' % e)
|
logging.info('config-e:%s' % e)
|
||||||
raise UserError("工件配送请求agv失败")
|
raise UserError("工件配送请求agv失败")
|
||||||
|
|
||||||
@api.depends('production_id.production_line_id')
|
@api.onchange('production_id.production_line_id')
|
||||||
def _compute_production_line_id(self):
|
def _compute_production_line_id(self):
|
||||||
if self.production_id.production_line_id:
|
if self.production_id.production_line_id:
|
||||||
self.production_line_id = self.production_id.production_line_id.id
|
self.production_line_id = self.production_id.production_line_id.id
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
import logging
|
import logging
|
||||||
import base64
|
import base64
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import requests
|
||||||
import os
|
import os
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from stl import mesh
|
from stl import mesh
|
||||||
# from OCC.Core.GProp import GProp_GProps
|
# from OCC.Core.GProp import GProp_GProps
|
||||||
from OCC.Extend.DataExchange import read_step_file
|
# from OCC.Extend.DataExchange import read_step_file
|
||||||
from OCC.Extend.DataExchange import write_stl_file
|
# from OCC.Extend.DataExchange import write_stl_file
|
||||||
|
from odoo.addons.sf_base.commons.common import Common
|
||||||
from odoo import models, fields, api
|
from odoo import models, fields, api
|
||||||
from odoo.modules import get_resource_path
|
from odoo.modules import get_resource_path
|
||||||
from odoo.exceptions import ValidationError, UserError
|
from odoo.exceptions import ValidationError, UserError
|
||||||
@@ -79,6 +81,8 @@ class QuickEasyOrder(models.Model):
|
|||||||
report_path = attachment._full_path(attachment.store_fname)
|
report_path = attachment._full_path(attachment.store_fname)
|
||||||
vals['model_file'] = self.transition_glb_file(report_path, model_code)
|
vals['model_file'] = self.transition_glb_file(report_path, model_code)
|
||||||
obj = super(QuickEasyOrder, self).create(vals)
|
obj = super(QuickEasyOrder, self).create(vals)
|
||||||
|
logging.info('---------向cloud生成模型库-------')
|
||||||
|
self.model_coloring()
|
||||||
logging.info('---------开始派单到工厂-------')
|
logging.info('---------开始派单到工厂-------')
|
||||||
self.distribute_to_factory(obj)
|
self.distribute_to_factory(obj)
|
||||||
obj.state = '待接单'
|
obj.state = '待接单'
|
||||||
@@ -160,7 +164,7 @@ class QuickEasyOrder(models.Model):
|
|||||||
try:
|
try:
|
||||||
logging.info('---------派单到工厂-------')
|
logging.info('---------派单到工厂-------')
|
||||||
res = {'bfm_process_order_list': []}
|
res = {'bfm_process_order_list': []}
|
||||||
for item in obj:
|
for item in self:
|
||||||
attachment = item.upload_model_file[0]
|
attachment = item.upload_model_file[0]
|
||||||
base64_data = base64.b64encode(attachment.datas)
|
base64_data = base64.b64encode(attachment.datas)
|
||||||
base64_datas = base64_data.decode('utf-8')
|
base64_datas = base64_data.decode('utf-8')
|
||||||
@@ -262,3 +266,45 @@ class QuickEasyOrder(models.Model):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
# self.cr.rollback()
|
# self.cr.rollback()
|
||||||
return UserError('工厂创建销售订单和产品失败,请联系管理员')
|
return UserError('工厂创建销售订单和产品失败,请联系管理员')
|
||||||
|
|
||||||
|
# 模型上色
|
||||||
|
|
||||||
|
def model_coloring(self):
|
||||||
|
url = '/api/library_of_models/create'
|
||||||
|
config = self.env['res.config.settings'].get_values()
|
||||||
|
config_header = Common.get_headers(self, config['token'], config['sf_secret_key'])
|
||||||
|
logging.info('order: %s' % self.name)
|
||||||
|
if self:
|
||||||
|
attachment = self.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()
|
||||||
|
logging.info('model_file-size: %s' % len(self.model_file))
|
||||||
|
logging.info('attachment.datas-size: %s' % len(attachment.datas))
|
||||||
|
vals = {
|
||||||
|
'programme_way': 'manual operation',
|
||||||
|
'model_code': model_code,
|
||||||
|
'model_data': base64.b64decode(attachment.datas),
|
||||||
|
'model_color_data': '',
|
||||||
|
'model_name': attachment.name,
|
||||||
|
'model_long': self.model_length,
|
||||||
|
'model_width': self.model_width,
|
||||||
|
'model_height': self.model_height,
|
||||||
|
'model_volume': self.model_volume,
|
||||||
|
'color_model_path': '/tmp/' + str(model_code) + ".step",
|
||||||
|
'model_order_no': self.name,
|
||||||
|
'remark': '订单号:%s 客户:%s' % (self.name, self.customer_id.name)
|
||||||
|
}
|
||||||
|
try:
|
||||||
|
ret = requests.post((config['sf_url'] + url), json={}, data=vals, headers=config_header,
|
||||||
|
timeout=60)
|
||||||
|
ret = ret.json()
|
||||||
|
# result = json.loads(ret['result'])
|
||||||
|
if ret['status'] == 1:
|
||||||
|
self.model_color_state = 'success'
|
||||||
|
else:
|
||||||
|
self.model_color_state = 'fail'
|
||||||
|
raise UserError(ret['message'])
|
||||||
|
except Exception as e:
|
||||||
|
self.model_color_state = 'fail'
|
||||||
|
raise UserError("模型上色失败")
|
||||||
Reference in New Issue
Block a user