You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.9 KiB

7 years ago
  1. # -*- coding: utf-8 -*-
  2. # © 2017 Stefan Becker <s.becker@humanilog.org>
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  4. from openerp.exceptions import ValidationError
  5. from openerp.tests.common import SavepointCase
  6. class TestContract(SavepointCase):
  7. @classmethod
  8. def setUpClass(cls):
  9. super(TestContract, cls).setUpClass()
  10. cls.partner = cls.env.ref('base.res_partner_2')
  11. cls.product = cls.env.ref('product.product_product_2')
  12. cls.product.description_sale = 'Test description sale'
  13. cls.purchase_journal = cls.env['account.journal'].create({
  14. 'name': 'Purchase Journal',
  15. 'type': 'purchase',
  16. 'company_id': cls.env.user.company_id.id,
  17. 'code': '1337'
  18. })
  19. contract = cls.env['account.analytic.account'].new({
  20. 'name': 'Test Contract',
  21. 'type': 'purchase',
  22. 'company_id': cls.env.user.company_id.id,
  23. 'partner_id': cls.partner.id,
  24. 'pricelist_id': cls.partner.property_product_pricelist.id,
  25. 'recurring_invoices': True,
  26. 'date_start': '2016-02-15',
  27. 'recurring_next_date': '2016-02-29',
  28. })
  29. contract.onchange_type()
  30. cls.contract = cls.env['account.analytic.account'].create(
  31. contract._convert_to_write(contract._cache))
  32. cls.contract_line = cls.env['account.analytic.invoice.line'].create({
  33. 'analytic_account_id': cls.contract.id,
  34. 'product_id': cls.product.id,
  35. 'name': 'Services from #START# to #END#',
  36. 'quantity': 1,
  37. 'uom_id': cls.product.uom_id.id,
  38. 'price_unit': 100,
  39. 'discount': 50,
  40. })
  41. def test_contract(self):
  42. self.assertEqual(self.contract.journal_id, self.purchase_journal)
  43. new_invoice = self.contract.recurring_create_invoice()
  44. self.assertEqual(new_invoice.type, 'in_invoice')