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/1/16, 8:26 AM 187 views

Can anyone please help this!!!


class FloatingPurchase(models.Model):

_name= "floating.purchase"

_description = "Purchase Order"


name = fields.Integer(string="Quantity", align="center", required=True)

product_id = fields.Many2one('product.template', string ="Product")

brand_id = fields.Many2one('product.brand', string="Product Brand", required=True)

part_number = fields.Many2one('product.parts', string ="Part Number", required=True)

vendors = fields.Many2one('res.partner', string= "Vendor")

store_id = fields.Many2one('res.store', string= "Shop")


@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


0
Divyang Jariwala
On 9/8/16, 2:36 AM

Hi Jithin,

Self is not defined error can occur when your indentation is not proper. so, check your indentation.

another one thing i am seeing in your code is return statement doesn't have ending  "}" .

0

Jignesh Mehta

--Jignesh Mehta--
2081
| 6 4 8
Surat, India
--Jignesh Mehta--


Jignesh Mehta
On 9/2/16, 12:08 AM

Hello Jithin,


In purchase order line, product's object is product.product and you taken here product.template

Try with take product.product instead of product.template


product_id = fields.Many2one('product.product', string ="Product")


Hope this will helps you.

Thanks,


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/1/16, 8:26 AM
Seen: 187 times
Last updated: 9/8/16, 2:36 AM