Wrong value computation in fields with expressions

Bug #452388 reported by Jordi Esteve (www.zikzakmedia.com)
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Power Email
Invalid
Medium
Sharoon Thomas http://openlabs.co.in

Bug Description

If you define emails templates using openerp field expressions with the variable object (like the expression generator does), the corresponding values are not computed and an empty string appears. For example:
${object.address_contact_id.email}
Invoice num. ${object.number}

The problem is in line 77 in poweremail_send_wizard.py: mako render_unicode() method doesn't like a parameter called object. It gives this error: type object 'object' has no attribute 'address_contact_id'

If you change this line

                reply = templ.render_unicode(object=object,peobject=object)

to
                reply = templ.render_unicode(object2=object,peobject=object)

and you define a message with the expression "Invoice num. ${object2.number}" in the email template, it works well.

Now, the temporal solution is to use peobject instead of object inside the expressions in the email template. But the expression generator computes object instead of peobject and it confuses the user.

Revision history for this message
Sharoon Thomas http://openlabs.co.in (sharoonthomas) wrote :

Hi esteve,

the conversion to object was made from peobject in ver 0.6 by the siggestion of mga.
I was not sure if this will have any implications so i retained backward combatibility.

but not sure if ur problem is that.

can u check again. it works for me ...

Changed in poweremail:
assignee: nobody → Sharoon Thomas (openlabs.co.in) (sharoonthomas)
importance: Undecided → Medium
milestone: none → 0.7
status: New → Incomplete
Revision history for this message
Sharoon Thomas http://openlabs.co.in (sharoonthomas) wrote :

it will help if you can give me ur template

Revision history for this message
Jordi Esteve (www.zikzakmedia.com) (jesteve-zikzakmedia) wrote :

Attached there is a screen shot with a template for sending invoices. It works. But if you change peobject to object, all the fields containing ${object.... } (to, cc, subject, body, filename) are empty when the email is computed.

Maybe is the mako version I use (python-mako 0.1.10-1 included in Ubuntu 8.04 LTS: ) that doesn't like a parameter called object.

A solution is replace these calls in poweremail_send_wizard.py: and poweremail_template.py

reply = templ.render_unicode(object=object,peobject=object)
reply = Template(message).render_unicode(object=object,peobject=object)

to

reply = templ.render_unicode(peobject=object)
reply = Template(message).render_unicode(peobject=object)

and before that, change ${object.... } to ${peobject.... }

Revision history for this message
Jordi Esteve (www.zikzakmedia.com) (jesteve-zikzakmedia) wrote :

Last line in my last comment:

and before that, change ${object.... } to ${peobject.... }

I would say:

and in a previous line, change the string "${object." to the string "${peobject."

Revision history for this message
tst (tst9842) wrote :

Dear all,

i have installed the power email in 5.06 it's ok for installtion,

now if i create the invoice i hve this error " NameError: global name 'Super' is not defined"

i look for the log error t have this text:

File "C:\Documents and Settings\admin\OpenERPAllInOne\Server\addons\poweremail.zip\poweremail\poweremail_serveraction.py", line 64, in run
NameError: global name 'Super' is not defined

thank you

Revision history for this message
Sharoon Thomas http://openlabs.co.in (sharoonthomas) wrote :

tst, moving your bug to a separate bug, since its not the same as above discussion

lp:455410

and i have fixed it too

Revision history for this message
Sharoon Thomas http://openlabs.co.in (sharoonthomas) wrote :

The error with object looks like an error with the mako version.

Mako has to be minimum ver 2

Changed in poweremail:
status: Incomplete → Invalid
Revision history for this message
Jordi Esteve (www.zikzakmedia.com) (jesteve-zikzakmedia) wrote :

Yes, I confirm that I had python-mako 0.1.10 installed (by default in Hardy Haron 8.04.3 LTS)

Now I have update to python-mako 0.2.2.

Thanks.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.