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.

37 lines
1.2 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2018 ACSONE SA/NV
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  4. from openerp.tests import common
  5. class TestConfigurator(common.TransactionCase):
  6. def test_configurator(self):
  7. placeholders_obj = self.env['email.template.placeholder']
  8. templates_obj = self.env['email.template']
  9. invoice_model = self.env['ir.model'].search([
  10. ('model', '=', 'res.partner'),
  11. ])
  12. placeholders_vals = [
  13. {
  14. 'name': 'Invoice partner name',
  15. 'model_id': invoice_model.id,
  16. 'placeholder': '${object.partner_id.name}',
  17. },
  18. {
  19. 'name': 'Invoice partner vat',
  20. 'model_id': invoice_model.id,
  21. 'placeholder': '${object.partner_id.vat}',
  22. },
  23. ]
  24. for vals in placeholders_vals:
  25. placeholder = placeholders_obj.create(vals)
  26. res = templates_obj.onchange({
  27. 'placeholder_id': placeholder.id,
  28. 'placeholder_value': False,
  29. }, 'placeholder_id', {
  30. 'placeholder_id': "1",
  31. })['value']
  32. self.assertEqual(res['placeholder_value'], vals['placeholder'])