[FIX] stock_picking_batch_custom: require collected before batch validation
This commit is contained in:
parent
12d434d4c7
commit
d4be0ae23e
4 changed files with 107 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
|||
# Copyright 2026 Criptomart
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.tests import tagged
|
||||
from odoo.tests.common import TransactionCase
|
||||
|
||||
|
|
@ -287,3 +288,27 @@ class TestBatchSummary(TransactionCase):
|
|||
lambda line: line.product_id == product2
|
||||
)
|
||||
self.assertAlmostEqual(line_product2.qty_demanded, 10.0)
|
||||
|
||||
def test_done_requires_all_summary_lines_collected(self):
|
||||
"""Batch validation must fail if there are unchecked collected lines."""
|
||||
|
||||
batch = self._create_batch_with_pickings()
|
||||
batch.action_confirm()
|
||||
batch._compute_summary_line_ids()
|
||||
|
||||
self.assertTrue(batch.summary_line_ids)
|
||||
self.assertFalse(batch.summary_line_ids.mapped("is_collected")[0])
|
||||
|
||||
with self.assertRaises(UserError):
|
||||
batch.action_done()
|
||||
|
||||
def test_check_all_products_collected_passes_when_all_checked(self):
|
||||
"""Collected validation helper must pass when all lines are checked."""
|
||||
|
||||
batch = self._create_batch_with_pickings()
|
||||
batch.action_confirm()
|
||||
batch._compute_summary_line_ids()
|
||||
batch.summary_line_ids.write({"is_collected": True})
|
||||
|
||||
# Should not raise
|
||||
batch._check_all_products_collected()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue