Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX]stock_ux: reserved qty #547

Open
wants to merge 2 commits into
base: 17.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions stock_ux/models/stock_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,26 @@ def _check_manual_lines(self):
lambda x:
not x.location_id.should_bypass_reservation() and
x.picking_id.picking_type_id.block_manual_lines and
x.reserved_qty < x.quantity)):
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),
('name', '=', 'Stock')
], limit=1)
quant = self.env['stock.quant'].search([
('product_id', '=', self.product_id.id),
('location_id', '=', location.id)
], limit=1)
if quant:
if self.location_id.warehouse_id.delivery_steps == 'ship_only':
return quant.inventory_quantity_auto_apply - self.quantity
else:
return quant.inventory_quantity_auto_apply
else:
return 0.0

@api.constrains('quantity')
def _check_quantity(self):
Expand Down Expand Up @@ -104,4 +121,3 @@ def _get_aggregated_product_quantities(self, **kwargs):
aggregated_move_lines[line]['name'] = ', '.join(moves.mapped('origin_description'))

return aggregated_move_lines