Files
odoo_source/addons/stock/tests/test_picking_tours.py
T
William Henrotin c03768487d [FIX] stock: missing field in form views
The field `move_line_nosuggest_ids` was missing on the stock move form
view. Depending on the `show_reserved` setting on the picking type, we
should show either `move_line_ids` or `move_line_nosuggest_ids`.
Displaying the wrong field will trigger the wrong computes

Part-of: odoo/odoo#136067
2023-09-27 09:11:48 +00:00

82 lines
3.4 KiB
Python

# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.tests import HttpCase, tagged
@tagged('-at_install', 'post_install')
class TestStockPickingTour(HttpCase):
def setUp(self):
self.receipt = self.env['stock.picking'].create({
'picking_type_id': self.env.ref('stock.picking_type_in').id,
'location_id': self.env.ref('stock.stock_location_suppliers').id,
'location_dest_id': self.env.ref('stock.stock_location_stock').id,
})
return super().setUp()
def _get_picking_url(self, picking_id):
action = self.env["ir.actions.actions"]._for_xml_id("stock.action_picking_tree_incoming")
return '/web#action=%s&id=%s&model=stock.picking&view_type=form' % (action['id'], picking_id)
def test_detailed_op_no_save_1(self):
"""validate a receipt with some move without any save except the last one"""
product_lot = self.env['product.product'].create({
'name': 'Product Lot',
'type': 'product',
'tracking': 'lot',
})
url = self._get_picking_url(self.receipt.id)
self.start_tour(url, 'test_detailed_op_no_save_1', login='admin', timeout=60)
self.assertEqual(self.receipt.state, 'done')
self.assertEqual(self.receipt.move_ids.product_uom_qty, 0)
self.assertEqual(self.receipt.move_ids.quantity_done, 4)
lot = self.env['stock.lot'].search([
('name', '=', 'lot1'),
('product_id', '=', product_lot.id),
])
self.assertEqual(len(lot), 1)
self.assertEqual(lot.product_qty, 4)
def test_generate_serial_1(self):
"""generate some serial numbers in the detailed operation modal"""
product_serial = self.env['product.product'].create({
'name': 'Product Serial',
'type': 'product',
'tracking': 'serial',
})
url = self._get_picking_url(self.receipt.id)
self.start_tour(url, 'test_generate_serial_1', login='admin', timeout=60)
self.assertEqual(self.receipt.state, 'done')
self.assertEqual(self.receipt.move_ids.product_uom_qty, 0)
self.assertEqual(self.receipt.move_ids.quantity_done, 5)
self.assertEqual(len(self.receipt.move_ids.move_line_ids), 5)
serial = self.env['stock.lot'].search([
('name', 'ilike', 'serial_n_%'),
('product_id', '=', product_serial.id),
])
self.assertEqual(len(serial), 5)
def test_generate_serial_2(self):
"""generate some serial numbers in the detailed operation modal on a planned picking"""
self.receipt.action_reset_draft()
product_serial = self.env['product.product'].create({
'name': 'Product Serial',
'type': 'product',
'tracking': 'serial',
})
url = self._get_picking_url(self.receipt.id)
self.start_tour(url, 'test_generate_serial_2', login='admin', timeout=60)
self.assertEqual(self.receipt.state, 'done')
self.assertEqual(self.receipt.move_ids.product_uom_qty, 0)
self.assertEqual(self.receipt.move_ids.quantity_done, 5)
self.assertEqual(len(self.receipt.move_ids.move_line_ids), 5)
serial = self.env['stock.lot'].search([
('name', 'ilike', 'serial_n_%'),
('product_id', '=', product_serial.id),
])
self.assertEqual(len(serial), 5)