合并代码
This commit is contained in:
@@ -17,7 +17,7 @@ class ResMrpRoutingWorkcenter(models.Model):
|
||||
('装夹', '装夹'),
|
||||
('前置三元定位检测', '前置三元定位检测'),
|
||||
('CNC加工', 'CNC加工'),
|
||||
('置三元质量检测', '置三元质量检测'),
|
||||
('后置三元质量检测', '后置三元质量检测'),
|
||||
('解除装夹', '解除装夹'),
|
||||
], string="工序类型")
|
||||
is_repeat = fields.Boolean('重复', default=False)
|
||||
@@ -60,7 +60,7 @@ 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')
|
||||
|
||||
86
sf_bpm_api/models/product_template.py
Normal file
86
sf_bpm_api/models/product_template.py
Normal file
@@ -0,0 +1,86 @@
|
||||
from odoo import models, fields
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class ResProductTemplate(models.Model):
|
||||
_inherit = 'product.template'
|
||||
|
||||
# 模型的长,宽,高,体积,精度,材料
|
||||
model_long = fields.Float('长[mm]', digits=(16, 3))
|
||||
model_width = fields.Float('宽[mm]', digits=(16, 3))
|
||||
model_height = fields.Float('高[mm]', digits=(16, 3))
|
||||
model_volume = fields.Float('体积[mm³]', digits=(16, 3))
|
||||
model_precision = fields.Float('精度要求', digits=(16, 3))
|
||||
model_materials_id = fields.Many2one('mrs.production.materials', string='材料')
|
||||
model_materials_type_id = fields.Many2one('mrs.materials.model', string='型号')
|
||||
# 胚料的长,宽,高
|
||||
embryo_long = fields.Float('长[mm]', digits=(16, 3))
|
||||
embryo_width = fields.Float('宽[mm]', digits=(16, 3))
|
||||
embryo_height = fields.Float('高[mm]', digits=(16, 3))
|
||||
embryo_materials_id = fields.Many2one('mrs.production.materials', string='材料')
|
||||
embryo_materials_type_id = fields.Many2one('mrs.materials.model', string='型号')
|
||||
|
||||
# 业务平台分配工厂后在智能工厂先创建销售订单再创建该产品
|
||||
def product_create(self, product_id, item, order_id, order_number, i):
|
||||
copy_product_id = product_id.with_user(self.env.ref("base.user_admin")).copy()
|
||||
copy_product_id.product_tmpl_id.active = True
|
||||
vals = {
|
||||
'name': '%s-%s' % (order_id.name, i),
|
||||
'model_long': item['model_long'],
|
||||
'model_width': item['model_width'],
|
||||
'model_height': item['model_height'],
|
||||
'model_volume': item['model_volume'],
|
||||
'list_price': item['price'],
|
||||
'model_materials_id': self.env['mrs.production.materials'].search(
|
||||
[('materials_no', '=', item['texture_code'])]).id,
|
||||
'model_materials_type_id': self.env['mrs.materials.model'].search(
|
||||
[('materials_no', '=', item['texture_type_code'])]).id,
|
||||
'default_code': '%s-%s' % (order_number, i),
|
||||
'barcode': item['barcode'],
|
||||
'active': True
|
||||
}
|
||||
copy_product_id.sudo().write(vals)
|
||||
return copy_product_id
|
||||
|
||||
|
||||
class ResProductCategory(models.Model):
|
||||
_inherit = "product.category"
|
||||
|
||||
is_embryo = fields.Boolean('胚料')
|
||||
|
||||
|
||||
class ResMrpBom(models.Model):
|
||||
_inherit = 'mrp.bom'
|
||||
|
||||
# 业务平台分配工厂后在智能工厂先创建销售订单再创建该产品后再次进行创建bom
|
||||
def bom_create(self, product):
|
||||
bom_id = self.env['mrp.bom'].create({
|
||||
'product_tmpl_id': product.product_tmpl_id.id,
|
||||
'type': 'normal',
|
||||
'product_qty': 1,
|
||||
'product_uom_id': 1
|
||||
})
|
||||
return bom_id
|
||||
|
||||
# 生成产品BOM匹配胚料,胚料的匹配规则:
|
||||
# 一、匹配的胚料类别需要带有胚料的标签;
|
||||
# 二、胚料的材料型号与生成产品的材料型号一致;
|
||||
# 三、胚料的长宽高均要大于模型的长宽高;
|
||||
# 四、如果匹配成功多个胚料,则选取体积最小的胚料;
|
||||
def bom_create_Line(self, product):
|
||||
embryo = self.env['product.product'].search(
|
||||
[('categ_id.is_embryo', '=', True), ('embryo_materials_type_id', '=', product.model_materials_type_id.id),
|
||||
('embryo_long', '>', product.model_long), ('embryo_width', '>', product.model_width),
|
||||
('embryo_height', '>', product.model_height)
|
||||
],
|
||||
limit=1,
|
||||
order='volume desc'
|
||||
)
|
||||
vals = {
|
||||
'bom_id': self.id,
|
||||
'product_id': embryo.id,
|
||||
'product_tmpl_id': embryo.product_tmpl_id.id,
|
||||
'product_qty': 1,
|
||||
'product_uom_id': 1
|
||||
}
|
||||
return self.env['mrp.bom.line'].create(vals)
|
||||
34
sf_bpm_api/models/sale_order.py
Normal file
34
sf_bpm_api/models/sale_order.py
Normal file
@@ -0,0 +1,34 @@
|
||||
from odoo import models, fields
|
||||
from odoo.exceptions import ValidationError
|
||||
import datetime
|
||||
|
||||
|
||||
class ReSaleOrder(models.Model):
|
||||
_inherit = 'sale.order'
|
||||
|
||||
deadline_of_delivery = fields.Date('交货截止日期')
|
||||
|
||||
# 业务平台分配工厂后在智能工厂先创建销售订单
|
||||
def sale_order_create(self, deadline_of_delivery, company_id):
|
||||
now_time = datetime.datetime.now()
|
||||
order_id = self.env['sale.order'].sudo().create({
|
||||
'company_id': company_id.id,
|
||||
'date_order': now_time,
|
||||
'name': self.env['ir.sequence'].next_by_code('sale.order', sequence_date=now_time),
|
||||
'partner_id': 8,
|
||||
'state': 'sale',
|
||||
'user_id': 6,
|
||||
'deadline_of_delivery': deadline_of_delivery
|
||||
})
|
||||
return order_id
|
||||
|
||||
# 业务平台分配工厂时在创建完产品后再创建销售明细信息
|
||||
def sale_order_create_line(self, product, item):
|
||||
vals = {
|
||||
'order_id': self.id,
|
||||
'product_id': product.id,
|
||||
'name': '%s/%s/%s/%s/%s' % (item['model_long'], item['model_width'], item['model_height'], item['model_volume'], product.model_materials_id.name),
|
||||
'price_unit': item['price'],
|
||||
'product_uom_qty': item['number']
|
||||
}
|
||||
return self.env['sale.order.line'].create(vals)
|
||||
@@ -16,7 +16,7 @@ class ResMrpWorkOrder(models.Model):
|
||||
('装夹', '装夹'),
|
||||
('前置三元定位检测', '前置三元定位检测'),
|
||||
('CNC加工', 'CNC加工'),
|
||||
('置三元质量检测', '置三元质量检测'),
|
||||
('后置三元质量检测', '后置三元质量检测'),
|
||||
('解除装夹', '解除装夹'),
|
||||
], string="工序类型")
|
||||
|
||||
|
||||
@@ -129,6 +129,9 @@ class MrpWorkOrder(models.Model):
|
||||
# 扫码绑定托盘方法
|
||||
def gettray(self):
|
||||
return ""
|
||||
#解除托盘绑定
|
||||
def unbindtray(self):
|
||||
return ""
|
||||
|
||||
# 计算配料中心点和与x轴倾斜度方法
|
||||
def getcenter(self):
|
||||
|
||||
@@ -7,19 +7,19 @@
|
||||
<field name="inherit_id" ref="mrp.mrp_production_workorder_form_view_inherit"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//page[last()]" position="after">
|
||||
<page string="获取CNC加工程序">
|
||||
<page string="获取CNC加工程序" attrs='{"invisible": [("routing_type","!=","获取CNC加工程序")]}'>
|
||||
<group>
|
||||
<field name="cnc_id" widget="many2many_binary"/>
|
||||
</group>
|
||||
</page>
|
||||
|
||||
</xpath>
|
||||
<xpath expr="//page[last()]" position="after">
|
||||
<page string="装夹托盘">
|
||||
<group>
|
||||
<xpath expr="//page[last()]" position="after" >
|
||||
<page string="装夹托盘" attrs='{"invisible": [("routing_type","!=","装夹")]}'>
|
||||
<group >
|
||||
|
||||
|
||||
<field name="processing_panel" readonly = "1"/>
|
||||
<field name="routing_type" invisible="1"/>
|
||||
<field name="processing_panel" readonly = "1" />
|
||||
<div class="col-12 col-lg-6 o_setting_box">
|
||||
<button type="object" class="oe_highlight" name="gettray" string="扫描托盘"
|
||||
attrs='{"invisible": [("production_id","=",False)]}'
|
||||
@@ -32,7 +32,7 @@
|
||||
</xpath>
|
||||
<xpath expr="//page[last()]" position="after">
|
||||
|
||||
<page string="三元前置检测定位参数">
|
||||
<page string="三元前置检测定位参数" attrs='{"invisible": [("routing_type","!=","前置三元定位检测")]}'>
|
||||
<group>
|
||||
<group>
|
||||
<field name="processing_panel" readonly = "1"/>
|
||||
@@ -151,7 +151,7 @@
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//page[last()]" position="after">
|
||||
<page string="CNC加工">
|
||||
<page string="CNC加工" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'>
|
||||
<group>
|
||||
<field name="cnc_ids" widget="one2many"/>
|
||||
|
||||
@@ -161,7 +161,7 @@
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//page[last()]" position="after">
|
||||
<page string="后置三元检测">
|
||||
<page string="后置三元检测" attrs='{"invisible": [("routing_type","!=","后置三元质量检测")]}'>
|
||||
<group>
|
||||
<field name="test_results" widget="radio"/>
|
||||
<div class="col-12 col-lg-6 o_setting_box">
|
||||
@@ -180,8 +180,12 @@
|
||||
|
||||
</xpath>
|
||||
<xpath expr="//page[last()]" position="after">
|
||||
<page string="解除装夹">
|
||||
<field name="test_results" widget="radio"/>
|
||||
<page string="解除装夹" attrs='{"invisible": [("routing_type","!=","解除装夹")]}' >
|
||||
<div class="col-12 col-lg-6 o_setting_box">
|
||||
<button type="object" class="oe_highlight" name="unbindtray" string="解除装夹"
|
||||
|
||||
/>
|
||||
</div>
|
||||
</page>
|
||||
|
||||
</xpath>
|
||||
|
||||
Reference in New Issue
Block a user