Merge branch 'feature/110301' into develop

This commit is contained in:
jinling.yang
2022-11-07 10:31:58 +08:00
7 changed files with 65 additions and 47 deletions

View File

@@ -23,6 +23,22 @@ class ResMrpRoutingWorkcenter(models.Model):
company_id = fields.Many2one('res.company', compute="get_company_id", related=False) company_id = fields.Many2one('res.company', compute="get_company_id", related=False)
# 工单对应的工作中心,根据工序中的工作中心去匹配,
# 如果只配置了一个工作中心,则默认采用该工作中心;
# 如果有多个工作中心,
# 则根据该工作中心的工单个数进行分配(优先分配给工单个数最少的);
def get_workcenter(self, workcenter_ids):
if workcenter_ids:
if len(workcenter_ids) == 1:
return workcenter_ids[0]
elif len(workcenter_ids) >= 2:
# workcenter_ids_str = ','.join([str(s) for s in workcenter_ids])
self.env.cr.execute("""
SELECT workcenter_id FROM mrp_workorder where workcenter_id
in %s group by workcenter_id
order by count(*),workcenter_id asc limit 1 """, [tuple(workcenter_ids)])
return self.env.cr.dictfetchall()[0].get('workcenter_id')
class ModelTypeRoutingSort(models.Model): class ModelTypeRoutingSort(models.Model):
_name = 'sf.model.type.routing.sort' _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_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_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 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_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,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 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,27 +17,49 @@
</record> </record>
#-----------------工单------------------- #-----------------工单-------------------
<record model="ir.ui.view" id="view_mrp_workorder_form_inherit_sf"> <record model="ir.ui.view" id="view_mrp_production_workorder_form_inherit_sf">
<field name="name">mrp.workorder.form.inherit.sf</field> <field name="name">mrp.production.workorder.form.inherit.sf</field>
<field name="model">mrp.workorder</field> <field name="model">mrp.workorder</field>
<field name="inherit_id" ref="mrp.mrp_production_workorder_tree_view"/> <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="arch" type="xml">
<field name="name" position="after"> <field name="name" position="after">
<field name="processing_panel"/> <field name="processing_panel"/>
</field> </field>
</field> </field>
</record> </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> </data>
</odoo> </odoo>

View File

@@ -277,7 +277,7 @@
</record> </record>
#------------------托盘------------------ #------------------托盘------------------
<record id="action_sf_tray" model="ir.actions.act_window"> <record id="action_sf_tray" model="ir.actions.act_window">
<field name="name">托盘</field> <field name="name">托盘</field>
<field name="type">ir.actions.act_window</field> <field name="type">ir.actions.act_window</field>
<field name="res_model">sf.tray</field> <field name="res_model">sf.tray</field>
@@ -293,27 +293,10 @@
<field name="name">sf.tray.search</field> <field name="name">sf.tray.search</field>
<field name="model">sf.tray</field> <field name="model">sf.tray</field>
<field name="arch" type="xml"> <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="托盘"> <search string="托盘">
<field name="name" string="名称" filter_domain="[('name','ilike',self)]"/> <field name="name" string="名称" filter_domain="[('name','ilike',self)]"/>
<field name="code" string="编码" filter_domain="[('code','ilike',self)]"/> <field name="code" string="编码" filter_domain="[('code','ilike',self)]"/>
</search> </search>
<!-- <group string="分组">-->
<!-- <filter name="state" string="状态" domain="[]" context="{'group_by': 'state'}"/>-->
>>>>>>> 8e337dda97a98a9a8d0a892a2c39bc076640f6ac
<!-- </group>-->
</field> </field>
</record> </record>
@@ -333,7 +316,9 @@
<field name="name">sf.tray.form</field> <field name="name">sf.tray.form</field>
<field name="model">sf.tray</field> <field name="model">sf.tray</field>
<field name="arch" type="xml"> <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="托盘"> <form string="托盘">
<group string="基本信息" name="group1"> <group string="基本信息" name="group1">
<group> <group>
@@ -348,6 +333,5 @@
</record> </record>
</data> </data>
</odoo> </odoo>

View File

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

View File

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

View File

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