-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] sale_stock_prebook: Do not allow to set quantity done
on reserved stock moves
- Loading branch information
1 parent
af037f9
commit 57f3768
Showing
6 changed files
with
30 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ Sale Stock Prebook | |
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:aed36ba76df99d50d42777ac488e6dc77420d6966a044bf7cd1f6a8d0dd97ad5 | ||
!! source digest: sha256:c262f3d0d45546530ef14056caae0e4f81a04ccbb70a5f8f9600ebda66e382f0 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
|
@@ -66,6 +66,7 @@ Contributors | |
~~~~~~~~~~~~ | ||
|
||
* Michael Tietz (MT Software) <[email protected]> | ||
* Laurent Mignon <[email protected]> (https://www.acsone.eu/) | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# Copyright 2023 Michael Tietz (MT Software) <[email protected]> | ||
# Copyright 2025 ACSONE SA/NV | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). | ||
from odoo import api, fields, models | ||
|
||
|
@@ -31,7 +32,8 @@ def _action_confirm(self): | |
|
||
def _prepare_reserve_procurement_group_values(self): | ||
self.ensure_one() | ||
values = self.order_line[0]._prepare_procurement_group_vals() | ||
line = fields.first(self.order_line) | ||
values = line._prepare_procurement_group_vals() | ||
values["name"] = f"Reservation for {values['name']}" | ||
return values | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,25 @@ | ||
# Copyright 2023 Michael Tietz (MT Software) <[email protected]> | ||
# Copyright 2025 ACSONE SA/NV | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). | ||
from odoo import fields, models | ||
from odoo import _, api, fields, models | ||
from odoo.exceptions import ValidationError | ||
|
||
|
||
class StockMove(models.Model): | ||
_inherit = "stock.move" | ||
|
||
used_for_sale_reservation = fields.Boolean(default=False) | ||
|
||
@api.constrains("used_for_sale_reservation", "quantity_done") | ||
def _check_used_for_sale_reservation(self): | ||
for move in self: | ||
if move.used_for_sale_reservation and move.quantity_done: | ||
raise ValidationError( | ||
_( | ||
"You cannot set a quantity done on a move used for sale reservation" | ||
) | ||
) | ||
|
||
def _action_assign(self): | ||
self = self.filtered(lambda m: not m.used_for_sale_reservation) | ||
return super(StockMove, self)._action_assign() | ||
new_self = self.filtered(lambda m: not m.used_for_sale_reservation) | ||
return super(StockMove, new_self)._action_assign() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
* Michael Tietz (MT Software) <[email protected]> | ||
* Laurent Mignon <[email protected]> (https://www.acsone.eu/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
# Copyright 2023 Michael Tietz (MT Software) <[email protected]> | ||
# Copyright 2025 ACSONE SA/NV | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). | ||
from odoo.exceptions import UserError | ||
from odoo.exceptions import UserError, ValidationError | ||
from odoo.tests import tagged | ||
|
||
from .common import TestSaleStockPrebookCase | ||
|
@@ -49,3 +50,8 @@ def test_40_action_assign(self): | |
self.assertFalse(self.sale.picking_ids.move_lines.move_line_ids) | ||
with self.assertRaises(UserError): | ||
self.sale.picking_ids.button_validate() | ||
|
||
def test_50_process_move(self): | ||
self.sale.reserve_stock() | ||
with self.assertRaisesRegex(ValidationError, "You cannot set a quantity done"): | ||
self.sale.picking_ids.move_lines.quantity_done = 3 |