更新制造订单生成工单时的工序字段

This commit is contained in:
gqh
2022-11-17 17:27:05 +08:00
parent 4f0df9f2bd
commit 057ec915d9
23 changed files with 792 additions and 148 deletions

View File

@@ -14,9 +14,9 @@
'data': [
'security/group_security.xml',
'security/ir.model.access.csv',
'data/product_data.xml',
'views/mrs_base_view.xml',
'views/mrs_common_view.xml',
'views/mrp_routing_workcenter_view.xml',
"views/menu_view.xml",
'views/sale_order_view.xml',
'views/product_template_view.xml',

View File

@@ -11,27 +11,30 @@ class ResProductTemplate(models.Model):
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='模型类型')
model_processing_panel = fields.Char('模型加工面板')
model_surface_process_id = fields.Many2one('mrs.production.process', string='表面工艺')
model_process_parameters_id = fields.Many2one('mrs.processing.technology', string='工艺参数')
model_price = fields.Float('模型单价', digits=(16, 3))
model_total_amount = fields.Float('模型金额', digits=(16, 3))
model_number = fields.Integer('模型数量', default=1)
model_remark = fields.Char('模型备注说明')
# price = fields.Float('单价', digits=(16, 3))
# number = fields.Integer('数量', default=1)
# total_amount = fields.Float('金额', digits=(16, 3), compute='_compute_total_amount')
# model_number =
long = fields.Float('长[mm]', digits=(16, 3), onchange='count_embryo_size')
width = fields.Float('[mm]', digits=(16, 3), onchange='count_embryo_size')
height = fields.Float('[mm]', digits=(16, 3), onchange='count_embryo_size')
materials_id = fields.Many2one('mrs.production.materials', string='材料')
materials_type_id = fields.Many2one('mrs.materials.model', string='材料型号')
# 胚料的长,宽,高
embryo_long = fields.Float('胚料长[mm]', digits=(16, 3), onchange='count_embryo_size')
embryo_width = fields.Float('胚料宽[mm]', digits=(16, 3), onchange='count_embryo_size')
embryo_height = fields.Float('胚料高[mm]', digits=(16, 3), onchange='count_embryo_size')
embryo_materials_id = fields.Many2one('mrs.production.materials', string='胚料材料')
embryo_materials_type_id = fields.Many2one('mrs.materials.model', string='胚料材料型号')
volume = fields.Float(compute='_compute_volume', store=True)
@api.depends('long', 'width', 'height')
@api.depends('embryo_long', 'embryo_width', 'embryo_height')
def _compute_volume(self):
self.volume = self.long * self.width * self.height
self.volume = self.embryo_long * self.embryo_width * self.embryo_height
# 业务平台分配工厂后在智能工厂先创建销售订单再创建该产品
def product_create(self, product_id, item, order_id, order_number, i):
@@ -43,21 +46,18 @@ class ResProductTemplate(models.Model):
'model_width': item['model_width'],
'model_height': item['model_height'],
'model_volume': item['model_volume'],
'model_price': item['price'],
'model_total_amount': item['total_amount'],
'model_number': item['number'],
'list_price': item['price'],
'materials_id': self.env['mrs.production.materials'].search(
'model_materials_id': self.env['mrs.production.materials'].search(
[('materials_no', '=', item['texture_code'])]).id,
'materials_type_id': self.env['mrs.materials.model'].search(
'model_materials_type_id': self.env['mrs.materials.model'].search(
[('materials_no', '=', item['texture_type_code'])]).id,
# 'model_surface_process_id': self.env['mrs.production.process'].search(
# [('process_encode', '=', item['surface_process_code'])]).id,
# 'model_process_parameters_id': self.env['mrs.processing.technology'].search(
# [('process_encode', '=', item['process_parameters_code'])]).id,
'model_surface_process_id': self.env['mrs.production.process'].search(
[('process_encode', '=', item['surface_process_code'])]).id,
'model_process_parameters_id': self.env['mrs.processing.technology'].search(
[('process_encode', '=', item['process_parameters_code'])]).id,
''
'default_code': '%s-%s' % (order_number, i),
'model_remark': item['remark'],
# 'barcode': item['barcode'],
'barcode': item['barcode'],
'active': True
}
copy_product_id.sudo().write(vals)
@@ -65,19 +65,19 @@ class ResProductTemplate(models.Model):
# 在产品上增加模型类型和加工的面例如A、B)
# 并根据模型类型计算出产品的胚料尺寸;
# @api.onchange('model_type_id')
# def count_embryo_size(self):
# if not self.model_type_id:
# return
# bom = self.env['product.product'].search(
# [('categ_id.is_embryo', '=', True), ('product_tmpl_id', '=', self.id)],
# limit=1,
# order='volume desc'
# )
# for item in self:
# item.embryo_long = bom.embryo_long + 1
# item.embryo_width = bom.embryo_width + 1
# item.embryo_height = bom.embryo_height + 1
@api.onchange('model_type_id')
def count_embryo_size(self):
if not self.model_type_id:
return
bom = self.env['product.product'].search(
[('categ_id.is_embryo', '=', True), ('product_tmpl_id', '=', self.id)],
limit=1,
order='volume desc'
)
for item in self:
item.embryo_long = bom.embryo_long + 1
item.embryo_width = bom.embryo_width + 1
item.embryo_height = bom.embryo_height + 1
@@ -104,32 +104,22 @@ class ResMrpBom(models.Model):
# 生成产品BOM匹配胚料胚料的匹配规则
# 一、匹配的胚料类别需要带有胚料的标签;
# 二、胚料的材料型号与生成产品的材料型号一致;如没有新增一条
# 二、胚料的材料型号与生成产品的材料型号一致;
# 三、胚料的长宽高均要大于模型的长宽高;
# 四、如果匹配成功多个胚料,则选取体积最小的胚料;
def bom_create_Line(self, product):
embryo = self.env['product.product'].search(
[('categ_id.is_embryo', '=', True), ('materials_type_id', '=', product.materials_type_id.id),
('long', '>', product.long), ('width', '>', product.width),
('height', '>', product.height)
[('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'
)
# if not embryo:
# embryo = self.env['product.product'].search(
# [('categ_id.is_embryo', '=', True), ('materials_type_id', '=', product.materials_type_id.id),
# ('long', '>', product.long), ('width', '>', product.width),
# ('height', '>', product.height)
# ],
# limit=1,
# order='volume desc'
# )
vals = {
'bom_id': self.id,
'product_id': embryo.id or 1,
'product_tmpl_id': embryo.product_tmpl_id.id or 1,
'product_id': embryo.id,
'product_tmpl_id': embryo.product_tmpl_id.id,
'product_qty': 1,
'product_uom_id': 1
}

View File

@@ -7,12 +7,9 @@ class ReSaleOrder(models.Model):
_inherit = 'sale.order'
deadline_of_delivery = fields.Date('交货截止日期')
person_of_delivery = fields.Char('交货人')
telephone_of_delivery = fields.Char('交货人电话号码')
address_of_delivery = fields.Char('交货人地址')
# 业务平台分配工厂后在智能工厂先创建销售订单
def sale_order_create(self, company_id, delivery_name, delivery_telephone, delivery_address, deadline_of_delivery):
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,
@@ -21,9 +18,6 @@ class ReSaleOrder(models.Model):
'partner_id': 8,
'state': 'sale',
'user_id': 6,
'person_of_delivery': delivery_name,
'telephone_of_delivery': delivery_telephone,
'address_of_delivery': delivery_address,
'deadline_of_delivery': deadline_of_delivery
})
return order_id
@@ -33,7 +27,7 @@ class ReSaleOrder(models.Model):
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.materials_id.name),
'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']
}

