Accept Merge Request #1521: (feature/sale_order_route_pick -> develop)

Merge Request: 修改坯料冗余

Created By: @胡尧
Accepted By: @胡尧
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/1521?initial=true
This commit is contained in:
胡尧
2024-11-19 11:57:29 +08:00
committed by Coding
7 changed files with 29 additions and 16 deletions

View File

@@ -2,7 +2,7 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details. # Part of Odoo. See LICENSE file for full copyright and licensing details.
{ {
'name': '机企猫智能工厂 制造管理', 'name': '机企猫智能工厂 制造管理',
'version': '1.1', 'version': '1.0',
'summary': '智能工厂制造模块', 'summary': '智能工厂制造模块',
'sequence': 1, 'sequence': 1,
'description': """ 'description': """

View File

@@ -1,6 +0,0 @@
def migrate(cr, version):
cr.execute("""
UPDATE sf_model_type
SET embryo_tolerance = (SELECT id FROM sf_embryo_redundancy LIMIT 1)
WHERE embryo_tolerance = 0;
""")

View File

@@ -6,7 +6,8 @@ class ModelType(models.Model):
_description = '模型类型' _description = '模型类型'
name = fields.Char('名称') name = fields.Char('名称')
embryo_tolerance = fields.Many2one('sf.embryo.redundancy', string='坯料容余', required=True) # embryo_tolerance = fields.Char('坯料容余')
embryo_tolerance_id = fields.Many2one('sf.embryo.redundancy', string='坯料容余')
product_routing_tmpl_ids = fields.One2many('sf.product.model.type.routing.sort', 'product_model_type_id', product_routing_tmpl_ids = fields.One2many('sf.product.model.type.routing.sort', 'product_model_type_id',
'成品工序模板(自动化产线加工') '成品工序模板(自动化产线加工')
embryo_routing_tmpl_ids = fields.One2many('sf.embryo.model.type.routing.sort', 'embryo_model_type_id', embryo_routing_tmpl_ids = fields.One2many('sf.embryo.model.type.routing.sort', 'embryo_model_type_id',

View File

@@ -852,9 +852,11 @@ class ResProductMo(models.Model):
attachment = self.attachment_create(item['model_name'], item['model_data']) attachment = self.attachment_create(item['model_name'], item['model_data'])
# 获取坯料冗余配置 # 获取坯料冗余配置
if not item.get('embryo_redundancy'): if not item.get('embryo_redundancy'):
embryo_redundancy_id = model_type.embryo_tolerance embryo_redundancy_id = model_type.embryo_tolerance_id
else: else:
embryo_redundancy_id = item.get('embryo_redundancy') embryo_redundancy_id = item.get('embryo_redundancy')
if not embryo_redundancy_id:
raise UserError('请先配置模型类型内的坯料冗余')
vals = { vals = {
'name': '%s-%s-%s' % ('P', order_id.name, i), 'name': '%s-%s-%s' % ('P', order_id.name, i),
'model_long': item['model_long'] + embryo_redundancy_id.long, 'model_long': item['model_long'] + embryo_redundancy_id.long,
@@ -948,9 +950,11 @@ class ResProductMo(models.Model):
supplier = self.env['mrp.bom'].get_supplier(materials_type_id) supplier = self.env['mrp.bom'].get_supplier(materials_type_id)
# 获取坯料冗余配置 # 获取坯料冗余配置
if not item.get('embryo_redundancy_id'): if not item.get('embryo_redundancy_id'):
embryo_redundancy_id = model_type.embryo_tolerance embryo_redundancy_id = model_type.embryo_tolerance_id
else: else:
embryo_redundancy_id = item.get('embryo_redundancy_id') embryo_redundancy_id = item.get('embryo_redundancy_id')
if not embryo_redundancy_id:
raise UserError('请先配置模型类型内的坯料冗余')
logging.info('no_bom_copy_product_supplier-vals:%s' % supplier) logging.info('no_bom_copy_product_supplier-vals:%s' % supplier)
vals = { vals = {
'name': '%s-%s-%s [%s %s-%s * %s * %s]' % ('R', 'name': '%s-%s-%s [%s %s-%s * %s * %s]' % ('R',

View File

@@ -309,9 +309,10 @@ class StockRule(models.Model):
production_item.write({'programming_no': production_programming.programming_no, production_item.write({'programming_no': production_programming.programming_no,
'programming_state': '编程中'}) 'programming_state': '编程中'})
if not technology_design_values: if not technology_design_values:
i = 0
if production_item.product_id.categ_id.type == '成品': if production_item.product_id.categ_id.type == '成品':
# 根据加工面板的面数及成品工序模板生成工序设计 # 根据加工面板的面数及成品工序模板生成工序设计
i = 0
for k in (production_item.product_id.model_processing_panel.split(',')): for k in (production_item.product_id.model_processing_panel.split(',')):
if production_item.production_type == '自动化产线加工': if production_item.production_type == '自动化产线加工':
product_routing_workcenter = self.env['sf.product.model.type.routing.sort'].search( product_routing_workcenter = self.env['sf.product.model.type.routing.sort'].search(
@@ -940,6 +941,11 @@ class ReStockMove(models.Model):
qty_by_location[loc.id] += 1 qty_by_location[loc.id] += 1
return move_lines_commands return move_lines_commands
# def _prepare_procurement_origin(self):
# """修改采购来源"""
# self.ensure_one()
# return self.group_id and self.group_id.name or (self.origin or self.picking_id.name or "/")
class ReStockQuant(models.Model): class ReStockQuant(models.Model):
_inherit = 'stock.quant' _inherit = 'stock.quant'

View File

@@ -31,7 +31,7 @@
<form string="模型类型"> <form string="模型类型">
<group> <group>
<field name="name" required="1"/> <field name="name" required="1"/>
<field name="embryo_tolerance" required="1" string="坯料容余(mm)"/> <field name="embryo_tolerance_id" required="1" string="坯料容余(mm)"/>
</group> </group>
<group> <group>
<field name='product_routing_tmpl_ids'> <field name='product_routing_tmpl_ids'>

View File

@@ -93,7 +93,11 @@ class sf_production_plan(models.Model):
@api.model @api.model
def search_read(self, domain=None, fields=None, offset=0, limit=None, order=None): def search_read(self, domain=None, fields=None, offset=0, limit=None, order=None):
"""
修改搜索方法,只有制造订单状态为待排程时才显示
"""
domain = domain or []
domain.append(('production_id.state', '!=', 'confirmed'))
info = super(sf_production_plan, self).search_read(domain, fields, offset, limit, order) info = super(sf_production_plan, self).search_read(domain, fields, offset, limit, order)
return info return info
@@ -446,8 +450,12 @@ class MrpProductionInheritForPlan(models.Model):
def toggle_active(self): def toggle_active(self):
# 调用父类方法切换 active 状态 # 调用父类方法切换 active 状态
res = super(MrpProductionInheritForPlan, self).toggle_active() res = super(MrpProductionInheritForPlan, self).toggle_active()
stage_active = self.filtered('active')
stage_inactive = self - stage_active
self.env['sf.production.plan'].search( self.env['sf.production.plan'].search(
[('production_id', '=', self.id), '|', ('active', '=', False), ('active', '=', True)]).write( [('production_id', 'in', stage_active.ids)]).write(
{'active': self.active}) {'active': True})
self.env['sf.production.plan'].search(
[('production_id', 'in', stage_inactive.ids)]).write(
{'active': False})
return res return res