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.

67 lines
2.5 KiB

  1. # Copyright 2018 Eficent Business and IT Consulting Services S.L.
  2. # (http://www.eficent.com)
  3. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
  4. from odoo.tests.common import TransactionCase
  5. class TestCustomerActivityStatement(TransactionCase):
  6. """
  7. Tests for Customer Activity Statement.
  8. """
  9. def setUp(self):
  10. super(TestCustomerActivityStatement, self).setUp()
  11. self.res_users_model = self.env['res.users']
  12. self.company = self.env.ref('base.main_company')
  13. self.partner1 = self.env.ref('base.res_partner_1')
  14. self.partner2 = self.env.ref('base.res_partner_2')
  15. self.g_account_user = self.env.ref('account.group_account_user')
  16. self.user = self._create_user('user_1', [self.g_account_user],
  17. self.company).id
  18. self.statement_model = \
  19. self.env['report.customer_activity_statement.statement']
  20. self.wiz = self.env['customer.activity.statement.wizard']
  21. self.report_name = 'customer_activity_statement.statement'
  22. self.report_title = 'Customer Activity Statement'
  23. def _create_user(self, login, groups, company):
  24. group_ids = [group.id for group in groups]
  25. user = self.res_users_model.create({
  26. 'name': login,
  27. 'login': login,
  28. 'password': 'demo',
  29. 'email': 'example@yourcompany.com',
  30. 'company_id': company.id,
  31. 'company_ids': [(4, company.id)],
  32. 'groups_id': [(6, 0, group_ids)]
  33. })
  34. return user
  35. def test_customer_activity_statement(self):
  36. wiz_id = self.wiz.with_context(
  37. active_ids=[self.partner1.id, self.partner2.id],
  38. ).create({})
  39. statement = wiz_id.button_export_pdf()
  40. self.assertDictContainsSubset(
  41. {
  42. 'type': 'ir.actions.report',
  43. 'report_name': self.report_name,
  44. 'report_type': 'qweb-pdf',
  45. },
  46. statement,
  47. 'There was an error and the PDF report was not generated.'
  48. )
  49. data = wiz_id._prepare_activity_statement()
  50. docids = data['partner_ids']
  51. report = self.statement_model.get_report_values(docids, data)
  52. self.assertIsInstance(report, dict,
  53. "There was an error while compiling the report.")
  54. self.assertIn("Show_Buckets", report,
  55. "There was an error while compiling the report.")