Giter Site home page Giter Site logo

[17.0][BUG] Mail Wizard in Account Move (only!) doesn't attach report specified in mail template, instead keeps default report about odoo HOT 22 OPEN

TastenExpress avatar TastenExpress commented on May 24, 2024
[17.0][BUG] Mail Wizard in Account Move (only!) doesn't attach report specified in mail template, instead keeps default report

from odoo.

Comments (22)

TastenExpress avatar TastenExpress commented on May 24, 2024

Thank you @vava-odoo for adding labels. Is there any chance to raise priority to this issue if we offer some sponsoring for this issue? For our odoo 17 CE deployment it is a serious issue.

from odoo.

vava-odoo avatar vava-odoo commented on May 24, 2024

Hi @TastenExpress
Maybe I misunderstood the problem, but I was not able to reproduce on the runbot. When changing the template, the attachments are changed as well.
Is it possible that it was recently fixed (in 622c018 maybe?) and that you need to update your code?
Cheers!

from odoo.

JKE-be avatar JKE-be commented on May 24, 2024

Thank you for the report.
I can confirm the bug; it is reproducible and (probably) caused by the function _get_default_mail_attachments_widget, which only handles the case of the main invoice ('_get_placeholder_mail_attachments_data'), without respecting the report linked to the template.

This code (that cause your bug) is only present in the 'account.move.send' wizard, which is why you don't encounter it with other models.
Also, if you use the standard email sending functionality, it will work fine. You can access it from the chatter by clicking 'Send message' > Expanding at the bottom right > Choosing your template."

Let's see what the accounting team (@odoo/rd-accounting ) can do about it since it's a standard bug.

Via standard composer:
image

Via custom wizard:
image

from odoo.

william-andre avatar william-andre commented on May 24, 2024

@smetl

from odoo.

smetl avatar smetl commented on May 24, 2024

@TastenExpress Hello. This is intended. The generation of the report + EDI documents + potentially some web-services is very long so all attachments that are not already loaded are only created when clicking on "Send & Print". In others words, for example, "INV_2024_XXXX.pdf" is only a placeholder representing a document that is not yet generated.

from odoo.

TastenExpress avatar TastenExpress commented on May 24, 2024

Hi @smetl, thanks for your help. But how useful could that be if I can't attach my custom reports to a mail if I can specify it in my custom template? This is far from intuitive usability since the mail sending works fine in other models.

In my case this issue is a no go to the deployment of odoo 17, because we have multiple templates with different reports sent from account move.

So what is your best advice to make my custom reports and templates work?

Thanks in advance for the support! If it helps I can offer a little donation to support the fix from my end.

from odoo.

TastenExpress avatar TastenExpress commented on May 24, 2024

@JKE-be , thanks for confirming my reported bug and attaching the screenshots. Since I need to send invoices from a cron job, I am not sure if I can use the workaround via chatter mailing. At the moment we are calling the standard mail wizard with force_send to send monthly mails in the background.

So I am curious about the fix of this bug, because in odoo 16 we used an old OCA module called mail_template_multi_attachment which ran fine with some little adjustments. In odoo 17 it is now new that I can add m2m reports in mail template (which is awesome for me).

@vava-odoo , you said you were not able to reproduce this bug. Are u sure you tried it from account move in combination with any other report which is not the default invoice "placeholder"? If yes, maybe we'll find a workaround for me, because this fix is a bit urgent for me.

Thanks to all of you odoo'ers for your support! Let me know if I can contribute anything else to this issue.

from odoo.

JKE-be avatar JKE-be commented on May 24, 2024

@smetl

In others words, for example, "INV_2024_XXXX.pdf" is only a placeholder representing a document that is not yet generated.

Yes, I agree. It's not an issue to have a placeholder in case you request to print a specific document that hasn't been created yet.

However, if you send a template without a document or custom report, I believe we should use what is configured in the template instead of the 'default template behavior'. It's not immediately obvious that you can customize your accounting template with(out) custom report, but it will be silently ignored and not applied.
Do you consider this behavior normal and don't plan to 'check/improve/fix' it? Not sure to understand the status of this issue ?

from odoo.

smetl avatar smetl commented on May 24, 2024

@JKE-be The problem is we absolutely have no idea about what is inside the template. Is it an invoice report? A copy of the report that don't contains the extra values added by others modules like an EDI? Another thing and then, we need to add the default invoice's report ourself?
Also, we have many flows in which the sending of the invoice is automatic and then, you can't select the correct template.

We are improving this flow for 17.3 here:
#164548
... in which you can configure which report needs to be used by the wizard. It's probably only the first step.

from odoo.

JKE-be avatar JKE-be commented on May 24, 2024

@smetl

we absolutely have no idea about what is inside the template

not sure what you means here... You can see if self.mail_template_id == ref('account.email_template_edi_invoice') or to know if it is the default Invoices report 'account.account_invoices' in template_id.report_template_ids ... the placeholder should be based on it no ? Instead to ignore the configured report ?

many flows in which the sending of the invoice

Yes that (probably) will send the account.email_template_edi_invoiceand is (unfortunately/probably) not configurable, but we could at least respect the customization done in this report... no? Based on the report_template_ids's value...

from odoo.

pimodoo avatar pimodoo commented on May 24, 2024

