mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[FIX] fix multi-company test
Record rules used to not be checked on stock quants, but now they are since Odoo's commit 2fd14db57433d08ab368a7e18d18ae8d49dafab1 (https://github.com/odoo/odoo/commit/2fd14db). In our test we changed the company of the products and BoMs but we neglected that the stock was not attached to the right company, and that made the test fail. To fix that, make the test inventory for the right company. Since there is a little inconsistency in the demo data with a negative quantity of an unrelated product, use the `partial` filter for the inventories instead of the `none` filter, so that no wrong inventory lines are added automatically.
This commit is contained in:
committed by
Cyril Gaudin
parent
fe21ce9d91
commit
707363fc62
@@ -74,27 +74,33 @@ class TestPotentialQty(TransactionCase):
|
||||
"The potential without a BoM should be 0")
|
||||
|
||||
def test_potential_qty_no_bom_for_company(self):
|
||||
# Receive 1000x CPUa8s
|
||||
chicago_id = self.ref('stock.res_company_1')
|
||||
|
||||
# Receive 1000x CPUa8s owned by Chicago
|
||||
inventory = self.env['stock.inventory'].create(
|
||||
{'name': 'Receive CPUa8',
|
||||
'company_id': chicago_id,
|
||||
'location_id': self.wh_ch.lot_stock_id.id,
|
||||
'filter': 'none'})
|
||||
'filter': 'partial'})
|
||||
inventory.prepare_inventory()
|
||||
self.env['stock.inventory.line'].create({
|
||||
'inventory_id': inventory.id,
|
||||
'company_id': chicago_id,
|
||||
'product_id': self.ref('product.product_product_23'),
|
||||
'location_id': self.wh_ch.lot_stock_id.id,
|
||||
'product_qty': 1000.0})
|
||||
inventory.action_done()
|
||||
|
||||
# Receive enough RAM-SR3 to make 1000x the 1st variant in main WH
|
||||
# Put RAM-SR3 owned by Chicago for 1000x the 1st variant in main WH
|
||||
inventory = self.env['stock.inventory'].create(
|
||||
{'name': 'components for 1st variant',
|
||||
'company_id': chicago_id,
|
||||
'location_id': self.wh_ch.lot_stock_id.id,
|
||||
'filter': 'none'})
|
||||
'filter': 'partial'})
|
||||
inventory.prepare_inventory()
|
||||
self.env['stock.inventory.line'].create({
|
||||
'inventory_id': inventory.id,
|
||||
'company_id': chicago_id,
|
||||
'product_id': self.ref('product.product_product_15'),
|
||||
'location_id': self.wh_ch.lot_stock_id.id,
|
||||
'product_qty': 1000.0})
|
||||
@@ -123,10 +129,8 @@ class TestPotentialQty(TransactionCase):
|
||||
# and the demo user on Chicago (child of main company)
|
||||
self.env['product.product'].search([
|
||||
TRUE_LEAF]).write({'company_id': False})
|
||||
chicago_id = self.ref('stock.res_company_1')
|
||||
test_user.write({'company_id': chicago_id,
|
||||
'company_ids': [(4, chicago_id)]})
|
||||
test_user = test_user.sudo(test_user)
|
||||
bom.company_id = self.ref('base.main_company')
|
||||
self.assertPotentialQty(
|
||||
test_user_tmpl, 0,
|
||||
@@ -146,7 +150,7 @@ class TestPotentialQty(TransactionCase):
|
||||
inventory = self.env['stock.inventory'].create(
|
||||
{'name': 'Receive CPUa8',
|
||||
'location_id': self.wh_main.lot_stock_id.id,
|
||||
'filter': 'none'})
|
||||
'filter': 'partial'})
|
||||
inventory.prepare_inventory()
|
||||
self.env['stock.inventory.line'].create({
|
||||
'inventory_id': inventory.id,
|
||||
@@ -164,7 +168,7 @@ class TestPotentialQty(TransactionCase):
|
||||
inventory = self.env['stock.inventory'].create(
|
||||
{'name': 'components for 1st variant',
|
||||
'location_id': self.wh_main.lot_stock_id.id,
|
||||
'filter': 'none'})
|
||||
'filter': 'partial'})
|
||||
inventory.prepare_inventory()
|
||||
self.env['stock.inventory.line'].create({
|
||||
'inventory_id': inventory.id,
|
||||
@@ -187,7 +191,7 @@ class TestPotentialQty(TransactionCase):
|
||||
inventory = self.env['stock.inventory'].create(
|
||||
{'name': 'components for 2nd variant',
|
||||
'location_id': self.wh_ch.lot_stock_id.id,
|
||||
'filter': 'none'})
|
||||
'filter': 'partial'})
|
||||
inventory.prepare_inventory()
|
||||
self.env['stock.inventory.line'].create({
|
||||
'inventory_id': inventory.id,
|
||||
|
||||
Reference in New Issue
Block a user