Files
odoo_source/addons/stock/tests/test_picking.py
T
William Henrotin fc326082c8 [FIX] stock: hide reset to draft button when no needed
Only immediate transfers should have the ability to reset the state to
draft. Also rewording it as "Plan" as the goal of this button is to left
the stock move to be done later and impact the forecast

Task: 3256447
Part-of: odoo/odoo#124409
2023-09-20 10:02:05 +00:00

36 lines
1.5 KiB
Python

from odoo.tests import common
from odoo.exceptions import UserError
class TestPicking(common.TransactionCase):
def test_00_no_duplicate_sequence_code(self):
stock_location = self.env.ref('stock.stock_location_stock')
operation_type_1 = self.env['stock.picking.type'].create({
'name':'test 1',
'code': 'internal',
'default_location_src_id':stock_location.id,
'default_location_dest_id':stock_location.id,
'sequence_code':'testpicking'
})
with self.assertRaises(UserError) as er:
self.env['stock.picking.type'].create({
'name':'test 2',
'code': 'internal',
'default_location_src_id':stock_location.id,
'default_location_dest_id':stock_location.id,
'sequence_code':'testpicking'
})
self.assertEqual(
er.exception.args[0], f'Sequences {operation_type_1.sequence_id.name} already exist.')
def test_empty_picking_draft(self):
""" test an empty still can be reset to draft """
picking = self.env['stock.picking'].create({
'picking_type_id': self.env.ref('stock.picking_type_in').id,
'location_id': self.env.ref('stock.stock_location_stock').id,
'location_dest_id': self.env.ref('stock.stock_location_stock').id,
})
self.assertFalse(picking.move_ids)
picking.action_reset_draft()
self.assertEqual(picking.state, 'draft')