diff --git a/addons/account/account.py b/addons/account/account.py index 1380a01d139..45909b6c920 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -1585,7 +1585,7 @@ class account_move(osv.osv): obj_move_line.write(cr, uid, line_draft_ids, { 'state': 'valid' - }, context, check=False) + }, context=context, check=False) account = {} account2 = {} @@ -1604,7 +1604,7 @@ class account_move(osv.osv): obj_move_line.write(cr, uid, [line.id], { 'tax_code_id': code, 'tax_amount': amount - }, context, check=False) + }, context=context, check=False) elif journal.centralisation: # If the move is not balanced, it must be centralised... @@ -1619,7 +1619,7 @@ class account_move(osv.osv): self._centralise(cr, uid, move, 'credit', context=context) obj_move_line.write(cr, uid, line_draft_ids, { 'state': 'valid' - }, context, check=False) + }, context=context, check=False) else: # We can't validate it (it's unbalanced) # Setting the lines as draft @@ -1627,7 +1627,7 @@ class account_move(osv.osv): if not_draft_line_ids: obj_move_line.write(cr, uid, not_draft_line_ids, { 'state': 'draft' - }, context, check=False) + }, context=context, check=False) # Create analytic lines for the valid moves for record in valid_moves: obj_move_line.create_analytic_lines(cr, uid, [line.id for line in record.line_id], context) diff --git a/addons/account_budget/tests/test_theoreticalamount.py b/addons/account_budget/tests/test_theoreticalamount.py index a1e090e2184..ab1c4dabf7c 100644 --- a/addons/account_budget/tests/test_theoreticalamount.py +++ b/addons/account_budget/tests/test_theoreticalamount.py @@ -3,7 +3,7 @@ from datetime import datetime from mock import patch from openerp.tests.common import TransactionCase -from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT +from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT, float_compare # --------------------------------------------------------- @@ -32,65 +32,71 @@ class TestTheoreticalAmount(TransactionCase): self.patcher = patch('openerp.addons.account_budget.account_budget.datetime', wraps=datetime) self.mock_datetime = self.patcher.start() + def assertFloatEqual(self, value1, value2, *args, **kwargs): + """ Compare two values of the field theoritical_amount """ + digits = type(self.line).theoritical_amount.digits + result = float_compare(value1, value2, precision_digits=digits[1]) + return self.assertFalse(result, *args, **kwargs) + def test_01(self): """Start""" date = datetime.strptime('2014-01-01 00:00:00', DEFAULT_SERVER_DATETIME_FORMAT) self.mock_datetime.now.return_value = date - self.assertEqual(self.line.theoritical_amount, 0) + self.assertFloatEqual(self.line.theoritical_amount, 0) def test_02(self): """After 24 hours""" date = datetime.strptime('2014-01-02 00:00:00', DEFAULT_SERVER_DATETIME_FORMAT) self.mock_datetime.now.return_value = date - self.assertEqual(self.line.theoritical_amount, -1) + self.assertFloatEqual(self.line.theoritical_amount, -1) def test_03(self): """After 36 hours""" date = datetime.strptime('2014-01-02 12:00:00', DEFAULT_SERVER_DATETIME_FORMAT) self.mock_datetime.now.return_value = date - self.assertEqual(self.line.theoritical_amount, -1.5) + self.assertFloatEqual(self.line.theoritical_amount, -1.5) def test_04(self): """After 48 hours""" date = datetime.strptime('2014-01-03 00:00:00', DEFAULT_SERVER_DATETIME_FORMAT) self.mock_datetime.now.return_value = date - self.assertEqual(self.line.theoritical_amount, -2) + self.assertFloatEqual(self.line.theoritical_amount, -2) def test_05(self): """After 10 days""" date = datetime.strptime('2014-01-11 00:00:00', DEFAULT_SERVER_DATETIME_FORMAT) self.mock_datetime.now.return_value = date - self.assertEqual(self.line.theoritical_amount, -10) + self.assertFloatEqual(self.line.theoritical_amount, -10) def test_06(self): """After 50 days""" date = datetime.strptime('2014-02-20 00:00:00', DEFAULT_SERVER_DATETIME_FORMAT) self.mock_datetime.now.return_value = date - self.assertEqual(self.line.theoritical_amount, -50) + self.assertFloatEqual(self.line.theoritical_amount, -50) def test_07(self): """After 182 days, exactly half of the budget line""" date = datetime.strptime('2014-07-02 00:00:00', DEFAULT_SERVER_DATETIME_FORMAT) self.mock_datetime.now.return_value = date - self.assertEqual(self.line.theoritical_amount, -182) + self.assertFloatEqual(self.line.theoritical_amount, -182) def test_08(self): """After 308 days at noon""" date = datetime.strptime('2014-11-05 12:00:00', DEFAULT_SERVER_DATETIME_FORMAT) # remember, remember self.mock_datetime.now.return_value = date - self.assertEqual(self.line.theoritical_amount, -308.5) + self.assertFloatEqual(self.line.theoritical_amount, -308.5) def test_09(self): """One day before""" date = datetime.strptime('2014-12-30 00:00:00', DEFAULT_SERVER_DATETIME_FORMAT) self.mock_datetime.now.return_value = date - self.assertEqual(self.line.theoritical_amount, -363) + self.assertFloatEqual(self.line.theoritical_amount, -363) def test_10(self): """At last""" date = datetime.strptime('2014-12-31 00:00:00', DEFAULT_SERVER_DATETIME_FORMAT) self.mock_datetime.now.return_value = date - self.assertEqual(self.line.theoritical_amount, -364) + self.assertFloatEqual(self.line.theoritical_amount, -364) def tearDown(self): self.patcher.stop() diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index 82f06d3e935..f0d772dfc4a 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -1494,6 +1494,7 @@ class account_voucher_line(osv.osv): 'amount_unreconciled': fields.function(_compute_balance, multi='dc', type='float', string='Open Balance', store=True, digits_compute=dp.get_precision('Account')), 'company_id': fields.related('voucher_id','company_id', relation='res.company', type='many2one', string='Company', store=True, readonly=True), 'currency_id': fields.function(_currency_id, string='Currency', type='many2one', relation='res.currency', readonly=True), + 'state': fields.related('voucher_id', 'state', type='char', string='State', readonly=True), } _defaults = { 'name': '', diff --git a/addons/account_voucher/voucher_payment_receipt_view.xml b/addons/account_voucher/voucher_payment_receipt_view.xml index 231ead2665f..35cc4c96101 100644 --- a/addons/account_voucher/voucher_payment_receipt_view.xml +++ b/addons/account_voucher/voucher_payment_receipt_view.xml @@ -163,10 +163,11 @@