Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

[8.0] Aeroo Reports: report_aeroo_direct_print error: NameError: global name 'context' is not defined

By
Luke Branch
on 4/1/15, 6:42 AM 1,213 views

I've managed to setup CUPS and have installed my HP CM1415 printer in the Aeroo Reports direct printing configuration wizard.

Using my own ODS (input template format) / XLS (output format) i've created a report for sale.order. The report is stored in the database, and all other settings are default.

When I tick the Report Wizard option I get the following error:

NameError: global name 'context' is not defined

The full traceback is here for reference:

https://gist.github.com/lukebranch/6109989e6048ad313f63

I'm running on Ubuntu 14.04 with Odoo 8.0, using this installation method:

https://www.odoo.com/forum/help-1/question/8-0-how-can-i-install-the-official-aeroo-reports-alistek-for-odoo-version-8-solved-76044

Any insight or suggestions would be very much appreciated. I've opened a github issue on the Official Aeroo Reports repository here:

https://github.com/aeroo/aeroo_reports/issues/51

0

Temur

--Temur--
2894
| 6 5 7
Tbilisi, Georgia
--Temur--
Programmer
Temur
On 4/1/15, 7:51 AM

most probably it's because  v7 code were not (or not completelly) ported to v8... in v8 context is replaced by recs.env.context (or recs._context as it's shortcut)

according the error log, you can try to replace following line:

ctx = context.copy()

with

ctx = recs.env.context.copy()


in File "/opt/odoo/custom/addons/report_aeroo_direct_print/report_aeroo_direct_print.py", line 289 


You'll need to restart the odoo server after this change, in order to get it worked

Temur
on 4/1/15, 9:06 AM

@Temur,

Thank you! I'll try this and report back here to let you know if it's worked.

Luke Branch
on 4/1/15, 9:44 AM

@Temur,

It worked, thanks for your help. I've just run into another issue. When going to: Settings >> Aeroo Reports >> Printers >> HP LaserJet CM1415fnw [Or Your Printer Model Here] > Switch to Form View > Click Refresh.

I've now run into the follow error message:

TypeError: write() got an unexpected keyword argument 'context'

The full traceback is here:

https://gist.github.com/lukebranch/ac1fa483f608ce5cb9fd

I think the line that is throwing the error is here:

File "/opt/odoo/custom/addons/report_aeroo_direct_print/report_aeroo_direct_print.py", line 163, in refresh r.write({'note':note}, context=context)

There have been a few other similar issues like this reported and they all seem to be quite similar. In your opinion, is this a good place to start to learn some of the changes between the old and new API: https://www.odoo.com/documentation/8.0/reference/orm.html Do you have a github account by the way? I'd like to submit a PR with your suggested changes to the official repository and want to make sure you're properly attributed in the commit messages.

Luke Branch
on 4/1/15, 10:39 AM

regarding the error, replacing this line:

r.write({'note':note}, context=context)

with
r.write({'note':note})
may help
Temur
on 4/1/15, 11:11 AM

yes, good place. but if you're familiar with old (v7) API, then you may find it interesting: http://fr.slideshare.net/openobject/odoo-from-v7-to-v8-the-new-api

Temur
on 4/1/15, 11:19 AM

yes, I have couple of accounts on github, but I grant you all rights if you like to contribute to that project. these are really minor fixes and based on error log, I have not read the code anyway, it's not necessary to mention me.

Temur
on 4/1/15, 11:25 AM

@Temur,

Thank you for all of your help. I will be submitting the PR's today, and will comment back here with the links and attribute yourself and this post in the commit notes.

Luke Branch
on 4/3/15, 10:22 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 4/1/15, 6:42 AM
Seen: 1213 times
Last updated: 4/1/15, 12:31 PM