From 6a90fee4c1402d163cf099f4c4429e5738becc84 Mon Sep 17 00:00:00 2001 From: Ugaitz Olaizola Date: Thu, 18 Apr 2024 15:45:51 +0200 Subject: [PATCH] [FIX] l10n_es_edi_tbai, sudo on company when creating TicketBAI chain sequence for the first time. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this commit: When creating the first invoice TicketBAI chain sequence does not exists therefore it is created, if user does not belong to Administration/Settings group, an access error is raised and invoice is not posted. In the same time, a write operation is done in the company to set the value of the sequence on l10n_es_tbai_chain_sequence_id field, and writing in a company only is allowed for users that belongs to Administration/Settings. With this commit: We make a sudo in self (res.company), no errors are raised, invoice is posted and TicketBAI XML file is created and posted to the agency. closes odoo/odoo#163432 X-original-commit: 55bb16a6b5c44a86cf20f29c4cd705bb2403ae27 Signed-off-by: William André (wan) --- addons/l10n_es_edi_tbai/models/res_company.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/l10n_es_edi_tbai/models/res_company.py b/addons/l10n_es_edi_tbai/models/res_company.py index 306fc39ee51..6608da94e95 100644 --- a/addons/l10n_es_edi_tbai/models/res_company.py +++ b/addons/l10n_es_edi_tbai/models/res_company.py @@ -98,7 +98,8 @@ class ResCompany(models.Model): def _get_l10n_es_tbai_next_chain_index(self): if not self.l10n_es_tbai_chain_sequence_id: - self.l10n_es_tbai_chain_sequence_id = self.env['ir.sequence'].create({ + self_sudo = self.sudo() + self_sudo.l10n_es_tbai_chain_sequence_id = self_sudo.env['ir.sequence'].create({ 'name': f'TicketBAI account move sequence for {self.name} (id: {self.id})', 'code': f'l10n_es.edi.tbai.account.move.{self.id}', 'implementation': 'no_gap',