Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion addons/stock/models/stock_warehouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from odoo import _, _lt, api, fields, models
from odoo.exceptions import UserError
from odoo.tools.misc import clean_context

_logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -125,7 +126,7 @@ def create(self, vals):
# actually create WH
warehouse = super(Warehouse, self).create(vals)
# create sequences and operation types
new_vals = warehouse._create_or_update_sequences_and_picking_types()
new_vals = warehouse.with_context(clean_context(self.env.context))._create_or_update_sequences_and_picking_types()
warehouse.write(new_vals) # TDE FIXME: use super ?
# create routes and push/stock rules
route_vals = warehouse._create_or_update_route()
Expand Down
1 change: 1 addition & 0 deletions addons/stock/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@
from . import test_report
from . import test_report_stock_quantity
from . import test_report_tours
from . import test_res_company
from . import test_stock_return_picking
13 changes: 13 additions & 0 deletions addons/stock/tests/test_res_company.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from odoo.tests.common import TransactionCase


class TestResCompany(TransactionCase):
def test_create_warehouse_default_code(self):
code = 'TEST'
company = self.env['res.company'].with_context(default_code=code).create({
'name': 'name',
})
warehouse = self.env['stock.warehouse'].search([('company_id', '=', company.id)])
self.assertEqual(code, warehouse.code)
sequences = self.env['ir.sequence'].search([('company_id', '=', company.id), ('code', '=', code)])
self.assertEqual([], list(sequences), 'warehouse default_code should not overwrite sequence codes')