Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/自建模块日志警告信息处理
# Conflicts: # sf_base/models/fixture.py # sf_manufacturing/models/model_type.py # sf_manufacturing/models/product_template.py # sf_sale/models/quick_easy_order.py
This commit is contained in:
@@ -179,3 +179,9 @@ class MrsProductionProcessParameter(models.Model):
|
||||
def get_gain_way(self, item):
|
||||
process_parameter = self.env['sf.production.process.parameter'].search([('id', '=', item.id)])
|
||||
return process_parameter
|
||||
|
||||
def _json_production_process_item_code(self, item):
|
||||
code_arr = []
|
||||
for i in item.parameter_ids:
|
||||
code_arr.append(i.code)
|
||||
return code_arr
|
||||
|
||||
@@ -34,16 +34,18 @@ class FixtureModel(models.Model):
|
||||
clamping_way = fields.Char(string="装夹方式")
|
||||
port_type = fields.Char(string="接口类型")
|
||||
model_file = fields.Binary(string="3D模型图")
|
||||
length = fields.Char(string="长度[mm]")
|
||||
width = fields.Char(string="宽度[mm]")
|
||||
height = fields.Char(string="高度[mm]")
|
||||
weight = fields.Char(string="重量[kg]")
|
||||
clamp_workpiece_length_max = fields.Integer(string="夹持工件长度MAX[mm]")
|
||||
clamp_workpiece_width_max = fields.Integer(string="夹持工件宽度MAX[mm]")
|
||||
clamp_workpiece_height_max = fields.Integer(string="夹持工件高度MAX[mm]")
|
||||
clamp_workpiece_diameter_max = fields.Float(string="夹持工件直径MAX[mm]")
|
||||
maximum_carrying_weight = fields.Float(string="最大承载重量[kg]")
|
||||
maximum_clamping_force = fields.Integer(string="最大夹持力[n]")
|
||||
|
||||
length = fields.Char(string="长度(mm)")
|
||||
width = fields.Char(string="宽度(mm)")
|
||||
height = fields.Char(string="高度(mm)")
|
||||
weight = fields.Char(string="重量(kg)")
|
||||
clamp_workpiece_length_max = fields.Integer(string="夹持工件长度max(mm)")
|
||||
clamp_workpiece_width_max = fields.Integer(string="夹持工件宽度max(mm)")
|
||||
clamp_workpiece_height_max = fields.Integer(string="夹持工件高度max(mm)")
|
||||
clamp_workpiece_diameter_max = fields.Float(string="夹持工件直径max(mm)")
|
||||
maximum_carrying_weight = fields.Float(string="最大承载重量(kg)")
|
||||
maximum_clamping_force = fields.Integer(string="最大夹持力(n)")
|
||||
|
||||
materials_model_id = fields.Many2one('sf.materials.model', string="材料型号")
|
||||
driving_way = fields.Selection([('气动', '气动'), ('液压', '液压'), ('机械', '机械')], string="驱动方式")
|
||||
apply_machine_tool_type_ids = fields.Many2many('sf.machine_tool.type', 'rel_fixture_model_machine_tool_type',
|
||||
|
||||
@@ -115,7 +115,7 @@
|
||||
<record model="ir.ui.view" id="sf_production_process_form">
|
||||
<field name="model">sf.production.process</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="表面工艺" create="0" edit="0" delete="1">
|
||||
<form string="表面工艺" create="0" edit="1" delete="1">
|
||||
<sheet>
|
||||
<div class="oe_title">
|
||||
<h1>
|
||||
|
||||
@@ -32,22 +32,26 @@ class ProductModelTypeRoutingSort(models.Model):
|
||||
sequence = fields.Integer('Sequence')
|
||||
route_workcenter_id = fields.Many2one('mrp.routing.workcenter')
|
||||
is_repeat = fields.Boolean('重复', related='route_workcenter_id.is_repeat')
|
||||
routing_type = fields.Selection([
|
||||
('获取CNC加工程序', '获取CNC加工程序'),
|
||||
('装夹', '装夹'),
|
||||
('前置三元定位检测', '前置三元定位检测'),
|
||||
('CNC加工', 'CNC加工'),
|
||||
('后置三元质量检测', '后置三元质量检测'),
|
||||
('解除装夹', '解除装夹'), ('切割', '切割'), ('表面工艺', '表面工艺')
|
||||
], string="工序类型", compute='_compute_route_workcenter_id')
|
||||
|
||||
@api.depends('route_workcenter_id')
|
||||
def _compute_route_workcenter_id(self):
|
||||
for record in self:
|
||||
if record:
|
||||
record.routing_type = record.route_workcenter_id.routing_type
|
||||
# routing_type = fields.Selection([
|
||||
# ('获取CNC加工程序', '获取CNC加工程序'),
|
||||
# ('装夹', '装夹'),
|
||||
# ('前置三元定位检测', '前置三元定位检测'),
|
||||
# ('CNC加工', 'CNC加工'),
|
||||
# ('后置三元质量检测', '后置三元质量检测'),
|
||||
# ('解除装夹', '解除装夹'), ('切割', '切割'), ('表面工艺', '表面工艺')
|
||||
# ], string="工序类型", compute='_compute_route_workcenter_id')
|
||||
#
|
||||
# @api.depends('route_workcenter_id')
|
||||
# def _compute_route_workcenter_id(self):
|
||||
# for record in self:
|
||||
# if record:
|
||||
# record.routing_type = record.route_workcenter_id.routing_type
|
||||
|
||||
|
||||
|
||||
routing_type = fields.Selection(string="工序类型", related='route_workcenter_id.routing_type')
|
||||
|
||||
workcenter_ids = fields.Many2many('mrp.workcenter', required=False, related='route_workcenter_id.workcenter_ids')
|
||||
product_model_type_id = fields.Many2one('sf.model.type')
|
||||
|
||||
@@ -63,20 +67,24 @@ class EmbryoModelTypeRoutingSort(models.Model):
|
||||
sequence = fields.Integer('Sequence')
|
||||
route_workcenter_id = fields.Many2one('mrp.routing.workcenter')
|
||||
is_repeat = fields.Boolean('重复', related='route_workcenter_id.is_repeat')
|
||||
routing_type = fields.Selection([
|
||||
('获取CNC加工程序', '获取CNC加工程序'),
|
||||
('装夹', '装夹'),
|
||||
('前置三元定位检测', '前置三元定位检测'),
|
||||
('CNC加工', 'CNC加工'),
|
||||
('后置三元质量检测', '后置三元质量检测'),
|
||||
('解除装夹', '解除装夹'), ('切割', '切割'), ('表面工艺', '表面工艺')
|
||||
], string="工序类型", compute='_compute_route_workcenter_id')
|
||||
|
||||
@api.depends('route_workcenter_id')
|
||||
def _compute_route_workcenter_id(self):
|
||||
for record in self:
|
||||
if record:
|
||||
record.routing_type = record.route_workcenter_id.routing_type
|
||||
# routing_type = fields.Selection([
|
||||
# ('获取CNC加工程序', '获取CNC加工程序'),
|
||||
# ('装夹', '装夹'),
|
||||
# ('前置三元定位检测', '前置三元定位检测'),
|
||||
# ('CNC加工', 'CNC加工'),
|
||||
# ('后置三元质量检测', '后置三元质量检测'),
|
||||
# ('解除装夹', '解除装夹'), ('切割', '切割'), ('表面工艺', '表面工艺')
|
||||
# ], string="工序类型", compute='_compute_route_workcenter_id')
|
||||
#
|
||||
# @api.depends('route_workcenter_id')
|
||||
# def _compute_route_workcenter_id(self):
|
||||
# for record in self:
|
||||
# if record:
|
||||
# record.routing_type = record.route_workcenter_id.routing_type
|
||||
|
||||
|
||||
routing_type = fields.Selection(string="工序类型", related='route_workcenter_id.routing_type')
|
||||
|
||||
workcenter_ids = fields.Many2many('mrp.workcenter', required=False, related='route_workcenter_id.workcenter_ids')
|
||||
embryo_model_type_id = fields.Many2one('sf.model.type')
|
||||
@@ -93,20 +101,24 @@ class SurfaceTechnicsModelTypeRoutingSort(models.Model):
|
||||
sequence = fields.Integer('Sequence')
|
||||
route_workcenter_id = fields.Many2one('mrp.routing.workcenter')
|
||||
is_repeat = fields.Boolean('重复', related='route_workcenter_id.is_repeat')
|
||||
routing_type = fields.Selection([
|
||||
('获取CNC加工程序', '获取CNC加工程序'),
|
||||
('装夹', '装夹'),
|
||||
('前置三元定位检测', '前置三元定位检测'),
|
||||
('CNC加工', 'CNC加工'),
|
||||
('后置三元质量检测', '后置三元质量检测'),
|
||||
('解除装夹', '解除装夹'), ('切割', '切割'), ('表面工艺', '表面工艺')
|
||||
], string="工序类型", compute='_compute_route_workcenter_id')
|
||||
|
||||
@api.depends('route_workcenter_id')
|
||||
def _compute_route_workcenter_id(self):
|
||||
for record in self:
|
||||
if record:
|
||||
record.routing_type = record.route_workcenter_id.routing_type
|
||||
# routing_type = fields.Selection([
|
||||
# ('获取CNC加工程序', '获取CNC加工程序'),
|
||||
# ('装夹', '装夹'),
|
||||
# ('前置三元定位检测', '前置三元定位检测'),
|
||||
# ('CNC加工', 'CNC加工'),
|
||||
# ('后置三元质量检测', '后置三元质量检测'),
|
||||
# ('解除装夹', '解除装夹'), ('切割', '切割'), ('表面工艺', '表面工艺')
|
||||
# ], string="工序类型", compute='_compute_route_workcenter_id')
|
||||
#
|
||||
# @api.depends('route_workcenter_id')
|
||||
# def _compute_route_workcenter_id(self):
|
||||
# for record in self:
|
||||
# if record:
|
||||
# record.routing_type = record.route_workcenter_id.routing_type
|
||||
|
||||
|
||||
routing_type = fields.Selection(string="工序类型", related='route_workcenter_id.routing_type')
|
||||
|
||||
workcenter_ids = fields.Many2many('mrp.workcenter', required=False, related='route_workcenter_id.workcenter_ids')
|
||||
surface_technics_model_type_id = fields.Many2one('sf.model.type')
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from odoo import models, fields, api
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.modules import get_resource_path
|
||||
# from OCC.Extend.DataExchange import read_step_file
|
||||
# from OCC.Extend.DataExchange import write_stl_file
|
||||
from OCC.Extend.DataExchange import read_step_file
|
||||
from OCC.Extend.DataExchange import write_stl_file
|
||||
import logging
|
||||
import base64
|
||||
import hashlib
|
||||
@@ -12,17 +12,21 @@ import os
|
||||
class ResProductMo(models.Model):
|
||||
_inherit = 'product.template'
|
||||
model_file = fields.Binary('模型文件')
|
||||
categ_type = fields.Selection(
|
||||
[("成品", "成品"), ("坯料", "坯料"), ("原材料", "原材料"), ("表面工艺", "表面工艺"), ("刀具", "刀具"),
|
||||
("夹具", "夹具")],
|
||||
string='产品的类别', compute='_compute_categ_id',
|
||||
store=True)
|
||||
|
||||
@api.depends('categ_id')
|
||||
def _compute_categ_id(self):
|
||||
for record in self:
|
||||
if record:
|
||||
record.categ_type = record.categ_id.type
|
||||
# categ_type = fields.Selection(
|
||||
# [("成品", "成品"), ("坯料", "坯料"), ("原材料", "原材料"), ("表面工艺", "表面工艺"), ("刀具", "刀具"),
|
||||
# ("夹具", "夹具")],
|
||||
# string='产品的类别', compute='_compute_categ_id',
|
||||
# store=True)
|
||||
#
|
||||
# @api.depends('categ_id')
|
||||
# def _compute_categ_id(self):
|
||||
# for record in self:
|
||||
# if record:
|
||||
# record.categ_type = record.categ_id.type
|
||||
|
||||
|
||||
categ_type = fields.Selection(string='产品的类别', related='categ_id.type', store=True)
|
||||
|
||||
model_name = fields.Char('模型名称')
|
||||
model_long = fields.Float('模型长(mm)', digits=(16, 3))
|
||||
@@ -67,7 +71,8 @@ class ResProductMo(models.Model):
|
||||
tool_width = fields.Integer('宽度(mm)')
|
||||
tool_height = fields.Integer('高度(mm)')
|
||||
tool_thickness = fields.Integer('厚度(mm)')
|
||||
tool_weight = fields.Float('重量(kg)', digits=(16, 3))
|
||||
tool_weight = fields.Float('重量(kg)')
|
||||
|
||||
coating_material = fields.Char('涂层材质')
|
||||
# 整体式刀具参数
|
||||
cutting_tool_total_length = fields.Float('总长度(mm)')
|
||||
@@ -145,10 +150,12 @@ class ResProductMo(models.Model):
|
||||
fixture_clamping_way = fields.Char(string="装夹方式")
|
||||
fixture_port_type = fields.Char(string="接口类型")
|
||||
fixture_model_file = fields.Binary(string="3D模型图")
|
||||
fixture_clamp_workpiece_length_max = fields.Integer(string="夹持工件长度MAX(mm)")
|
||||
fixture_clamp_workpiece_width_max = fields.Integer(string="夹持工件宽度MAX(mm)")
|
||||
fixture_clamp_workpiece_height_max = fields.Integer(string="夹持工件高度MAX(mm)")
|
||||
fixture_clamp_workpiece_diameter_max = fields.Float(string="夹持工件直径MAX(mm)", digits=(16, 6))
|
||||
|
||||
fixture_clamp_workpiece_length_max = fields.Integer(string="夹持工件长度max(mm)")
|
||||
fixture_clamp_workpiece_width_max = fields.Integer(string="夹持工件宽度max(mm)")
|
||||
fixture_clamp_workpiece_height_max = fields.Integer(string="夹持工件高度max(mm)")
|
||||
fixture_clamp_workpiece_diameter_max = fields.Float(string="夹持工件直径max(mm)", digits=(16, 6))
|
||||
|
||||
fixture_maximum_carrying_weight = fields.Float(string="最大承载重量(kg)", digits=(16, 4))
|
||||
fixture_maximum_clamping_force = fields.Integer(string="最大夹持力(n)")
|
||||
fixture_driving_way = fields.Char(string="驱动方式")
|
||||
@@ -426,7 +433,8 @@ class ResProductMo(models.Model):
|
||||
'materials_type_id': self.env['sf.materials.model'].search(
|
||||
[('materials_no', '=', item['texture_type_code'])]).id,
|
||||
# 'model_surface_process_ids': self.get_production_process_id(item['surface_process_code']),
|
||||
'model_process_parameters_ids': [(6, 0, [])] if not item.get('process_parameters_code') else self.get_process_parameters_id(item['process_parameters_code']),
|
||||
'model_process_parameters_ids': [(6, 0, [])] if not item.get(
|
||||
'process_parameters_code') else self.get_process_parameters_id(item['process_parameters_code']),
|
||||
'model_remark': item['remark'],
|
||||
'default_code': '%s-%s' % (order_number, i),
|
||||
# 'barcode': item['barcode'],
|
||||
@@ -558,20 +566,20 @@ class ResProductMo(models.Model):
|
||||
item.model_file = self.transition_glb_file(report_path, model_code)
|
||||
|
||||
# 将attach的datas内容转为glb文件
|
||||
# def transition_glb_file(self, report_path, code):
|
||||
# shapes = read_step_file(report_path)
|
||||
# output_file = os.path.join('/tmp', str(code) + '.stl')
|
||||
# write_stl_file(shapes, output_file, 'binary', 0.03, 0.5)
|
||||
# # 转化为glb
|
||||
# output_glb_file = os.path.join('/tmp', str(code) + '.glb')
|
||||
# util_path = get_resource_path('sf_dlm', 'static/util')
|
||||
# cmd = 'python3 %s/stl2gltf.py %s %s -b' % (util_path, output_file, output_glb_file)
|
||||
# os.system(cmd)
|
||||
# # 转base64
|
||||
# with open(output_glb_file, 'rb') as fileObj:
|
||||
# image_data = fileObj.read()
|
||||
# base64_data = base64.b64encode(image_data)
|
||||
# return base64_data
|
||||
def transition_glb_file(self, report_path, code):
|
||||
shapes = read_step_file(report_path)
|
||||
output_file = os.path.join('/tmp', str(code) + '.stl')
|
||||
write_stl_file(shapes, output_file, 'binary', 0.03, 0.5)
|
||||
# 转化为glb
|
||||
output_glb_file = os.path.join('/tmp', str(code) + '.glb')
|
||||
util_path = get_resource_path('sf_dlm', 'static/util')
|
||||
cmd = 'python3 %s/stl2gltf.py %s %s -b' % (util_path, output_file, output_glb_file)
|
||||
os.system(cmd)
|
||||
# 转base64
|
||||
with open(output_glb_file, 'rb') as fileObj:
|
||||
image_data = fileObj.read()
|
||||
base64_data = base64.b64encode(image_data)
|
||||
return base64_data
|
||||
|
||||
|
||||
class ResMrpBomMo(models.Model):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from odoo import models, fields, api
|
||||
from odoo.modules import get_resource_path
|
||||
# from OCC.Extend.DataExchange import read_step_file
|
||||
# from OCC.Extend.DataExchange import write_stl_file
|
||||
from OCC.Extend.DataExchange import read_step_file
|
||||
from OCC.Extend.DataExchange import write_stl_file
|
||||
from odoo.exceptions import ValidationError, UserError
|
||||
from odoo.addons.sf_base.commons.common import Common
|
||||
from datetime import datetime
|
||||
@@ -32,8 +32,8 @@ class QuickEasyOrder(models.Model):
|
||||
('0.01', '±0.01mm')], string='加工精度', default='0.10')
|
||||
material_id = fields.Many2one('sf.production.materials', '材料', compute='_compute_material_model', store=True)
|
||||
material_model_id = fields.Many2one('sf.materials.model', '型号', compute='_compute_material_model', store=True)
|
||||
process_id = fields.Many2one('sf.production.process', string='表面工艺')
|
||||
parameter_ids = fields.One2many('sf.production.process.parameter', 'process_id', string='可选参数')
|
||||
# process_id = fields.Many2one('sf.production.process', string='表面工艺')
|
||||
parameter_ids = fields.Many2many('sf.production.process.parameter', 'process_item_order_rel', string='可选参数')
|
||||
quantity = fields.Integer('数量', default=1)
|
||||
unit_price = fields.Float('单价')
|
||||
price = fields.Float('总价')
|
||||
@@ -49,6 +49,11 @@ class QuickEasyOrder(models.Model):
|
||||
('success', '成功'),
|
||||
('fail', '失败')], string='模型上色状态')
|
||||
|
||||
@api.depends('unit_price', 'quantity')
|
||||
def _compute_total_amount(self):
|
||||
for item in self:
|
||||
item.price = item.unit_price * item.quantity
|
||||
|
||||
@api.depends('material_id', 'material_model_id')
|
||||
def _compute_material_model(self):
|
||||
for item in self:
|
||||
@@ -75,27 +80,28 @@ class QuickEasyOrder(models.Model):
|
||||
logging.info('create-model_file:%s' % len(vals['model_file']))
|
||||
|
||||
obj = super(QuickEasyOrder, self).create(vals)
|
||||
self.model_coloring()
|
||||
self.model_coloring(obj)
|
||||
self.distribute_to_factory(obj)
|
||||
return obj
|
||||
|
||||
# 将attach的datas内容转为glb文件
|
||||
# def transition_glb_file(self, report_path, model_code):
|
||||
# shapes = read_step_file(report_path)
|
||||
# #output_file = os.path.join('C:/Users/43484/Desktop/机企猫工作文档', str(model_code) + '.stl')
|
||||
# output_file = os.path.join('/tmp', str(model_code) + '.stl')
|
||||
# write_stl_file(shapes, output_file, 'binary', 0.03, 0.5)
|
||||
# # 转化为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')
|
||||
# util_path = get_resource_path('sf_dlm', 'static/util')
|
||||
# cmd = 'python3 %s/stl2gltf.py %s %s -b' % (util_path, output_file, output_glb_file)
|
||||
# os.system(cmd)
|
||||
# # 转base64
|
||||
# with open(output_glb_file, 'rb') as fileObj:
|
||||
# image_data = fileObj.read()
|
||||
# base64_data = base64.b64encode(image_data)
|
||||
# return base64_data
|
||||
def transition_glb_file(self, report_path, model_code):
|
||||
shapes = read_step_file(report_path)
|
||||
# output_file = os.path.join('C:/Users/43484/Desktop/机企猫工作文档', str(model_code) + '.stl')
|
||||
output_file = os.path.join('/tmp', str(model_code) + '.stl')
|
||||
write_stl_file(shapes, output_file, 'binary', 0.03, 0.5)
|
||||
# 转化为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')
|
||||
util_path = get_resource_path('sf_dlm', 'static/util')
|
||||
cmd = 'python3 %s/stl2gltf.py %s %s -b' % (util_path, output_file, output_glb_file)
|
||||
os.system(cmd)
|
||||
# 转base64
|
||||
with open(output_glb_file, 'rb') as fileObj:
|
||||
image_data = fileObj.read()
|
||||
base64_data = base64.b64encode(image_data)
|
||||
return base64_data
|
||||
|
||||
# return False
|
||||
|
||||
@api.onchange('upload_model_file')
|
||||
@@ -137,62 +143,106 @@ class QuickEasyOrder(models.Model):
|
||||
派单到工厂
|
||||
:return:
|
||||
"""
|
||||
web_base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url', default='')
|
||||
logging.info("web_base_url: %s" % web_base_url)
|
||||
url = '/api/bfm_process_order/list'
|
||||
res = {'order_number': obj.name, 'delivery_end_date': str(datetime.now()),
|
||||
'delivery_name': 'XXXXX', 'delivery_telephone': 'XXXXX',
|
||||
'delivery_address': 'XXXXX',
|
||||
'bfm_process_order_list': []}
|
||||
factory = self.env['res.partner'].sudo().search([], limit=1, order='id desc')
|
||||
config_header = Common.get_headers(self, factory.sf_token, factory.sf_secret_key)
|
||||
for item in obj:
|
||||
attachment = item.upload_model_file[0]
|
||||
base64_data = base64.b64encode(attachment.datas)
|
||||
base64_datas = base64_data.decode('utf-8')
|
||||
barcode = hashlib.sha1(base64_datas.encode('utf-8')).hexdigest()
|
||||
logging.info('model_file-size: %s' % len(item.model_file))
|
||||
val = {
|
||||
'model_long': item.model_length,
|
||||
'model_width': item.model_width,
|
||||
'model_height': item.model_height,
|
||||
'model_volume': item.model_volume,
|
||||
'model_machining_precision': item.machining_precision,
|
||||
'model_name': attachment.name,
|
||||
'model_data': base64_datas,
|
||||
'model_file': base64.b64encode(item.model_file).decode('utf-8'),
|
||||
'texture_code': item.material_id.materials_no,
|
||||
'texture_type_code': item.material_model_id.materials_no,
|
||||
# 'surface_process_code': self.env['jikimo.surface.process']._json_surface_process_code(item),
|
||||
# 'process_parameters_code': self.env['jikimo.surface.process.item']._json_surface_process_item_code(
|
||||
# item),
|
||||
'price': item.price,
|
||||
'number': item.quantity,
|
||||
'total_amount': item.price,
|
||||
'remark': '',
|
||||
'barcode': barcode
|
||||
}
|
||||
res['bfm_process_order_list'].append(val)
|
||||
res['bfm_process_order_list'] = json.dumps(res['bfm_process_order_list'])
|
||||
try:
|
||||
ret = requests.post((web_base_url[0] + url), json={}, data=res,
|
||||
headers=config_header)
|
||||
ret = ret.json()
|
||||
if ret['status'] == 1:
|
||||
self.write(
|
||||
{'state': '待接单'})
|
||||
else:
|
||||
raise UserError(ret['message'])
|
||||
res = {'bfm_process_order_list': []}
|
||||
for item in obj:
|
||||
attachment = item.upload_model_file[0]
|
||||
base64_data = base64.b64encode(attachment.datas)
|
||||
base64_datas = base64_data.decode('utf-8')
|
||||
barcode = hashlib.sha1(base64_datas.encode('utf-8')).hexdigest()
|
||||
logging.info('model_file-size: %s' % len(item.model_file))
|
||||
res['bfm_process_order_list'].append({
|
||||
'model_long': item.model_length,
|
||||
'model_width': item.model_width,
|
||||
'model_height': item.model_height,
|
||||
'model_volume': item.model_volume,
|
||||
'model_machining_precision': item.machining_precision,
|
||||
'model_name': attachment.name,
|
||||
'model_data': base64_datas,
|
||||
'model_file': base64.b64encode(item.model_file).decode('utf-8'),
|
||||
'texture_code': item.material_id.materials_no,
|
||||
'texture_type_code': item.material_model_id.materials_no,
|
||||
# 'surface_process_code': self.env['jikimo.surface.process']._json_surface_process_code(item),
|
||||
'process_parameters_code': self.env[
|
||||
'sf.production.process.parameter']._json_production_process_item_code(
|
||||
item),
|
||||
'price': item.price,
|
||||
'number': item.quantity,
|
||||
'total_amount': item.price,
|
||||
'remark': '',
|
||||
'barcode': barcode
|
||||
})
|
||||
# res['bfm_process_order_list'] = json.dumps(res['bfm_process_order_list'])
|
||||
product_id = self.env.ref('sf_dlm.product_template_sf').sudo()
|
||||
self_machining_id = self.env.ref('sf_dlm.product_embryo_sf_self_machining').sudo()
|
||||
outsource_id = self.env.ref('sf_dlm.product_embryo_sf_outsource').sudo()
|
||||
purchase_id = self.env.ref('sf_dlm.product_embryo_sf_purchase').sudo()
|
||||
company_id = self.env.ref('base.main_company').sudo()
|
||||
# user_id = request.env.ref('base.user_admin').sudo()
|
||||
order_id = self.env['sale.order'].sale_order_create(company_id, 'XXXXX', 'XXXXX', 'XXXXX',
|
||||
str(datetime.now()))
|
||||
i = 1
|
||||
# 给sale_order的default_code字段赋值
|
||||
aa = self.env['sale.order'].sudo().search([('name', '=', order_id.name)])
|
||||
aa.default_code = obj.name
|
||||
for item in res['bfm_process_order_list']:
|
||||
product = self.env['product.template'].sudo().product_create(product_id, item, order_id,
|
||||
obj.name, i)
|
||||
bom_data = self.env['mrp.bom'].get_bom(product)
|
||||
logging.info('bom_data:%s' % bom_data)
|
||||
if bom_data:
|
||||
bom = self.env['mrp.bom'].bom_create(product, 'normal', False)
|
||||
bom.bom_create_line_has(bom_data)
|
||||
else:
|
||||
if product.materials_type_id.gain_way == '自加工':
|
||||
# 创建坯料
|
||||
self_machining_embryo = self.env['product.template'].sudo().no_bom_product_create(
|
||||
self_machining_id,
|
||||
item, order_id,
|
||||
'self_machining',
|
||||
i)
|
||||
# 创建坯料的bom
|
||||
self_machining_bom = self.env['mrp.bom'].bom_create(self_machining_embryo, 'normal', False)
|
||||
# 创建坯料里bom的组件
|
||||
self_machining_bom_line = self_machining_bom.bom_create_line(self_machining_embryo)
|
||||
if self_machining_bom_line == False:
|
||||
self.cr.rollback()
|
||||
return UserError('该订单模型的材料型号在您分配的工厂里暂未有原材料,请先配置再进行分配')
|
||||
# 产品配置bom
|
||||
product_bom_self_machining = self.env['mrp.bom'].bom_create(product, 'normal', False)
|
||||
product_bom_self_machining.bom_create_line_has(self_machining_embryo)
|
||||
elif product.materials_type_id.gain_way == '外协':
|
||||
# 创建坯料
|
||||
outsource_embryo = self.env['product.template'].sudo().no_bom_product_create(outsource_id, item,
|
||||
order_id,
|
||||
'subcontract', i)
|
||||
# 创建坯料的bom
|
||||
outsource_bom = self.env['mrp.bom'].bom_create(outsource_embryo, 'subcontract', True)
|
||||
# 创建坯料的bom的组件
|
||||
outsource_bom_line = outsource_bom.with_user(
|
||||
self.env.ref("base.user_admin")).bom_create_line(outsource_embryo)
|
||||
if outsource_bom_line == False:
|
||||
self.cr.rollback()
|
||||
return UserError('该订单模型的材料型号在您分配的工厂里暂未有原材料,请先配置再进行分配')
|
||||
# 产品配置bom
|
||||
product_bom_outsource = self.env['mrp.bom'].bom_create(product, 'normal', False)
|
||||
product_bom_outsource.bom_create_line_has(outsource_embryo)
|
||||
elif product.materials_type_id.gain_way == '采购':
|
||||
purchase_embryo = self.env['product.template'].sudo().no_bom_product_create(purchase_id, item,
|
||||
order_id,
|
||||
'purchase', i)
|
||||
# 产品配置bom
|
||||
product_bom_purchase = self.env['mrp.bom'].bom_create(product, 'normal', False)
|
||||
product_bom_purchase.bom_create_line_has(purchase_embryo)
|
||||
order_id.with_user(self.env.ref("base.user_admin")).sale_order_create_line(product, item)
|
||||
except Exception as e:
|
||||
if ret['status'] != 1:
|
||||
raise UserError(e)
|
||||
else:
|
||||
raise UserError("分配工厂失败,请联系管理员")
|
||||
self.cr.rollback()
|
||||
return UserError('工厂创建销售订单和产品失败,请联系管理员')
|
||||
|
||||
# 特征识别
|
||||
|
||||
# 特征识别
|
||||
def feature_recognition(self, report_path, model_code):
|
||||
feature_path = self.env['sf.auto_quatotion.common'].sudo().get_feature_full_path()
|
||||
# price_path = self.env['jikimo.auto_quatotion.common'].get_price_full_path()
|
||||
process_time_db_path = self.env['sf.auto_quatotion.common'].sudo().get_process_time_db_path()
|
||||
ret = self.env['sf.auto_quatotion.common'].sudo().get_auto_quatotion(report_path, feature_path,
|
||||
process_time_db_path,
|
||||
@@ -200,11 +250,10 @@ class QuickEasyOrder(models.Model):
|
||||
return ret
|
||||
|
||||
# 模型上色
|
||||
def model_coloring(self):
|
||||
def model_coloring(self, order):
|
||||
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'])
|
||||
order = self.search([('id', '=', self.id)])
|
||||
logging.info('order: %s' % order.name)
|
||||
if order:
|
||||
attachment = order.upload_model_file[0]
|
||||
@@ -252,11 +301,13 @@ class QuickEasyOrder(models.Model):
|
||||
vals['accuracy'] = order.machining_precision
|
||||
vals['number'] = order.quantity
|
||||
vals['process_code'] = 0
|
||||
vals['texture_code'] = order.material_model_id.code
|
||||
vals['texture_code'] = order.material_model_id.materials_no
|
||||
vals['delivery_days'] = 15
|
||||
if order.model_file:
|
||||
attachment = self.env['ir.attachment'].sudo().search(
|
||||
[('id', '=', order.upload_model_file[0])])
|
||||
for item in order.upload_model_file:
|
||||
if item.ids[0]:
|
||||
logging.info('create-attachment:%s' % int(item.ids[0]))
|
||||
attachment = self.env['ir.attachment'].sudo().search([('id', '=', int(item.ids[0]))])
|
||||
vals['attachment_id'] = attachment.id
|
||||
else:
|
||||
vals['attachment_id'] = ''
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_quick_easy_order,quick_easy_order,model_quick_easy_order,base.group_user,1,1,1,1
|
||||
access_sf_auto_quatotion_common,sf_auto_quatotion_common,model_sf_auto_quatotion_common,base.group_user,1,1,1,1
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -19,7 +19,7 @@
|
||||
<field optional="show" name="customer_id" string="客户"/>
|
||||
<field optional="show" name="material_id"/>
|
||||
<field optional="show" name="material_model_id"/>
|
||||
<field optional="show" name="process_id"/>
|
||||
<field optional="show" name="parameter_ids"/>
|
||||
<field optional="show" name="quantity"/>
|
||||
<field optional="show" name="price"/>
|
||||
<field optional="hide" name="delivery_time"/>
|
||||
@@ -41,8 +41,8 @@
|
||||
<field name="customer_id" readonly="1" force_save="1"/>
|
||||
<field name="material_id"/>
|
||||
<field name="material_model_id"/>
|
||||
<field name="process_id"/>
|
||||
<field name="parameter_ids" widget="many2many_tags"/>
|
||||
<!-- <field name="process_id"/>-->
|
||||
<field name="parameter_ids" widget="many2many_tags" string="表面工艺参数"/>
|
||||
<field name="machining_precision"/>
|
||||
<field name="quantity"/>
|
||||
<field name="unit_price"/>
|
||||
|
||||
@@ -13,7 +13,7 @@ class FunctionalCuttingToolEntity(models.Model):
|
||||
_description = '功能刀具列表'
|
||||
|
||||
code = fields.Char('编码')
|
||||
name = fields.Char('名称')
|
||||
name = fields.Char('名称', required=True, size=20)
|
||||
mrs_cutting_tool_model_id = fields.Many2one('sf.cutting.tool.model', string='刀具型号')
|
||||
mrs_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型',
|
||||
group_expand='_read_group_mrs_cutting_tool_type_id', compute_sudo=True)
|
||||
|
||||
@@ -29,12 +29,12 @@
|
||||
<sheet>
|
||||
<div class="oe_title">
|
||||
<h1>
|
||||
<field name="name" invisible="False"/>
|
||||
<field name="name" invisible="False" placeholder="请输入20字以内的名称"/>
|
||||
</h1>
|
||||
</div>
|
||||
<group>
|
||||
<group>
|
||||
<field name="code" readonly="1"/>
|
||||
<field name="code" readonly="1" nolabel="True"/>
|
||||
<field name="mrs_cutting_tool_type_id"/>
|
||||
|
||||
<field name="mrs_cutting_tool_integral_model_ids"
|
||||
|
||||
@@ -19,5 +19,6 @@
|
||||
'web.assets_backend': [
|
||||
'web_widget_model_viewer/static/src/js/*',
|
||||
],
|
||||
}
|
||||
},
|
||||
'license': 'LGPL-3',
|
||||
}
|
||||
Reference in New Issue
Block a user