View File

@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<data>
#-----------------作业-------------------
<record model="ir.ui.view" id="view_mrp_routing_workcenter_form_inherit_sf">
<field name="name">mrp.routing.workcenter.form.inherit.sf</field>
<field name="model">mrp.routing.workcenter</field>
<field name="inherit_id" ref="mrp.mrp_routing_workcenter_form_view"/>
<field name="arch" type="xml">
<field name="workcenter_id" position="replace">
<field name="workcenter_ids" widget="many2many_tags" string="工作中心" required="0"/>
</field>
<field name="bom_product_template_attribute_value_ids" position="after">
<field name="routing_type" required="1"/>
<field name="is_repeat"/>
</field>
</field>
</record>
#-----------------工单-------------------
<record model="ir.ui.view" id="view_mrp_production_workorder_form_inherit_sf">
<field name="name">mrp.production.workorder.form.inherit.sf</field>
<field name="model">mrp.workorder</field>
<field name="inherit_id" ref="mrp.mrp_production_workorder_form_view_inherit"/>
<field name="arch" type="xml">
<field name="production_id" position="after">
<field name="processing_panel" readonly="1"/>
</field>
</field>
</record>
<!-- <record model="ir.ui.view" id="view_mrp_production_workorder_tree_inherit_sf">-->
<!-- <field name="name">mrp.production.workorder.tree.inherit.sf</field>-->
<!-- <field name="model">mrp.workorder</field>-->
<!-- <field name="inherit_id" ref="mrp.mrp_production_workorder_tree_view"/>-->
<!-- <field name="arch" type="xml">-->
<!-- <field name="workcenter_id" position="replace">-->
<!-- <filter name="workcenter_ids" string="工作中心" />-->
<!-- </field>-->
<!-- </field>-->
<!-- </record>-->
<!-- <record model="ir.ui.view" id="view_mrp_production_workorder_filter_inherit_sf">-->
<!-- <field name="name">mrp.production.workorder.filter.inherit.sf</field>-->
<!-- <field name="model">mrp.workorder</field>-->
<!-- <field name="inherit_id" ref="mrp.view_mrp_production_workorder_form_view_filter"/>-->
<!-- <field name="arch" type="xml">-->
<!-- <xpath expr="//filter[@name='work_center']" position="replace">-->
<!-- <filter name="work_center" string="工作中心" context="{'group_by': 'workcenter_ids'}"/>-->
<!-- </xpath>-->
<!-- </field>-->
<!-- </record>-->
#-----------------制造订单里的工单-------------------
<record model="ir.ui.view" id="view_mrp_production_workorder_tree_editable_inherit_sf">
<field name="name">mrp.production.workorder.tree.editable.inherit.sf</field>
<field name="model">mrp.workorder</field>
<field name="inherit_id" ref="mrp.mrp_production_workorder_tree_editable_view"/>
<field name="arch" type="xml">
<field name="name" position="after">
<field name="processing_panel"/>
</field>
</field>
</record>
</data>
</odoo>

View File

@@ -6,43 +6,30 @@
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_only_form_view"/>
<field name="arch" type="xml">
<field name="invoice_policy" position="after">
<field name="materials_id" string="材料"/>
<field name="materials_type_id" string="型号"
domain="[('materials_id', '=', materials_id)]"/>
</field>
<xpath expr="//label[@for='volume']" position="before">
<label for="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="long" string="长"/>
<field name="long" class="o_address_zip"/>
<span>&amp;nbsp;</span>
<label for="width" string="宽"/>
<field name="width" class="o_address_zip"/>
<span>&amp;nbsp;</span>
<label for="height" string="高"/>
<field name="height" class="o_address_zip"/>
</div>
</xpath>
<xpath expr="//page[last()]" position="after">
<page string="加工参数">
<group string="模型">
<field name="model_long" string="长[mm]"/>
<field name="model_width" string="[mm]"/>
<field name="model_height" string="[mm]"/>
<field name="model_volume" string="体积[mm]"/>
<field name="model_type_id" string="模板类型"/>
<field name="model_processing_panel" placeholder="例如A,B" string="加工面板"/>
<field name="model_precision" string="精度要求"/>
<field name="model_surface_process_id" string="表面工艺"/>
<field name="model_process_parameters_id" string="工艺参数"
domain="[('processing_order_ids', '=', model_surface_process_id)]"/>
<field name="model_price" string="单价"/>
<field name="model_total_amount" string="金额"/>
<field name="model_number" string="数量"/>
<field name="model_remark" string="备注说明"/>
<group>
<group string="模型">
<field name="model_long" string="[mm]"/>
<field name="model_width" string="[mm]"/>
<field name="model_height" string="[mm]"/>
<field name="model_volume" string="体积[mm]"/>
<field name="model_type_id" string="模板类型"/>
<field name="model_processing_panel" placeholder="例如A,B" string="加工面板"/>
<field name="model_precision" string="精度要求"/>
<field name="model_materials_id" string="材料"/>
<field name="model_materials_type_id" string="型号"
domain="[('materials_id', '=', model_materials_id)]"/>
</group>
<group string="胚料">
<field name="embryo_long" string="长[mm]"/>
<field name="embryo_width" string="宽[mm]"/>
<field name="embryo_height" string="高[mm]"/>
<field name="volume" string="体积[mm³]"/>
<field name="embryo_materials_id" string="材料"/>
<field name="embryo_materials_type_id" string="型号"
domain="[('materials_id', '=',embryo_materials_id)]"/>
</group>
</group>
</page>
</xpath>

View File

@@ -9,18 +9,6 @@
<field name="payment_term_id" position="after">
<field name="deadline_of_delivery"/>
</field>
<field name="sale_order_template_id" position="after">
<label for="person_of_delivery" string="交货信息"/>
<div>
<field name="person_of_delivery"/>
<span>&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
</span>
<field name="telephone_of_delivery"/>
<span>&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
</span>
<field name="address_of_delivery"/>
</div>
</field>
</field>
</record>
</data>