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

Error: NameError: name 'self' is not defined

By
Jithin
on 9/5/16, 4:56 AM 202 views

@api.multi

def generate_purchase_history(self):

action = self.env.ref('purchase.action_purchase_line_product_tree')

domain="[('product_id', '=', self.product_id)]"

return {

'name': action.name,

'help': action.help,

'type': action.type,

'view_type': action.view_type,

'view_mode': action.view_mode,

'target': action.target,

'res_model': action.res_model,

'domain': domain

}


in view file i have created a button and type is object.


Zahin
on 9/6/16, 8:43 AM
0

Jithin,


Problem is in this line :

domain="[('product_id', '=', self.product_id)]"


The corrected code is :

domain="[('product_id', '=', " + str(self.product_id.id) + " )]"


I Hope it solves your problem.

Geo i need the particular products purchase history so when i write this domain only a blank form view is shown

Jithin
on 9/6/16, 6:33 AM
0
ayman mohammed adam
On 9/5/16, 6:13 AM

dear Jithin,

I think this error from the indentation , check the 

action = self.env.ref('purchase.action_purchase_line_product_tree')

must be into the def generate_purchase_history(self): 
like this:

@api.multi

def generate_purchase_history(self):

####action = self.env.ref('purchase.action_purchase_line_product_tree')

####domain="[('product_id', '=', self.product_id)]"

####return {

'name': action.name,

'help': action.help,

'type': action.type,

'view_type': action.view_type,

'view_mode': action.view_mode,

'target': action.target,

'res_model': action.res_model,

'domain': domain

}


if all are ok then check this function must be into your class

I hope I helped you

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: 9/5/16, 4:56 AM
Seen: 202 times
Last updated: 9/5/16, 9:04 AM