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

Why a global name of a model is not defined?

By
Juan Formoso
on 7/1/14, 7:18 AM 1,479 views

I am trying to inherit from the module account.balance.reporting to add some extras. My custom module has this structure:

account_balance_reporting_xls
|__ wizard
|   |__ __init__.py
|   |__ wizard_print.py
|
|__ __init__.py
|__ __openerp__.py
|__ account_balance_reporting.py

Can someone explain me why I get this error?

File ".../account_balance_reporting_xls/wizard/wizard_print.py", line 30, in xls_export 'model': account.balance.reporting, NameError: global name 'account' is not defined

This is the code of my custom file wizard_print.py, the error is in the first line of the definition of the dictionary data:

from osv import fields, osv
import pooler
from openerp.osv import orm

class print_wizard(osv.osv_memory):
    _inherit = 'account.balance.reporting.print.wizard'

    def xls_export(self, cr, uid, ids, context=None):
        wiz_form = self.browse(cr, uid, ids)[0]
        data = {
            'model': account.balance.reporting,
            'report_id': wiz_form.report_id,
            'report_xml_id': wiz_form.report_xml_id,
        }
        return {
            'type': 'ir.actions.report.xml',
            'report_name': 'reporting.xls',
            'datas': data
        }                

print_wizard()

The issue is with 'model': account.balance.reporting, where you need to write the model in string format (Quoted).

Serpent Consulting Services Pvt. Ltd.
on 7/1/14, 11:39 AM
2

Prakash

--Prakash--
3173
| 5 4 7
Bikaner, India
--Prakash--

OpenERP Devloper at SunARC Technology

Prakash
On 7/1/14, 7:32 AM

Define return type model 'account.balance.reporting' in quotes

  wiz_form = self.browse(cr, uid, ids)[0]
        data = {
            'model': 'account.balance.reporting',
            'report_id': wiz_form.report_id,
            'report_xml_id': wiz_form.report_xml_id,
        }

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

2 follower(s)

Stats

Asked: 7/1/14, 7:18 AM
Seen: 1479 times
Last updated: 3/16/15, 8:10 AM