1、优化刀具组装单、刀具组装单弹窗、刀具拆解单,添加除刀柄外刀具物料按批次号进行管理;优化界面布局,优化组装流程;

This commit is contained in:
yuxianghui
2024-06-03 17:34:47 +08:00
parent a7102c81d4
commit 67c4f64d08
6 changed files with 201 additions and 201 deletions

View File

@@ -233,7 +233,10 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
# 功能刀具组装信息
# ===============整体式刀具型号=================
integral_freight_barcode = fields.Char('整体式刀具货位')
integral_freight_barcode_id = fields.Many2one('sf.shelf.location', string='整体式刀具货位',
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_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='整体式刀具型号',
@@ -243,28 +246,18 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
sf_tool_brand_id_1 = fields.Many2one('sf.machine.brand', string='整体式刀具品牌',
related='integral_product_id.brand_id')
@api.depends('integral_freight_barcode')
@api.depends('integral_freight_lot_id')
def _compute_integral_product_id(self):
if self.integral_freight_barcode:
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.integral_freight_barcode)])
if location:
if not location.product_id:
raise ValidationError('编码为【%s】的货位为空货位!' % location.barcode)
else:
material_name_id = location.product_id.cutting_tool_material_id
if material_name_id and material_name_id.name == '整体式刀具':
if location.product_num == 0:
raise ValidationError('编码为【%s】的货位的产品库存数量为0,请重新选择!' % location.barcode)
self.integral_product_id = location.product_id.id
else:
raise ValidationError(
'编码为【%s】的货位存放的产品为【%s】,不是整体式刀具,请重新选择!' % (
location.barcode, location.product_id.name))
else:
raise ValidationError('编码为【%s】的货位不存在!' % self.integral_freight_barcode)
if self.integral_freight_lot_id:
self.integral_product_id = self.integral_freight_lot_id.lot_id.product_id.id
else:
self.integral_product_id = False
# ===============刀片型号====================
blade_freight_barcode = fields.Char('刀片货位')
blade_freight_barcode_id = fields.Many2one('sf.shelf.location', string='刀片货位',
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_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='刀片型号',
@@ -273,28 +266,18 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
related='blade_product_id.specification_id')
sf_tool_brand_id_2 = fields.Many2one('sf.machine.brand', '刀片品牌', related='blade_product_id.brand_id')
@api.depends('blade_freight_barcode')
@api.depends('blade_freight_lot_id')
def _compute_blade_product_id(self):
if self.blade_freight_barcode:
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.blade_freight_barcode)])
if location:
if not location.product_id:
raise ValidationError('编码为【%s】的货位为空货位!' % location.barcode)
else:
material_name_id = location.product_id.cutting_tool_material_id
if material_name_id and material_name_id.name == '刀片':
if location.product_num == 0:
raise ValidationError('编码为【%s】的货位的产品库存数量为0,请重新选择!' % location.barcode)
self.blade_product_id = location.product_id.id
else:
raise ValidationError(
'编码为【%s】的货位存放的产品为【%s】,不是刀片,请重新选择!' % (
location.barcode, location.product_id.name))
else:
raise ValidationError('编码为【%s】的货位不存在!' % self.blade_freight_barcode)
if self.blade_freight_lot_id:
self.blade_product_id = self.blade_freight_lot_id.lot_id.product_id.id
else:
self.blade_product_id = False
# ====================刀杆型号==================
bar_freight_barcode = fields.Char('刀杆货位')
bar_freight_barcode_id = fields.Many2one('sf.shelf.location', string='刀杆货位',
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_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='刀杆型号',
@@ -303,28 +286,18 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
related='bar_product_id.specification_id')
sf_tool_brand_id_3 = fields.Many2one('sf.machine.brand', '刀杆品牌', related='bar_product_id.brand_id')
@api.depends('bar_freight_barcode')
@api.depends('bar_freight_lot_id')
def _compute_bar_product_id(self):
if self.bar_freight_barcode:
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.bar_freight_barcode)])
if location:
if not location.product_id:
raise ValidationError('编码为【%s】的货位为空货位!' % location.barcode)
else:
material_name_id = location.product_id.cutting_tool_material_id
if material_name_id and material_name_id.name == '刀杆':
if location.product_num == 0:
raise ValidationError('编码为【%s】的货位的产品库存数量为0,请重新选择!' % location.barcode)
self.bar_product_id = location.product_id.id
else:
raise ValidationError(
'编码为【%s】的货位存放的产品为【%s】,不是刀杆,请重新选择!' % (
location.barcode, location.product_id.name))
else:
raise ValidationError('编码为【%s】的货位不存在!' % self.bar_freight_barcode)
if self.bar_freight_lot_id:
self.bar_product_id = self.bar_freight_lot_id.lot_id.product_id.id
else:
self.bar_product_id = False
# ===============刀盘型号===================
pad_freight_barcode = fields.Char('刀盘货位')
pad_freight_barcode_id = fields.Many2one('sf.shelf.location', string='刀盘货位',
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_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='刀盘型号',
@@ -333,25 +306,12 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
related='pad_product_id.specification_id')
sf_tool_brand_id_4 = fields.Many2one('sf.machine.brand', '刀盘品牌', related='pad_product_id.brand_id')
@api.depends('pad_freight_barcode')
@api.depends('pad_freight_lot_id')
def _compute_pad_product_id(self):
if self.pad_freight_barcode:
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.pad_freight_barcode)])
if location:
if not location.product_id:
raise ValidationError('编码为【%s】的货位为空货位!' % location.barcode)
else:
material_name_id = location.product_id.cutting_tool_material_id
if material_name_id and material_name_id.name == '刀盘':
if location.product_num == 0:
raise ValidationError('编码为【%s】的货位的产品库存数量为0,请重新选择!' % location.barcode)
self.pad_product_id = location.product_id.id
else:
raise ValidationError(
'编码为【%s】的货位存放的产品为【%s】,不是刀盘,请重新选择!' % (
location.barcode, location.product_id.name))
else:
raise ValidationError('编码为【%s】的货位不存在!' % self.pad_freight_barcode)
if self.pad_freight_lot_id:
self.pad_product_id = self.pad_freight_lot_id.lot_id.product_id.id
else:
self.pad_product_id = False
# ================刀柄型号===============
handle_freight_rfid = fields.Char('刀柄Rfid', compute='_compute_rfid')
@@ -374,7 +334,10 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
self.pad_product_id = False
# =================夹头型号==============
chuck_freight_barcode = fields.Char('夹头货位')
chuck_freight_barcode_id = fields.Many2one('sf.shelf.location', string='夹头货位',
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_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='夹头型号',
@@ -383,25 +346,12 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
related='chuck_product_id.specification_id')
sf_tool_brand_id_6 = fields.Many2one('sf.machine.brand', '夹头品牌', related='chuck_product_id.brand_id')
@api.depends('chuck_freight_barcode')
@api.depends('chuck_freight_lot_id')
def _compute_chuck_product_id(self):
if self.chuck_freight_barcode:
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.chuck_freight_barcode)])
if location:
if not location.product_id:
raise ValidationError('编码为【%s】的货位为空货位!' % location.barcode)
else:
material_name_id = location.product_id.cutting_tool_material_id
if material_name_id and material_name_id.name == '夹头':
if location.product_num == 0:
raise ValidationError('编码为【%s】的货位的产品库存数量为0,请重新选择!' % location.barcode)
self.chuck_product_id = location.product_id.id
else:
raise ValidationError(
'编码为【%s】的货位存放的产品为【%s】,不是夹头,请重新选择!' % (
location.barcode, location.product_id.name))
else:
raise ValidationError('编码为【%s】的货位不存在!' % self.chuck_freight_barcode)
if self.chuck_freight_lot_id:
self.chuck_product_id = self.chuck_freight_lot_id.lot_id.product_id.id
else:
self.chuck_product_id = False
# ========================================
def on_barcode_scanned(self, barcode):
@@ -423,23 +373,23 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
if location:
material_name = location.product_id.cutting_tool_material_id.name
if material_name == '夹头':
record.chuck_freight_barcode = barcode
record.chuck_freight_barcode_id = location.id
elif material_name == '整体式刀具':
record.integral_freight_barcode = barcode
record.blade_freight_barcode = ''
record.bar_freight_barcode = ''
record.pad_freight_barcode = ''
record.integral_freight_barcode_id = location.id
record.blade_freight_barcode_id = False
record.bar_freight_barcode_id = False
record.pad_freight_barcode_id = False
elif material_name == '刀片':
record.blade_freight_barcode = barcode
record.integral_freight_barcode = ''
record.blade_freight_barcode_id = location.id
record.integral_freight_barcode_id = False
elif material_name == '刀杆':
record.bar_freight_barcode = barcode
record.integral_freight_barcode = ''
record.pad_freight_barcode = ''
record.bar_freight_barcode_id = location.id
record.integral_freight_barcode_id = False
record.pad_freight_barcode_id = False
elif material_name == '刀盘':
record.pad_freight_barcode = barcode
record.integral_freight_barcode = ''
record.bar_freight_barcode = ''
record.pad_freight_barcode_id = location.id
record.integral_freight_barcode_id = False
record.bar_freight_barcode_id = False
else:
raise ValidationError('扫描的刀具物料不存在,请重新扫描!')
else:
@@ -550,7 +500,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
else:
obj.after_assembly_functional_tool_name = ''
@api.onchange('integral_freight_barcode')
@api.onchange('integral_freight_barcode_id')
def _onchange_after_assembly_functional_tool_diameter(self):
for obj in self:
if obj.integral_product_id:
@@ -558,7 +508,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
else:
obj.after_assembly_functional_tool_diameter = 0
@api.onchange('blade_freight_barcode')
@api.onchange('blade_freight_barcode_id')
def _onchange_after_assembly_knife_tip_r_angle(self):
for obj in self:
if obj.blade_product_id:
@@ -617,15 +567,20 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
if self.handle_code_id:
product_id.tool_material_stock_moves(self.handle_code_id, self.assembly_order_code)
if self.integral_product_id:
self.integral_product_id.material_stock_moves(self.integral_freight_barcode, self.assembly_order_code)
self.integral_product_id.material_stock_moves(self.integral_freight_barcode_id,
self.integral_freight_lot_id, self.assembly_order_code)
if self.blade_product_id:
self.blade_product_id.material_stock_moves(self.blade_freight_barcode, self.assembly_order_code)
self.blade_product_id.material_stock_moves(self.blade_freight_barcode_id,
self.blade_freight_lot_id, self.assembly_order_code)
if self.bar_product_id:
self.bar_product_id.material_stock_moves(self.bar_freight_barcode, self.assembly_order_code)
self.bar_product_id.material_stock_moves(self.bar_freight_barcode_id,
self.bar_freight_lot_id, self.assembly_order_code)
if self.pad_product_id:
self.pad_product_id.material_stock_moves(self.pad_freight_barcode, self.assembly_order_code)
self.pad_product_id.material_stock_moves(self.pad_freight_barcode_id,
self.pad_freight_lot_id, self.assembly_order_code)
if self.chuck_product_id:
self.chuck_product_id.material_stock_moves(self.chuck_freight_barcode, self.assembly_order_code)
self.chuck_product_id.material_stock_moves(self.chuck_freight_barcode_id,
self.chuck_freight_lot_id, self.assembly_order_code)
# ============================创建功能刀具列表、安全库存记录===============================
# 封装功能刀具数据
@@ -673,12 +628,17 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
'code': self.code,
'rfid': self.rfid,
'tool_groups_id': self.after_tool_groups_id.id,
'integral_freight_barcode': self.integral_freight_barcode,
'blade_freight_barcode': self.blade_freight_barcode,
'bar_freight_barcode': self.bar_freight_barcode,
'pad_freight_barcode': self.pad_freight_barcode,
'handle_code_id': self.handle_code_id.id,
'chuck_freight_barcode': self.chuck_freight_barcode,
'integral_freight_barcode_id': self.integral_freight_barcode_id.id,
'integral_lot_id': self.integral_freight_lot_id.lot_id.id,
'blade_freight_barcode_id': self.blade_freight_barcode_id.id,
'blade_lot_id': self.blade_freight_lot_id.lot_id.id,
'bar_freight_barcode_id': self.bar_freight_barcode_id.id,
'bar_lot_id': self.bar_freight_lot_id.lot_id.id,
'pad_freight_barcode_id': self.pad_freight_barcode_id.id,
'pad_lot_id': self.pad_freight_lot_id.lot_id.id,
'chuck_freight_barcode_id': self.chuck_freight_barcode_id.id,
'chuck_lot_id': self.chuck_freight_lot_id.lot_id.id,
'after_assembly_functional_tool_name': self.after_assembly_functional_tool_name,
'after_assembly_functional_tool_type_id': self.after_assembly_functional_tool_type_id.id,
@@ -851,7 +811,7 @@ class ProductProduct(models.Model):
tool_material.create_stock_quant(location_inventory_id, stock_location_id, None, assembly_order_code, False,
False)
def material_stock_moves(self, shelf_location_barcode, assembly_order_code):
def material_stock_moves(self, shelf_location_barcode_id, lot_id, assembly_order_code):
# 创建库存移动记录
stock_move_id = self.env['stock.move'].sudo().create({
'name': assembly_order_code,
@@ -862,21 +822,22 @@ class ProductProduct(models.Model):
'state': 'done'
})
location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', shelf_location_barcode)])
# 创建移动历史记录
stock_move_line_id = self.env['stock.move.line'].sudo().create({
'product_id': self.id,
'move_id': stock_move_id.id,
'current_location_id': location.id,
'lot_id': lot_id.id,
'current_location_id': shelf_location_barcode_id.id,
'install_tool_time': fields.Datetime.now(),
'qty_done': 1.0,
'state': 'done',
})
if location.product_num > 0:
location.product_num = location.product_num - 1
if shelf_location_barcode_id.product_num > 0:
shelf_location_barcode_id.product_num = shelf_location_barcode_id.product_num - 1
else:
raise ValidationError(
'%s】货位的【%s】产品库存数量为零,请采购入库后再重新组装!' % (location.barcode, location.product_id.name))
'%s】货位的【%s】产品库存数量为零,请采购入库后再重新组装!' % (
shelf_location_barcode_id.barcode, shelf_location_barcode_id.product_id.name))
return stock_move_id, stock_move_line_id

