diff --git a/sf_dlm_management/views/product_template_management_view.xml b/sf_dlm_management/views/product_template_management_view.xml
index 8842f8bf..8dc5005d 100644
--- a/sf_dlm_management/views/product_template_management_view.xml
+++ b/sf_dlm_management/views/product_template_management_view.xml
@@ -31,9 +31,11 @@
options="{'no_create': True}"
attrs="{'invisible': [('categ_type', '!=', '刀具')],'required': [('categ_type', '=', '刀具')],'readonly': [('id', '!=', False)]}"
placeholder="请选择"/>
+
@@ -47,10 +49,10 @@
-
-
@@ -95,6 +97,16 @@
+
+ {'readonly': ['|',('id','!=',False),('categ_type', '=',
+ '刀具')], 'required': True}
+
+
+
+ {'readonly': [('categ_type', '=', '刀具')], 'invisible':
+ [('product_variant_count', '>' , 1)]}
+
+
@@ -455,7 +467,8 @@
-
+
diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py
index 7d9bbac5..0e09b018 100644
--- a/sf_manufacturing/models/product_template.py
+++ b/sf_manufacturing/models/product_template.py
@@ -50,8 +50,8 @@ class ResProductMo(models.Model):
cutting_tool_material_id = fields.Many2one('sf.cutting.tool.material', string='刀具物料')
cutting_tool_type = fields.Char(string="刀具物料类型", related='cutting_tool_material_id.name', store=True)
- cutting_tool_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='型号')
- specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='规格')
+ cutting_tool_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='型号名称')
+ specification_id = fields.Many2one('sf.tool.materials.basic.parameters', string='物料号')
cutting_tool_type_id = fields.Many2one('sf.cutting.tool.type', string='类型',
domain="[('cutting_tool_material_id.name', '=', cutting_tool_type)]")
@@ -104,6 +104,25 @@ class ResProductMo(models.Model):
compaction_way_id = fields.Many2one('maintenance.equipment.image',
'压紧方式', domain=[('type', '=', '压紧方式')])
+ name = fields.Char('产品名称', compute='_compute_tool_name', store=True, required=False)
+ default_code = fields.Char('内部参考', compute='_onchange_tool_default_code', store=True)
+
+ @api.depends('cutting_tool_model_id', 'specification_id')
+ def _compute_tool_name(self):
+ for item in self:
+ if item.cutting_tool_model_id and item.specification_id:
+ name = '%s%s' % (item.cutting_tool_model_id.name, item.specification_id.name)
+ item.name = name
+
+ @api.depends('categ_id', 'cutting_tool_material_id', 'cutting_tool_model_id')
+ def _onchange_tool_default_code(self):
+ for item in self:
+ if item.categ_id and item.cutting_tool_material_id and item.cutting_tool_model_id:
+ if item.cutting_tool_model_id.code:
+ default_code = '%s-T-DJWL-%s' % (
+ item.cutting_tool_model_id.code.split('-')[0], item.cutting_tool_material_id.code)
+ item.default_code = default_code
+
@api.onchange('cutting_tool_model_id')
def _onchange_cutting_tool_model_id(self):
for item in self:
@@ -721,6 +740,10 @@ class ResProductMo(models.Model):
logging.info('create-model_file:%s' % len(vals['model_file']))
self._sanitize_vals(vals)
templates = super(ResProductMo, self).create(vals_list)
+ # 产品名称唯一性校验
+ for item in templates:
+ if len(self.search([('name', '=', item.name)])) > 1:
+ raise ValidationError('产品名称【%s】已存在' % item.name)
if "create_product_product" not in self._context:
templates._create_variant_ids()