@adwid Could you do a bugfix for this? Or you prefer that the customer create a one app free and open a ticket?

from odoo.

smetl avatar smetl commented on May 24, 2024

@pimodoo There is nothing to fix. Plz read the messages above.

from odoo.

JKE-be avatar JKE-be commented on May 24, 2024

@smetl

We might consider adding other documents if the report is the default invoice report based on the XMLID.

Additionally, users want to utilize a simple invoice flow with their customers, without EDI and other complexities, and the customization will function as expected.

Moreover, users want a custom report with full EDI capabilities. In this scenario, they will need to modify the default template or relocate the XMLID.

I'm uncertain why we are hesitant to have a customizable basic flow. Not all countries utilize EDI, blackbox systems, or governmental APIs.

from odoo.

pimodoo avatar pimodoo commented on May 24, 2024

@pimodoo There is nothing to fix. Plz read the messages above.

Hello, i've read it and you say that you have no idea of what there is inside the template. If I am not wrong you can use the model and/or check the xml id of the report to know if you are on your default template or not.

If the customer changes the template and the report linked to it, you can just not apply the extra stuff you apply on the default one. It is not an issue if the behavior changes when a customer customize its flows.

I think that @JKE-be already gave you some hint to fix this issue and your prefer to reply me "please read" instead of trying to find constructive solutions with people who want to help.

Have a nice day

from odoo.

smetl avatar smetl commented on May 24, 2024

@JKE-be When you customize the report (using studio for example, that is what quite all people does), you get a full copy of the report and there is no way to retrieve the xml id from it. It means, the report becomes completely standalone and we are not able to distinguish if we need to use it as a custom invoice report or if it's something else like a invoice PDF about stock/linked SO or whatever.

On invoices, there is a field that must be filled pointing to the legal invoice document. If we don't know what we rendered using the custom reports set on the mail template, then we are not able to fill this field correctly (it could work by chance or not). Then, you break the invoice flow. For example, if you open again the send & print, the legal PDF is restored using this field instead of generating a new one. This is very important because you don't want to send twice the same invoice through the EDI and that is exactly what could happen when deleting yourself the invoice report.

I already suggested such improvement to product owners in charge of accounting (@chklop & @Olivier-olma ) but whatever we do, it will not work with custom reports created by studio. We can make something based on the xml id but that will be only for people making an inheritance with the original invoice template.

So, consider it's a limitation. We are aware of that and we are focusing on improving the master branch.

from odoo.

TastenExpress avatar TastenExpress commented on May 24, 2024

All this discussion here leads to the conclusion, that specifying reports in a template which is applied to AM is totally useless and missguiding the user. That's sad. I get a rough idea what you mean about the EDI issue (which does only work for the default reports, so far I understood), but this does mean, that as a user I can configure and customize any other report totally free in the entire system, execpt my own invoice report, because it breaks the EDI rules?!? Sounds strange and unsafisfying for me as a user...

However, if you need to make sure, you apply the EDI code on the default template only, why not adding a field in ir.actions.report to mark a report as default (so you can apply the necessary EDI features, else skip it)?

However, so does anyone know a workaround for this issue? I am very surprised that this is a big issue here, because I guess it will be an important issue to other useres now or later.

from odoo.

TastenExpress avatar TastenExpress commented on May 24, 2024

I'm just asking again: Is anyone here who can offer support for this issue, because it is the last issue which is preventing us from going live. Of course , if necessary I will donate for your help in this case. Please contact me if you have any idea how to attach the correct report specified in themplate while sending from AM.
This issue is no fun for us.
grafik
Thanks in advance for your support!

from odoo.

chklop avatar chklop commented on May 24, 2024

We'll be considering as a new option for future versions #164548

from odoo.

TastenExpress avatar TastenExpress commented on May 24, 2024

@chklop , great to read your pr. I'll keep watching it. I will also try to check your commit as soon as possible.
Maybe I can soon close this ticket. Thank you for notifying me! :-)

from odoo.

JKE-be avatar JKE-be commented on May 24, 2024

@TastenExpress

Since I need to send invoices from a cron job, I am not sure if I can use the workaround via chatter mailing. At the moment we are calling the standard mail wizard with force_send to send monthly mails in the background.

You can always use meanwhile, the default mail wizard that will respect your custom report. Here, we are debating the account_move wizard, not the standard mail chatter. Unless I'm missing something, this one should work as expected, right?

from odoo.

TastenExpress avatar TastenExpress commented on May 24, 2024

I got your point, @JKE-be , but we are running a scheduled action which sends recurring invoices regularly. I'm not sure, but so far I know we can't send via chatter in the background?

from odoo.

intero-chz avatar intero-chz commented on May 24, 2024

@TastenExpress that should be possible, an example with self as one invoice:

        if self.move_type == "out_invoice":
            template = self.env.ref("account.email_template_edi_invoice")
        elif self.move_type == "out_refund":
            template = self.env.ref("account.email_template_edi_credit_note")
        if template:
            ctx = {
                "default_model": "account.move",
                "default_res_id": self.id,
                "default_template_id": template.id,
            }
            composer = (
                self.env["mail.compose.message"].with_context(**ctx).create({})
            )
            composer._onchange_template_id_wrapper()
            composer.action_send_mail()

from odoo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.