Vishal Khichadiya Vishal Khichadiya -4 years ago 173
Python Question

Getting Error. How to create Property field in Odoo V10?

def _commercial_fields(self, context=None):
return super(res_partner, self)._commercial_fields(context=context) + ['property_product_pricelist_purchase']

_columns = {
'property_product_pricelist_purchase': fields.Property(
type='many2one',
relation='product.pricelist',
domain=[('type','=','purchase')],
string="Purchase Pricelist",
help="This pricelist will be used, instead of the default one, for purchases from the current partner"),
'purchase_order_count': fields.function(_purchase_invoice_count, string='# of Purchase Order', type='integer', multi="count"),
'supplier_invoice_count': fields.function(_purchase_invoice_count, string='# Supplier Invoices', type='integer', multi="count"),
}


Error:


'property_product_pricelist_purchase': fields.property(
AttributeError: 'module' object has no attribute 'property'

2017-03-24 04:50:04,366 6333 INFO odoo_test odoo.http: Generating
nondb routing 2017-03-24 04:50:04,379 6333 ERROR odoo_test
odoo.http: Exception during JSON request handling.

Answer Source

Here is your solution.

You have to just write property above the fields name and you have to remove the domain from fields because there is no type field in pricelist.

So, You have to replace property_product_pricelist_purchase fields with below code :

property_product_pricelist_purchase = fields.Many2one('product.pricelist', string="Purchase Pricelist", company_dependent=True, help="This pricelist will be used, instead of the default one, for purchases from the current partner")

This may help you.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download