开完库存处新增需求基本完成
This commit is contained in:
@@ -132,7 +132,7 @@ class SfLocation(models.Model):
|
|||||||
for record in self:
|
for record in self:
|
||||||
if record.product_sn_id:
|
if record.product_sn_id:
|
||||||
record.product_id = record.product_sn_id.product_id
|
record.product_id = record.product_sn_id.product_id
|
||||||
record.location_status = '占用'
|
# record.location_status = '占用'
|
||||||
else:
|
else:
|
||||||
record.product_id = False
|
record.product_id = False
|
||||||
# record.location_status = '空闲'
|
# record.location_status = '空闲'
|
||||||
@@ -361,13 +361,21 @@ class ShelfLocation(models.Model):
|
|||||||
('空闲', '空闲'),
|
('空闲', '空闲'),
|
||||||
('占用', '占用'),
|
('占用', '占用'),
|
||||||
('禁用', '禁用')
|
('禁用', '禁用')
|
||||||
], string='货位状态', default='空闲', readonly=True)
|
], string='货位状态', default='空闲', compute='_compute_product_num', store=True)
|
||||||
# product_id = fields.Many2one('product.template', string='产品')
|
# product_id = fields.Many2one('product.template', string='产品')
|
||||||
product_id = fields.Many2one('product.product', string='产品', compute='_compute_product_id', store=True)
|
product_id = fields.Many2one('product.product', string='产品', compute='_compute_product_id', store=True)
|
||||||
product_sn_id = fields.Many2one('stock.lot', string='产品序列号')
|
product_sn_id = fields.Many2one('stock.lot', string='产品序列号')
|
||||||
# 产品数量
|
# 产品数量
|
||||||
product_num = fields.Integer('数量')
|
product_num = fields.Integer('数量')
|
||||||
|
|
||||||
|
@api.depends('product_num')
|
||||||
|
def _compute_product_num(self):
|
||||||
|
for record in self:
|
||||||
|
if record.product_num > 0:
|
||||||
|
record.location_status = '占用'
|
||||||
|
elif record.product_num == 0:
|
||||||
|
record.location_status = '空闲'
|
||||||
|
|
||||||
# 修改货位状态为禁用
|
# 修改货位状态为禁用
|
||||||
def action_location_status_disable(self):
|
def action_location_status_disable(self):
|
||||||
self.location_status = '禁用'
|
self.location_status = '禁用'
|
||||||
@@ -385,7 +393,7 @@ class ShelfLocation(models.Model):
|
|||||||
if record.product_sn_id:
|
if record.product_sn_id:
|
||||||
try:
|
try:
|
||||||
record.sudo().product_id = record.product_sn_id.product_id
|
record.sudo().product_id = record.product_sn_id.product_id
|
||||||
record.sudo().location_status = '占用'
|
# record.sudo().location_status = '占用'
|
||||||
record.sudo().product_num = 1
|
record.sudo().product_num = 1
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('eeeeeee占用', e)
|
print('eeeeeee占用', e)
|
||||||
@@ -393,7 +401,7 @@ class ShelfLocation(models.Model):
|
|||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
record.sudo().product_id = False
|
record.sudo().product_id = False
|
||||||
record.sudo().location_status = '空闲'
|
# record.sudo().location_status = '空闲'
|
||||||
record.sudo().product_num = 0
|
record.sudo().product_num = 0
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('eeeeeee空闲', e)
|
print('eeeeeee空闲', e)
|
||||||
@@ -735,8 +743,8 @@ class Sf_stock_move_line(models.Model):
|
|||||||
self.destination_location_id.name)])
|
self.destination_location_id.name)])
|
||||||
if obj:
|
if obj:
|
||||||
obj.product_id = record.product_id.id
|
obj.product_id = record.product_id.id
|
||||||
obj.location_status = '占用'
|
# obj.location_status = '占用'
|
||||||
obj.product_num = record.reserved_uom_qty
|
obj.product_num += record.reserved_uom_qty
|
||||||
|
|
||||||
|
|
||||||
class SfStockPicking(models.Model):
|
class SfStockPicking(models.Model):
|
||||||
@@ -761,8 +769,11 @@ class SfStockPicking(models.Model):
|
|||||||
for line in self.move_line_ids:
|
for line in self.move_line_ids:
|
||||||
if line:
|
if line:
|
||||||
if line.current_location_id:
|
if line.current_location_id:
|
||||||
line.current_location_id.product_sn_id = False
|
if line.current_location_id.product_sn_id:
|
||||||
line.current_location_id.location_status = '空闲'
|
line.current_location_id.product_sn_id = False
|
||||||
|
# line.current_location_id.location_status = '空闲'
|
||||||
|
line.current_location_id.product_num = 0
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
# def print_all_barcode(self):
|
# def print_all_barcode(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user