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.

57 lines
2.5 KiB

  1. # Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
  2. # License MIT (https://opensource.org/licenses/MIT).
  3. import odoo.tests
  4. from odoo.api import Environment
  5. @odoo.tests.common.at_install(True)
  6. @odoo.tests.common.post_install(True)
  7. class TestUi(odoo.tests.HttpCase):
  8. def test_create_new_partner_and_move_message(self):
  9. env = Environment(self.registry.test_cr, self.uid, {})
  10. # needed because tests are run before the module is marked as
  11. # installed. In js web will only load qweb coming from modules
  12. # that are returned by the backend in module_boot. Without
  13. # this you end up with js, css but no qweb.
  14. env["ir.module.module"].search(
  15. [("name", "=", "mail_move_message")], limit=1
  16. ).state = "installed"
  17. self.registry.cursor().release()
  18. # updating models, to be able relocate messages to a partner at_install
  19. config_parameters = self.env["ir.config_parameter"].sudo()
  20. config_parameters.set_param(
  21. "mail_relocation_models", "crm.lead,project.task,res.partner"
  22. )
  23. code = """
  24. var delayed_button_click = function(delay, button){
  25. setTimeout(function(){
  26. if (button.length) {
  27. return button.click();
  28. }
  29. return console.log('error', 'There is no element with the next selector: ' + button.selector);
  30. }, delay);
  31. };
  32. var delay = 1000;
  33. var message = $('.o_thread_message_core:contains("virginie")');
  34. var relocate = message.find('.o_thread_icons .fa-exchange');
  35. delayed_button_click(delay, relocate);
  36. // form is opened
  37. var create_partner_button = $('button[special="quick_create"]');
  38. delayed_button_click(delay, create_partner_button);
  39. // partner creation wizard is opened
  40. var save_button = $('.modal-content .btn-primary:contains("Save")');
  41. delayed_button_click(delay, save_button);
  42. var move_button = $('.btn-sm.oe_highlight:contains("Move")');
  43. delayed_button_click(delay, move_button);
  44. console.log('ok')
  45. """
  46. self.phantom_js(
  47. "/web", code, login="admin", ready="$('.o_thread_icons').length"
  48. )