1.模型类型增加跟修改各字段
2.智能工厂成品名称优化 3.智能工厂产品根据产品类型增加默认筛选条件的优化(在筛选器内根据产品类型增加筛选条件) 4.智能工厂胚料名称的优化 5.自加工产品的制造订单优化
This commit is contained in:
@@ -23,13 +23,11 @@ class Sf_Bf_Connect(http.Controller):
|
||||
# ret = json.loads(datas)
|
||||
# ret = json.loads(ret['result'])
|
||||
product_id = request.env.ref('sf_dlm.product_template_sf').sudo()
|
||||
logging.info('product_id:%s' % product_id)
|
||||
self_machining_id = request.env.ref('sf_dlm.product_embryo_sf_self_machining').sudo()
|
||||
outsource_id = request.env.ref('sf_dlm.product_embryo_sf_outsource').sudo()
|
||||
purchase_id = request.env.ref('sf_dlm.product_embryo_sf_purchase').sudo()
|
||||
company_id = request.env.ref('base.main_company').sudo()
|
||||
user_id = request.env.ref('base.user_admin').sudo()
|
||||
logging.info('user_id:%s' % user_id)
|
||||
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(
|
||||
company_id, kw['delivery_name'], kw['delivery_telephone'], kw['delivery_address'],
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<data noupdate="1">
|
||||
<record id="product_template_sf" model="product.product">
|
||||
<field name="name">CNC加工产品模板</field>
|
||||
<!-- <field name="categ_id" ref="product.product_category_5"/>-->
|
||||
<field name="invoice_policy">delivery</field>
|
||||
<field name="detailed_type">product</field>
|
||||
<field name="purchase_ok">false</field>
|
||||
<field name="uom_id" ref="uom.product_uom_unit"/>
|
||||
<field name="uom_po_id" ref="uom.product_uom_unit"/>
|
||||
<field name="company_id" ref="base.main_company"/>
|
||||
<field name="active">False</field>
|
||||
</record>
|
||||
|
||||
<record id="product_category_embryo_sf" model="product.category">
|
||||
<field name="name">胚料</field>
|
||||
<field name="type">胚料</field>
|
||||
</record>
|
||||
|
||||
<record id="product_embryo_sf_self_machining" model="product.product">
|
||||
<field name="name">自加工</field>
|
||||
<!-- <field name="categ_id" ref="product_category_embryo_sf"/>-->
|
||||
<field name="invoice_policy">delivery</field>
|
||||
<field name="detailed_type">product</field>
|
||||
<field name="purchase_ok">false</field>
|
||||
<field name="uom_id" ref="uom.product_uom_unit"/>
|
||||
<field name="uom_po_id" ref="uom.product_uom_unit"/>
|
||||
<field name="company_id" ref="base.main_company"/>
|
||||
<field name="active">False</field>
|
||||
</record>
|
||||
|
||||
<record id="product_embryo_sf_outsource" model="product.product">
|
||||
<field name="name">外协</field>
|
||||
<!-- <field name="categ_id" ref="product_category_embryo_sf"/>-->
|
||||
<field name="invoice_policy">delivery</field>
|
||||
<field name="detailed_type">product</field>
|
||||
<field name="purchase_ok">false</field>
|
||||
<field name="uom_id" ref="uom.product_uom_unit"/>
|
||||
<field name="uom_po_id" ref="uom.product_uom_unit"/>
|
||||
<field name="company_id" ref="base.main_company"/>
|
||||
<field name="active">False</field>
|
||||
</record>
|
||||
|
||||
<record id="product_embryo_sf_purchase" model="product.product">
|
||||
<field name="name">采购</field>
|
||||
<!-- <field name="categ_id" ref="product_category_embryo_sf"/>-->
|
||||
<field name="invoice_policy">delivery</field>
|
||||
<field name="detailed_type">product</field>
|
||||
<field name="purchase_ok">false</field>
|
||||
<field name="uom_id" ref="uom.product_uom_unit"/>
|
||||
<field name="uom_po_id" ref="uom.product_uom_unit"/>
|
||||
<field name="company_id" ref="base.main_company"/>
|
||||
<field name="active">False</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
@@ -73,7 +73,7 @@ class ResProductTemplate(models.Model):
|
||||
model_type = self.env['sf.model.type'].search([], limit=1)
|
||||
attachment = self.attachment_create(item['model_name'], item['model_data'])
|
||||
vals = {
|
||||
'name': '%s-%s' % (order_id.name, i),
|
||||
'name': '%s-%s-%s' % ('P', order_id.name, i),
|
||||
'model_long': item['model_long'] + model_type.embryo_tolerance,
|
||||
'model_width': item['model_width'] + model_type.embryo_tolerance,
|
||||
'model_height': item['model_height'] + model_type.embryo_tolerance,
|
||||
@@ -135,9 +135,10 @@ class ResProductTemplate(models.Model):
|
||||
supplier = self.env['mrp.bom'].get_supplier(materials_type_id)
|
||||
logging.info('no_bom_copy_product_supplier-vals:%s' % supplier)
|
||||
vals = {
|
||||
'name': '%s-%s %s %s %s * %s * %s' % (
|
||||
'name': '%s-%s-%s [%s %s-%s * %s * %s]' % ('R',
|
||||
order_id.name, i, materials_id.name, materials_type_id.name,
|
||||
item['model_long'] + model_type.embryo_tolerance, item['model_width'] + model_type.embryo_tolerance,
|
||||
item['model_long'] + model_type.embryo_tolerance,
|
||||
item['model_width'] + model_type.embryo_tolerance,
|
||||
item['model_height'] + model_type.embryo_tolerance),
|
||||
'length': item['model_long'] + model_type.embryo_tolerance,
|
||||
'width': item['model_width'] + model_type.embryo_tolerance,
|
||||
@@ -208,7 +209,6 @@ class ResMrpBom(models.Model):
|
||||
'product_qty': 1,
|
||||
'product_uom_id': 1
|
||||
}
|
||||
logging.info('bom_create_line_has-vals:%s' % vals)
|
||||
return self.env['mrp.bom.line'].create(vals)
|
||||
|
||||
# 业务平台分配工厂后在智能工厂先创建销售订单再创建该产品后再次进行创建bom
|
||||
@@ -223,7 +223,6 @@ class ResMrpBom(models.Model):
|
||||
if bom_type == 'subcontract' and product_type != False:
|
||||
subcontract = self.get_supplier(product.materials_type_id)
|
||||
bom_id.subcontractor_id = subcontract.partner_id.id
|
||||
logging.info('bom_create-vals:%s' % bom_id)
|
||||
return bom_id
|
||||
|
||||
# 胚料BOM组件:选取当前胚料原材料,
|
||||
@@ -239,7 +238,6 @@ class ResMrpBom(models.Model):
|
||||
'product_qty': bom_line.volume * bom_line.materials_type_id.density * 1000,
|
||||
'product_uom_id': bom_line.uom_id.id
|
||||
}
|
||||
logging.info('bom_create_line-vals1:%s' % vals)
|
||||
return self.env['mrp.bom.line'].create(vals)
|
||||
|
||||
# 查询材料型号默认排第一的供应商
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<!-- </field>-->
|
||||
|
||||
<field name="invoice_policy" position="after">
|
||||
<field name="model_file" widget="model_viewer" />
|
||||
<field name="model_file" widget="model_viewer"/>
|
||||
<field name="materials_id" string="材料"/>
|
||||
<field name="materials_type_id" string="型号"
|
||||
domain="[('materials_id', '=', materials_id)]"/>
|
||||
@@ -125,5 +125,16 @@
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="mrp_product_template_search_view_sf" model="ir.ui.view">
|
||||
<field name="name">mrp.product.template.search</field>
|
||||
<field name="model">product.template</field>
|
||||
<field name="inherit_id" ref="mrp.mrp_product_template_search_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//filter[@name='consumable']" position="after">
|
||||
<filter string="胚料" name="embryo" domain="[('categ_id.type', '=', '胚料')]"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
@@ -6,13 +6,16 @@ class ModelType(models.Model):
|
||||
_description = '模型类型'
|
||||
|
||||
name = fields.Char('名称')
|
||||
embryo_tolerance = fields.Boolean('胚料的容余量', default=False)
|
||||
routing_tmpl_ids = fields.One2many('sf.model.type.routing.sort', 'model_type_id', '工序模板')
|
||||
embryo_tolerance = fields.Integer('胚料容余')
|
||||
product_routing_tmpl_ids = fields.One2many('sf.product.model.type.routing.sort', 'product_model_type_id',
|
||||
'成品工序模板')
|
||||
embryo_routing_tmpl_ids = fields.One2many('sf.embryo.model.type.routing.sort', 'embryo_model_type_id',
|
||||
'胚料工序模板')
|
||||
|
||||
|
||||
class ModelTypeRoutingSort(models.Model):
|
||||
_name = 'sf.model.type.routing.sort'
|
||||
_description = '工序排序'
|
||||
class ProductModelTypeRoutingSort(models.Model):
|
||||
_name = 'sf.product.model.type.routing.sort'
|
||||
_description = '成品工序排序'
|
||||
|
||||
sequence = fields.Integer('Sequence')
|
||||
route_workcenter_id = fields.Many2one('mrp.routing.workcenter')
|
||||
@@ -23,11 +26,34 @@ class ModelTypeRoutingSort(models.Model):
|
||||
('前置三元定位检测', '前置三元定位检测'),
|
||||
('CNC加工', 'CNC加工'),
|
||||
('后置三元质量检测', '后置三元质量检测'),
|
||||
('解除装夹', '解除装夹'),
|
||||
('解除装夹', '解除装夹'), ('切割', '切割')
|
||||
], string="工序类型", related='route_workcenter_id.routing_type')
|
||||
workcenter_ids = fields.Many2many('mrp.workcenter', required=False, related='route_workcenter_id.workcenter_ids')
|
||||
model_type_id = fields.Many2one('sf.model.type')
|
||||
product_model_type_id = fields.Many2one('sf.model.type')
|
||||
|
||||
_sql_constraints = [
|
||||
('route_model_type_uniq', 'unique (route_workcenter_id,model_type_id)', '工序不能重复!')
|
||||
('route_model_type_uniq', 'unique (route_workcenter_id,product_model_type_id)', '成品工序不能重复!')
|
||||
]
|
||||
|
||||
|
||||
class EmbryoModelTypeRoutingSort(models.Model):
|
||||
_name = 'sf.embryo.model.type.routing.sort'
|
||||
_description = '胚料工序排序'
|
||||
|
||||
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="工序类型", 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')
|
||||
|
||||
_sql_constraints = [
|
||||
('route_model_type_uniq', 'unique (route_workcenter_id,embryo_model_type_id)', '胚料工序不能重复!')
|
||||
]
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from odoo import api, fields, models,_
|
||||
from odoo import api, fields, models, _
|
||||
|
||||
|
||||
class resProduct(models.Model):
|
||||
_inherit = 'product.template'
|
||||
model_file = fields.Binary('模型文件')
|
||||
|
||||
|
||||
class MrpProduction(models.Model):
|
||||
_inherit = 'mrp.production'
|
||||
_description = "制造订单"
|
||||
@@ -102,16 +103,17 @@ class MrpProduction(models.Model):
|
||||
'operation_id': operation.id,
|
||||
'state': 'pending',
|
||||
}]
|
||||
if production.product_id.categ_id.type == '成品':
|
||||
# 根据加工面板的面数及对应的工序模板生成工单
|
||||
i = 0
|
||||
processing_panel_len = len(production.product_id.model_processing_panel.split(','))
|
||||
for k in (production.product_id.model_processing_panel.split(',')):
|
||||
routingworkcenter = self.env['sf.model.type.routing.sort'].search(
|
||||
product_routing_workcenter = self.env['sf.product.model.type.routing.sort'].search(
|
||||
[('model_type_id', '=', production.product_id.model_type_id.id)],
|
||||
order='sequence asc'
|
||||
)
|
||||
i += 1
|
||||
for route in routingworkcenter:
|
||||
for route in product_routing_workcenter:
|
||||
if i == 1 and route.routing_type == '获取CNC加工程序':
|
||||
workorders_values.append(
|
||||
self.env['mrp.workorder'].json_workorder_str('', production, route))
|
||||
@@ -121,6 +123,14 @@ class MrpProduction(models.Model):
|
||||
if i == processing_panel_len and route.routing_type == '解除装夹':
|
||||
workorders_values.append(
|
||||
self.env['mrp.workorder'].json_workorder_str(k, production, route))
|
||||
elif production.product_id.categ_id.type == '胚料':
|
||||
embryo_routing_workcenter = self.env['sf.embryo.model.type.routing.sort'].search(
|
||||
[('model_type_id', '=', production.product_id.model_type_id.id)],
|
||||
order='sequence asc'
|
||||
)
|
||||
for route in embryo_routing_workcenter:
|
||||
workorders_values.append(
|
||||
self.env['mrp.workorder'].json_workorder_str('', production, route))
|
||||
production.workorder_ids = workorders_values
|
||||
for workorder in production.workorder_ids:
|
||||
workorder.duration_expected = workorder._get_duration_expected()
|
||||
@@ -181,7 +191,7 @@ class MrpProduction(models.Model):
|
||||
'operation_id': operation.id,
|
||||
'state': 'pending',
|
||||
}]
|
||||
# 根据加工面板的面数及对应的工序模板生成工单
|
||||
# 根据加工面板的面数及对应的成品工序模板生成工单
|
||||
i = 0
|
||||
production.product_id.model_processing_panel = k
|
||||
processing_panel_len = len(k)
|
||||
|
||||
@@ -11,6 +11,7 @@ class ResMrpRoutingWorkcenter(models.Model):
|
||||
('CNC加工', 'CNC加工'),
|
||||
('后置三元质量检测', '后置三元质量检测'),
|
||||
('解除装夹', '解除装夹'),
|
||||
('切割', '切割')
|
||||
], string="工序类型")
|
||||
is_repeat = fields.Boolean('重复', default=False)
|
||||
workcenter_id = fields.Many2one('mrp.workcenter', required=False)
|
||||
@@ -38,26 +39,3 @@ class ResMrpRoutingWorkcenter(models.Model):
|
||||
in %s group by workcenter_id
|
||||
order by count(*),workcenter_id asc limit 1 """, [tuple(workcenter_ids)])
|
||||
return self.env.cr.dictfetchall()[0].get('workcenter_id')
|
||||
|
||||
|
||||
# class ModelTypeRoutingSort(models.Model):
|
||||
# _name = 'sf.model.type.routing.sort'
|
||||
# _description = '工序排序'
|
||||
#
|
||||
# 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="工序类型", related='route_workcenter_id.routing_type')
|
||||
# workcenter_ids = fields.Many2many('mrp.workcenter', required=False, related='route_workcenter_id.workcenter_ids')
|
||||
# model_type_id = fields.Many2one('sf.model.type')
|
||||
#
|
||||
# _sql_constraints = [
|
||||
# ('route_model_type_uniq', 'unique (route_workcenter_id,model_type_id)', '工序不能重复!')
|
||||
# ]
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_sf_cnc_processing,sf_cnc_processing,model_sf_cnc_processing,base.group_user,1,1,1,1
|
||||
access_sf_model_type,sf_model_type,model_sf_model_type,base.group_user,1,1,1,1
|
||||
access_sf_model_type_routing_sort,sf_model_type_routing_sort,model_sf_model_type_routing_sort,base.group_user,1,1,1,1
|
||||
access_sf_product_model_type_routing_sort,sf_product_model_type_routing_sort,model_sf_product_model_type_routing_sort,base.group_user,1,1,1,1
|
||||
access_sf_embryo_model_type_routing_sort,sf_embryo_model_type_routing_sort,model_sf_embryo_model_type_routing_sort,base.group_user,1,1,1,1
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -31,10 +31,21 @@
|
||||
<form string="模型类型">
|
||||
<group>
|
||||
<field name="name" required="1"/>
|
||||
<field name="embryo_tolerance" required="1"/>
|
||||
<field name="embryo_tolerance" required="1" string="胚料容余(mm)"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name='routing_tmpl_ids'>
|
||||
<field name='product_routing_tmpl_ids'>
|
||||
<tree editable='bottom'>
|
||||
<field name="sequence" widget="handle" string="序号"/>
|
||||
<field name="route_workcenter_id" string="工序"/>
|
||||
<field name="routing_type" string="类型"/>
|
||||
<field name="is_repeat" string="重复"/>
|
||||
<field name="workcenter_ids" string="工作中心" widget="many2many_tags"/>
|
||||
</tree>
|
||||
</field>
|
||||
</group>
|
||||
<group>
|
||||
<field name='embryo_routing_tmpl_ids'>
|
||||
<tree editable='bottom'>
|
||||
<field name="sequence" widget="handle" string="序号"/>
|
||||
<field name="route_workcenter_id" string="工序"/>
|
||||
|
||||
@@ -308,6 +308,9 @@
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//page[1]" position="before">
|
||||
<field name="production_id" position="after">
|
||||
<field name="processing_panel" readonly="1"/>
|
||||
</field>
|
||||
<page string="CNC程序" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'>
|
||||
<group>
|
||||
<field name="cnc_ids" widget="one2many" string="工作程序">
|
||||
@@ -327,6 +330,8 @@
|
||||
<field name="remark"/>
|
||||
</tree>
|
||||
</field>
|
||||
</group>
|
||||
<group>
|
||||
<field name="cnc_worksheet" string="工作指令" widget="pdf_viewer"/>
|
||||
</group>
|
||||
</page>
|
||||
@@ -335,7 +340,6 @@
|
||||
<page string="后置三元检测" attrs='{"invisible": [("routing_type","!=","后置三元质量检测")]}'>
|
||||
<group>
|
||||
<field name="test_results" widget="selection"/>
|
||||
|
||||
</group>
|
||||
<div class="col-12 col-lg-6 o_setting_box">
|
||||
<button type="object" class="oe_highlight" name="recreateManufacturingOrWorkerOrder"
|
||||
|
||||
@@ -15,10 +15,9 @@ class ReSaleOrder(models.Model):
|
||||
# 业务平台分配工厂后在智能工厂先创建销售订单
|
||||
|
||||
def sale_order_create(self, company_id, delivery_name, delivery_telephone, delivery_address,
|
||||
deadline_of_delivery,user_id):
|
||||
deadline_of_delivery, user_id):
|
||||
now_time = datetime.datetime.now()
|
||||
partner = self.env.user.partner_id
|
||||
logging.info('partner:%s' % partner)
|
||||
order_id = self.env['sale.order'].sudo().create({
|
||||
'company_id': company_id.id,
|
||||
'date_order': now_time,
|
||||
@@ -31,7 +30,6 @@ class ReSaleOrder(models.Model):
|
||||
'address_of_delivery': delivery_address,
|
||||
'deadline_of_delivery': deadline_of_delivery
|
||||
})
|
||||
logging.info('sale_order_create:%s' % order_id)
|
||||
return order_id
|
||||
|
||||
# 业务平台分配工厂时在创建完产品后再创建销售明细信息
|
||||
|
||||
Reference in New Issue
Block a user