From 88ecb702f012ed058ec519a3ceb09bdb124ac957 Mon Sep 17 00:00:00 2001 From: "maximilien(malb)" Date: Thu, 8 Sep 2022 08:08:39 +0000 Subject: [PATCH] [FIX] account: Onboarding invoicing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. When an invoice is created, the action is completed task-2974631 closes odoo/odoo#99820 Related: odoo/upgrade#3891 Signed-off-by: William André (wan) --- addons/account/models/company.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/addons/account/models/company.py b/addons/account/models/company.py index 1cf17d753db..6eda34236a4 100644 --- a/addons/account/models/company.py +++ b/addons/account/models/company.py @@ -109,7 +109,9 @@ class ResCompany(models.Model): account_setup_coa_state = fields.Selection(ONBOARDING_STEP_STATES, string="State of the onboarding charts of account step", default='not_done') account_setup_taxes_state = fields.Selection(ONBOARDING_STEP_STATES, string="State of the onboarding Taxes 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_create_invoice_state = fields.Selection(ONBOARDING_STEP_STATES, string="State of the onboarding create invoice step", default='not_done') + account_onboarding_create_invoice_state = fields.Selection(ONBOARDING_STEP_STATES, string="State of the onboarding create invoice step", compute='_compute_account_onboarding_create_invoice_state') + #this field must be there to ensure that the create_invoice_state stay complete and because we can't use a dependencies on account move + account_onboarding_create_invoice_state_flag = fields.Boolean(default=False, store=True) account_onboarding_sale_tax_state = fields.Selection(ONBOARDING_STEP_STATES, string="State of the onboarding sale tax step", default='not_done') # account dashboard onboarding @@ -205,6 +207,17 @@ class ResCompany(models.Model): foreign_vat_fpos = self.env['account.fiscal.position'].search([('company_id', '=', record.id), ('foreign_vat', '!=', False)]) record.account_enabled_tax_country_ids = foreign_vat_fpos.country_id + record.account_fiscal_country_id + @api.depends('account_onboarding_create_invoice_state_flag') + def _compute_account_onboarding_create_invoice_state(self): + for record in self: + if record.account_onboarding_create_invoice_state_flag: + record.account_onboarding_create_invoice_state = 'done' + elif self.env['account.move'].search([('company_id', '=', record.id), ('move_type', '=', 'out_invoice')], limit=1): + record.account_onboarding_create_invoice_state = 'just_done' + record.account_onboarding_create_invoice_state_flag = True + else: + record.account_onboarding_create_invoice_state = 'not_done' + @api.depends('terms_type') def _compute_invoice_terms_html(self): for company in self.filtered(lambda company: is_html_empty(company.invoice_terms_html) and company.terms_type == 'html'): @@ -521,8 +534,7 @@ class ResCompany(models.Model): @api.model 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 + return self.env["ir.actions.actions"]._for_xml_id("account.action_open_account_onboarding_create_invoice") @api.model def action_open_taxes_onboarding(self):