test_payment_term.py 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # -*- coding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # Copyright (C) 2015 Akretion (http://www.akretion.com)
  5. # @author Alexis de Lattre <alexis.delattre@akretion.com>
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU Affero General Public License as
  9. # published by the Free Software Foundation, either version 3 of the
  10. # License, or (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU Affero General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Affero General Public License
  18. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. #
  20. ##############################################################################
  21. from openerp.tests.common import TransactionCase
  22. class TestAccountPaymentTerm(TransactionCase):
  23. def setUp(self):
  24. super(TestAccountPaymentTerm, self).setUp()
  25. self.account_payment_term = self.registry('account.payment.term')
  26. self.sixty_days_end_of_month =\
  27. self.registry('ir.model.data').xmlid_to_res_id(
  28. self.cr, self.uid,
  29. 'account_payment_term_extension.sixty_days_end_of_month')
  30. def test_00_compute(self):
  31. cr, uid = self.cr, self.uid
  32. res = self.account_payment_term.compute(
  33. cr, uid, self.sixty_days_end_of_month, 10, date_ref='2015-01-30')
  34. self.assertEquals(
  35. res[0][0],
  36. '2015-03-31',
  37. 'Error in the compute of payment terms with months')
  38. def test_01_compute(self):
  39. cr, uid = self.cr, self.uid
  40. two_week_payterm_id = self.account_payment_term.create(
  41. cr, uid, {
  42. 'name': '2 weeks',
  43. 'line_ids': [(0, 0, {
  44. 'value': 'balance',
  45. 'days': 0,
  46. 'weeks': 2})]
  47. })
  48. res = self.account_payment_term.compute(
  49. cr, uid, two_week_payterm_id, 10, date_ref='2015-03-02')
  50. self.assertEquals(
  51. res[0][0],
  52. '2015-03-16',
  53. 'Error in the compute of payment terms with weeks')