Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/bug修复

This commit is contained in:
jinling.yang
2023-09-14 18:08:05 +08:00
19 changed files with 664 additions and 311 deletions

View File

@@ -49,24 +49,29 @@ td.o_required_modifier {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
position: absolute; position: absolute;
top: 0; top: 28px;
bottom: 0; bottom: 0;
right: 8px; right: 18px;
margin: auto; margin: auto;
height: 34px; //height: 34px;
height: unset !important;
align-items: center;
} }
.show_state > div { .show_state > div {
width: 12px; width: 20px;
height: 12px; height: 12px;
border: 1px solid #000 border: 1px solid #000
} }
.show_state > div:nth-child(2) { .show_state > div:nth-child(1) {
border-top: none;
border-bottom: none; border-bottom: none;
} }
.show_state > div:nth-child(2) {
border-top: 1px solid black !important;
}
.oe_kanban_card.kanban_color_2 { .oe_kanban_card.kanban_color_2 {
background-color: #FF4343 !important; background-color: #FF4343 !important;
color: #fff; color: #fff;
@@ -83,6 +88,11 @@ td.o_required_modifier {
color: #fff; color: #fff;
} }
.my-image div {
width: 122px !important;
height: 122px !important;
}
.my-image img { .my-image img {
width: 100%; width: 100%;
height: 100%; height: 100%;
@@ -149,3 +159,61 @@ td.o_required_modifier {
} }
//----------------------------------------------------------- //-----------------------------------------------------------
div[class="o_content o_component_with_search_panel"] .oe_kanban_color_0 {
position: relative;
padding: 0 !important;
}
div[class="o_content o_component_with_search_panel"] img[name="equipment_image"] {
width: 150px !important;
}
div[class="o_content o_component_with_search_panel"] .o_kanban_card_content button {
position: absolute;
top: -52px;
left: -55px;
width: 80px;
}
div[class="o_content o_component_with_search_panel"] .o_primary > span:nth-of-type(1) {
position: absolute;
top: 10px;
left: 168px;
}
div[class="o_content o_component_with_search_panel"] .o_primary > span:nth-of-type(2) {
margin-left: 18px;
}
div[class="o_content o_component_with_search_panel"] .o_kanban_dashboard:not(.o_legacy_kanban_view) .o_kanban_record > div .o_kanban_manage_toggle_button {
top: 10px !important;
right: 17px !important;
}
div[class="o_content o_component_with_search_panel"] .o_kanban_record_headings .ml8 {
margin-left: 0px !important;
}
div[class="o_content o_component_with_search_panel"] .o_kanban_dashboard:not(.o_legacy_kanban_view) .o_kanban_record > div .o_kanban_card_content {
min-height: 0 !important;
height: 0 !important;
}
div[class="o_content o_component_with_search_panel"] .o_kanban_dashboard:not(.o_legacy_kanban_view) .o_kanban_record > div .o_kanban_card_header + .container.o_kanban_card_content {
margin-top: -5px !important;
}
div[class="o_content o_component_with_search_panel"] .o_kanban_primary_left {
right: 10px;
padding: 0 !important;
}
div[class="o_content o_component_with_search_panel"] .show_state {
right: 10px !important;
top: 45px !important;
}
div[class="o_content o_component_with_search_panel"] .show_state span {
margin-top: 10px;
font-size: 12px;
}

View File

@@ -27,7 +27,7 @@ class Sf_Bf_Connect(http.Controller):
bfm_process_order_list = json.loads(kw['bfm_process_order_list']) bfm_process_order_list = json.loads(kw['bfm_process_order_list'])
order_id = request.env['sale.order'].with_user(request.env.ref("base.user_admin")).sale_order_create( order_id = request.env['sale.order'].with_user(request.env.ref("base.user_admin")).sale_order_create(
company_id, kw['delivery_name'], kw['delivery_telephone'], kw['delivery_address'], company_id, kw['delivery_name'], kw['delivery_telephone'], kw['delivery_address'],
kw['delivery_end_date']) kw['delivery_end_date'], kw['payments_way'], kw['pay_way'])
i = 1 i = 1
# 给sale_order的default_code字段赋值 # 给sale_order的default_code字段赋值
aa = request.env['sale.order'].sudo().search([('name', '=', order_id.name)]) aa = request.env['sale.order'].sudo().search([('name', '=', order_id.name)])

View File

@@ -11,7 +11,7 @@
'category': 'sf', 'category': 'sf',
'website': 'https://www.sf.jikimo.com', 'website': 'https://www.sf.jikimo.com',
'depends': ['mrp', 'base', 'sale', 'sf_manufacturing', 'web_widget_model_viewer', 'mrp_subcontracting', 'purchase_stock', 'depends': ['mrp', 'base', 'sale', 'sf_manufacturing', 'web_widget_model_viewer', 'mrp_subcontracting', 'purchase_stock',
'uom'], 'uom','jikimo_frontend'],
'data': [ 'data': [
'data/product_data.xml', 'data/product_data.xml',
'data/uom_data.xml', 'data/uom_data.xml',

View File

@@ -336,23 +336,24 @@
</group> </group>
<group col="1" attrs="{'invisible': [('cutting_tool_type', '!=', '整体式刀具')]}"> <group col="1" attrs="{'invisible': [('cutting_tool_type', '!=', '整体式刀具')]}">
<group string="适合加工方式"> <group string="适合加工方式">
<field name="suitable_machining_method_ids" string="" widget="many2many_checkboxes"/> <field name="suitable_machining_method_ids" string=""
widget="custom_many2many_checkboxes"/>
</group> </group>
<group> <group>
<group string="刀尖特征"> <group string="刀尖特征">
<field name="blade_tip_characteristics_ids" string="" <field name="blade_tip_characteristics_ids" string=""
widget="many2many_checkboxes"/> widget="custom_many2many_checkboxes"/>
</group> </group>
<group string="柄部类型"> <group string="柄部类型">
<field name="handle_type_ids" string="" widget="many2many_checkboxes"/> <field name="handle_type_ids" string="" widget="custom_many2many_checkboxes"/>
</group> </group>
</group> </group>
<group> <group>
<group string="走刀方向"> <group string="走刀方向">
<field name="cutting_direction_ids" string="" widget="many2many_checkboxes"/> <field name="cutting_direction_ids" string="" widget="custom_many2many_checkboxes"/>
</group> </group>
<group string="适合冷却液"> <group string="适合冷却液">
<field name="suitable_coolant_ids" string="" widget="many2many_checkboxes"/> <field name="suitable_coolant_ids" string="" widget="custom_many2many_checkboxes"/>
</group> </group>
</group> </group>
<notebook> <notebook>

View File

@@ -62,7 +62,6 @@ class SfSaintenanceStandards(models.Model):
fault_type = fields.Selection( fault_type = fields.Selection(
[('电气类', '电气类'), ('机械类', '机械类'), ('程序类', '程序类'), ('系统类', '系统类')], string='类别') [('电气类', '电气类'), ('机械类', '机械类'), ('程序类', '程序类'), ('系统类', '系统类')], string='类别')
equipment_maintenance_standards_id = fields.Many2one('equipment.maintenance.standards', string='设备维保标准') equipment_maintenance_standards_id = fields.Many2one('equipment.maintenance.standards', string='设备维保标准')
maintenance_request_id = fields.Many2one('maintenance.request', string='设备维保计划')
images = fields.One2many('maintenance.standard.image', 'standard_id', string='反馈图片') images = fields.One2many('maintenance.standard.image', 'standard_id', string='反馈图片')
Period = fields.Integer('周期/频次(天)') Period = fields.Integer('周期/频次(天)')
remark = fields.Char('备注说明') remark = fields.Char('备注说明')

View File

@@ -44,11 +44,9 @@ class SfMaintenanceEquipment(models.Model):
overhaul_period = fields.Integer(string='预防检修频次') overhaul_period = fields.Integer(string='预防检修频次')
overhaul_duration = fields.Float(string='检修时长') overhaul_duration = fields.Float(string='检修时长')
overhaul_id = fields.Many2one('equipment.maintenance.standards', string='设备检修标准', overhaul_id = fields.Many2one('equipment.maintenance.standards', string='设备检修标准',
domain="[('maintenance_type','=','检修')]") domain="[('maintenance_type','=','检修')]")
@api.onchange('eq_maintenance_id', 'overhaul_id') @api.onchange('eq_maintenance_id', 'overhaul_id')
def _compute_equipment_maintenance_standards_ids(self): def _compute_equipment_maintenance_standards_ids(self):
for record in self: for record in self:
@@ -145,7 +143,6 @@ class SfMaintenanceEquipment(models.Model):
machine_tool_id = fields.Many2one('sf.machine_tool', '机床') machine_tool_id = fields.Many2one('sf.machine_tool', '机床')
sf_maintenance_logs_ids = fields.One2many('sf.maintenance.logs', 'maintenance_equipment_id', '设备故障日志') sf_maintenance_logs_ids = fields.One2many('sf.maintenance.logs', 'maintenance_equipment_id', '设备故障日志')
def name_get(self): def name_get(self):
result = [] result = []
for parameter in self: for parameter in self:
@@ -156,7 +153,6 @@ class SfMaintenanceEquipment(models.Model):
result.append((parameter.id, name)) result.append((parameter.id, name))
return result return result
@api.constrains('rotate_speed') @api.constrains('rotate_speed')
def _check_rotate_speed(self): def _check_rotate_speed(self):
if self.rotate_speed <= 0: if self.rotate_speed <= 0:
@@ -478,14 +474,17 @@ class SfMaintenanceEquipment(models.Model):
image_id = fields.Many2many('maintenance.equipment.image', 'equipment_id', string='设备图文') image_id = fields.Many2many('maintenance.equipment.image', 'equipment_id', string='设备图文')
class MaintenanceStandardImage(models.Model): class MaintenanceStandardImage(models.Model):
_name = 'maintenance.equipment.image' _name = 'maintenance.equipment.image'
_description = '设备图文展示' _description = '能力特征库'
active = fields.Boolean('有效', default=True) active = fields.Boolean('有效', default=True)
name = fields.Char('加工能力') name = fields.Char('名称')
image = fields.Binary(string='设备图文') image = fields.Binary(string='图文')
type = fields.Selection(
[('加工能力', '加工能力'), ('刀尖特征', '刀尖特征'), ('柄部类型', '柄部类型'), ('走刀方向', '走刀方向'), ('冷却液', '冷却液')],
string='特征')
equipment_id = fields.Many2many('maintenance.equipment', 'image_id', string='设备') equipment_id = fields.Many2many('maintenance.equipment', 'image_id', string='设备')
@api.model @api.model
@@ -518,6 +517,3 @@ class MaintenanceStandardImage(models.Model):
new_res.append([id, name, data_uri]) new_res.append([id, name, data_uri])
# 返回新的结果列表 # 返回新的结果列表
return new_res return new_res

View File

@@ -25,7 +25,7 @@ class SfMaintenanceEquipmentCategory(models.Model):
if not record.equipment_maintenance_id: if not record.equipment_maintenance_id:
record.equipment_maintenance_id = False record.equipment_maintenance_id = False
maintenance_standards = fields.One2many('maintenance.standards', 'maintenance_request_id', string='维保标准') maintenance_standards = fields.Many2many('maintenance.standards', string='维保标准')
@api.constrains('equipment_maintenance_id') @api.constrains('equipment_maintenance_id')
def _check_equipment_maintenance_id(self): def _check_equipment_maintenance_id(self):

View File

@@ -381,8 +381,9 @@
<field name="name">maintenance.equipment.image.tree</field> <field name="name">maintenance.equipment.image.tree</field>
<field name="model">maintenance.equipment.image</field> <field name="model">maintenance.equipment.image</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<tree string="设备图文"> <tree string="能力特征库">
<field name="name"/> <field name="name"/>
<field name="type"/>
<field name="image" widget="image"/> <field name="image" widget="image"/>
<field name="equipment_id" invisible="1"/> <field name="equipment_id" invisible="1"/>
<field name="active" invisible="1"/> <field name="active" invisible="1"/>
@@ -394,11 +395,12 @@
<field name="name">maintenance.equipment.image.form</field> <field name="name">maintenance.equipment.image.form</field>
<field name="model">maintenance.equipment.image</field> <field name="model">maintenance.equipment.image</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="设备图文"> <form string="能力特征库">
<sheet> <sheet>
<group> <group>
<field name="name"/> <field name="name" required="1"/>
<field name="image" widget="image"/> <field name="type" required="1"/>
<field name="image" widget="image" required="1"/>
<field name="equipment_id" invisible="1"/> <field name="equipment_id" invisible="1"/>
<field name="active" invisible="1"/> <field name="active" invisible="1"/>
</group> </group>
@@ -408,14 +410,14 @@
</record> </record>
<record id="action_maintenance_equipment_image" model="ir.actions.act_window"> <record id="action_maintenance_equipment_image" model="ir.actions.act_window">
<field name="name">设备图文图文</field> <field name="name">能力特征库</field>
<field name="res_model">maintenance.equipment.image</field> <field name="res_model">maintenance.equipment.image</field>
<field name="view_mode">tree,form</field> <field name="view_mode">tree,form</field>
<field name="domain">[]</field> <field name="domain">[]</field>
</record> </record>
<menuitem <menuitem
id="maintenance_equipment_image_form" id="maintenance_equipment_image_form"
name="设备图文展示" name="能力特征库"
parent="maintenance.menu_m_request" parent="maintenance.menu_m_request"
action="action_maintenance_equipment_image" action="action_maintenance_equipment_image"
groups="maintenance.group_equipment_manager,base.group_user" groups="maintenance.group_equipment_manager,base.group_user"

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
@@ -91,15 +91,19 @@ class ResProductMo(models.Model):
cutting_tool_coarse_medium_fine = fields.Selection([('', ''), ('', ''), ('', '')], '粗/中/精') cutting_tool_coarse_medium_fine = fields.Selection([('', ''), ('', ''), ('', '')], '粗/中/精')
cutting_tool_run_out_accuracy_max = fields.Float('端跳精度max', digits=(6, 1)) cutting_tool_run_out_accuracy_max = fields.Float('端跳精度max', digits=(6, 1))
cutting_tool_run_out_accuracy_min = fields.Float('端跳精度min', digits=(6, 1)) cutting_tool_run_out_accuracy_min = fields.Float('端跳精度min', digits=(6, 1))
suitable_machining_method_ids = fields.Many2many('sf.suitable.machining.method', suitable_machining_method_ids = fields.Many2many('maintenance.equipment.image',
'rel_suitable_machining_method_product_template', '适合加工方式') 'rel_machining_product_template', '适合加工方式',
blade_tip_characteristics_ids = fields.Many2many('sf.blade.tip.characteristics', domain=[('type', '=', '加工能力')])
'rel_blade_tip_characteristics_product_template', '刀尖特征') blade_tip_characteristics_ids = fields.Many2many('maintenance.equipment.image',
handle_type_ids = fields.Many2many('sf.handle.type', 'rel_handle_type_product_template', '柄部类型') 'rel_blade_tip_product_template', '刀尖特征',
cutting_direction_ids = fields.Many2many('sf.cutting.direction', 'rel_cutting_direction_product_template', domain=[('type', '=', '刀尖特征')])
'走刀方向') handle_type_ids = fields.Many2many('maintenance.equipment.image', 'rel_handle_product_template', '柄部类型',
suitable_coolant_ids = fields.Many2many('sf.suitable.coolant', 'rel_suitable_coolant_product_template', domain=[('type', '=', '柄部类型')])
'适合冷却液') cutting_direction_ids = fields.Many2many('maintenance.equipment.image', 'rel_cutting_product_template',
'走刀方向', domain=[('type', '=', '走刀方向')])
suitable_coolant_ids = fields.Many2many('maintenance.equipment.image', 'rel_coolant_product_template',
'适合冷却液', domain=[('type', '=', '冷却液')])
# @api.constrains('suitable_machining_method_ids') # @api.constrains('suitable_machining_method_ids')
# def _check_suitable_machining_method_ids(self): # def _check_suitable_machining_method_ids(self):
@@ -734,7 +738,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 +801,7 @@ class ResMrpBomMo(models.Model):
else: else:
return False return False
# 查询材料型号默认排第一的供应商 # 查询材料型号默认排第一的供应商
def get_supplier(self, materials_type): def get_supplier(self, materials_type):

View File

@@ -189,6 +189,8 @@ 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)
''' '''
创建生产计划 创建生产计划
''' '''
@@ -211,7 +213,6 @@ class StockRule(models.Model):
'product_id': production.product_id.id, 'product_id': production.product_id.id,
'state': 'draft', 'state': 'draft',
}) })
return True return True