View File

@@ -226,13 +226,16 @@
</group>
</group>
<group col="1"
attrs="{'invisible': ['|','|',('blade_freight_barcode', '!=', False),('bar_freight_barcode', '!=', False),('pad_freight_barcode', '!=', False)]}">
attrs="{'invisible': ['|','|',('blade_freight_barcode_id', '!=', False),('bar_freight_barcode_id', '!=', False),('pad_freight_barcode_id', '!=', False)]}">
<div>
<separator string="整体式刀具:" style="font-size: 13px;"/>
</div>
<group>
<group>
<field name="integral_freight_barcode" string="货位"/>
<field name="integral_freight_barcode_id" options="{'no_create': True}" placeholder="请选择" string="货位"/>
</group>
<group>
<field name="integral_freight_lot_id" options="{'no_create': True}" placeholder="请选择" string="批次"/>
</group>
</group>
<group col="2">
@@ -246,13 +249,16 @@
</group>
</group>
</group>
<group col="1" attrs="{'invisible': [('integral_freight_barcode', '!=', False)]}">
<group col="1" attrs="{'invisible': [('integral_freight_barcode_id', '!=', False)]}">
<div>
<separator string="刀片:" style="font-size: 13px;"/>
</div>
<group>
<group>
<field name="blade_freight_barcode" string="货位"/>
<field name="blade_freight_barcode_id" options="{'no_create': True}" placeholder="请选择" string="货位"/>
</group>
<group>
<field name="blade_freight_lot_id" options="{'no_create': True}" placeholder="请选择" string="批次"/>
</group>
</group>
<group col="2">
@@ -267,13 +273,16 @@
</group>
</group>
<group col="1"
attrs="{'invisible': ['|',('integral_freight_barcode', '!=', False),('pad_freight_barcode', '!=', False)]}">
attrs="{'invisible': ['|',('integral_freight_barcode_id', '!=', False),('pad_freight_barcode_id', '!=', False)]}">
<div>
<separator string="刀杆:" style="font-size: 13px;"/>
</div>
<group>
<group>
<field name="bar_freight_barcode" string="货位"/>
<field name="bar_freight_barcode_id" options="{'no_create': True}" placeholder="请选择" string="货位"/>
</group>
<group>
<field name="bar_freight_lot_id" options="{'no_create': True}" placeholder="请选择" string="批次"/>
</group>
</group>
<group col="2">
@@ -288,13 +297,16 @@
</group>
</group>
<group col="1"
attrs="{'invisible': ['|',('integral_freight_barcode', '!=', False),('bar_freight_barcode', '!=', False)]}">
attrs="{'invisible': ['|',('integral_freight_barcode_id', '!=', False),('bar_freight_barcode_id', '!=', False)]}">
<div>
<separator string="刀盘:" style="font-size: 13px;"/>
</div>
<group>
<group>
<field name="pad_freight_barcode" string="货位"/>
<field name="pad_freight_barcode_id" options="{'no_create': True}" placeholder="请选择" string="货位"/>
</group>
<group>
<field name="pad_freight_lot_id" options="{'no_create': True}" placeholder="请选择" string="批次"/>
</group>
</group>
<group col="2">
@@ -314,7 +326,10 @@
</div>
<group>
<group>
<field name="chuck_freight_barcode" string="货位"/>
<field name="chuck_freight_barcode_id" options="{'no_create': True}" placeholder="请选择" string="货位"/>
</group>
<group>
<field name="chuck_freight_lot_id" options="{'no_create': True}" placeholder="请选择" string="批次"/>
</group>
</group>
<group col="2">