货位代码优化
This commit is contained in:
@@ -212,6 +212,7 @@ class SfLocation(models.Model):
|
|||||||
class ShelfLocation(models.Model):
|
class ShelfLocation(models.Model):
|
||||||
_name = 'sf.shelf.location'
|
_name = 'sf.shelf.location'
|
||||||
_description = '货架货位'
|
_description = '货架货位'
|
||||||
|
_order = 'name'
|
||||||
|
|
||||||
name = fields.Char('名称', required=True, size=20)
|
name = fields.Char('名称', required=True, size=20)
|
||||||
barcode = fields.Char('编码', copy=False, size=15)
|
barcode = fields.Char('编码', copy=False, size=15)
|
||||||
@@ -290,7 +291,6 @@ class ShelfLocation(models.Model):
|
|||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# 生成货位
|
|
||||||
def create_location(self):
|
def create_location(self):
|
||||||
"""
|
"""
|
||||||
当仓库类型为货架时,自动生成其下面的货位,数量为货架层数*层数容量
|
当仓库类型为货架时,自动生成其下面的货位,数量为货架层数*层数容量
|
||||||
@@ -298,13 +298,17 @@ class ShelfLocation(models.Model):
|
|||||||
if self.location_type == '货架':
|
if self.location_type == '货架':
|
||||||
for i in range(self.shelf_layer):
|
for i in range(self.shelf_layer):
|
||||||
for j in range(self.layer_capacity):
|
for j in range(self.layer_capacity):
|
||||||
self.create({
|
location_name = self.name + '-' + str(i + 1) + '层' + '-' + str(j + 1) + '位置'
|
||||||
'name': self.name + '-' + str(i + 1) + '层' + '-' + str(j + 1) + '位置',
|
# 检查是否已经有同名的位置存在
|
||||||
'location_id': self.shelf_location_id.id,
|
existing_location = self.search([('name', '=', location_name)])
|
||||||
'location_type': '货位',
|
if not existing_location:
|
||||||
'barcode': self.generate_barcode(i, j),
|
self.create({
|
||||||
'location_status': '空闲',
|
'name': location_name,
|
||||||
})
|
'location_id': self.shelf_location_id.id,
|
||||||
|
'location_type': '货位',
|
||||||
|
'barcode': self.generate_barcode(i, j),
|
||||||
|
'location_status': '空闲',
|
||||||
|
})
|
||||||
|
|
||||||
def generate_barcode(self, i, j):
|
def generate_barcode(self, i, j):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user