匹配加工中心

This commit is contained in:
jinling.yang
2022-11-03 17:58:33 +08:00
parent 671901cb8d
commit 14d0d32ab6
7 changed files with 41 additions and 44 deletions

View File

@@ -23,6 +23,22 @@ class ResMrpRoutingWorkcenter(models.Model):
company_id = fields.Many2one('res.company', compute="get_company_id", related=False)
# 工单对应的工作中心,根据工序中的工作中心去匹配,
# 如果只配置了一个工作中心,则默认采用该工作中心;
# 如果有多个工作中心,
# 则根据该工作中心的工单个数进行分配(优先分配给工单个数最少的);
# def get_workcenter(self, workcenter_ids):
# print(workcenter_ids[0].id)
# if workcenter_ids:
# if len(workcenter_ids) == 1:
# return workcenter_ids[0].id
# elif len(workcenter_ids) >= 2:
# workcenter_id = self.env['mrp.workorder'].search(
# [('workcenter_ids.id', 'in', True)],
# limit=1,
# group_by =
# )
class ModelTypeRoutingSort(models.Model):
_name = 'sf.model.type.routing.sort'

View File

@@ -13,12 +13,10 @@ access_mrs_production_materials,mrs_production_materials,model_mrs_production_ma
access_mrs_materials_model,mrs_materials_model,model_mrs_materials_model,base.group_user,1,1,1,1
access_mrs_processing_technology,mrs_processing_technology,model_mrs_processing_technology,base.group_user,1,1,1,1
access_sf_tray,sf_tray,model_sf_tray,base.group_user,1,1,1,1
<<<<<<< HEAD
access_cnc_processing,cnc_processing,model_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
>>>>>>> 8e337dda97a98a9a8d0a892a2c39bc076640f6ac
Can't render this file because it has a wrong number of fields in line 16.

View File

@@ -17,8 +17,8 @@
</record>
#-----------------工单-------------------
<record model="ir.ui.view" id="view_mrp_workorder_form_inherit_sf">
<field name="name">mrp.workorder.form.inherit.sf</field>
<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">
@@ -28,16 +28,16 @@
</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>-->
#-----------------制造订单的工单-------------------
<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

@@ -293,27 +293,10 @@
<field name="name">sf.tray.search</field>
<field name="model">sf.tray</field>
<field name="arch" type="xml">
<<<<<<< HEAD
<!-- <group>-->
<search string="托盘">
<field name="name" string="名称" filter_domain="[('name','like',self)]"/>
<field name="code" string="编码" filter_domain="[('code','like',self)]"/>
</search>
<group string="分组">
<filter name="state" string="状态" domain="[]" context="{'group_by': 'state'}"/>
</group>
=======
<search string="托盘">
<field name="name" string="名称" filter_domain="[('name','ilike',self)]"/>
<field name="code" string="编码" filter_domain="[('code','ilike',self)]"/>
</search>
<!-- <group string="分组">-->
<!-- <filter name="state" string="状态" domain="[]" context="{'group_by': 'state'}"/>-->
>>>>>>> 8e337dda97a98a9a8d0a892a2c39bc076640f6ac
<!-- </group>-->
</field>
</record>
@@ -333,7 +316,9 @@
<field name="name">sf.tray.form</field>
<field name="model">sf.tray</field>
<field name="arch" type="xml">
<header><field name = 'state' widget="radio" options="{'horizontal': True}"/></header>
<header>
<field name='state' widget="radio" options="{'horizontal': True}"/>
</header>
<form string="托盘">
<group string="基本信息" name="group1">
<group>
@@ -348,6 +333,5 @@
</record>
</data>
</odoo>

View File

@@ -11,3 +11,5 @@ class ResMrpWorkOrder(models.Model):
workcenter_id = fields.Many2one('mrp.workcenter', required=False)
processing_panel = fields.Char('加工面')

View File

@@ -31,10 +31,6 @@ class MrpProduction(models.Model):
# 重载根据工序生成工单的程序如果产品BOM中没有工序时
# 根据产品对应的模板类型中工序,去生成工单;
# 工单对应的工作中心,根据工序中的工作中心去匹配,
# 如果只配置了一个工作中心,则默认采用该工作中心;
# 如果有多个工作中心,
# 则根据该工作中心的工单个数进行分配(优先分配给工单个数最少的);
# CNC加工工序的选取规则
# 如果自动报价有带过来预分配的机床,
# 则根据设备找到工作中心;否则采用前面描述的工作中心分配机制;
@@ -68,10 +64,10 @@ class MrpProduction(models.Model):
'operation_id': operation.id,
'state': 'pending',
}]
# 根据加工面板的面数及对应的工序模板生成工
# 根据加工面板的面数及对应的工序模板生成工
for k in (production.product_id.processing_panel.split(',')):
for route in production.product_id.model_type_id.routing_tmpl_ids:
if route.route_workcenter_id:
if route:
workorders_values_str = [0, '', {
'product_uom_id': production.product_uom_id.id,
'qty_producing': 0,
@@ -79,6 +75,7 @@ class MrpProduction(models.Model):
'name': route.route_workcenter_id.name,
'processing_panel': k,
'workcenter_id': False,
# 'workcenter_ids': self.env['mrp.routing.workcenter'].get_workcenter(route.workcenter_ids),
'date_planned_start': False,
'date_planned_finished': False,
'duration_expected': 60,

View File

@@ -9,8 +9,8 @@ import qrcode
from io import BytesIO
from odoo import api, fields, models
import barcode
from barcode.writer import ImageWriter
from pystrich.code128 import Code128Encoder
# from barcode.writer import ImageWriter
# from pystrich.code128 import Code128Encoder
from odoo.exceptions import UserError
_logger = logging.getLogger(__name__)