How to call a method in odoo 7?

吃可爱长大的小学妹 提交于 2019-12-13 19:12:23

问题


I've created a method and I was using field function to call the method. But, the method never executes.
here is my code :

def _get_data_from_puchase_order(self, cr, ids, field, arg, context=None):
    print "SUCCESS"
    print ":::::::::::::::::"
    result = {}
    for row in self.browse(cr, uid, ids):
        print row
        print "::::::::::::"

_columns = {
        "data_purchase_product" : fields.function(_get_data_from_puchase_order, method=True, string='origin', type='char', strore=False)
    }

i was add :

for data in self.pool.get('purchase.order').browse(cr, uid, ids):
    print data.name
    print "++++++++++++++++++"

and i got error :

MissingError: ('MissingError', u'One of the documents you are trying to access has been deleted, please try again after refreshing.')

回答1:


This help,

ids : list of id of your object,

def _get_data_from_puchase_order(self,cr,uid,ids,name, args, context=None) :
        print "SUCCESS"
        print ":::::::::::::::::"
        result = {}
        for row in ids:
            result[row] = "test"
        return result 

_columns = {
        'data_purchase_product': fields.function(_get_data_from_puchase_order, string='origin', method = True, type='integer'),
    }


来源:https://stackoverflow.com/questions/46644444/how-to-call-a-method-in-odoo-7

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