报价和销售订单页面优化
This commit is contained in:
@@ -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
|
||||||
@@ -734,7 +734,7 @@ class ResProductMo(models.Model):
|
|||||||
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')
|
||||||
@@ -797,6 +797,7 @@ class ResMrpBomMo(models.Model):
|
|||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
# 查询材料型号默认排第一的供应商
|
# 查询材料型号默认排第一的供应商
|
||||||
|
|
||||||
def get_supplier(self, materials_type):
|
def get_supplier(self, materials_type):
|
||||||
|
|||||||
@@ -189,27 +189,27 @@ class StockRule(models.Model):
|
|||||||
'mail.message_origin_link',
|
'mail.message_origin_link',
|
||||||
values={'self': production, 'origin': origin_production},
|
values={'self': production, 'origin': origin_production},
|
||||||
subtype_id=self.env.ref('mail.mt_note').id)
|
subtype_id=self.env.ref('mail.mt_note').id)
|
||||||
'''
|
# '''
|
||||||
创建生产计划
|
# 创建生产计划
|
||||||
'''
|
# '''
|
||||||
# 工单耗时
|
# # 工单耗时
|
||||||
workorder_duration = 0
|
# workorder_duration = 0
|
||||||
for workorder in production.workorder_ids:
|
# for workorder in production.workorder_ids:
|
||||||
workorder_duration += workorder.duration_expected
|
# workorder_duration += workorder.duration_expected
|
||||||
|
#
|
||||||
sale_order = self.env['sale.order'].sudo().search([('name', '=', production.origin)])
|
# sale_order = self.env['sale.order'].sudo().search([('name', '=', production.origin)])
|
||||||
if sale_order:
|
# if sale_order:
|
||||||
bb = sale_order.deadline_of_delivery
|
# bb = sale_order.deadline_of_delivery
|
||||||
productions = self.env['sf.production.plan'].with_user(SUPERUSER_ID).sudo().with_company(company_id). \
|
# productions = self.env['sf.production.plan'].with_user(SUPERUSER_ID).sudo().with_company(company_id). \
|
||||||
create({
|
# create({
|
||||||
'name': production.name,
|
# 'name': production.name,
|
||||||
'production_id': production.id,
|
# 'production_id': production.id,
|
||||||
'date_planned_start': production.date_planned_start,
|
# 'date_planned_start': production.date_planned_start,
|
||||||
'origin': production.origin,
|
# 'origin': production.origin,
|
||||||
'product_qty': production.product_qty,
|
# 'product_qty': production.product_qty,
|
||||||
'product_id': production.product_id.id,
|
# 'product_id': production.product_id.id,
|
||||||
'state': 'draft',
|
# 'state': 'draft',
|
||||||
})
|
# })
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
@@ -77,10 +77,10 @@ class QuickEasyOrder(models.Model):
|
|||||||
model_code = hashlib.sha1(base64_datas.encode('utf-8')).hexdigest()
|
model_code = hashlib.sha1(base64_datas.encode('utf-8')).hexdigest()
|
||||||
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)
|
||||||
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(obj)
|
# self.model_coloring(obj)
|
||||||
self.distribute_to_factory(obj)
|
self.distribute_to_factory(obj)
|
||||||
obj.state = '待接单'
|
obj.state = '待接单'
|
||||||
return obj
|
return obj
|
||||||
@@ -88,14 +88,14 @@ class QuickEasyOrder(models.Model):
|
|||||||
# 将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 = 'python %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:
|
||||||
@@ -120,17 +120,17 @@ class QuickEasyOrder(models.Model):
|
|||||||
model_code = hashlib.sha1(base64_datas.encode('utf-8')).hexdigest()
|
model_code = hashlib.sha1(base64_datas.encode('utf-8')).hexdigest()
|
||||||
logging.info("模型编码: %s" % model_code)
|
logging.info("模型编码: %s" % model_code)
|
||||||
item.model_file = self.transition_glb_file(report_path, model_code)
|
item.model_file = self.transition_glb_file(report_path, model_code)
|
||||||
ret = self.feature_recognition(report_path, model_code)
|
# ret = self.feature_recognition(report_path, model_code)
|
||||||
logging.info("自动报价返回值: %s" % ret)
|
# logging.info("自动报价返回值: %s" % ret)
|
||||||
boxshape = ret['boxshape'].tolist()
|
# boxshape = ret['boxshape'].tolist()
|
||||||
logging.info("自动报价boxshape: %s" % boxshape)
|
# logging.info("自动报价boxshape: %s" % boxshape)
|
||||||
logging.info('自动报价feature_infos:%s' % ret['feature_infos'])
|
# logging.info('自动报价feature_infos:%s' % ret['feature_infos'])
|
||||||
item.model_length = boxshape[0] # 长 单位mm
|
# item.model_length = boxshape[0] # 长 单位mm
|
||||||
item.model_width = boxshape[1] # 宽
|
# item.model_width = boxshape[1] # 宽
|
||||||
item.model_height = boxshape[2] # 高
|
# item.model_height = boxshape[2] # 高
|
||||||
item.model_volume = boxshape[0] * boxshape[1] * boxshape[2]
|
# item.model_volume = boxshape[0] * boxshape[1] * boxshape[2]
|
||||||
item.model_feature = json.dumps(ret['feature_infos'], ensure_ascii=False)
|
# item.model_feature = json.dumps(ret['feature_infos'], ensure_ascii=False)
|
||||||
self._get_price(item)
|
# self._get_price(item)
|
||||||
else:
|
else:
|
||||||
item.model_file = False
|
item.model_file = False
|
||||||
item.model_feature = False
|
item.model_feature = False
|
||||||
@@ -151,7 +151,7 @@ class QuickEasyOrder(models.Model):
|
|||||||
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))
|
||||||
res['bfm_process_order_list'].append({
|
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,
|
||||||
|
|||||||
@@ -16,13 +16,13 @@
|
|||||||
<field name="model">quick.easy.order</field>
|
<field name="model">quick.easy.order</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree string="快速订单">
|
<tree string="快速订单">
|
||||||
<field name="state" widget="label_selection"
|
<field name="state" widget="label_selection" string="状态"
|
||||||
options="{'classes': {'待接单': 'default', '加工中':'primary','物流中':'warning','已交付': 'success'}}"/>
|
options="{'classes': {'待接单': 'default', '加工中':'primary','物流中':'warning','已交付': 'success'}}"/>
|
||||||
<field name="name" string="订单号"/>
|
<field name="name" string="订单号"/>
|
||||||
<field name="customer_id" string="客户"/>
|
<field name="customer_id" string="客户"/>
|
||||||
<field name="material_id"/>
|
<field name="material_id"/>
|
||||||
<field name="material_model_id"/>
|
<field name="material_model_id"/>
|
||||||
<field name="parameter_ids" string="表面工艺参数" widget="many2many_tags"/>
|
<!-- <field name="parameter_ids" string="表面工艺参数" widget="many2many_tags"/>-->
|
||||||
<field name="quantity"/>
|
<field name="quantity"/>
|
||||||
<field name="unit_price"/>
|
<field name="unit_price"/>
|
||||||
<field name="price"/>
|
<field name="price"/>
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<odoo>
|
<odoo>
|
||||||
<data>
|
<data>
|
||||||
|
<record id="view_order_tree_inherit_sf" model="ir.ui.view">
|
||||||
|
<field name="name">sale.order.tree</field>
|
||||||
|
<field name="model">sale.order</field>
|
||||||
|
<field name="inherit_id" ref="sale.view_order_tree"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//field[@name='name']" position="after">
|
||||||
|
<!-- <attribute name="string">订单号</attribute>-->
|
||||||
|
<field name="deadline_of_delivery"/>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
<record model="ir.ui.view" id="view_sale_order_form_inherit_sf">
|
<record model="ir.ui.view" id="view_sale_order_form_inherit_sf">
|
||||||
<field name="name">sale.order.form.inherit.sf</field>
|
<field name="name">sale.order.form.inherit.sf</field>
|
||||||
<field name="model">sale.order</field>
|
<field name="model">sale.order</field>
|
||||||
@@ -39,5 +51,22 @@
|
|||||||
</field>
|
</field>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|
||||||
|
<record id="view_quotation_tree_inherit_sf" model="ir.ui.view">
|
||||||
|
<field name="name">sale.order.tree</field>
|
||||||
|
<field name="model">sale.order</field>
|
||||||
|
<field name="inherit_id" ref="sale.view_quotation_tree"/>
|
||||||
|
<field name="mode">primary</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//field[@name='name']" position="attributes">
|
||||||
|
<attribute name="string">订单号</attribute>
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="//field[@name='create_date']" position="attributes">
|
||||||
|
<attribute name="string">下单时间</attribute>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
Reference in New Issue
Block a user