1、优化刀柄物料产品适用夹头型号没有数据的问题,优化刀具标准库基本参数同步接口;2、优化功能刀具组装时,只需扫入刀柄的Rfid,将自动带出刀柄信息,并根据刀柄适用夹头型号和适配夹头尺寸随机带出一个可用夹头物料信息,同时将刀柄的Rfid码填入功能刀具的Rfid码。3、优化刀柄物料采购入库时的验证的判断条件;

This commit is contained in:
yuxianghui
2024-04-01 16:56:15 +08:00
parent 48809cd654
commit f0b972e705
5 changed files with 95 additions and 91 deletions

View File

@@ -295,35 +295,70 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
"""
for record in self:
if 'DJWL' in barcode:
records = record.env['stock.lot'].search([('name', '=', barcode)])
if not records:
lot_ids = record.env['stock.lot'].sudo().search([('name', '=', barcode)])
if not lot_ids:
raise ValidationError('扫描的条形码数据不存在,请重新扫描!')
for record_stock_lot in records:
if record_stock_lot.quant_ids[-1].location_id.name == '刀具组装位置':
raise ValidationError('该刀具物料已使用,请重新选择')
elif record_stock_lot.quant_ids[-1].location_id.name not in '刀具房':
raise ValidationError('该刀具物料未入库,请重新选择')
tool_material_name = record_stock_lot.product_id.cutting_tool_material_id.name
for lot_id in lot_ids:
if lot_id.quant_ids[-1].location_id.name == '刀具组装位置':
raise ValidationError('该刀具物料已使用,请重新扫描')
elif lot_id.quant_ids[-1].location_id.name not in '刀具房':
raise ValidationError('该刀具物料未入库,请重新扫描')
tool_material_name = lot_id.product_id.cutting_tool_material_id.name
if tool_material_name == '整体式刀具':
record.integral_code_id = record_stock_lot.id
record.integral_code_id = lot_id.id
elif tool_material_name == '刀片':
record.blade_code_id = record_stock_lot.id
record.blade_code_id = lot_id.id
elif tool_material_name == '刀杆':
record.bar_code_id = record_stock_lot.id
record.bar_code_id = lot_id.id
elif tool_material_name == '刀盘':
record.pad_code_id = record_stock_lot.id
record.pad_code_id = lot_id.id
elif tool_material_name == '刀柄':
record.handle_code_id = record_stock_lot.id
record.handle_code_id = lot_id.id
record.chuck_code_id = record.get_chuck_code_id(lot_id).id or False
elif tool_material_name == '夹头':
record.chuck_code_id = record_stock_lot.id
record.chuck_code_id = lot_id.id
else:
raise ValidationError('扫描的刀具物料不存在,请重新扫描!')
else:
record.rfid = barcode
lot_ids = self.env['stock.lot'].sudo().search([('rfid', '=', barcode)])
if not lot_ids:
raise ValidationError('扫描的刀具物料不存在,请重新扫描!')
for lot_id in lot_ids:
if lot_id.quant_ids[-1].location_id.name in '刀具房':
record.handle_code_id = lot_id.id
record.chuck_code_id = record.get_chuck_code_id(lot_id).id or False
elif lot_id.quant_ids[-1].location_id.name == '刀具组装位置':
raise ValidationError('该刀柄已使用,请重新扫描!!!')
else:
raise ValidationError('该刀柄未入库,请重新扫描!!!')
def get_chuck_code_id(self, lot_id):
# 适用夹头型号
cutting_tool_chuck_id = lot_id.product_id.cutting_tool_chuck_id
# 适用夹头尺寸
fit_chuck_size = lot_id.product_id.cutting_tool_fit_chuck_size
# 适用夹头产品
chuck_product_id = self.env['product.product'].sudo().search(
[('cutting_tool_model_id', '=', cutting_tool_chuck_id.id),
('cutting_tool_er_size_model', '=', fit_chuck_size)])
# 适用夹头产品序列号
chuck_product_lot_ids = self.env['stock.lot'].sudo().search(
[('product_id', '=', chuck_product_id.id), ('tool_material_status', '=', '可用')])
for chuck_product_lot_id in chuck_product_lot_ids:
if chuck_product_lot_id.quant_ids[-1].location_id.name in '刀具房':
return chuck_product_lot_id
@api.depends('handle_code_id')
def _compute_rfid(self):
for item in self:
if item:
item.rfid = item.handle_code_id.rfid
else:
item.rfid = None
# 组装功能刀具参数信息
barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号')
rfid = fields.Char('Rfid', required=True)
rfid = fields.Char('Rfid', readonly=True, store=True, compute='_compute_rfid')
tool_code = fields.Char(string='功能刀具编码', readonly=True, compute='_compute_tool_code')
after_assembly_functional_tool_name = fields.Char(string='组装后功能刀具名称', compute='_compute_name')
after_assembly_functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model',
@@ -442,21 +477,6 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
if obj.after_assembly_functional_tool_length == 0:
raise ValidationError('组装参数信息【伸出长】不能为0')
@api.constrains('rfid')
def _check_rfid(self):
self.get_rfid()
@api.onchange('rfid')
def _onchange_rfid(self):
self.get_rfid()
def get_rfid(self):
for obj in self:
if obj.rfid:
tool_entity = self.env['sf.functional.cutting.tool.entity'].sudo().search([('rfid', '=', obj.rfid)])
if tool_entity:
raise ValidationError('%s】的Rfid已被使用请重新录入' % obj.rfid)
def functional_tool_assembly(self):
"""
功能刀具组装