Skip to content

Commit

Permalink
[IMP]stock_ux: _check_manual_lines method
Browse files Browse the repository at this point in the history
closes #580

X-original-commit: a1fb8f0
Signed-off-by: Juan Carreras <[email protected]>
  • Loading branch information
mav-adhoc committed Dec 4, 2024
1 parent 3574b83 commit 2de7a3c
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions stock_ux/models/stock_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,24 @@ def _check_manual_lines(self):
if any(self.filtered(
lambda x:
not x.location_id.should_bypass_reservation() and
x.picking_id.picking_type_id.block_manual_lines)):
x.picking_id.picking_type_id.block_manual_lines and
x._check_quantity_available() < 0)):
raise ValidationError(_(
"You can't transfer more quantity than reserved one!"))
"You can't transfer more quantity than the quantity on stock!"))

def _check_quantity_available(self):
location = self.env['stock.location'].search([
('company_id', '=', self.picking_id.company_id.id),
('id', '=', self.picking_id.location_id.id)
], limit=1)
quant = self.env['stock.quant'].search([
('product_id', '=', self.product_id.id),
('location_id', '=', location.id)
], limit=1)
if quant:
return quant.available_quantity - self.quantity
else:
return 0.0

@api.constrains('quantity')
def _check_quantity(self):
Expand Down

0 comments on commit 2de7a3c

Please sign in to comment.