diff --git a/sf_manufacturing/__manifest__.py b/sf_manufacturing/__manifest__.py index 35620913..2bde02d9 100644 --- a/sf_manufacturing/__manifest__.py +++ b/sf_manufacturing/__manifest__.py @@ -2,7 +2,7 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. { 'name': '机企猫智能工厂 制造管理', - 'version': '1.1', + 'version': '1.0', 'summary': '智能工厂制造模块', 'sequence': 1, 'description': """ diff --git a/sf_manufacturing/migrations/1.1/pre-migrate.py b/sf_manufacturing/migrations/1.1/pre-migrate.py deleted file mode 100644 index 2fb94a6c..00000000 --- a/sf_manufacturing/migrations/1.1/pre-migrate.py +++ /dev/null @@ -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; - """) diff --git a/sf_manufacturing/models/model_type.py b/sf_manufacturing/models/model_type.py index df47aecc..0dd272bd 100644 --- a/sf_manufacturing/models/model_type.py +++ b/sf_manufacturing/models/model_type.py @@ -6,7 +6,8 @@ class ModelType(models.Model): _description = '模型类型' 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', '成品工序模板(自动化产线加工') embryo_routing_tmpl_ids = fields.One2many('sf.embryo.model.type.routing.sort', 'embryo_model_type_id', diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index 23439e27..b01cc465 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -852,9 +852,11 @@ class ResProductMo(models.Model): attachment = self.attachment_create(item['model_name'], item['model_data']) # 获取坯料冗余配置 if not item.get('embryo_redundancy'): - embryo_redundancy_id = model_type.embryo_tolerance + embryo_redundancy_id = model_type.embryo_tolerance_id else: embryo_redundancy_id = item.get('embryo_redundancy') + if not embryo_redundancy_id: + raise UserError('请先配置模型类型内的坯料冗余') vals = { 'name': '%s-%s-%s' % ('P', order_id.name, i), '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) # 获取坯料冗余配置 if not item.get('embryo_redundancy_id'): - embryo_redundancy_id = model_type.embryo_tolerance + embryo_redundancy_id = model_type.embryo_tolerance_id else: 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) vals = { 'name': '%s-%s-%s [%s %s-%s * %s * %s]' % ('R', diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index 7831a05f..9642cb51 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -309,9 +309,10 @@ class StockRule(models.Model): production_item.write({'programming_no': production_programming.programming_no, 'programming_state': '编程中'}) if not technology_design_values: + i = 0 if production_item.product_id.categ_id.type == '成品': # 根据加工面板的面数及成品工序模板生成工序设计 - i = 0 + for k in (production_item.product_id.model_processing_panel.split(',')): if production_item.production_type == '自动化产线加工': product_routing_workcenter = self.env['sf.product.model.type.routing.sort'].search( @@ -939,6 +940,11 @@ class ReStockMove(models.Model): move_lines_commands.append((0, 0, move_line_cmd)) qty_by_location[loc.id] += 1 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): diff --git a/sf_manufacturing/views/model_type_view.xml b/sf_manufacturing/views/model_type_view.xml index 56d5f94c..f0ffd81a 100644 --- a/sf_manufacturing/views/model_type_view.xml +++ b/sf_manufacturing/views/model_type_view.xml @@ -31,7 +31,7 @@
- + diff --git a/sf_plan/models/custom_plan.py b/sf_plan/models/custom_plan.py index 273cbfc6..2cb89678 100644 --- a/sf_plan/models/custom_plan.py +++ b/sf_plan/models/custom_plan.py @@ -93,7 +93,11 @@ class sf_production_plan(models.Model): @api.model 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) return info @@ -446,8 +450,12 @@ class MrpProductionInheritForPlan(models.Model): def toggle_active(self): # 调用父类方法切换 active 状态 res = super(MrpProductionInheritForPlan, self).toggle_active() + stage_active = self.filtered('active') + stage_inactive = self - stage_active self.env['sf.production.plan'].search( - [('production_id', '=', self.id), '|', ('active', '=', False), ('active', '=', True)]).write( - {'active': self.active}) - + [('production_id', 'in', stage_active.ids)]).write( + {'active': True}) + self.env['sf.production.plan'].search( + [('production_id', 'in', stage_inactive.ids)]).write( + {'active': False}) return res