1、采购入库作业详情的目标位置字段关闭创建功能,关闭货位的创建功能;2、优化入库到货位流程(进行中);

This commit is contained in:
yuxianghui
2024-04-18 19:10:41 +08:00
parent 8dfef16b51
commit f26b4510cf
8 changed files with 45 additions and 24 deletions

View File

@@ -191,6 +191,7 @@ class SfLocation(models.Model):
# return res
# 生成货位
def create_location(self):
"""
当仓库类型为货架时,自动生成其下面的货位,数量为货架层数*层数容量
@@ -429,7 +430,6 @@ class ShelfLocation(models.Model):
}
return action
# # 仓库类别selection库区、库位、货位
# location_type = fields.Selection([
# ('货架', '货架'),
@@ -516,6 +516,19 @@ class ShelfLocation(models.Model):
else:
raise UserError("该库位无产品")
@api.model_create_multi
def create(self, vals_list):
# 编码重复校验
barcode_list = []
for val in vals_list:
location = self.search([('barcode', '=', val['barcode'])])
if location:
barcode_list.append(val['name'])
if barcode_list:
raise UserError("货位编码【%s】存在重复" % barcode_list)
records = super(ShelfLocation, self).create(vals_list)
return records
class Sf_stock_move_line(models.Model):
_name = 'stock.move.line'
@@ -812,35 +825,42 @@ class Sf_stock_move_line(models.Model):
destination_location_id = fields.Many2one(
'sf.shelf.location', string='目标货位')
@api.onchange('destination_location_id')
def _compute_destination_location_id(self):
def compute_destination_location_id(self):
for record in self:
obj = self.env['sf.shelf.location'].search([('name', '=',
self.destination_location_id.name)])
# if obj.product_id and obj.product_id != record.product_id:
# # 判断货位产品和将入到该货位的产品是否是同一种
# raise ValidationError(
# '【%s】产品和【%s】货位的【%s】产品不同请重新选择【%s】产品的货位' %
# (record.product_id, obj.name, obj.product_id, record.product_id))
if record.lot_id:
shelf_location_obj = self.env['sf.shelf.location'].search(
[('product_sn_id', '=', record.lot_id.id)])
if shelf_location_obj:
shelf_location_obj.product_sn_id = False
# obj = self.env['sf.shelf.location'].search([('location_id', '=',
# self.destination_location_id.id)])
obj = self.env['sf.shelf.location'].search([('name', '=',
self.destination_location_id.name)])
if obj:
obj.product_sn_id = record.lot_id.id
else:
pass
else:
obj = self.env['sf.shelf.location'].search([('name', '=',
self.destination_location_id.name)])
if obj:
obj.product_sn_id = record.lot_id.id
else:
obj = self.env['sf.shelf.location'].search([('name', '=',
self.destination_location_id.name)])
if obj:
obj.product_id = record.product_id.id
# obj.location_status = '占用'
obj.product_num += record.reserved_uom_qty
@api.onchange('destination_location_id')
def _check_destination_location_id(self):
for item in self:
if item:
line_destination_location_ids = []
for obj in item.picking_id.move_line_ids:
if obj.destination_location_id:
line_destination_location_ids.append(obj.destination_location_id.barcode)
if item.destination_location_id.barcode in line_destination_location_ids:
raise ValidationError('%s】货位已经被占用,请重新选择!!!' % item.destination_location_id.barcode)
class SfStockPicking(models.Model):
_inherit = 'stock.picking'
@@ -863,12 +883,15 @@ class SfStockPicking(models.Model):
res = super(SfStockPicking, self).button_validate()
for line in self.move_line_ids:
if line:
# 调用入库方法进行入库
line.compute_destination_location_id()
if line.current_location_id:
if line.current_location_id.product_sn_id:
line.current_location_id.product_sn_id = False
# line.current_location_id.location_status = '空闲'
line.current_location_id.product_num = 0
# 对入库作业的刀柄和托盘进行Rfid绑定校验
for move in self.move_ids:
if move and move.product_id.cutting_tool_material_id.name == '刀柄' or '托盘' in (
move.product_id.fixture_material_id.name or ''):

View File

@@ -19,7 +19,7 @@
<!-- ]"/> -->
<field name="destination_location_id" domain="[('location_id', '=', location_dest_id_value), '|',
('location_status', '=', '空闲'), ('product_id', '=', current_product_id), ('product_sn_id',
'=', there_is_no_sn)]"/>
'=', there_is_no_sn)]" options="{'no_create': True,'no_create_edit':True}"/>
<field name="rfid_barcode" string="Rfid"/>
<!-- <field name="location_dest_id_product_type"/> -->

View File

@@ -126,7 +126,7 @@
<field name="name">Shelf Location form</field>
<field name="model">sf.shelf.location</field>
<field name="arch" type="xml">
<form string="Shelf Location">
<form string="Shelf Location" create="0">
<header>
<field name="location_status" invisible="1"/>
@@ -175,7 +175,7 @@
<field name="name">shelf.location.kanban</field>
<field name="model">sf.shelf.location</field>
<field name="arch" type="xml">
<kanban class="o_kanban_mobile" js_class="custom_kanban">
<kanban class="o_kanban_mobile" js_class="custom_kanban" create="0">
<templates>
<t t-name="kanban-box">
<div t-attf-class="oe_kanban_card oe_kanban_global_click