This commit replaces the opening of the stock moves detailed operation wizard by the one2Many record preview. This means creating a move in a picking is still done via a new line but the edition is done via the `fa-list` button that open the record in the web client. The goal is to reduce the RPCs call as much as possible. The stock move lines data are stored in the stock move record until the picking save. Additionally, this commit change a bit the immediate transfers flows. The stock move show only initial demand (`product_uom_qty`) but the column wording is still "Done". In the detailed operation view, the stock move line `qty_done` is displayed as "Reserved". At picking validation, the user is expected to enter the same quantity in `product_uom_qty` and `quantity_done`. If `product_uom_qty` is equals to 0, the done quantity is used as actual transfer quantity. If `product_uom_qty` is different than 0 but small than the done quantity, an error is raised. Task: 3256447 Part-of: odoo/odoo#124409
62 lines
2.6 KiB
Python
62 lines
2.6 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo.tests import Form
|
|
from odoo.tests.common import TransactionCase
|
|
|
|
|
|
class StockMove(TransactionCase):
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
super().setUpClass()
|
|
cls.stock_location = cls.env.ref('stock.stock_location_stock')
|
|
cls.product = cls.env['product.product'].create({
|
|
'name': 'Product A',
|
|
'type': 'product',
|
|
'categ_id': cls.env.ref('product.product_category_all').id,
|
|
})
|
|
cls.env['stock.quant']._update_available_quantity(cls.product, cls.stock_location, 10.0)
|
|
cls.product_consu = cls.env['product.product'].create({
|
|
'name': 'Product A',
|
|
'type': 'consu',
|
|
'categ_id': cls.env.ref('product.product_category_all').id,
|
|
})
|
|
|
|
def test_show_detailed(self):
|
|
"""
|
|
Create an delivery immediate transfer with a storable and a consumable
|
|
product. The consumable product should not create move line from quants.
|
|
"""
|
|
# create a delivery order
|
|
picking = Form(self.env['stock.picking'].with_context(default_picking_type_id=self.ref('stock.picking_type_out')))
|
|
with picking.move_ids_without_package.new() as move:
|
|
move.product_id = self.product
|
|
move.product_uom_qty = 1.0
|
|
with picking.move_ids_without_package.new() as move:
|
|
move.product_id = self.product_consu
|
|
move.product_uom_qty = 1.0
|
|
picking = picking.save()
|
|
|
|
self.assertEqual(picking.move_ids[0].show_quant, True)
|
|
self.assertEqual(picking.move_ids[1].show_quant, False)
|
|
|
|
def test_create_move_line_reserved(self):
|
|
""" Create a delivery immediate transfer with a storable product.
|
|
The move line should be reserved.
|
|
"""
|
|
# create a delivery order
|
|
picking = Form(self.env['stock.picking'].with_context(default_picking_type_id=self.ref('stock.picking_type_out')))
|
|
with picking.move_ids_without_package.new() as move:
|
|
move.product_id = self.product
|
|
move.product_uom_qty = 1.0
|
|
picking = picking.save()
|
|
self.env['stock.move.line'].create({
|
|
'move_id': picking.move_ids_without_package.id,
|
|
'product_id': self.product.id,
|
|
'reserved_uom_qty': 1.0,
|
|
'qty_done': 0,
|
|
})
|
|
self.assertEqual(picking.move_ids.reserved_availability, 1.0)
|
|
self.assertEqual(picking.move_ids.state, 'assigned')
|
|
self.assertEqual(picking.move_ids.quantity_done, 0)
|