View File

@@ -8,6 +8,37 @@ class SuitableMachiningMethod(models.Model):
name = fields.Char('名称') name = fields.Char('名称')
image = fields.Image('图片') image = fields.Image('图片')
@api.model
def name_search(self, name='', args=None, operator='ilike', limit=100):
# 调用父类的name_search方法获取原始的结果列表
res = super().name_search(name, args, operator, limit)
# 定义一个空字典用来存储id和name的映射关系
name_dict = {}
# 遍历结果列表将id和name存入字典中
for item in res:
id = item[0]
name = item[1]
name_dict[id] = name
# 根据id列表搜索符合条件的记录
records = self.browse(name_dict.keys())
# 定义一个新的结果列表用来存储修改后的结果
new_res = []
# 遍历每条记录
for record in records:
# 获取记录的idname和image属性
id = record.id
name = name_dict[id]
image = record.image
# 如果image不为空将其转换为data URI scheme
if image:
data_uri = f"data:image/png;base64,{image.decode('utf-8')}"
else:
data_uri = ""
# 将这三个属性组成一个数组,并添加到结果列表中 result.append([id, name, data_uri]) # 返回结果列表 return result
new_res.append([id, name, data_uri])
# 返回新的结果列表
return new_res
class BladeTipCharacteristics(models.Model): class BladeTipCharacteristics(models.Model):
_name = 'sf.blade.tip.characteristics' _name = 'sf.blade.tip.characteristics'
@@ -16,6 +47,37 @@ class BladeTipCharacteristics(models.Model):
name = fields.Char('名称') name = fields.Char('名称')
image = fields.Image('图片') image = fields.Image('图片')
@api.model
def name_search(self, name='', args=None, operator='ilike', limit=100):
# 调用父类的name_search方法获取原始的结果列表
res = super().name_search(name, args, operator, limit)
# 定义一个空字典用来存储id和name的映射关系
name_dict = {}
# 遍历结果列表将id和name存入字典中
for item in res:
id = item[0]
name = item[1]
name_dict[id] = name
# 根据id列表搜索符合条件的记录
records = self.browse(name_dict.keys())
# 定义一个新的结果列表用来存储修改后的结果
new_res = []
# 遍历每条记录
for record in records:
# 获取记录的idname和image属性
id = record.id
name = name_dict[id]
image = record.image
# 如果image不为空将其转换为data URI scheme
if image:
data_uri = f"data:image/png;base64,{image.decode('utf-8')}"
else:
data_uri = ""
# 将这三个属性组成一个数组,并添加到结果列表中 result.append([id, name, data_uri]) # 返回结果列表 return result
new_res.append([id, name, data_uri])
# 返回新的结果列表
return new_res
class HandleType(models.Model): class HandleType(models.Model):
_name = 'sf.handle.type' _name = 'sf.handle.type'
@@ -24,6 +86,37 @@ class HandleType(models.Model):
name = fields.Char('名称') name = fields.Char('名称')
image = fields.Image('图片') image = fields.Image('图片')
@api.model
def name_search(self, name='', args=None, operator='ilike', limit=100):
# 调用父类的name_search方法获取原始的结果列表
res = super().name_search(name, args, operator, limit)
# 定义一个空字典用来存储id和name的映射关系
name_dict = {}
# 遍历结果列表将id和name存入字典中
for item in res:
id = item[0]
name = item[1]
name_dict[id] = name
# 根据id列表搜索符合条件的记录
records = self.browse(name_dict.keys())
# 定义一个新的结果列表用来存储修改后的结果
new_res = []
# 遍历每条记录
for record in records:
# 获取记录的idname和image属性
id = record.id
name = name_dict[id]
image = record.image
# 如果image不为空将其转换为data URI scheme
if image:
data_uri = f"data:image/png;base64,{image.decode('utf-8')}"
else:
data_uri = ""
# 将这三个属性组成一个数组,并添加到结果列表中 result.append([id, name, data_uri]) # 返回结果列表 return result
new_res.append([id, name, data_uri])
# 返回新的结果列表
return new_res
class CuttingDirection(models.Model): class CuttingDirection(models.Model):
_name = 'sf.cutting.direction' _name = 'sf.cutting.direction'
@@ -32,6 +125,37 @@ class CuttingDirection(models.Model):
name = fields.Char('名称') name = fields.Char('名称')
image = fields.Image('图片') image = fields.Image('图片')
@api.model
def name_search(self, name='', args=None, operator='ilike', limit=100):
# 调用父类的name_search方法获取原始的结果列表
res = super().name_search(name, args, operator, limit)
# 定义一个空字典用来存储id和name的映射关系
name_dict = {}
# 遍历结果列表将id和name存入字典中
for item in res:
id = item[0]
name = item[1]
name_dict[id] = name
# 根据id列表搜索符合条件的记录
records = self.browse(name_dict.keys())
# 定义一个新的结果列表用来存储修改后的结果
new_res = []
# 遍历每条记录
for record in records:
# 获取记录的idname和image属性
id = record.id
name = name_dict[id]
image = record.image
# 如果image不为空将其转换为data URI scheme
if image:
data_uri = f"data:image/png;base64,{image.decode('utf-8')}"
else:
data_uri = ""
# 将这三个属性组成一个数组,并添加到结果列表中 result.append([id, name, data_uri]) # 返回结果列表 return result
new_res.append([id, name, data_uri])
# 返回新的结果列表
return new_res
class SuitableCoolant(models.Model): class SuitableCoolant(models.Model):
_name = 'sf.suitable.coolant' _name = 'sf.suitable.coolant'
@@ -40,6 +164,37 @@ class SuitableCoolant(models.Model):
name = fields.Char('名称') name = fields.Char('名称')
image = fields.Image('图片') image = fields.Image('图片')
@api.model
def name_search(self, name='', args=None, operator='ilike', limit=100):
# 调用父类的name_search方法获取原始的结果列表
res = super().name_search(name, args, operator, limit)
# 定义一个空字典用来存储id和name的映射关系
name_dict = {}
# 遍历结果列表将id和name存入字典中
for item in res:
id = item[0]
name = item[1]
name_dict[id] = name
# 根据id列表搜索符合条件的记录
records = self.browse(name_dict.keys())
# 定义一个新的结果列表用来存储修改后的结果
new_res = []
# 遍历每条记录
for record in records:
# 获取记录的idname和image属性
id = record.id
name = name_dict[id]
image = record.image
# 如果image不为空将其转换为data URI scheme
if image:
data_uri = f"data:image/png;base64,{image.decode('utf-8')}"
else:
data_uri = ""
# 将这三个属性组成一个数组,并添加到结果列表中 result.append([id, name, data_uri]) # 返回结果列表 return result
new_res.append([id, name, data_uri])
# 返回新的结果列表
return new_res
class CuttingSpeed(models.Model): class CuttingSpeed(models.Model):
_name = 'sf.cutting.speed' _name = 'sf.cutting.speed'

