From 6ff41d8a16b649bc7b0172ca0bbd82fc757713dc Mon Sep 17 00:00:00 2001 From: Julien Van Roy Date: Wed, 19 Oct 2022 14:07:22 +0000 Subject: [PATCH] [FIX] account,account_accountant: fix the demo tour MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit fixes the account_accountant demo tour. Some attributes in the html have changed and the reconciliation widget was refactored. Fix the broken account_tour_upload_bill view. Fix the test of account_accountant_tour (missing import in __init__) closes odoo/odoo#104110 X-original-commit: 8414a5a77be5fbcc6f66ba2acf160f43748c891e Related: odoo/enterprise#33210 Signed-off-by: William André (wan) Signed-off-by: Julien Van Roy --- .../wizard/account_tour_upload_bill.py | 25 +++++++++++-------- .../wizard/account_tour_upload_bill.xml | 12 ++++----- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/addons/account/wizard/account_tour_upload_bill.py b/addons/account/wizard/account_tour_upload_bill.py index 57681409ed7..59482a869f1 100644 --- a/addons/account/wizard/account_tour_upload_bill.py +++ b/addons/account/wizard/account_tour_upload_bill.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import fields, models, _, Command +from odoo import fields, models, _, Command, tools import base64 from datetime import timedelta @@ -77,16 +77,7 @@ class AccountTourUploadBill(models.TransientModel): if self.selection == 'upload': return purchase_journal.with_context(default_journal_id=purchase_journal.id, default_move_type='in_invoice').create_document_from_attachment(attachment_ids=self.attachment_ids.ids) elif self.selection == 'sample': - bodies = self.env['ir.actions.report']._prepare_html(self.preview_invoice)[0] - sample_pdf = self.env['ir.actions.report']._run_wkhtmltopdf(bodies) - invoice_date = fields.Date.today() - timedelta(days=12) - attachment = self.env['ir.attachment'].create({ - 'type': 'binary', - 'name': 'INV-%s-0001.pdf' % invoice_date.strftime('%Y-%m'), - 'res_model': 'mail.compose.message', - 'datas': base64.encodebytes(sample_pdf), - }) partner = self.env['res.partner'].search([('name', '=', 'Deco Addict')], limit=1) if not partner: partner = self.env['res.partner'].create({ @@ -113,7 +104,19 @@ class AccountTourUploadBill(models.TransientModel): }) ], }) - bill.with_context(no_new_invoice=True).message_post(attachment_ids=[attachment.id]) + # In case of test environment, don't create the pdf + if tools.config['test_enable'] or tools.config['test_file']: + bill.with_context(no_new_invoice=True).message_post() + else: + bodies = self.env['ir.actions.report']._prepare_html(self.preview_invoice)[0] + content = self.env['ir.actions.report']._run_wkhtmltopdf(bodies) + attachment = self.env['ir.attachment'].create({ + 'type': 'binary', + 'name': 'INV-%s-0001.pdf' % invoice_date.strftime('%Y-%m'), + 'res_model': 'mail.compose.message', + 'datas': base64.encodebytes(content), + }) + bill.with_context(no_new_invoice=True).message_post(attachment_ids=[attachment.id]) return self._action_list_view_bill(bill.ids) else: diff --git a/addons/account/wizard/account_tour_upload_bill.xml b/addons/account/wizard/account_tour_upload_bill.xml index cdece8f9463..a4d43f9beb0 100644 --- a/addons/account/wizard/account_tour_upload_bill.xml +++ b/addons/account/wizard/account_tour_upload_bill.xml @@ -9,14 +9,14 @@

With Odoo, you won't have to record bills manually

We process bills automatically so that you only have to validate them. Choose how you want to test our artificial intelligence engine:

- - - + + + - - + + - +