Does any one can help how to solve this issue: Uncaught TypeError: undefined is not a function? Here is what i did:
I made a module that inhereit on sale, crm, and account. On class crm_lead i add some changes:
def _get_available_product(self, cr, uid, ids, name, arg, context=None):
vals = {}
pr_id = []
for rec in self.browse(cr, uid, ids, context=context):
id = rec.id
product_list = self.pool.get('product.product').search(cr,uid,[('product_state','=','available')])
pr_id = [product.id if product.id else False for product in self.pool.get('product.product').browse(cr,uid,product_list,context=context)]
vals[id] = {'product_ids':pr_id}
return vals
def _defaults_product(self, cr, uid, ids, context=None):
product_list = self.pool.get('product.product').search(cr,uid,[('product_state','=','available')])
pr_id = [product.id if product.id else False for product in self.pool.get('product.product').browse(cr,uid,product_list,context=context)]
value = {"value":{'product_ids':pr_id}}
_logger.info("\n\n\t\t\tVALUE %s"%(str(value)))
return value
_columns = {
'product_id' : fields.many2one('product.product','Product'),
'product_ids' : fields.function(_get_available_product, type='many2many', relation='product.product', method=True, store=False, multi='compute_available_product', string='Available Product'),
}
_defaults = {
'product_ids' : _defaults_product,
}
On crm_lead_view.xml
<group>
<field name="product_ids" nolabel="1" widget="many2many" invisible="1"
</group>
<group>
<group>
<field name="product_id" required="1" domain="[('id','in',product_ids[0][2])]"/>
....
and when i try to create a Lead, the client error pop up just like above. My aim actually is that if i create a lead, i want to filter the product_id so that the only shown are those products w/c product_state is 'available'.
You include relevant part of the log.