2014-12-02 12:54:51 +01:00
|
|
|
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
|
|
|
|
# this repository contains the full copyright notices and license terms.
|
2022-04-16 18:30:16 +02:00
|
|
|
|
2018-06-26 19:11:44 +02:00
|
|
|
from unittest.mock import Mock, patch
|
2014-09-04 22:50:43 +02:00
|
|
|
|
|
|
|
|
from trytond.pool import Pool
|
2022-04-16 18:30:16 +02:00
|
|
|
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
|
2011-01-16 22:07:50 +01:00
|
|
|
|
|
|
|
|
|
2015-01-27 18:13:05 +01:00
|
|
|
class AccountStockAngloSaxonTestCase(ModuleTestCase):
|
2014-01-12 19:59:27 +01:00
|
|
|
'Test Account Stock Anglo Saxon module'
|
2015-01-27 18:13:05 +01:00
|
|
|
module = 'account_stock_anglo_saxon'
|
2015-01-02 16:07:55 +01:00
|
|
|
|
2016-02-06 19:12:12 +01:00
|
|
|
@with_transaction()
|
2014-09-04 22:50:43 +02:00
|
|
|
def test_get_anglo_saxon_move(self):
|
|
|
|
|
'Test _get_anglo_saxon_move'
|
2016-02-06 19:12:12 +01:00
|
|
|
pool = Pool()
|
|
|
|
|
Move = pool.get('stock.move')
|
|
|
|
|
Uom = pool.get('product.uom')
|
|
|
|
|
Currency = pool.get('currency.currency')
|
2014-09-04 22:50:43 +02:00
|
|
|
|
2016-02-06 19:12:12 +01:00
|
|
|
def move(quantity, price):
|
|
|
|
|
move = Mock()
|
|
|
|
|
move.quantity = quantity
|
|
|
|
|
move.unit_price = price
|
|
|
|
|
move.cost_price = price
|
|
|
|
|
move.in_anglo_saxon_quantity = 0
|
|
|
|
|
move.out_anglo_saxon_quantity = 0
|
|
|
|
|
return move
|
2014-09-04 22:50:43 +02:00
|
|
|
|
2016-02-06 19:12:12 +01:00
|
|
|
with patch.object(Uom, 'compute_qty') as compute_qty, \
|
|
|
|
|
patch.object(Uom, 'compute_price') as compute_price, \
|
|
|
|
|
patch.object(Currency, 'compute') as compute:
|
|
|
|
|
compute_qty.side_effect = lambda *args, **kwargs: args[1]
|
|
|
|
|
compute_price.side_effect = lambda *args, **kwargs: args[1]
|
|
|
|
|
compute.side_effect = lambda *args, **kwargs: args[1]
|
2014-09-04 22:50:43 +02:00
|
|
|
|
2016-02-06 19:12:12 +01:00
|
|
|
moves = [move(1, 3), move(2, 2)]
|
|
|
|
|
result = list(Move._get_anglo_saxon_move(
|
|
|
|
|
moves, 1, 'in_supplier'))
|
|
|
|
|
self.assertEqual(result, [(moves[0], 1, 3)])
|
2014-09-04 22:50:43 +02:00
|
|
|
|
2016-02-06 19:12:12 +01:00
|
|
|
moves = [move(1, 3), move(2, 2)]
|
|
|
|
|
result = list(Move._get_anglo_saxon_move(
|
|
|
|
|
moves, 2, 'in_supplier'))
|
|
|
|
|
self.assertEqual(result,
|
|
|
|
|
[(moves[0], 1, 3), (moves[1], 1, 2)])
|
2014-09-04 22:50:43 +02:00
|
|
|
|
2012-04-03 20:06:29 +02:00
|
|
|
|
2022-04-16 18:30:16 +02:00
|
|
|
del ModuleTestCase
|