Skip to Content
Menu
This question has been flagged
2 Replies
4647 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.


Avatar
Discard
Best Answer

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.

Avatar
Discard
Author

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

Best Answer

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

Avatar
Discard