Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
3066 Vizualizări

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.

Imagine profil
Abandonează