Odoo Help


Problem with field function multi when display on treeview and kanban view

on 12/3/13, 10:53 PM 1,067 views

I have 2 fields

'total_pos': fields.function(_get_pos_order, method=True, type="integer", string="Total POS", multi="pos_order"),
'first_purchase_from_shop': fields.function(_get_pos_order, method=True, type="many2one", mutil="pos_order"),

 def _get_pos_order(self, cr, uid, ids, field_names, arg, context=None):
    res = dict.fromkeys(ids, {'total_pos': 0, 'first_purchase_from_shop': ''})
    pos_order = self.pool.get('pos.order')
    for customer_id in ids:
        pos_order_ids = pos_order.search(cr, uid, [('partner_id', '=', customer_id)], order='date_order')
        res[customer_id]['total_pos'] = len(pos_order_ids)
        res[customer_id]['first_purchase_from_shop'] = pos_order_ids and pos_order_ids[0] or ''

   return res

When display in list view if total_pos has value it always display 1 but you go to form view it has a another value (right value). It happen also in kanban view.

Anyone have problem like that before? It make me to write another function and remove multi from field define then it work well.

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 12/3/13, 10:53 PM
Seen: 1067 times
Last updated: 3/16/15, 8:10 AM