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.

52 lines
1.8 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. 'contract_template_id': cls.contract_template1.id,
  27. }
  28. )
  29. cls.sale = cls.env.ref('sale.sale_order_2')
  30. cls.sale.mandate_id = cls.mandate
  31. cls.order_line1 = cls.sale.order_line.filtered(
  32. lambda l: l.product_id == cls.product1
  33. )
  34. def test_01(self):
  35. """
  36. Data:
  37. - A sale order with a mandate
  38. Test case:
  39. - Confirm the sale order
  40. Expected result:
  41. - The mandate of the sale order is copied on the generated
  42. contract
  43. """
  44. self.order_line1.onchange_product()
  45. self.sale.action_confirm()
  46. contracts = self.sale.order_line.mapped('contract_id')
  47. self.assertEqual(len(contracts), 1)
  48. self.assertEqual(contracts[0].mandate_id, self.mandate)