View File

@@ -30,25 +30,37 @@
<field name="inherit_id" ref="mrp.mrp_workcenter_kanban"/> <field name="inherit_id" ref="mrp.mrp_workcenter_kanban"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<!-- Desktop view --> <!-- Desktop view -->
<xpath expr='(//field[@name="name"])[1]' position="after"> <xpath expr='(//field[@name="name"])[1]' position="before">
<field name="equipment_status"/> <field name="equipment_status"/>
<field name="equipment_image"/> <field name="equipment_image"/>
</xpath> </xpath>
<xpath expr='(//field[@name="name"])[2]' position="after"> <xpath expr='(//field[@name="name"])[2]' position="before">
<field name="equipment_status" />
<field name="equipment_image" widget="image"/> <field name="equipment_image" widget="image"/>
</xpath> </xpath>
<xpath expr='(//a[@name="unblock"])' position="after"> <xpath expr='(//a[@name="unblock"])' position="after">
<!-- <div class="czyg">绿色:正常,红色:故障,黄色:下线/暂停</div>-->
<div class="czyg">绿色:正常,红色:故障,黄色:下线/暂停</div> </xpath>
</field>
</record>
<!--&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;-->
<record id="mrp_workcenter_kanban_inherit1" model="ir.ui.view">
<field name="name">mrp.workcenter.kanban.inherit</field>
<field name="model">mrp.workcenter</field>
<field name="inherit_id" ref="mrp.mrp_workcenter_kanban"/>
<field name="arch" type="xml">
<xpath expr="//kanban//templates//t" position="inside">
<p class="show_state" t-attf-class="oe_kanban_global_click o_kanban_record_has_image_fill o_hr_kanban_record oe_kanban_card oe_kanban_global_click
">
<div t-attf-class="#{record.equipment_status.raw_value == '正常' ? 'color_1' : ''}"></div>
<div t-attf-class="#{record.equipment_status.raw_value == '故障' ? 'color_2' : ''}"></div>
<div t-attf-class="#{record.equipment_status.raw_value == '不可用' ? 'color_3' : ''}"></div>
<span t-attf-class="#{record.equipment_status.raw_value == '正常' ? 'font_color_1' : ''}
#{record.equipment_status.raw_value == '故障' ? 'font_color_2' : ''}
#{record.equipment_status.raw_value == '不可用' ? 'font_color_3' : ''}">
<field name="equipment_status"/>
</span>
</p>
</xpath> </xpath>
</field> </field>
</record> </record>
@@ -155,7 +167,8 @@
<!-- <t t-name="kanban-box" --> <!-- <t t-name="kanban-box" -->
<!-- t-if="record.production_line_id.value == record.production_line_show.raw_value"> --> <!-- t-if="record.production_line_id.value == record.production_line_show.raw_value"> -->
<!-- <div t-on-click="console.log(record.production_line_id,'11111111111')"></div>--> --> <!-- <div t-on-click="console.log(record.production_line_id,'11111111111')"></div>--> -->
<!-- <div t-on-click="console.log(record.production_line_show,'22222222222')"></div>--> --> <!-- <div t-on-click="console.log(record.production_line_show,'22222222222')"></div>-->
-->
<!-- <div t-attf-class="#{!selection_mode ? kanban_color(record.color.raw_value) : ''}"> --> <!-- <div t-attf-class="#{!selection_mode ? kanban_color(record.color.raw_value) : ''}"> -->
<!-- <div t-attf-class="o_kanban_card_header o_kanban_record_top"> --> <!-- <div t-attf-class="o_kanban_card_header o_kanban_record_top"> -->
<!-- <div class="o_kanban_record_headings o_kanban_card_header_title"> --> <!-- <div class="o_kanban_record_headings o_kanban_card_header_title"> -->

