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.

40 lines
1.5 KiB

  1. # -*- coding: utf-8 -*-
  2. # © 2017-2018 Therp BV <http://therp.nl>
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. from odoo.tests.common import TransactionCase
  5. class TestSubscriptionAction(TransactionCase):
  6. def test_subscription_action(self):
  7. subscription = self.env['subscription.subscription'].create({
  8. 'name': 'testsubscription',
  9. 'doc_source': 'res.partner,%d' % (
  10. self.env.ref('base.main_partner').id,
  11. ),
  12. 'server_action_id': self.env['ir.actions.server'].create({
  13. 'name': 'Subscription server action',
  14. 'model_id': self.env.ref('base.model_res_partner').id,
  15. 'state': 'object_write',
  16. 'use_write': 'current',
  17. 'fields_lines': [
  18. (
  19. 0, 0,
  20. {
  21. 'col1':
  22. self.env.ref('base.field_res_partner_name').id,
  23. 'type': 'value',
  24. 'value': 'Duplicated by subscription',
  25. }
  26. )
  27. ],
  28. }).id,
  29. })
  30. self.assertEqual(
  31. subscription.model_id.model, subscription.doc_source._name
  32. )
  33. subscription.set_process()
  34. subscription.model_copy()
  35. self.assertEqual(
  36. subscription.doc_lines[-1:].document_id.name,
  37. 'Duplicated by subscription',
  38. )