Hi again Ill try to explain the situation.
My first try i try to create on “notification_email” module an a new entry to send email to purchase petitioners when the purchase “state” change to processing. In my case each purchase line may come from two different petitioners, and i want to send diferent email to each one (only with own petition lines).
On the notification_email trigger i use “on update” but when purchase process, the purchase change the state but the trigger dont do nothing. I use diferent breakpoints on Trigger class but never go to this class. I think " On update" doesnt work properly, dont know exactly.
To try to solve my problem I try to implement replicating the same way that i can see on “tests” without success
Accept ideas to solve this …
Actually i load the “record” on HTML template but …
code.
with Transaction().set_context(lines_to_email=lines):
prueba = get_email(_REPORT, purchases[0], language)
from_ = config.get('email', 'from')
to_ = [employee]
from email.mime.text import MIMEText
msg = MIMEText(prueba, _charset='utf-8')
msg['From'] = from_
msg['To'] = to_
msg['Cc'] = 'user@email.es'
msg['Subject'] = Header('ENVIO FORZADOP', 'utf-8')
msg['Auto-Submitted'] = 'auto-generated'
msg['Message'] = prueba
# sendmail_transactional(
# from_, to_, msg, datamanager=datamanager)
sendmail(from_, to_, msg)
Traceback (most recent call last):
File "/home/jonatan/tryton/trytond/trytond/protocols/dispatcher.py", line 186, in _dispatch
result = rpc.result(meth(*c_args, **c_kwargs))
File "/home/jonatan/tryton/trytond/trytond/model/modelview.py", line 692, in wrapper
return func(cls, records, *args, **kwargs)
File "/home/jonatan/tryton/trytond/trytond/modules/electrans/purchase.py", line 113, in process
super(Purchase, cls).process(purchases)
File "/home/jonatan/tryton/trytond/trytond/modules/production_subcontract/production.py", line 305, in process
super(Purchase, cls).process(purchases)
File "/home/jonatan/tryton/trytond/trytond/model/modelview.py", line 692, in wrapper
return func(cls, records, *args, **kwargs)
File "/home/jonatan/tryton/trytond/trytond/modules/sale_supply/purchase.py", line 61, in wrapper
func(cls, purchases)
File "/home/jonatan/tryton/trytond/trytond/modules/sale_supply/purchase.py", line 74, in process
super(Purchase, cls).process(purchases)
File "/home/jonatan/tryton/trytond/trytond/model/modelview.py", line 692, in wrapper
return func(cls, records, *args, **kwargs)
File "/home/jonatan/tryton/trytond/trytond/modules/electrans_notification_email/purchase.py", line 48, in process
msg = MIMEText(prueba, _charset='utf-8')
File "/usr/lib/python3.8/email/mime/text.py", line 42, in __init__
self.set_payload(_text, _charset)
File "/usr/lib/python3.8/email/message.py", line 321, in set_payload
self.set_charset(charset)
File "/usr/lib/python3.8/email/message.py", line 364, in set_charset
payload = payload.encode('ascii', 'surrogateescape')
AttributeError: 'tuple' object has no attribute 'encode'
Maybe exist any easy way, comment that my Tryton version is 5.2
& Thanks in advance