View File

@@ -12,11 +12,26 @@
</field> </field>
</record> </record>
<record model="ir.ui.view" id="sf_suitable_machining_method_form">
<field name="name">适合加工方式</field>
<field name="model">sf.suitable.machining.method</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<field name="name"/>
<field name="image" widget="image"/>
</group>
</sheet>
</form>
</field>
</record>
<record id="sf_suitable_machining_method_act" model="ir.actions.act_window"> <record id="sf_suitable_machining_method_act" model="ir.actions.act_window">
<field name="name">适合加工方式</field> <field name="name">适合加工方式</field>
<field name="type">ir.actions.act_window</field> <field name="type">ir.actions.act_window</field>
<field name="res_model">sf.suitable.machining.method</field> <field name="res_model">sf.suitable.machining.method</field>
<field name="view_mode">tree</field> <field name="view_mode">tree,form</field>
</record> </record>
@@ -32,11 +47,26 @@
</field> </field>
</record> </record>
<record model="ir.ui.view" id="sf_blade_tip_characteristics_form">
<field name="name">刀尖特征</field>
<field name="model">sf.blade.tip.characteristics</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<field name="name"/>
<field name="image" widget="image"/>
</group>
</sheet>
</form>
</field>
</record>
<record id="sf_blade_tip_characteristics_act" model="ir.actions.act_window"> <record id="sf_blade_tip_characteristics_act" model="ir.actions.act_window">
<field name="name">刀尖特征</field> <field name="name">刀尖特征</field>
<field name="type">ir.actions.act_window</field> <field name="type">ir.actions.act_window</field>
<field name="res_model">sf.blade.tip.characteristics</field> <field name="res_model">sf.blade.tip.characteristics</field>
<field name="view_mode">tree</field> <field name="view_mode">tree,form</field>
</record> </record>
@@ -52,11 +82,26 @@
</field> </field>
</record> </record>
<record model="ir.ui.view" id="sf_handle_type_forme">
<field name="name">柄部类型</field>
<field name="model">sf.handle.type</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<field name="name"/>
<field name="image" widget="image"/>
</group>
</sheet>
</form>
</field>
</record>
<record id="sf_handle_type_act" model="ir.actions.act_window"> <record id="sf_handle_type_act" model="ir.actions.act_window">
<field name="name">柄部类型</field> <field name="name">柄部类型</field>
<field name="type">ir.actions.act_window</field> <field name="type">ir.actions.act_window</field>
<field name="res_model">sf.handle.type</field> <field name="res_model">sf.handle.type</field>
<field name="view_mode">tree</field> <field name="view_mode">tree,form</field>
</record> </record>
@@ -72,11 +117,26 @@
</field> </field>
</record> </record>
<record model="ir.ui.view" id="sf_cutting_direction_form">
<field name="name">走刀方向</field>
<field name="model">sf.cutting.direction</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<field name="name"/>
<field name="image" widget="image"/>
</group>
</sheet>
</form>
</field>
</record>
<record id="sf_cutting_direction_act" model="ir.actions.act_window"> <record id="sf_cutting_direction_act" model="ir.actions.act_window">
<field name="name">走刀方向</field> <field name="name">走刀方向</field>
<field name="type">ir.actions.act_window</field> <field name="type">ir.actions.act_window</field>
<field name="res_model">sf.cutting.direction</field> <field name="res_model">sf.cutting.direction</field>
<field name="view_mode">tree</field> <field name="view_mode">tree,form</field>
</record> </record>
@@ -92,11 +152,24 @@
</field> </field>
</record> </record>
<record model="ir.ui.view" id="sf_suitable_coolant_form">
<field name="name">适合冷却液</field>
<field name="model">sf.suitable.coolant</field>
<field name="arch" type="xml">
<form>
<sheet>
<field name="name"/>
<field name="image" widget="image"/>
</sheet>
</form>
</field>
</record>
<record id="sf_suitable_coolant_act" model="ir.actions.act_window"> <record id="sf_suitable_coolant_act" model="ir.actions.act_window">
<field name="name">适合冷却液</field> <field name="name">适合冷却液</field>
<field name="type">ir.actions.act_window</field> <field name="type">ir.actions.act_window</field>
<field name="res_model">sf.suitable.coolant</field> <field name="res_model">sf.suitable.coolant</field>
<field name="view_mode">tree</field> <field name="view_mode">tree,form</field>
</record> </record>

