From 037c0a6e3111f5dfeac7aeb4920a7bc668d5a9bb Mon Sep 17 00:00:00 2001 From: dbkosky Date: Wed, 1 Jun 2022 08:20:25 +0000 Subject: [PATCH] [FIX] l10n_it_edi_sdicoop: empty invoice company When the cron is fetching the xml from the database, an empty invoice with the xml as an attachment is created. The reason for this is so that, if the import fails, there is at least a file accessible on the invoice for the purposes of debugging. When the cron's fetching function loops through the proxy users for each company, fetching the results from the proxy server for each company in turn. However when the empty invoice is created, the company is not provided, and thus the context company is used (that of the cron), which is not necessarily correct. This commit uses the company of the proxy to create the empty invoice (which in turn selects the correct journal etc. for the empty invoice). closes odoo/odoo#92830 Ticket-id: 2854284 X-original-commit: a19cdf82f3276f84fba2961fbd82a5a1a2f7844e Signed-off-by: Josse Colpaert Signed-off-by: Daniel Kosky (dako) --- addons/l10n_it_edi_sdicoop/models/account_edi_format.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/l10n_it_edi_sdicoop/models/account_edi_format.py b/addons/l10n_it_edi_sdicoop/models/account_edi_format.py index d7a36f4b54c..804839b10ad 100644 --- a/addons/l10n_it_edi_sdicoop/models/account_edi_format.py +++ b/addons/l10n_it_edi_sdicoop/models/account_edi_format.py @@ -51,8 +51,7 @@ class AccountEdiFormat(models.Model): # should not happen as the file has been checked by SdiCoop _logger.info('Received file badly formatted, skipping: \n %s', file) continue - - invoice = self.env['account.move'].create({'move_type': 'in_invoice'}) + invoice = self.env['account.move'].with_company(company).create({'move_type': 'in_invoice'}) attachment = self.env['ir.attachment'].create({ 'name': fattura['filename'], 'raw': file,