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:
yuxianghui
2023-08-29 11:21:13 +08:00
11 changed files with 247 additions and 166 deletions

View File

@@ -179,3 +179,9 @@ class MrsProductionProcessParameter(models.Model):
def get_gain_way(self, item): def get_gain_way(self, item):
process_parameter = self.env['sf.production.process.parameter'].search([('id', '=', item.id)]) process_parameter = self.env['sf.production.process.parameter'].search([('id', '=', item.id)])
return process_parameter 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

View File

@@ -34,16 +34,18 @@ class FixtureModel(models.Model):
clamping_way = fields.Char(string="装夹方式") clamping_way = fields.Char(string="装夹方式")
port_type = fields.Char(string="接口类型") port_type = fields.Char(string="接口类型")
model_file = fields.Binary(string="3D模型图") model_file = fields.Binary(string="3D模型图")
length = fields.Char(string="长度[mm]")
width = fields.Char(string="宽度[mm]") length = fields.Char(string="长度(mm)")
height = fields.Char(string="高度[mm]") width = fields.Char(string="宽度(mm)")
weight = fields.Char(string="重量[kg]") height = fields.Char(string="高度(mm)")
clamp_workpiece_length_max = fields.Integer(string="夹持工件长度MAX[mm]") weight = fields.Char(string="重量(kg)")
clamp_workpiece_width_max = fields.Integer(string="夹持工件宽度MAX[mm]") clamp_workpiece_length_max = fields.Integer(string="夹持工件长度max(mm)")
clamp_workpiece_height_max = fields.Integer(string="夹持工件高度MAX[mm]") clamp_workpiece_width_max = fields.Integer(string="夹持工件宽度max(mm)")
clamp_workpiece_diameter_max = fields.Float(string="夹持工件直径MAX[mm]") clamp_workpiece_height_max = fields.Integer(string="夹持工件高度max(mm)")
maximum_carrying_weight = fields.Float(string="最大承载重量[kg]") clamp_workpiece_diameter_max = fields.Float(string="夹持工件直径max(mm)")
maximum_clamping_force = fields.Integer(string="最大夹持力[n]") maximum_carrying_weight = fields.Float(string="最大承载重量(kg)")
maximum_clamping_force = fields.Integer(string="最大夹持力(n)")
materials_model_id = fields.Many2one('sf.materials.model', string="材料型号") materials_model_id = fields.Many2one('sf.materials.model', string="材料型号")
driving_way = fields.Selection([('气动', '气动'), ('液压', '液压'), ('机械', '机械')], string="驱动方式") driving_way = fields.Selection([('气动', '气动'), ('液压', '液压'), ('机械', '机械')], string="驱动方式")
apply_machine_tool_type_ids = fields.Many2many('sf.machine_tool.type', 'rel_fixture_model_machine_tool_type', apply_machine_tool_type_ids = fields.Many2many('sf.machine_tool.type', 'rel_fixture_model_machine_tool_type',

View File

@@ -115,7 +115,7 @@
<record model="ir.ui.view" id="sf_production_process_form"> <record model="ir.ui.view" id="sf_production_process_form">
<field name="model">sf.production.process</field> <field name="model">sf.production.process</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="表面工艺" create="0" edit="0" delete="1"> <form string="表面工艺" create="0" edit="1" delete="1">
<sheet> <sheet>
<div class="oe_title"> <div class="oe_title">
<h1> <h1>

View File

@@ -32,22 +32,26 @@ class ProductModelTypeRoutingSort(models.Model):
sequence = fields.Integer('Sequence') sequence = fields.Integer('Sequence')
route_workcenter_id = fields.Many2one('mrp.routing.workcenter') route_workcenter_id = fields.Many2one('mrp.routing.workcenter')
is_repeat = fields.Boolean('重复', related='route_workcenter_id.is_repeat') 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') # routing_type = fields.Selection([
def _compute_route_workcenter_id(self): # ('获取CNC加工程序', '获取CNC加工程序'),
for record in self: # ('装夹', '装夹'),
if record: # ('前置三元定位检测', '前置三元定位检测'),
record.routing_type = record.route_workcenter_id.routing_type # ('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') workcenter_ids = fields.Many2many('mrp.workcenter', required=False, related='route_workcenter_id.workcenter_ids')
product_model_type_id = fields.Many2one('sf.model.type') product_model_type_id = fields.Many2one('sf.model.type')
@@ -63,20 +67,24 @@ class EmbryoModelTypeRoutingSort(models.Model):
sequence = fields.Integer('Sequence') sequence = fields.Integer('Sequence')
route_workcenter_id = fields.Many2one('mrp.routing.workcenter') route_workcenter_id = fields.Many2one('mrp.routing.workcenter')
is_repeat = fields.Boolean('重复', related='route_workcenter_id.is_repeat') 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') # routing_type = fields.Selection([
def _compute_route_workcenter_id(self): # ('获取CNC加工程序', '获取CNC加工程序'),
for record in self: # ('装夹', '装夹'),
if record: # ('前置三元定位检测', '前置三元定位检测'),
record.routing_type = record.route_workcenter_id.routing_type # ('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') workcenter_ids = fields.Many2many('mrp.workcenter', required=False, related='route_workcenter_id.workcenter_ids')
embryo_model_type_id = fields.Many2one('sf.model.type') embryo_model_type_id = fields.Many2one('sf.model.type')
@@ -93,20 +101,24 @@ class SurfaceTechnicsModelTypeRoutingSort(models.Model):
sequence = fields.Integer('Sequence') sequence = fields.Integer('Sequence')
route_workcenter_id = fields.Many2one('mrp.routing.workcenter') route_workcenter_id = fields.Many2one('mrp.routing.workcenter')
is_repeat = fields.Boolean('重复', related='route_workcenter_id.is_repeat') 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') # routing_type = fields.Selection([
def _compute_route_workcenter_id(self): # ('获取CNC加工程序', '获取CNC加工程序'),
for record in self: # ('装夹', '装夹'),
if record: # ('前置三元定位检测', '前置三元定位检测'),
record.routing_type = record.route_workcenter_id.routing_type # ('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') workcenter_ids = fields.Many2many('mrp.workcenter', required=False, related='route_workcenter_id.workcenter_ids')
surface_technics_model_type_id = fields.Many2one('sf.model.type') surface_technics_model_type_id = fields.Many2one('sf.model.type')

View File

@@ -1,8 +1,8 @@
from odoo import models, fields, api from odoo import models, fields, api
from odoo.exceptions import ValidationError from odoo.exceptions import ValidationError
from odoo.modules import get_resource_path from odoo.modules import get_resource_path
# 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
import logging import logging
import base64 import base64
import hashlib import hashlib
@@ -12,17 +12,21 @@ import os
class ResProductMo(models.Model): class ResProductMo(models.Model):
_inherit = 'product.template' _inherit = 'product.template'
model_file = fields.Binary('模型文件') model_file = fields.Binary('模型文件')
categ_type = fields.Selection(
[("成品", "成品"), ("坯料", "坯料"), ("原材料", "原材料"), ("表面工艺", "表面工艺"), ("刀具", "刀具"),
("夹具", "夹具")],
string='产品的类别', compute='_compute_categ_id',
store=True)
@api.depends('categ_id') # categ_type = fields.Selection(
def _compute_categ_id(self): # [("成品", "成品"), ("坯料", "坯料"), ("原材料", "原材料"), ("表面工艺", "表面工艺"), ("刀具", "刀具"),
for record in self: # ("夹具", "夹具")],
if record: # string='产品的类别', compute='_compute_categ_id',
record.categ_type = record.categ_id.type # 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_name = fields.Char('模型名称')
model_long = fields.Float('模型长(mm)', digits=(16, 3)) model_long = fields.Float('模型长(mm)', digits=(16, 3))
@@ -67,7 +71,8 @@ class ResProductMo(models.Model):
tool_width = fields.Integer('宽度(mm)') tool_width = fields.Integer('宽度(mm)')
tool_height = fields.Integer('高度(mm)') tool_height = fields.Integer('高度(mm)')
tool_thickness = 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('涂层材质') coating_material = fields.Char('涂层材质')
# 整体式刀具参数 # 整体式刀具参数
cutting_tool_total_length = fields.Float('总长度(mm)') cutting_tool_total_length = fields.Float('总长度(mm)')
@@ -145,10 +150,12 @@ class ResProductMo(models.Model):
fixture_clamping_way = fields.Char(string="装夹方式") fixture_clamping_way = fields.Char(string="装夹方式")
fixture_port_type = fields.Char(string="接口类型") fixture_port_type = fields.Char(string="接口类型")
fixture_model_file = fields.Binary(string="3D模型图") 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_length_max = fields.Integer(string="夹持工件长度max(mm)")
fixture_clamp_workpiece_height_max = fields.Integer(string="夹持工件高度MAX(mm)") fixture_clamp_workpiece_width_max = fields.Integer(string="夹持工件宽度max(mm)")
fixture_clamp_workpiece_diameter_max = fields.Float(string="夹持工件直径MAX(mm)", digits=(16, 6)) 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_carrying_weight = fields.Float(string="最大承载重量(kg)", digits=(16, 4))
fixture_maximum_clamping_force = fields.Integer(string="最大夹持力(n)") fixture_maximum_clamping_force = fields.Integer(string="最大夹持力(n)")
fixture_driving_way = fields.Char(string="驱动方式") fixture_driving_way = fields.Char(string="驱动方式")
@@ -426,7 +433,8 @@ class ResProductMo(models.Model):
'materials_type_id': self.env['sf.materials.model'].search( 'materials_type_id': self.env['sf.materials.model'].search(
[('materials_no', '=', item['texture_type_code'])]).id, [('materials_no', '=', item['texture_type_code'])]).id,
# 'model_surface_process_ids': self.get_production_process_id(item['surface_process_code']), # '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'], 'model_remark': item['remark'],
'default_code': '%s-%s' % (order_number, i), 'default_code': '%s-%s' % (order_number, i),
# 'barcode': item['barcode'], # 'barcode': item['barcode'],
@@ -558,20 +566,20 @@ class ResProductMo(models.Model):
item.model_file = self.transition_glb_file(report_path, model_code) item.model_file = self.transition_glb_file(report_path, model_code)
# 将attach的datas内容转为glb文件 # 将attach的datas内容转为glb文件
# def transition_glb_file(self, report_path, code): def transition_glb_file(self, report_path, code):
# shapes = read_step_file(report_path) shapes = read_step_file(report_path)
# output_file = os.path.join('/tmp', str(code) + '.stl') output_file = os.path.join('/tmp', str(code) + '.stl')
# 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('/tmp', str(code) + '.glb') output_glb_file = os.path.join('/tmp', str(code) + '.glb')
# util_path = get_resource_path('sf_dlm', 'static/util') util_path = get_resource_path('sf_dlm', '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)
# os.system(cmd) os.system(cmd)
# # 转base64 # 转base64
# with open(output_glb_file, 'rb') as fileObj: with open(output_glb_file, 'rb') as fileObj:
# image_data = fileObj.read() image_data = fileObj.read()
# base64_data = base64.b64encode(image_data) base64_data = base64.b64encode(image_data)
# return base64_data return base64_data
class ResMrpBomMo(models.Model): class ResMrpBomMo(models.Model):

View File

@@ -1,7 +1,7 @@
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 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.exceptions import ValidationError, UserError from odoo.exceptions import ValidationError, UserError
from odoo.addons.sf_base.commons.common import Common from odoo.addons.sf_base.commons.common import Common
from datetime import datetime from datetime import datetime
@@ -32,8 +32,8 @@ class QuickEasyOrder(models.Model):
('0.01', '±0.01mm')], string='加工精度', default='0.10') ('0.01', '±0.01mm')], string='加工精度', default='0.10')
material_id = fields.Many2one('sf.production.materials', '材料', compute='_compute_material_model', store=True) 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) material_model_id = fields.Many2one('sf.materials.model', '型号', compute='_compute_material_model', store=True)
process_id = fields.Many2one('sf.production.process', string='表面工艺') # process_id = fields.Many2one('sf.production.process', string='表面工艺')
parameter_ids = fields.One2many('sf.production.process.parameter', 'process_id', string='可选参数') parameter_ids = fields.Many2many('sf.production.process.parameter', 'process_item_order_rel', string='可选参数')
quantity = fields.Integer('数量', default=1) quantity = fields.Integer('数量', default=1)
unit_price = fields.Float('单价') unit_price = fields.Float('单价')
price = fields.Float('总价') price = fields.Float('总价')
@@ -49,6 +49,11 @@ class QuickEasyOrder(models.Model):
('success', '成功'), ('success', '成功'),
('fail', '失败')], string='模型上色状态') ('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') @api.depends('material_id', 'material_model_id')
def _compute_material_model(self): def _compute_material_model(self):
for item in self: for item in self:
@@ -75,27 +80,28 @@ class QuickEasyOrder(models.Model):
logging.info('create-model_file:%s' % len(vals['model_file'])) logging.info('create-model_file:%s' % len(vals['model_file']))
obj = super(QuickEasyOrder, self).create(vals) obj = super(QuickEasyOrder, self).create(vals)
self.model_coloring() self.model_coloring(obj)
self.distribute_to_factory(obj) self.distribute_to_factory(obj)
return obj return obj
# 将attach的datas内容转为glb文件 # 将attach的datas内容转为glb文件
# def transition_glb_file(self, report_path, model_code): def transition_glb_file(self, report_path, model_code):
# shapes = read_step_file(report_path) shapes = read_step_file(report_path)
# #output_file = os.path.join('C:/Users/43484/Desktop/机企猫工作文档', str(model_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')
# 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(model_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_dlm', 'static/util') util_path = get_resource_path('sf_dlm', '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)
# os.system(cmd) os.system(cmd)
# # 转base64 # 转base64
# with open(output_glb_file, 'rb') as fileObj: with open(output_glb_file, 'rb') as fileObj:
# image_data = fileObj.read() image_data = fileObj.read()
# base64_data = base64.b64encode(image_data) base64_data = base64.b64encode(image_data)
# return base64_data return base64_data
# return False # return False
@api.onchange('upload_model_file') @api.onchange('upload_model_file')
@@ -137,22 +143,15 @@ class QuickEasyOrder(models.Model):
派单到工厂 派单到工厂
:return: :return:
""" """
web_base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url', default='') try:
logging.info("web_base_url: %s" % web_base_url) res = {'bfm_process_order_list': []}
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: for item in obj:
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')
barcode = hashlib.sha1(base64_datas.encode('utf-8')).hexdigest() barcode = hashlib.sha1(base64_datas.encode('utf-8')).hexdigest()
logging.info('model_file-size: %s' % len(item.model_file)) logging.info('model_file-size: %s' % len(item.model_file))
val = { res['bfm_process_order_list'].append({
'model_long': item.model_length, 'model_long': item.model_length,
'model_width': item.model_width, 'model_width': item.model_width,
'model_height': item.model_height, 'model_height': item.model_height,
@@ -164,35 +163,86 @@ class QuickEasyOrder(models.Model):
'texture_code': item.material_id.materials_no, 'texture_code': item.material_id.materials_no,
'texture_type_code': item.material_model_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), # '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( 'process_parameters_code': self.env[
# item), 'sf.production.process.parameter']._json_production_process_item_code(
item),
'price': item.price, 'price': item.price,
'number': item.quantity, 'number': item.quantity,
'total_amount': item.price, 'total_amount': item.price,
'remark': '', 'remark': '',
'barcode': barcode 'barcode': barcode
} })
res['bfm_process_order_list'].append(val) # res['bfm_process_order_list'] = json.dumps(res['bfm_process_order_list'])
res['bfm_process_order_list'] = json.dumps(res['bfm_process_order_list']) product_id = self.env.ref('sf_dlm.product_template_sf').sudo()
try: self_machining_id = self.env.ref('sf_dlm.product_embryo_sf_self_machining').sudo()
ret = requests.post((web_base_url[0] + url), json={}, data=res, outsource_id = self.env.ref('sf_dlm.product_embryo_sf_outsource').sudo()
headers=config_header) purchase_id = self.env.ref('sf_dlm.product_embryo_sf_purchase').sudo()
ret = ret.json() company_id = self.env.ref('base.main_company').sudo()
if ret['status'] == 1: # user_id = request.env.ref('base.user_admin').sudo()
self.write( order_id = self.env['sale.order'].sale_order_create(company_id, 'XXXXX', 'XXXXX', 'XXXXX',
{'state': '待接单'}) 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: else:
raise UserError(ret['message']) 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: except Exception as e:
if ret['status'] != 1: self.cr.rollback()
raise UserError(e) return UserError('工厂创建销售订单和产品失败,请联系管理员')
else:
raise UserError("分配工厂失败,请联系管理员")
# 特征识别
# 特征识别
def feature_recognition(self, report_path, model_code): def feature_recognition(self, report_path, model_code):
feature_path = self.env['sf.auto_quatotion.common'].sudo().get_feature_full_path() 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() 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, ret = self.env['sf.auto_quatotion.common'].sudo().get_auto_quatotion(report_path, feature_path,
process_time_db_path, process_time_db_path,
@@ -200,11 +250,10 @@ class QuickEasyOrder(models.Model):
return ret return ret
# 模型上色 # 模型上色
def model_coloring(self): def model_coloring(self, order):
url = '/api/library_of_models/create' url = '/api/library_of_models/create'
config = self.env['res.config.settings'].get_values() config = self.env['res.config.settings'].get_values()
config_header = Common.get_headers(self, config['token'], config['sf_secret_key']) config_header = Common.get_headers(self, config['token'], config['sf_secret_key'])
order = self.search([('id', '=', self.id)])
logging.info('order: %s' % order.name) logging.info('order: %s' % order.name)
if order: if order:
attachment = order.upload_model_file[0] attachment = order.upload_model_file[0]
@@ -252,11 +301,13 @@ class QuickEasyOrder(models.Model):
vals['accuracy'] = order.machining_precision vals['accuracy'] = order.machining_precision
vals['number'] = order.quantity vals['number'] = order.quantity
vals['process_code'] = 0 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 vals['delivery_days'] = 15
if order.model_file: if order.model_file:
attachment = self.env['ir.attachment'].sudo().search( for item in order.upload_model_file:
[('id', '=', order.upload_model_file[0])]) 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 vals['attachment_id'] = attachment.id
else: else:
vals['attachment_id'] = '' vals['attachment_id'] = ''

View File

@@ -1,5 +1,6 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink 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_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
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_quick_easy_order quick_easy_order model_quick_easy_order base.group_user 1 1 1 1
3 access_sf_auto_quatotion_common sf_auto_quatotion_common model_sf_auto_quatotion_common base.group_user 1 1 1 1
4
5
6

View File

@@ -19,7 +19,7 @@
<field optional="show" name="customer_id" string="客户"/> <field optional="show" name="customer_id" string="客户"/>
<field optional="show" name="material_id"/> <field optional="show" name="material_id"/>
<field optional="show" name="material_model_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="quantity"/>
<field optional="show" name="price"/> <field optional="show" name="price"/>
<field optional="hide" name="delivery_time"/> <field optional="hide" name="delivery_time"/>
@@ -41,8 +41,8 @@
<field name="customer_id" readonly="1" force_save="1"/> <field name="customer_id" readonly="1" force_save="1"/>
<field name="material_id"/> <field name="material_id"/>
<field name="material_model_id"/> <field name="material_model_id"/>
<field name="process_id"/> <!-- <field name="process_id"/>-->
<field name="parameter_ids" widget="many2many_tags"/> <field name="parameter_ids" widget="many2many_tags" string="表面工艺参数"/>
<field name="machining_precision"/> <field name="machining_precision"/>
<field name="quantity"/> <field name="quantity"/>
<field name="unit_price"/> <field name="unit_price"/>

View File

@@ -13,7 +13,7 @@ class FunctionalCuttingToolEntity(models.Model):
_description = '功能刀具列表' _description = '功能刀具列表'
code = fields.Char('编码') 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_model_id = fields.Many2one('sf.cutting.tool.model', string='刀具型号')
mrs_cutting_tool_type_id = fields.Many2one('sf.functional.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) group_expand='_read_group_mrs_cutting_tool_type_id', compute_sudo=True)

View File

@@ -29,12 +29,12 @@
<sheet> <sheet>
<div class="oe_title"> <div class="oe_title">
<h1> <h1>
<field name="name" invisible="False"/> <field name="name" invisible="False" placeholder="请输入20字以内的名称"/>
</h1> </h1>
</div> </div>
<group> <group>
<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_type_id"/>
<field name="mrs_cutting_tool_integral_model_ids" <field name="mrs_cutting_tool_integral_model_ids"

View File

@@ -19,5 +19,6 @@
'web.assets_backend': [ 'web.assets_backend': [
'web_widget_model_viewer/static/src/js/*', 'web_widget_model_viewer/static/src/js/*',
], ],
} },
'license': 'LGPL-3',
} }