Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
4769 Widoki

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'.


Any help is much appreciated.



Awatar
Odrzuć

You include relevant part of the log.

Najlepsza odpowiedź

Hi friend!!!

Try to make it like this:

'product_id' : fields.many2one('product.product','Product',domain="[('id','in',product_ids[0][2])]"),

Awatar
Odrzuć

The problem here as i think is product_ids[0][2] is unrecognized :/

Powiązane posty Odpowiedzi Widoki Czynność
2
kwi 21
11323
0
mar 15
4153
1
sie 23
2516
1
sty 21
4054
3
wrz 20
71876