Problem in reception a notification email

Hi people There,

I have a problem in reception a notification email

The whole issue that i want to send an email when the invoice is posted with the report as an attachment

the steps i Did are :

1-create a notification email record

2-in the field content, I have created a new record about the model "account.invoice"

3-finally I have created a trigger with the condition Equal(Get(Eval("self", {}), "state", ""), "posted") and it looks work fine and a Tick on "On create"

4-then after i create a new invoice and post it , nothing sent to the email party that i have mentioned

Is There any other step i forgot it ? because i didn’t understand what’s wrong?

Thanks in advance

Probably you should tick “On write” instead of “On create”.

1 Like

thanks for your response, I have try modify the tick on "On write " but the same, no notification email delivered

Check if:

  • smtp email configuration is defined on trytond.conf
  • there is any error on server log

The invoice may be directly marked as paid, so your trigger should take that in consideration (also if you do not want to send notification each time the invoice change from paid to posted).
You may also consider filtering out supplier invoice.

Also changing the trigger will only apply to newly posted invoice.

Thanks M.@sergyo and M @ced , recently when i have seen the server log

This is the traceback after clicking on “Post” button

Traceback (most recent call last):
  File "/trytond/wsgi.py", line 104, in dispatch_request
    return endpoint(request, **request.view_args)
  File "/trytond/protocols/dispatcher.py", line 48, in rpc
    request, database_name, *request.rpc_params)
  File "/trytond/wsgi.py", line 72, in auth_required
    return wrapped(*args, **kwargs)
  File "/trytond/protocols/wrappers.py", line 131, in wrapper
    return func(request, pool, *args, **kwargs)
  File "/trytond/protocols/dispatcher.py", line 197, in _dispatch
    result = rpc.result(meth(*c_args, **c_kwargs))
  File "/trytond/modules/sale/invoice.py", line 21, in wrapper
    func(cls, invoices)
  File "/trytond/modules/sale/invoice.py", line 81, in post
    super(Invoice, cls).post(invoices)
  File "/trytond/modules/purchase/invoice.py", line 22, in wrapper
    func(cls, invoices)
  File "/trytond/modules/purchase/invoice.py", line 94, in post
    super(Invoice, cls).post(invoices)
  File "/trytond/model/modelview.py", line 692, in wrapper
    return func(cls, records, *args, **kwargs)
  File "/trytond/model/workflow.py", line 36, in wrapper
    result = func(cls, filtered, *args, **kwargs)
  File "/trytond/modules/account_deposit/invoice.py", line 33, in post
    super(Invoice, cls).post(invoices)
  File "/trytond/model/modelview.py", line 692, in wrapper
    return func(cls, records, *args, **kwargs)
  File "/trytond/model/workflow.py", line 36, in wrapper
    result = func(cls, filtered, *args, **kwargs)
  File "/trytond/modules/account_invoice/invoice.py", line 1374, in post
    cls.save(invoices)
  File "/trytond/model/descriptors.py", line 33, in newfunc
    return self.func(owner, *args, **kwargs)
  File "/trytond/model/modelstorage.py", line 1649, in save
    (([r], save_values[r]) for r in to_write), ()))
  File "/trytond/modules/account_tax_cash/account.py", line 270, in write
    super(Invoice, cls).write(*args)
  File "/trytond/modules/account_invoice/invoice.py", line 1112, in write
    super(Invoice, cls).write(*args)
  File "/trytond/model/modelsql.py", line 159, in wrapper
    return func(cls, *args, **kwargs)
  File "/trytond/model/modelsql.py", line 1015, in write
    cls.trigger_write(trigger_eligibles)
  File "/trytond/model/modelstorage.py", line 73, in wrapper
    return func(*args, **kwargs)
  File "/trytond/model/modelstorage.py", line 252, in trigger_write
    Trigger.trigger_action(triggered, trigger)
  File "/trytond/ir/trigger.py", line 244, in trigger_action
    getattr(ActionModel, trigger.action_function)(records, trigger)
  File "/trytond/modules/notification_email/notification.py", line 251, in trigger
    trigger.notification_email.send_email(records, trigger)
  File "/trytond/modules/notification_email/notification.py", line 298, in send_email
    msg = self.get_email(record, from_, to, cc, bcc, languagues)
  File "/trytond/modules/notification_email/notification.py", line 218, in get_email
    content, title = get_email(self.content, record, languages)
  File "/trytond/report/report.py", line 413, in get_email
    'language': language,
  File "/trytond/modules/account_invoice/invoice.py", line 2448, in execute
    result = super(InvoiceReport, cls).execute(ids, data)
  File "/trytond/report/report.py", line 191, in execute
    oext, content = cls._execute(records, data, action_report)
  File "/trytond/modules/account_invoice/invoice.py", line 2437, in _execute
    Invoice.invoice_report_cache.cast(data)
TypeError: string argument without an encoding

I have fixed the error by using the bytes function :

Invoice.invoice_report_cache.cast(data)

---->

Invoice.invoice_report_cache.cast(bytes(data, encoding='utf8'))

---->This Time no error displayed on the server log but still I can’t receive the email.

For me it seems you have changed (or override) the output of the standard invoice report (probably to HTML). Probably you have use the same Report class for the HTML email account.invoice. Normally the invoice report must be PDF or ODT.
It would be better if Tryton is not crashing https://bugs.tryton.org/issue10937.

Hi , Yeah I choice already the “invoice.odt” unless it doesn’t work , and lastly when i have seen my spam i found the email but there is no invoice there , there was just a file.txt and it contain the code XML of the invoice



Clearly you have changed the ouput format of the invoice report.