产品新增刀具规格向导
This commit is contained in:
@@ -63,10 +63,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.model', string='型号',
|
||||
)
|
||||
cutting_tool_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='型号')
|
||||
|
||||
cutting_tool_model = fields.Char('型号')
|
||||
cutting_tool_type_id = fields.Many2one('sf.cutting.tool.type', string='类型',
|
||||
domain="[('cutting_tool_material_id.name', '=', cutting_tool_type)]")
|
||||
|
||||
@@ -178,8 +176,8 @@ class ResProductMo(models.Model):
|
||||
# if self.integral_run_out_accuracy_min <= 0 and self.cutting_tool_type == '整体式刀具':
|
||||
# raise ValidationError("端跳精度最小(min)不能为0")
|
||||
|
||||
# cutting_speed_ids = fields.One2many('sf.cutting.speed', 'product_template_id', string='切削速度Vc')
|
||||
# feed_per_tooth_ids = fields.One2many('sf.feed.per.tooth', 'product_template_id', string='每齿走刀量fz')
|
||||
cutting_speed_ids = fields.One2many('sf.cutting.speed', 'product_template_id', string='切削速度Vc')
|
||||
feed_per_tooth_ids = fields.One2many('sf.feed.per.tooth', 'product_template_id', string='每齿走刀量fz')
|
||||
|
||||
# @api.constrains('suitable_machining_method_ids')
|
||||
# def _check_suitable_machining_method_ids(self):
|
||||
@@ -280,6 +278,21 @@ class ResProductMo(models.Model):
|
||||
# domain="[('cutting_tool_type', '=', '刀柄')]",
|
||||
# string='适用刀柄型号'
|
||||
# )
|
||||
|
||||
# @api.onchange('cutting_tool_model_id')
|
||||
# def onchange_method(self):
|
||||
# if self.cutting_tool_model_id:
|
||||
# return {
|
||||
# 'name': 'Import your first bill',
|
||||
# 'view_mode': 'form',
|
||||
# 'target': 'new',
|
||||
# 'view_type': 'form',
|
||||
# 'res_model': 'sf.cutting_tool.standard.library',
|
||||
# 'context': {'default_res_id': self.cutting_tool_model_id.id},
|
||||
# 'views': [[False, 'form']],
|
||||
# 'res_id': self.cutting_tool_model_id.id,
|
||||
# 'type': 'ir.actions.act_window',
|
||||
# }
|
||||
# 夹具参数
|
||||
fixture_material_id = fields.Many2one('sf.fixture.material', string="夹具物料")
|
||||
fixture_model_id = fields.Many2one('sf.fixture.model', string="夹具型号")
|
||||
@@ -408,41 +421,11 @@ class ResProductMo(models.Model):
|
||||
self.detailed_type = 'product'
|
||||
self.sale_ok = False
|
||||
|
||||
@api.onchange('cutting_tool_material_id')
|
||||
def _onchange_cutting_tool_material_id(self):
|
||||
if self.cutting_tool_material_id:
|
||||
try:
|
||||
config = self.env['res.config.settings'].get_values()
|
||||
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
|
||||
url = config['sf_url'] + '/api/cutting_model/list'
|
||||
res = {'token': config['token'], 'cutting_tool_material_code': self.cutting_tool_material_id.code}
|
||||
result = requests.post(url, json={}, data=res, headers=headers)
|
||||
result = result.json()
|
||||
if result['status'] == 1:
|
||||
data = result['data']
|
||||
model_ids = []
|
||||
for item in data:
|
||||
model_ids.append((0, 0, {
|
||||
'name': item['name']
|
||||
}))
|
||||
self.cutting_tool_model = model_ids
|
||||
return {}
|
||||
except Exception as e:
|
||||
logging.info("获取刀具标准库失败")
|
||||
# @api.onchange('cutting_tool_material_id')
|
||||
# def _onchange_cutting_tool_material_id(self):
|
||||
# if self.cutting_tool_material_id:
|
||||
|
||||
|
||||
@api.depends('cutting_tool_material_id')
|
||||
def _get_cutting_tool_model(self):
|
||||
try:
|
||||
config = self.env['res.config.settings'].get_values()
|
||||
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
|
||||
url = config['sf_url'] + '/api/cutting_model/list'
|
||||
res = {'token': config['token'], 'cutting_tool_material_code': self.cutting_tool_material_id.code}
|
||||
result = requests.post(url, json=res, data=None, headers=headers)
|
||||
cutting_model_data = result.json()
|
||||
if result['state'] == 1:
|
||||
return {'cutting_model_data': cutting_model_data}
|
||||
except Exception as e:
|
||||
logging.info("获取刀具标准库失败")
|
||||
|
||||
@api.onchange('fixture_material_id')
|
||||
def _onchange_fixture_material_id(self):
|
||||
|
||||
Reference in New Issue
Block a user