1、对组装单物料批次号获取逻辑进行优化,更改form视图批次字段显示条件;2、开发 寿命到期功能刀具完成拆解后关联生成并跳转到组装单的需求 需求
This commit is contained in:
@@ -476,7 +476,8 @@ class FunctionalToolAssembly(models.Model):
|
||||
domain="[('product_id.cutting_tool_material_id.name', '=', '整体式刀具'),('product_num', '>', 0)]")
|
||||
integral_freight_lot_id = fields.Many2one('sf.shelf.location.lot', string='整体式刀具批次',
|
||||
domain="[('shelf_location_id', '=', integral_freight_barcode_id)]")
|
||||
integral_lot_id = fields.Many2one('stock.lot', string='整体式刀具批次', related='integral_freight_lot_id.lot_id')
|
||||
integral_lot_id = fields.Many2one('stock.lot', string='整体式刀具批次', compute='_compute_integral_lot_id',
|
||||
store=True)
|
||||
integral_product_id = fields.Many2one('product.product', string='整体式刀具名称',
|
||||
compute='_compute_integral_product_id', store=True)
|
||||
cutting_tool_integral_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='整体式刀具型号',
|
||||
@@ -492,6 +493,12 @@ class FunctionalToolAssembly(models.Model):
|
||||
for item in self:
|
||||
item.integral_freight_lot_id = False
|
||||
|
||||
@api.depends('integral_freight_lot_id')
|
||||
def _compute_integral_lot_id(self):
|
||||
for item in self:
|
||||
if item.integral_freight_lot_id:
|
||||
item.integral_lot_id = item.integral_freight_lot_id.lot_id.id
|
||||
|
||||
@api.depends('integral_lot_id')
|
||||
def _compute_integral_product_id(self):
|
||||
for item in self:
|
||||
@@ -505,7 +512,7 @@ class FunctionalToolAssembly(models.Model):
|
||||
domain="[('product_id.cutting_tool_material_id.name', '=', '刀片'),('product_num', '>', 0)]")
|
||||
blade_freight_lot_id = fields.Many2one('sf.shelf.location.lot', string='刀片批次',
|
||||
domain="[('shelf_location_id', '=', blade_freight_barcode_id)]")
|
||||
blade_lot_id = fields.Many2one('stock.lot', string='刀片批次', related='blade_freight_lot_id.lot_id')
|
||||
blade_lot_id = fields.Many2one('stock.lot', string='刀片批次', compute='blade_freight_lot_id.lot_id', store=True)
|
||||
blade_product_id = fields.Many2one('product.product', string='刀片名称', compute='_compute_blade_product_id',
|
||||
store=True)
|
||||
cutting_tool_blade_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀片型号',
|
||||
@@ -520,6 +527,12 @@ class FunctionalToolAssembly(models.Model):
|
||||
for item in self:
|
||||
item.blade_freight_lot_id = False
|
||||
|
||||
@api.depends('blade_freight_lot_id')
|
||||
def _compute_blade_lot_id(self):
|
||||
for item in self:
|
||||
if item.blade_freight_lot_id:
|
||||
item.blade_lot_id = item.blade_freight_lot_id.lot_id.id
|
||||
|
||||
@api.depends('blade_lot_id')
|
||||
def _compute_blade_product_id(self):
|
||||
for item in self:
|
||||
@@ -533,7 +546,7 @@ class FunctionalToolAssembly(models.Model):
|
||||
domain="[('product_id.cutting_tool_material_id.name', '=', '刀杆'),('product_num', '>', 0)]")
|
||||
bar_freight_lot_id = fields.Many2one('sf.shelf.location.lot', string='刀杆批次',
|
||||
domain="[('shelf_location_id', '=', bar_freight_barcode_id)]")
|
||||
bar_lot_id = fields.Many2one('stock.lot', string='刀杆批次', related='bar_freight_lot_id.lot_id')
|
||||
bar_lot_id = fields.Many2one('stock.lot', string='刀杆批次', compute='_compute_bar_lot_id', store=True)
|
||||
bar_product_id = fields.Many2one('product.product', string='刀杆名称', compute='_compute_bar_product_id',
|
||||
store=True)
|
||||
cutting_tool_cutterbar_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀杆型号',
|
||||
@@ -548,6 +561,12 @@ class FunctionalToolAssembly(models.Model):
|
||||
for item in self:
|
||||
item.bar_freight_lot_id = False
|
||||
|
||||
@api.depends('bar_freight_lot_id')
|
||||
def _compute_bar_lot_id(self):
|
||||
for item in self:
|
||||
if item.bar_freight_lot_id:
|
||||
item.bar_lot_id = item.bar_freight_lot_id.lot_id.id
|
||||
|
||||
@api.depends('bar_lot_id')
|
||||
def _compute_bar_product_id(self):
|
||||
for item in self:
|
||||
@@ -561,7 +580,7 @@ class FunctionalToolAssembly(models.Model):
|
||||
domain="[('product_id.cutting_tool_material_id.name', '=', '刀盘'),('product_num', '>', 0)]")
|
||||
pad_freight_lot_id = fields.Many2one('sf.shelf.location.lot', string='刀盘批次',
|
||||
domain="[('shelf_location_id', '=', pad_freight_barcode_id)]")
|
||||
pad_lot_id = fields.Many2one('stock.lot', string='刀盘批次', related='pad_freight_lot_id.lot_id')
|
||||
pad_lot_id = fields.Many2one('stock.lot', string='刀盘批次', compute='_compute_pad_lot_id', store=True)
|
||||
pad_product_id = fields.Many2one('product.product', string='刀盘名称', compute='_compute_pad_product_id',
|
||||
store=True)
|
||||
cutting_tool_cutterpad_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀盘型号',
|
||||
@@ -576,6 +595,12 @@ class FunctionalToolAssembly(models.Model):
|
||||
for item in self:
|
||||
item.pad_freight_lot_id = False
|
||||
|
||||
@api.depends('pad_freight_lot_id')
|
||||
def _compute_pad_lot_id(self):
|
||||
for item in self:
|
||||
if item.pad_freight_lot_id:
|
||||
item.pad_lot_id = item.pad_freight_lot_id.lot_id.id
|
||||
|
||||
@api.depends('pad_lot_id')
|
||||
def _compute_pad_product_id(self):
|
||||
for item in self:
|
||||
@@ -615,7 +640,7 @@ class FunctionalToolAssembly(models.Model):
|
||||
domain="[('product_id.cutting_tool_material_id.name', '=', '夹头'),('product_num', '>', 0)]")
|
||||
chuck_freight_lot_id = fields.Many2one('sf.shelf.location.lot', string='夹头批次',
|
||||
domain="[('shelf_location_id', '=', chuck_freight_barcode_id)]")
|
||||
chuck_lot_id = fields.Many2one('stock.lot', string='夹头批次', related='chuck_freight_lot_id.lot_id')
|
||||
chuck_lot_id = fields.Many2one('stock.lot', string='夹头批次', compute='_compute_chuck_lot_id', store=True)
|
||||
chuck_product_id = fields.Many2one('product.product', string='夹头名称', compute='_compute_chuck_product_id',
|
||||
store=True)
|
||||
cutting_tool_cutterhead_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='夹头型号',
|
||||
@@ -630,6 +655,12 @@ class FunctionalToolAssembly(models.Model):
|
||||
for item in self:
|
||||
item.chuck_freight_lot_id = False
|
||||
|
||||
@api.depends('chuck_freight_lot_id')
|
||||
def _compute_chuck_lot_id(self):
|
||||
for item in self:
|
||||
if item.chuck_freight_lot_id:
|
||||
item.chuck_lot_id = item.chuck_freight_lot_id.lot_id.id
|
||||
|
||||
@api.depends('chuck_lot_id')
|
||||
def _compute_chuck_product_id(self):
|
||||
for item in self:
|
||||
@@ -710,15 +741,9 @@ class FunctionalToolAssembly(models.Model):
|
||||
@api.depends('after_assembly_tool_loading_length', 'after_assembly_handle_length')
|
||||
def _compute_length(self):
|
||||
for item in self:
|
||||
if item.assemble_status != '01':
|
||||
return True
|
||||
if item.after_assembly_tool_loading_length == 0:
|
||||
raise ValidationError('【总长度】值为0,请重新测量!')
|
||||
elif item.after_assembly_tool_loading_length > item.after_assembly_handle_length:
|
||||
if item.after_assembly_tool_loading_length > item.after_assembly_handle_length:
|
||||
item.after_assembly_functional_tool_length = (
|
||||
item.after_assembly_tool_loading_length - item.after_assembly_handle_length)
|
||||
elif item.after_assembly_tool_loading_length < item.after_assembly_handle_length:
|
||||
raise ValidationError('【总长度】不能小于【刀柄长度】')
|
||||
|
||||
@api.depends('integral_freight_barcode_id', 'blade_freight_barcode_id')
|
||||
def _compute_rota_tive(self):
|
||||
@@ -872,8 +897,8 @@ class FunctionalToolAssembly(models.Model):
|
||||
# raise ValidationError('组装参数信息【有效长】不能为0!!!')
|
||||
# if self.hiding_length == 0:
|
||||
# raise ValidationError('组装参数信息【避空长】不能为0!!!')
|
||||
if self.after_assembly_functional_tool_diameter == 0:
|
||||
raise ValidationError('组装参数信息【刀具直径】不能为0!')
|
||||
if self.after_assembly_functional_tool_diameter <= 0:
|
||||
raise ValidationError('组装参数信息【刀具直径】不能小于等于0!')
|
||||
if self.after_assembly_tool_loading_length == 0:
|
||||
raise ValidationError('组装参数信息【总长度】不能为0!!!')
|
||||
if self.after_assembly_handle_length == 0:
|
||||
@@ -1379,6 +1404,49 @@ class FunctionalToolDismantle(models.Model):
|
||||
})
|
||||
logging.info('【%s】刀具拆解成功!' % self.name)
|
||||
|
||||
# ==================根据条件创建功能刀具组装单=======================
|
||||
# 如果报废原因为【寿命到期报废】并且刀柄不报废时, 创建功能刀具组装单
|
||||
if self.dismantle_cause in ['寿命到期报废'] and not self.scrap_boolean:
|
||||
# 创建组装单
|
||||
assembly_id = self.env['sf.functional.tool.assembly'].sudo().create({
|
||||
'functional_tool_name': self.functional_tool_id.name,
|
||||
'handle_code_id': self.handle_lot_id.id,
|
||||
'loading_task_source': '3',
|
||||
'reason_for_applying': '刀具寿命到期'
|
||||
})
|
||||
action = self.env.ref('sf_tool_management.sf_functional_tool_assembly_form')
|
||||
|
||||
return {
|
||||
'type': 'ir.actions.client',
|
||||
'tag': 'display_notification',
|
||||
'params': {
|
||||
'title': '组装单创建完成',
|
||||
'message': '请组装同名称的功能刀具',
|
||||
'type': 'info',
|
||||
'links': [{
|
||||
'label': '组装单',
|
||||
'url': f'#action={action.id}&id={assembly_id.id}&model=sf.functional.tool.assembly',
|
||||
}],
|
||||
},
|
||||
}
|
||||
# {
|
||||
# 'type': 'ir.actions.act_window',
|
||||
# 'res_model': 'sf.functional.tool.assembly',
|
||||
# 'view_type': 'form',
|
||||
# 'view_mode': 'form',
|
||||
# 'res_id': assembly_id.id,
|
||||
# }
|
||||
|
||||
# 'params': {
|
||||
# 'title': _('The following replenishment order has been generated'),
|
||||
# 'message': '%s',
|
||||
# 'links': [{
|
||||
# 'label': order.display_name,
|
||||
# 'url': f'#action={action.id}&id={order.id}&model=purchase.order',
|
||||
# }],
|
||||
# 'sticky': False,
|
||||
# }
|
||||
|
||||
def create_tool_picking_scrap(self, datas):
|
||||
scrap_data = datas['scrap']
|
||||
picking_data = datas['picking']
|
||||
|
||||
Reference in New Issue
Block a user