From 4cf9fa928e2598aeb0a1bc881552952eb34787f1 Mon Sep 17 00:00:00 2001 From: wan Date: Tue, 18 Aug 2020 11:07:12 +0000 Subject: [PATCH] [IMP] account: redo the tour The tour has been updated Task 2306134 closes odoo/odoo#55624 Related: odoo/enterprise#12378 Related: odoo/upgrade#1659 Signed-off-by: Cedric Snauwaert (csn) --- addons/account/models/company.py | 67 +--------------- addons/account/static/src/js/tours/account.js | 80 +++++++++++++++---- addons/account/tests/__init__.py | 1 + addons/account/tests/test_tour.py | 15 ++++ .../views/account_onboarding_templates.xml | 45 +++-------- .../payment_acquirer_onboarding_templates.xml | 8 -- 6 files changed, 97 insertions(+), 119 deletions(-) create mode 100644 addons/account/tests/test_tour.py diff --git a/addons/account/models/company.py b/addons/account/models/company.py index 29b4c8b64cc..cf1b2d541b3 100644 --- a/addons/account/models/company.py +++ b/addons/account/models/company.py @@ -97,7 +97,7 @@ class ResCompany(models.Model): account_setup_fy_data_state = fields.Selection(ONBOARDING_STEP_STATES, string="State of the onboarding fiscal year step", default='not_done') account_setup_coa_state = fields.Selection(ONBOARDING_STEP_STATES, string="State of the onboarding charts of account step", default='not_done') account_onboarding_invoice_layout_state = fields.Selection(ONBOARDING_STEP_STATES, string="State of the onboarding invoice layout step", default='not_done') - account_onboarding_sample_invoice_state = fields.Selection(ONBOARDING_STEP_STATES, string="State of the onboarding sample invoice step", default='not_done') + account_onboarding_create_invoice_state = fields.Selection(ONBOARDING_STEP_STATES, string="State of the onboarding create invoice step", default='not_done') account_onboarding_sale_tax_state = fields.Selection(ONBOARDING_STEP_STATES, string="State of the onboarding sale tax step", default='not_done') # account dashboard onboarding @@ -168,7 +168,7 @@ class ResCompany(models.Model): return [ 'base_onboarding_company_state', 'account_onboarding_invoice_layout_state', - 'account_onboarding_sample_invoice_state', + 'account_onboarding_create_invoice_state', ] def get_and_update_account_dashboard_onboarding_state(self): @@ -437,67 +437,8 @@ class ResCompany(models.Model): return action @api.model - def _get_sample_invoice(self): - """ Get a sample invoice or create one if it does not exist. """ - # use current user as partner - partner = self.env.user.partner_id - - company_id = self.env.company.id - # try to find an existing sample invoice - sample_invoice = self.env['account.move'].search( - [('company_id', '=', company_id), - ('partner_id', '=', partner.id)], limit=1) - - if len(sample_invoice) == 0: - # If there are no existing accounts or no journal, fail - account = self.env.company.get_chart_of_accounts_or_fail() - - journal = self.env['account.journal'].search([('company_id', '=', company_id)], limit=1) - if len(journal) == 0: - action = self.env.ref('account.action_account_journal_form') - msg = _("We cannot find any journal for this company. You should create one." - "\nPlease go to Configuration > Journals.") - raise RedirectWarning(msg, action.id, _("Go to the journal configuration")) - - account = journal.default_credit_account_id or account - sample_invoice = self.env['account.move'].with_context(default_move_type='out_invoice', default_journal_id=journal.id).create({ - 'payment_reference': _('Sample invoice'), - 'partner_id': partner.id, - 'invoice_line_ids': [ - (0, 0, { - 'name': _('Sample invoice line name'), - 'account_id': account.id, - 'quantity': 2, - 'price_unit': 199.99, - }), - (0, 0, { - 'name': _('Sample invoice line name 2'), - 'account_id': account.id, - 'quantity': 1, - 'price_unit': 25.0, - }), - ], - }) - return sample_invoice - - @api.model - def action_open_account_onboarding_sample_invoice(self): - """ Onboarding step for sending a sample invoice. Open a window to compose an email, - with the edi_invoice_template message loaded by default. """ - sample_invoice = self._get_sample_invoice() - template = self.env.ref('account.email_template_edi_invoice', False) - action = self.env["ir.actions.actions"]._for_xml_id("account.action_open_account_onboarding_sample_invoice") - action['context'] = { - 'default_res_id': sample_invoice.id, - 'default_use_template': bool(template), - 'default_template_id': template and template.id or False, - 'default_model': 'account.move', - 'default_composition_mode': 'comment', - 'mark_invoice_as_sent': True, - 'custom_layout': 'mail.mail_notification_borders', - 'force_email': True, - 'mail_notify_author': True, - } + def action_open_account_onboarding_create_invoice(self): + action = self.env["ir.actions.actions"]._for_xml_id("account.action_open_account_onboarding_create_invoice") return action def action_save_onboarding_invoice_layout(self): diff --git a/addons/account/static/src/js/tours/account.js b/addons/account/static/src/js/tours/account.js index 74b0dcda95b..0b4365ce23e 100644 --- a/addons/account/static/src/js/tours/account.js +++ b/addons/account/static/src/js/tours/account.js @@ -7,21 +7,69 @@ var tour = require('web_tour.tour'); var _t = core._t; tour.register('account_tour', { - 'skip_enabled': true, -}, [{ - trigger: ".o_form_readonly .o_invoice_validate", - extra_trigger: '.o_invoice_form', - content: _t("Click to validate your invoice. A reference will be assigned to this invoice and you will not be able to modify it anymore."), - position: "right" -}, { - trigger: ".o_invoice_send", - extra_trigger: '.o_invoice_form', - content: _t("Click to send the invoice by email."), - position: "bottom" -}, { - trigger: ".o_mail_send", - content: _t("Click to send the invoice."), - position: "bottom" -} ]); + skip_enabled: true, + url: "/web", +}, [ + ...tour.stepUtils.goToAppSteps('account.menu_finance', _t('Send invoices to your customers in no time with the Invoicing app.')), + { + trigger: "a.o_onboarding_step_action[data-method=action_open_base_onboarding_company]", + content: _t("Start by checking your company's data."), + }, { + trigger: "button[name=action_save_onboarding_company_step]", + content: _t("Looks good. Let's continue."), + }, { + trigger: "a.o_onboarding_step_action[data-method=action_open_base_document_layout]", + content: _t("Customize your layout."), + }, { + trigger: "button[name=document_layout_save]", + content: _t("Once everything is as you want it, validate."), + }, { + trigger: "a.o_onboarding_step_action[data-method=action_open_account_onboarding_create_invoice]", + content: _t("Now, we'll create a your first invoice."), + }, { + trigger: "input[name=name]", + content: _t("Customize the prefix and number to fit your needs."), + run: 'text SALE/0000000001' + }, { + trigger: "div[name=partner_id] input", + content: _t("Write a company name to create one or see suggestions."), + position: "bottom", + }, { + trigger: ".o_m2o_dropdown_option a:contains('Create')", + content: _t("Select first partner"), + auto: true, + }, { + trigger: ".modal-content button.btn-primary", + content: _t("Once everything is set, you are good to continue. You will be able to edit this later in the Customers menu."), + }, { + trigger: "div[name=invoice_line_ids] .o_field_x2many_list_row_add a:not([data-context])", + content: _t("Add a line to your invoice"), + }, { + trigger: "div[name=invoice_line_ids] textarea[name=name]", + content: _t("Fill in the details of the line.
Tip: all the details can be set automatically if you configure your products."), + position: "bottom", + }, { + trigger: "div[name=invoice_line_ids] input[name=price_unit]", + content: _t("Set a price"), + position: "bottom", + run: 'text 100', + }, { + trigger: "button[name=action_post]", + content: _t("Once your invoice is ready, validate."), + }, { + trigger: "button[name=action_invoice_sent]", + content: _t("Send the invoice and check what the customer will receive."), + }, { + trigger: "input[name=email]", + content: _t("Write here your own email address to test the flow."), + run: 'text customer@example.com', + }, { + trigger: ".modal-content button.btn-primary", + content: _t("Validate."), + }, { + trigger: "button[name=send_and_print_action]", + content: _t("Let's send the invoice."), + } +]); }); diff --git a/addons/account/tests/__init__.py b/addons/account/tests/__init__.py index 8e09703a225..4936b997dbc 100644 --- a/addons/account/tests/__init__.py +++ b/addons/account/tests/__init__.py @@ -31,3 +31,4 @@ from . import test_tax_report from . import test_transfer_wizard from . import test_account_incoming_supplier_invoice from . import test_account_payment_register +from . import test_tour diff --git a/addons/account/tests/test_tour.py b/addons/account/tests/test_tour.py new file mode 100644 index 00000000000..8dc70195f36 --- /dev/null +++ b/addons/account/tests/test_tour.py @@ -0,0 +1,15 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +import odoo.tests + + +@odoo.tests.tagged('post_install', '-at_install') +class TestUi(odoo.tests.HttpCase): + + def test_01_account_tour(self): + # This tour doesn't work with demo data on runbot + all_moves = self.env['account.move'].search([('move_type', '!=', 'entry')]) + all_moves.button_draft() + all_moves.posted_before = False + all_moves.unlink() + self.start_tour("/web", 'account_tour', login="admin") diff --git a/addons/account/views/account_onboarding_templates.xml b/addons/account/views/account_onboarding_templates.xml index 353cdce152c..67bd9481373 100644 --- a/addons/account/views/account_onboarding_templates.xml +++ b/addons/account/views/account_onboarding_templates.xml @@ -13,17 +13,17 @@ -