AttributeError: 'NoneType' object has no attribute '_columns'

不问归期 提交于 2019-12-24 15:53:44

问题


I am writing a module in OpenERP that would inherit from the Accounts module. Below is my simplified code

from osv import fields, osv
import decimal_precision as dp

class account_molly(osv.osv):

    def __computeOB(self, cr, uid, ids, context=None):
        res = []
        return 0

    def __computeCB(self, cr, uid, ids, context=None):
        res = []
        return 0

    _name = "account.molly"
    _description = "This is Molly Special Account View"
    _inherit = "account.account"
    _columns = {
        'opening_balance': fields.function(__computeOB, digits_compute=dp.get_precision('Account'), method=True, string='Opening Balance'),
        'end_balance': fields.function(__computeCB, digits_compute=dp.get_precision('Account'), method=True, string='End Balance'),
    }   

account_molly()

# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

When I try to install the module, I get

AttributeError: 'NoneType' object has no attribute '_columns'
Please what could be the problem

回答1:


Please check the dependency of the module you have created. In the openerp.py file, in the dependency list if 'account' is not added, please add it. If this didnt solve your problem please provide the error log




回答2:


does this solve the problem?

class account_molly(osv):
    ... 

you seem to mix module and class and class attribute



来源:https://stackoverflow.com/questions/10565288/attributeerror-nonetype-object-has-no-attribute-columns

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!