Basket Assembly is where the reverting quantity was noticed, so it depends on stock_move_manual_quantity now and its two lists load `picked`: the web client only saves the fields present in the arch, and without it the onchange that freezes a hand-typed quantity never reaches the server. Collecting a line does the same, minus the demand. It is the operator saying the goods are in the basket, so the quantity has to survive the reservation engine even when it was never retyped -- but only a quantity typed by hand says what the demand should become, and a line collected at zero would otherwise lose its demand and be cancelled on validation. Drops views/stock_move_line_views.xml on the way. It declared a second record under the id stock_picking_batch_views.xml already uses, so it was loaded first and immediately overwritten: dead weight that would have turned into a duplicate-field view had anyone renamed it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
73 lines
2.6 KiB
Python
73 lines
2.6 KiB
Python
# Copyright 2026 Criptomart
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
|
|
from odoo import Command
|
|
from odoo.tests import TransactionCase
|
|
from odoo.tests import tagged
|
|
|
|
|
|
@tagged("-at_install", "post_install")
|
|
class TestCollectedPicked(TransactionCase):
|
|
"""Collecting a line protects its quantity from the reservation engine."""
|
|
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
super().setUpClass()
|
|
cls.stock_location = cls.env.ref("stock.stock_location_stock")
|
|
cls.customer_location = cls.env.ref("stock.stock_location_customers")
|
|
cls.picking_type = cls.env.ref("stock.picking_type_out")
|
|
cls.product = cls.env["product.product"].create(
|
|
{
|
|
"name": "Collected Apples",
|
|
"is_storable": True,
|
|
"uom_id": cls.env.ref("uom.product_uom_kgm").id,
|
|
"uom_po_id": cls.env.ref("uom.product_uom_kgm").id,
|
|
}
|
|
)
|
|
cls.env["stock.quant"]._update_available_quantity(
|
|
cls.product, cls.stock_location, 50.0
|
|
)
|
|
|
|
def _create_picking(self, demand):
|
|
picking = self.env["stock.picking"].create(
|
|
{
|
|
"picking_type_id": self.picking_type.id,
|
|
"location_id": self.stock_location.id,
|
|
"location_dest_id": self.customer_location.id,
|
|
"move_ids": [
|
|
Command.create(
|
|
{
|
|
"name": self.product.name,
|
|
"product_id": self.product.id,
|
|
"product_uom": self.product.uom_id.id,
|
|
"product_uom_qty": demand,
|
|
"location_id": self.stock_location.id,
|
|
"location_dest_id": self.customer_location.id,
|
|
}
|
|
)
|
|
],
|
|
}
|
|
)
|
|
picking.action_confirm()
|
|
picking.action_assign()
|
|
return picking
|
|
|
|
def test_collecting_a_line_marks_it_picked(self):
|
|
picking = self._create_picking(2.0)
|
|
line = picking.move_ids.move_line_ids
|
|
|
|
line.is_collected = True
|
|
|
|
self.assertTrue(line.picked)
|
|
self.assertTrue(picking.move_ids.picked)
|
|
|
|
def test_collecting_a_line_keeps_its_demand(self):
|
|
"""Only a hand-typed quantity lowers the demand, collecting does not."""
|
|
picking = self._create_picking(2.0)
|
|
move = picking.move_ids
|
|
move.move_line_ids.write({"quantity": 1.5, "picked": True})
|
|
|
|
move.move_line_ids.is_collected = True
|
|
|
|
self.assertEqual(move.product_uom_qty, 1.5)
|
|
self.assertTrue(move.picked)
|