根据工序模板生成工单,及相关页面新增加工面板及重复字段

This commit is contained in:
jinling.yang
2022-11-03 15:01:15 +08:00
parent ae85009a18
commit f2988ddffb
5 changed files with 63 additions and 118 deletions

View File

@@ -12,7 +12,6 @@ class ModelType(models.Model):
class ResMrpRoutingWorkcenter(models.Model):
_inherit = 'mrp.routing.workcenter'
code = fields.Char('唯一编码')
is_repeat = fields.Boolean('重复', default=False)
workcenter_id = fields.Many2one('mrp.workcenter', required=False)
workcenter_ids = fields.Many2many('mrp.workcenter', 'rel_workcenter_route', required=True)
@@ -20,10 +19,9 @@ class ResMrpRoutingWorkcenter(models.Model):
# 获得当前登陆者公司
def get_company_id(self):
company = self.env.ref('base.main_company')
return company.id
self.company_id = self.env.user.company_id.id
company_id = fields.Many2one('res.company', default=lambda self: self.env.company)
company_id = fields.Many2one('res.company', compute="get_company_id", related=False)
class ModelTypeRoutingSort(models.Model):

View File

@@ -16,12 +16,17 @@ class ResProductTemplate(models.Model):
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_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('embryo_long', 'embryo_width', 'embryo_height')
def _compute_volume(self):
self.volume = self.embryo_long * self.embryo_width * self.embryo_height
# 业务平台分配工厂后在智能工厂先创建销售订单再创建该产品
def product_create(self, product_id, item, order_id, order_number, i):
@@ -49,16 +54,18 @@ class ResProductTemplate(models.Model):
# 并根据模型类型计算出产品的胚料尺寸;
@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.model_long = bom.embryo_long + 1
item.embryo_long = bom.embryo_long + 1
item.embryo_width = bom.embryo_width + 1
item.embryo_height = bom.embryo_height + 1
item.volume = item.model_long * item.embryo_width * item.embryo_height

View File

@@ -1,6 +1,7 @@
<?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>
@@ -9,7 +10,34 @@
<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="is_repeat"/>
</field>
</field>
</record>
#-----------------工单-------------------
<record model="ir.ui.view" id="view_mrp_workorder_form_inherit_sf">
<field name="name">mrp.workorder.form.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="name" position="after">
<field name="processing_panel"/>
</field>
</field>
</record>
#-----------------制造订单-------------------
<!-- <record model="ir.ui.view" id="view_mrp_production_form_inherit_sf">-->
<!-- <field name="name">mrp.production.form.inherit.sf</field>-->
<!-- <field name="model">mrp.production</field>-->
<!-- <field name="inherit_id" ref="mrp.mrp_production_form_view"/>-->
<!-- <field name="arch" type="xml">-->
<!-- <field name="workorder_ids" position="after">-->
<!-- </field>-->
<!-- </field>-->
<!-- </record>-->
</data>
</odoo>