问题
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