Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
4169 Переглядів


Hello,

I would count the number of products in the product_template table corresponding to a category of product_public_categ table.

I can get it with a calculated field but then if I want to display the contents of this field is calculated with the Qweb frontend, he referred me an error like "2" while Evaluating

Can you explain why the Qweb does not happen to the show? Sorry for my English 

class product_category(osv.Model):

_inherit='product.public.category'

def _nb_product_fnc(self, cr, uid, ids, name, arg, context=None):

         category=None

         res,id_ ={}, None

        for categ in self.browse(cr, uid, ids, context=context):

            category = categ.id

            id_ = categ.id

        cr.execute("select count(id) from product_template where categ=%s" %(category))

        rep = cr.fetchone()[0] or 0 

        if id_:

            res[id_] =rep

        return res

_columns={

'nb_product': fields.function(_nb_product_fnc, type="integer", string="Total product for this categories"),

}

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
1
лип. 25
1620
1
трав. 25
1571
1
квіт. 25
2214
1
лют. 25
1499
0
жовт. 24
1259