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

  1. # Copyright 2019 ACSONE SA/NV
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  3. from odoo.addons.contract.tests.test_contract import TestContractBase
  4. class TestContractSaleMandate(TestContractBase):
  5. @classmethod
  6. def setUpClass(cls):
  7. super(TestContractSaleMandate, cls).setUpClass()
  8. cls.partner_bank = cls.env['res.partner.bank'].create({
  9. 'acc_number': '1234',
  10. 'partner_id': cls.partner.id,
  11. })
  12. cls.mandate = cls.env['account.banking.mandate'].create({
  13. 'partner_id': cls.partner.id,
  14. 'partner_bank_id': cls.partner_bank.id,
  15. 'signature_date': '2017-01-01',
  16. })
  17. cls.product1 = cls.env.ref('product.product_product_1')
  18. cls.contract_template1 = cls.env['contract.template'].create(
  19. {'name': 'Template 1'}
  20. )
  21. cls.product1.write(
  22. {
  23. 'is_contract': True,
  24. 'default_qty': 12,
  25. 'recurring_rule_type': "monthlylastday",
  26. 'recurring_invoicing_type': "post-paid",
  27. 'contract_template_id': cls.contract_template1.id,
  28. }
  29. )
  30. cls.sale = cls.env.ref('sale.sale_order_2')
  31. cls.sale.mandate_id = cls.mandate
  32. cls.order_line1 = cls.sale.order_line.filtered(
  33. lambda l: l.product_id == cls.product1
  34. )
  35. def test_01(self):
  36. """
  37. Data:
  38. - A sale order with a mandate
  39. Test case:
  40. - Confirm the sale order
  41. Expected result:
  42. - The mandate of the sale order is copied on the generated
  43. contract
  44. """
  45. self.order_line1.onchange_product()
  46. self.sale.action_confirm()
  47. contracts = self.sale.order_line.mapped('contract_id')
  48. self.assertEqual(len(contracts), 1)
  49. self.assertEqual(contracts[0].mandate_id, self.mandate)