View File

@@ -10,7 +10,7 @@
""", """,
'category': 'sf', 'category': 'sf',
'website': 'https://www.sf.jikimo.com', 'website': 'https://www.sf.jikimo.com',
'depends': ['sale_management', 'web_widget_model_viewer',], 'depends': ['sale', 'web_widget_model_viewer'],
'data': [ 'data': [
'security/group_security.xml', 'security/group_security.xml',
'security/ir.model.access.csv', 'security/ir.model.access.csv',

View File

@@ -16,6 +16,7 @@ import requests
class QuickEasyOrder(models.Model): class QuickEasyOrder(models.Model):
_name = 'quick.easy.order' _name = 'quick.easy.order'
_description = '简易下单' _description = '简易下单'
_order = 'id desc'
name = fields.Char('订单编号', default=lambda self: self.env['ir.sequence'].next_by_code('quick.easy.order')) name = fields.Char('订单编号', default=lambda self: self.env['ir.sequence'].next_by_code('quick.easy.order'))
model_length = fields.Float('长(mm)', digits=(16, 3)) model_length = fields.Float('长(mm)', digits=(16, 3))
@@ -48,6 +49,7 @@ class QuickEasyOrder(models.Model):
model_color_state = fields.Selection([ model_color_state = fields.Selection([
('success', '成功'), ('success', '成功'),
('fail', '失败')], string='模型上色状态') ('fail', '失败')], string='模型上色状态')
processing_time = fields.Integer('加工时长(min)')
@api.depends('unit_price', 'quantity') @api.depends('unit_price', 'quantity')
def _compute_total_amount(self): def _compute_total_amount(self):
@@ -77,10 +79,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 +90,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 +122,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 +153,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,

View File

@@ -6,14 +6,16 @@ import base64
class ReSaleOrder(models.Model): class ReSaleOrder(models.Model):
_inherit = 'sale.order' _inherit = 'sale.order'
deadline_of_delivery = fields.Date('货截止日') deadline_of_delivery = fields.Date('订单交期')
person_of_delivery = fields.Char('交货人') person_of_delivery = fields.Char('交货人')
telephone_of_delivery = fields.Char('交货人电话号码') telephone_of_delivery = fields.Char('交货人电话号码')
address_of_delivery = fields.Char('交货人地址') address_of_delivery = fields.Char('交货人地址')
payments_way = fields.Selection([('现结', '现结'), ('月结', '月结')], '结算方式', default='现结')
pay_way = fields.Selection([('转账', '转账'), ('微信', '微信'), ('支付宝', '支付宝')], '支付方式')
# 业务平台分配工厂后在智能工厂先创建销售订单 # 业务平台分配工厂后在智能工厂先创建销售订单
def sale_order_create(self, company_id, delivery_name, delivery_telephone, delivery_address, def sale_order_create(self, company_id, delivery_name, delivery_telephone, delivery_address,
deadline_of_delivery): deadline_of_delivery, payments_way, pay_way):
now_time = datetime.datetime.now() now_time = datetime.datetime.now()
partner = self.get_customer() partner = self.get_customer()
order_id = self.env['sale.order'].sudo().create({ order_id = self.env['sale.order'].sudo().create({
@@ -22,11 +24,12 @@ class ReSaleOrder(models.Model):
'name': self.env['ir.sequence'].next_by_code('sale.order', sequence_date=now_time), 'name': self.env['ir.sequence'].next_by_code('sale.order', sequence_date=now_time),
'partner_id': partner.id, 'partner_id': partner.id,
'state': 'draft', 'state': 'draft',
# 'user_id': user_id.id,
'person_of_delivery': delivery_name, 'person_of_delivery': delivery_name,
'telephone_of_delivery': delivery_telephone, 'telephone_of_delivery': delivery_telephone,
'address_of_delivery': delivery_address, 'address_of_delivery': delivery_address,
'deadline_of_delivery': deadline_of_delivery 'deadline_of_delivery': deadline_of_delivery,
'payments_way': payments_way,
'pay_way': pay_way,
}) })
return order_id return order_id

View File

@@ -16,16 +16,18 @@
<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"/>
<field name="create_uid" string="创建人"/>
<field name="create_date" string="创建时间"/>
<field optional="hide" name="delivery_time"/> <field optional="hide" name="delivery_time"/>
</tree> </tree>
</field> </field>
@@ -74,6 +76,7 @@
options="{'format': false}"/> options="{'format': false}"/>
</div> </div>
<field name="model_volume" attrs="{'invisible': [('model_file', '=', False)]}"/> <field name="model_volume" attrs="{'invisible': [('model_file', '=', False)]}"/>
<field name="processing_time"/>
</group> </group>
</group> </group>
</sheet> </sheet>

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<odoo> <odoo>
<data> <data>
<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>
@@ -8,6 +9,8 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<field name="payment_term_id" position="after"> <field name="payment_term_id" position="after">
<field name="deadline_of_delivery"/> <field name="deadline_of_delivery"/>
<field name="payments_way"/>
<field name="pay_way"/>
</field> </field>
<xpath expr="//field[@name='order_line']/tree/field[@name='name']" position="before"> <xpath expr="//field[@name='order_line']/tree/field[@name='name']" position="before">
<field name="model_glb_file" widget="Viewer3D" optional="show" <field name="model_glb_file" widget="Viewer3D" optional="show"
@@ -25,6 +28,9 @@
<field name="model">sale.order</field> <field name="model">sale.order</field>
<field name="inherit_id" ref="sale_management.sale_order_form_quote"/> <field name="inherit_id" ref="sale_management.sale_order_form_quote"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<field name="date_order" position="attributes">
<attribute name="string">下单日期</attribute>
</field>
<field name="sale_order_template_id" position="after"> <field name="sale_order_template_id" position="after">
<!-- <label for="person_of_delivery" string="交货信息"/>--> <!-- <label for="person_of_delivery" string="交货信息"/>-->
<!-- <div>--> <!-- <div>-->
@@ -39,5 +45,31 @@
</field> </field>
</field> </field>
</record> </record>
<record id="view_quotation_with_onboarding_tree_inherit_sf" model="ir.ui.view">
<field name="name">sale.order.quotation.tree.inherit.sf</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_quotation_tree_with_onboarding"/>
<field name="arch" type="xml">
<field name="name" position="attributes">
<attribute name="string">订单号</attribute>
</field>
<field name="create_date" position="attributes">
<attribute name="string">下单时间</attribute>
</field>
</field>
</record>
<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">
<field name="name" position="attributes">
<attribute name="string">订单号</attribute>
</field>
</field>
</record>
</data> </data>
</odoo> </odoo>

View File

@@ -25,7 +25,7 @@
</model-viewer> </model-viewer>
</t> </t>
<t t-if="!props.value"> <t t-if="!props.value">
<div style="color:#D23F3A">当前制造订单暂无模型</div> <div style="color:#D23F3A">暂无模型</div>
</t> </t>
<!-- <model-viewer--> <!-- <model-viewer-->