产品模板的型号手动输入时型号对象的编码,联装类型,夹具物料字段的值显示
This commit is contained in:
@@ -3,7 +3,7 @@ from . import common
|
||||
from . import tool_base_new
|
||||
from . import fixture
|
||||
from . import functional_fixture
|
||||
# from . import quick_easy_order
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ class FixtureModel(models.Model):
|
||||
_name = 'sf.fixture.model'
|
||||
_description = "夹具型号"
|
||||
|
||||
code = fields.Char(string='编码')
|
||||
name = fields.Char(string="名称", size=15)
|
||||
fixture_material_id = fields.Many2one('sf.fixture.material', string="夹具物料", )
|
||||
fixture_material_type = fields.Char(string="夹具物料类型", related='fixture_material_id.name', store=True)
|
||||
@@ -53,10 +52,38 @@ class FixtureModel(models.Model):
|
||||
screw_size = fields.Integer(string="螺牙大小[mm]", size=6)
|
||||
active = fields.Boolean('有效', default=True)
|
||||
|
||||
# @api.model
|
||||
# def create(self, vals):
|
||||
# obj = super(FixtureModel, self).create(vals)
|
||||
# return obj
|
||||
def _get_code(self, fixture_model_type_code):
|
||||
fixture_model = self.env['sf.fixture.model'].sudo().search(
|
||||
[('code', 'ilike', fixture_model_type_code)],
|
||||
limit=1,
|
||||
order="id desc")
|
||||
if not fixture_model:
|
||||
num = "%03d" % 1
|
||||
else:
|
||||
m = int(fixture_model.code[-3:]) + 1
|
||||
num = "%03d" % m
|
||||
return "%s%s" % (fixture_model_type_code, num)
|
||||
|
||||
code = fields.Char(string='编码', readonly=True)
|
||||
|
||||
def _onchange_fixture_material_id(self, fixture_material_id):
|
||||
if fixture_material_id:
|
||||
if fixture_material_id.name == "气动夹具":
|
||||
code = self._get_code("JKM-C-JJWL-QDJJ-")
|
||||
elif fixture_material_id.name == "转接板(锁板)夹具":
|
||||
code = self._get_code("JKM-C-JJWL-ZJBJJ-")
|
||||
elif fixture_material_id.name == "磁吸夹具":
|
||||
code = self._get_code("JKM-C-JJWL-CXJJ-")
|
||||
elif fixture_material_id.name == "虎钳夹具":
|
||||
code = self._get_code("JKM-C-JJWL-HQJJ-")
|
||||
else:
|
||||
code = self._get_code("JKM-C-JJWL-LDKP-")
|
||||
return code
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
obj = super(FixtureModel, self).create(vals)
|
||||
if obj.fixture_material_id:
|
||||
code = self._onchange_fixture_material_id(obj.fixture_material_id)
|
||||
obj.code = code
|
||||
return obj
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
from odoo import models, fields
|
||||
import datetime
|
||||
import base64
|
||||
|
||||
|
||||
class QuickEasyOrder(models.Model):
|
||||
_name = 'quick.easy.order'
|
||||
_description = '简易下单'
|
||||
|
||||
name = fields.Char('订单编号', default=lambda self: self.env['ir.sequence'].next_by_code('quick.easy.order'))
|
||||
machining_precision = fields.Selection([
|
||||
('0.10', '±0.10mm'),
|
||||
('0.05', '±0.05mm'),
|
||||
('0.03', '±0.03mm'),
|
||||
('0.02', '±0.02mm'),
|
||||
('0.01', '±0.01mm')], string='加工精度')
|
||||
material_id = fields.Many2one('sf.production.materials', '材料')
|
||||
material_model_id = fields.Many2one('sf.materials.model', '型号')
|
||||
process_id = fields.Many2one('sf.production.process', string='表面工艺')
|
||||
parameter_ids = fields.One2many('sf.production.process.parameter', 'process_id', string='可选参数')
|
||||
quantity = fields.Integer('数量')
|
||||
price = fields.Float('总价')
|
||||
model_file = fields.Binary('模型文件')
|
||||
upload_model_file = fields.Many2many('ir.attachment', 'upload_qf_model_file_attachment_ref', string='上传模型文件')
|
||||
delivery_time = fields.Date('交货日期')
|
||||
customer_id = fields.Many2one('res.partner', string='客户', default=lambda self: self.env.user.partner_id.id)
|
||||
@@ -1,5 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from odoo import fields, models, api
|
||||
|
||||
|
||||
# from datetime import datetime
|
||||
# from odoo.exceptions import ValidationError
|
||||
|
||||
@@ -95,7 +97,6 @@ class CuttingToolModel(models.Model):
|
||||
_description = '刀具型号'
|
||||
|
||||
name = fields.Char('名称')
|
||||
code = fields.Char('编码')
|
||||
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_type_id = fields.Many2one('sf.cutting.tool.type', string='刀具类型',
|
||||
@@ -177,12 +178,43 @@ class CuttingToolModel(models.Model):
|
||||
)
|
||||
active = fields.Boolean('有效', default=True)
|
||||
|
||||
# @api.model
|
||||
# def create(self, vals):
|
||||
# if vals.get('name', '/') == '/' or vals.get('name', '/') is False:
|
||||
# vals['name'] = '/'
|
||||
# obj = super(CuttingToolModel, self).create(vals)
|
||||
# return obj
|
||||
def _get_code(self, cutting_tool_type_code):
|
||||
cutting_tool_model = self.search(
|
||||
[('code', 'ilike', cutting_tool_type_code)],
|
||||
limit=1,
|
||||
order="id desc")
|
||||
if not cutting_tool_model:
|
||||
num = "%03d" % 1
|
||||
else:
|
||||
m = int(cutting_tool_model.code[-3:]) + 1
|
||||
num = "%03d" % m
|
||||
return "%s%s" % (cutting_tool_type_code, num)
|
||||
|
||||
code = fields.Char(string='编码', readonly=True)
|
||||
|
||||
def _onchange_cutting_tool_material_id(self, cutting_tool_material_id):
|
||||
if cutting_tool_material_id:
|
||||
if cutting_tool_material_id.name == "整体式刀具":
|
||||
code = self._get_code("JKM-T-DJWL-ZTDJ-")
|
||||
elif cutting_tool_material_id.name == "刀片":
|
||||
code = self._get_code("JKM-T-DJWL-DPIA-")
|
||||
elif cutting_tool_material_id.name == "刀杆":
|
||||
code = self._get_code("JKM-T-DJWL-DGAN-")
|
||||
elif cutting_tool_material_id.name == "刀盘":
|
||||
code = self._get_code("JKM-T-DJWL-DPAN-")
|
||||
elif cutting_tool_material_id.name == "夹头":
|
||||
code = self._get_code("JKM-T-DJWL-DJIA-")
|
||||
else:
|
||||
code = self._get_code("JKM-T-DJWL-DBIN-")
|
||||
return code
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
obj = super(CuttingToolModel, self).create(vals)
|
||||
if obj.cutting_tool_material_id:
|
||||
code = self._onchange_cutting_tool_material_id(obj.cutting_tool_material_id)
|
||||
obj.code = code
|
||||
return obj
|
||||
|
||||
|
||||
# 刀具类型
|
||||
|
||||
Reference in New Issue
Block a user