mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[COV] Update tests
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.tests import common
|
||||
from odoo.tools import mute_logger
|
||||
from psycopg2 import IntegrityError
|
||||
|
||||
|
||||
class StockMoveConfirmationCase(common.SavepointCase):
|
||||
@@ -60,7 +59,7 @@ class StockMoveConfirmationCase(common.SavepointCase):
|
||||
'type': 'general',
|
||||
})
|
||||
|
||||
def _create_done_move(self):
|
||||
def _create_move(self):
|
||||
"""Create a dummy move from Gate A to Gate B."""
|
||||
res = self.env['stock.move'].create({
|
||||
'location_id': self.location_from.id,
|
||||
@@ -77,9 +76,11 @@ class StockMoveConfirmationCase(common.SavepointCase):
|
||||
'product_uom_id': self.product.uom_id.id,
|
||||
}),
|
||||
],
|
||||
'picking_type_id': self.env.ref('stock.picking_type_internal').id,
|
||||
})
|
||||
res._action_done()
|
||||
res.value = res.product_id.standard_price * res.quantity_done
|
||||
# FIXME: refuses to play well w/ moves w/o picking_id
|
||||
# res._assign_picking(self.env.ref('stock.picking_type_internal'))
|
||||
res._assign_picking()
|
||||
return res
|
||||
|
||||
def test_00_regular_move(self):
|
||||
@@ -91,39 +92,23 @@ class StockMoveConfirmationCase(common.SavepointCase):
|
||||
self.location_from.force_accounting_entries = False
|
||||
self.location_to.force_accounting_entries = False
|
||||
# simple as that - we're just ensuring that we're allowed to do it.
|
||||
self._create_done_move()
|
||||
self._create_move()
|
||||
|
||||
@mute_logger('odoo.sql_db')
|
||||
def test_10_constraint(self):
|
||||
"""Test that it's impossible to force entries w/o an account."""
|
||||
with self.assertRaises(IntegrityError):
|
||||
with self.assertRaises(ValidationError):
|
||||
self.location_from.write({
|
||||
'force_accounting_entries': True,
|
||||
'valuation_in_account_id': False,
|
||||
})
|
||||
|
||||
def test_20_wrongly_configured_from_location(self):
|
||||
"""Test behavior when one of locations isn't configured properly.
|
||||
|
||||
I.e., one of those locations doesn't have a valuation account on it:
|
||||
while the other does - this should prevent users from creating
|
||||
moves between those locations.
|
||||
"""
|
||||
with self.assertRaises(ValidationError):
|
||||
self._create_done_move()
|
||||
|
||||
def test_30_wrongly_configured_to_location(self):
|
||||
"""Test behavior when one of locations isn't configured properly.
|
||||
|
||||
Same as above, but now it is dest location that is misconfigured.
|
||||
"""
|
||||
with self.assertRaises(ValidationError):
|
||||
self._create_done_move()
|
||||
|
||||
def test_50_create_account_move_line(self):
|
||||
kekes = self._create_done_move()
|
||||
move = self._create_move()
|
||||
move._action_done()
|
||||
# perform a manual evaluation of teh fresh move
|
||||
# we don't really care about those numbers
|
||||
kekes._create_account_move_line(
|
||||
move._create_account_move_line(
|
||||
self.location_from.valuation_out_account_id.id,
|
||||
self.location_to.valuation_in_account_id.id,
|
||||
self.fake_stock_journal.id)
|
||||
|
||||
Reference in New Issue
Block a user