一键同步 代码优化 常量共享

This commit is contained in:
gqh
2022-10-08 09:41:57 +08:00
parent 28d76109e7
commit 2e6b2489ee
8 changed files with 135 additions and 116 deletions

View File

@@ -80,47 +80,7 @@ class MachineTool(models.Model):
active = fields.Boolean('有效', default=True)
# @api.depends('type_id')
# def _compute_type_id(self):
# to_reset = self.filtered(lambda e: e.type_id != e.type_id.id)
# to_reset.type_id = False
# 编码规则:加工工厂编码-品牌编码-注册年月-00001
# def get_machine_tool_code(self):
# partner = self.env['res.partner'].sudo().search(
# [('is_factory', '=', True)],
# limit=1,
# order="id desc")
# brand = self.env['mrs.machine.brand'].sudo().search(
# [('tag_ids', '=', '机床')],
# limit=1,
# order="id desc")
# if not brand:
# num = item.brand_id.code + "%04d" % 1
# item.code = num
# else:
# print('--------')
# print(type)
# m = int(type.code[-4:]) + 1
# num = item.brand_id.code + "%04d" % m
# item.code = num
# 选择机床型号时,该型号的基本信息带出并赋给机床对应的信息里
# @api.onchange('type_id')
# def get_type_info(self):
# for item in self:
# item.knife_type = item.type_id.knife_type
# item.number_of_knife_library = item.type_id.number_of_knife_library
# item.number_of_axles = item.type_id.number_of_axles
# item.rotate_speed = item.type_id.rotate_speed
# item.precision = item.type_id.precision
# item.control_system_id = item.type_id.control_system_id
# item.x_axis = item.type_id.x_axis
# item.y_axis = item.type_id.y_axis
# item.z_axis = item.type_id.z_axis
# item.b_axis = item.type_id.b_axis
# item.c_axis = item.type_id.c_axis
class MachineToolType(models.Model):
@@ -153,48 +113,15 @@ class MachineToolType(models.Model):
active = fields.Boolean('有效', default=True)
code = fields.Char('编码')
# @api.onchange('brand_id')
# def get_machine_tool_type_code(self):
# for item in self:
# if not item.brand_id:
# return False
# type = self.env['mrs.machine_tool.type'].sudo().search(
# [('brand_id', '=', item.brand_id.id)],
# limit=1,
# order="id desc"
# )
# print(item.brand_id.id)
# if not type:
# num = item.brand_id.code + "%04d" % 1
# item.code = num
# print(item.code)
# else:
# print('----------')
# m = int(type.code[-4:]) + 1
# num = item.brand_id.code + "%04d" % m
# item.code = num
# print(item.code)
# 刀具
class CuttingTool(models.Model):
_name = 'mrs.cutting_tool.category'
_description = '刀具类别'
# def get_cutting_tool_category_code(self):
# code = self.env['mrs.cutting_tool.category'].sudo().search(
# [('code', '!=', False)], limit=1,
# order="id desc")
# if not code:
# num = "%03d" % 1
# else:
# m = int(code.code) + 1
# num = "%03d" % m
# return num
code = fields.Char('编码')
name = fields.Char('名称')
# type_ids = fields.One2many('mrs.cutting_tool.type', 'category_id', string='刀具型号')
remark = fields.Text('备注')
active = fields.Boolean('有效', default=True)
@@ -216,23 +143,3 @@ class CuttingToolType(models.Model):
brand_id = fields.Many2one('mrs.machine.brand', string='品牌')
remark = fields.Text('备注')
active = fields.Boolean('有效', default=True)
# @api.onchange('brand_id', 'category_id')
# def get_cutting_tool_type_code(self):
# for item in self:
# if not item.brand_id:
# return False
# if not item.category_id:
# return False
# type = self.env['mrs.cutting_tool.type'].sudo().search(
# [('brand_id', '=', item.brand_id.id), ('brand_id', '=', item.category_id.id)],
# limit=1,
# order="id desc"
# )
# if not type:
# num = item.brand_id.code + item.category_id.code + "%03d" % 1
# item.code = num
# else:
# m = int(type.code[-4:]) + 1
# num = item.brand_id.code + item.category_id.code + "%03d" % m
# item.code = num