生成产品的BOM上的加工工序
This commit is contained in:
@@ -14,10 +14,6 @@
|
||||
'data': [
|
||||
'security/group_security.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'data/product_data.xml',
|
||||
'data/process_data.xml',
|
||||
'views/product_template_view.xml',
|
||||
'views/sale_order_view.xml'
|
||||
],
|
||||
'demo': [
|
||||
],
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<data>
|
||||
|
||||
<record id="mrp_workcenter_3" model="mrp.workcenter">
|
||||
<field name="name">Assembly Line 1</field>
|
||||
<field name="active">false</field>
|
||||
</record>
|
||||
|
||||
<record id="mrp_bom_manufacture" model="mrp.bom">
|
||||
<field name="product_tmpl_id" ref="product.product_product_3_product_template"/>
|
||||
<field name="product_uom_id" ref="uom.product_uom_unit"/>
|
||||
<field name="sequence">1</field>
|
||||
<field name="active">false</field>
|
||||
</record>
|
||||
|
||||
<record id="mrp_routing_workcenter_template_automatic_coding_sf" model="mrp.routing.workcenter">
|
||||
<field name="name">获取自动编码程序</field>
|
||||
<field name="code">automatic coding</field>
|
||||
<field name="time_mode">manual</field>
|
||||
<field name="workcenter_id" ref="mrp_workcenter_3"/>
|
||||
<field name="bom_id" ref="mrp_bom_manufacture"/>
|
||||
<field name="time_cycle">60</field>
|
||||
<field name="active">false</field>
|
||||
</record>
|
||||
|
||||
<record id="mrp_routing_workcenter_template_clamping_sf" model="mrp.routing.workcenter">
|
||||
<field name="name">装夹</field>
|
||||
<field name="code">clamping</field>
|
||||
<field name="time_mode">manual</field>
|
||||
<field name="workcenter_id" ref="mrp_workcenter_3"/>
|
||||
<field name="bom_id" ref="mrp_bom_manufacture"/>
|
||||
<field name="time_cycle">60</field>
|
||||
<field name="active">false</field>
|
||||
</record>
|
||||
|
||||
<record id="mrp_routing_workcenter_template_pre_ternary_sf" model="mrp.routing.workcenter">
|
||||
<field name="name">前置三元定位检测</field>
|
||||
<field name="code">pre-ternary positioning detection</field>
|
||||
<field name="time_mode">manual</field>
|
||||
<field name="workcenter_id" ref="mrp_workcenter_3"/>
|
||||
<field name="bom_id" ref="mrp_bom_manufacture"/>
|
||||
<field name="time_cycle">60</field>
|
||||
<field name="active">false</field>
|
||||
</record>
|
||||
|
||||
<record id="mrp_routing_workcenter_template_cnc_sf" model="mrp.routing.workcenter">
|
||||
<field name="name">CNC加工</field>
|
||||
<field name="code">CNC machining</field>
|
||||
<field name="time_mode">manual</field>
|
||||
<field name="workcenter_id" ref="mrp_workcenter_3"/>
|
||||
<field name="bom_id" ref="mrp_bom_manufacture"/>
|
||||
<field name="time_cycle">60</field>
|
||||
<field name="active">false</field>
|
||||
</record>
|
||||
|
||||
<record id="mrp_routing_workcenter_template_post_ternary_sf" model="mrp.routing.workcenter">
|
||||
<field name="name">后置三元质量检测</field>
|
||||
<field name="code">post ternary quality inspection</field>
|
||||
<field name="time_mode">manual</field>
|
||||
<field name="workcenter_id" ref="mrp_workcenter_3"/>
|
||||
<field name="bom_id" ref="mrp_bom_manufacture"/>
|
||||
<field name="time_cycle">60</field>
|
||||
<field name="active">false</field>
|
||||
</record>
|
||||
|
||||
<record id="mrp_routing_workcenter_template_remove_clamping_sf" model="mrp.routing.workcenter">
|
||||
<field name="name">解除装夹</field>
|
||||
<field name="code">remove the clamping</field>
|
||||
<field name="time_mode">manual</field>
|
||||
<field name="workcenter_id" ref="mrp_workcenter_3"/>
|
||||
<field name="bom_id" ref="mrp_bom_manufacture"/>
|
||||
<field name="time_cycle">60</field>
|
||||
<field name="active">false</field>
|
||||
</record>
|
||||
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<data>
|
||||
<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>
|
||||
</data>
|
||||
</odoo>
|
||||
@@ -1,7 +1,5 @@
|
||||
from . import sale_order
|
||||
from . import product_template
|
||||
from . import http
|
||||
from . import models
|
||||
from . import process
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
from odoo import fields, models, api
|
||||
|
||||
|
||||
class ResMrpRoutingWorkcenter(models.Model):
|
||||
_inherit = 'mrp.routing.workcenter'
|
||||
|
||||
code = fields.Char('唯一编码')
|
||||
is_repeat = fields.Boolean('重复',default=False)
|
||||
sort = fields.Integer('排序')
|
||||
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
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='型号')
|
||||
model_type_id = fields.Many2one('sf.model.type', string='类型')
|
||||
processing_panel = fields.Char('加工面板')
|
||||
# 胚料的长,宽,高
|
||||
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)
|
||||
|
||||
|
||||
class ModelType(models.Model):
|
||||
_name = 'sf.model.type'
|
||||
_description = '模型类型'
|
||||
|
||||
name = fields.Char('名称')
|
||||
code = fields.Char('编码')
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
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)
|
||||
@@ -1,2 +1,2 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_sf_model_type,sf_model_type,model_sf_model_type,base.group_user,1,1,1,1
|
||||
|
||||
|
||||
|
@@ -1,85 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<data>
|
||||
<record model="ir.ui.view" id="view_product_template_form_inherit_sf">
|
||||
<field name="name">product.template.form.inherit.sf</field>
|
||||
<field name="model">product.template</field>
|
||||
<field name="inherit_id" ref="product.product_template_only_form_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//page[last()]" position="after">
|
||||
<page string="加工参数">
|
||||
<group>
|
||||
<group string="模型">
|
||||
<field name="model_long"/>
|
||||
<field name="model_width"/>
|
||||
<field name="model_height"/>
|
||||
<field name="model_volume"/>
|
||||
<field name="model_type_id"/>
|
||||
<field name="processing_panel" placeholder="例如A,B"/>
|
||||
<field name="model_precision"/>
|
||||
<field name="model_materials_id"/>
|
||||
<field name="model_materials_type_id"
|
||||
domain="[('materials_id', '=', model_materials_id)]"/>
|
||||
</group>
|
||||
<group string="胚料">
|
||||
<field name="embryo_long"/>
|
||||
<field name="embryo_width"/>
|
||||
<field name="embryo_height"/>
|
||||
<field name="volume" string="体积[mm³]"/>
|
||||
<field name="embryo_materials_id"/>
|
||||
<field name="embryo_materials_type_id"
|
||||
domain="[('materials_id', '=',embryo_materials_id)]"/>
|
||||
</group>
|
||||
</group>
|
||||
</page>
|
||||
</xpath>
|
||||
<!-- <xpath expr="//label[@for='volume']" position="before">-->
|
||||
<!-- <label for="embryo_long" string="尺寸"-->
|
||||
<!-- attrs="{'invisible':[('product_variant_count', '>', 1), ('is_product_variant', '=', False)]}"/>-->
|
||||
<!-- <div class="o_address_format"-->
|
||||
<!-- attrs="{'invisible':[('product_variant_count', '>', 1), ('is_product_variant', '=', False)]}">-->
|
||||
<!-- <label for="embryo_long" string="长"-->
|
||||
<!-- attrs="{'invisible':[('product_variant_count', '>', 1), ('is_product_variant', '=', False)]}"/>-->
|
||||
<!-- <field name="embryo_long" class="o_address_zip"-->
|
||||
<!-- attrs="{'invisible':[('product_variant_count', '>', 1), ('is_product_variant', '=', False)]}"/>-->
|
||||
<!-- <span>&nbsp;</span>-->
|
||||
<!-- <label for="embryo_width" string="宽"-->
|
||||
<!-- attrs="{'invisible':[('product_variant_count', '>', 1), ('is_product_variant', '=', False)]}"/>-->
|
||||
<!-- <field name="embryo_width" class="o_address_zip"-->
|
||||
<!-- attrs="{'invisible':[('product_variant_count', '>', 1), ('is_product_variant', '=', False)]}"/>-->
|
||||
<!-- <span>&nbsp;</span>-->
|
||||
<!-- <label for="embryo_height" string="高"-->
|
||||
<!-- attrs="{'invisible':[('product_variant_count', '>', 1), ('is_product_variant', '=', False)]}"/>-->
|
||||
<!-- <field name="embryo_height" class="o_address_zip"-->
|
||||
<!-- attrs="{'invisible':[('product_variant_count', '>', 1), ('is_product_variant', '=', False)]}"/>-->
|
||||
<!-- </div>-->
|
||||
<!-- </xpath>-->
|
||||
<!-- <xpath expr="//label[@for='produce_delay']" position="before">-->
|
||||
<!-- <label for="embryo_materials_id"-->
|
||||
<!-- attrs="{'invisible':[('product_variant_count', '>', 1), ('is_product_variant', '=', False)]}"/>-->
|
||||
<!-- <div class="o_row"-->
|
||||
<!-- attrs="{'invisible':[('product_variant_count', '>', 1), ('is_product_variant', '=', False)]}">-->
|
||||
<!-- <field name="embryo_materials_id"/>-->
|
||||
<!-- </div>-->
|
||||
<!-- <label for="embryo_materials_type_id"-->
|
||||
<!-- attrs="{'invisible':[('product_variant_count', '>', 1), ('is_product_variant', '=', False)]}"/>-->
|
||||
<!-- <div class="o_row"-->
|
||||
<!-- attrs="{'invisible':[('product_variant_count', '>', 1), ('is_product_variant', '=', False)]}">-->
|
||||
<!-- <field name="embryo_materials_type_id" domain="[('materials_id', '=', embryo_materials_id)]"/>-->
|
||||
<!-- </div>-->
|
||||
<!-- </xpath>-->
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_product_category_form_inherit_sf" model="ir.ui.view">
|
||||
<field name="name">product.category.form.inherit.sf</field>
|
||||
<field name="model">product.category</field>
|
||||
<field name="inherit_id" ref="product.product_category_form_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="parent_id" position="before">
|
||||
<field name="is_embryo"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<data>
|
||||
<record model="ir.ui.view" id="view_sale_order_form_inherit_sf">
|
||||
<field name="name">sale.order.form.inherit.sf</field>
|
||||
<field name="model">sale.order</field>
|
||||
<field name="inherit_id" ref="sale.view_order_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="payment_term_id" position="after">
|
||||
<field name="deadline_of_delivery"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user