fields.related on many2many field always indicate (0)

Bug #356628 reported by Christophe CHAUVET
4
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Status tracked in Trunk
5.0
Won't Fix
Low
Unassigned
Trunk
Confirmed
Wishlist
OpenERP's Framework R&D

Bug Description

Server revno: 1755
Addons revno: 2267
Client revno: 949

On a new module, add fields.related to a many2many field.
Add this field on the tree view and a search form
the fields always indicate (0) all the times, thus there are a multi value on the original object.
See screenshot

Distribution: Ubuntu
Version: 8.10 (intrepid)
Python 2.5.2

Locale:
  LANG=fr_FR.UTF-8

Related branches

Revision history for this message
Christophe CHAUVET (christophe-chauvet) wrote :
Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) wrote :

Hello Christophe,

Can you please send me your module?

I do not get the situation. My records are not saved even.

Thanks.

Changed in openobject-server:
assignee: nobody → jvo-openerp
Revision history for this message
Fabien (Open ERP) (fp-tinyerp) wrote :

related sields still does not support m2m.

Changed in openobject-server:
importance: Undecided → Wishlist
Revision history for this message
António Anacleto (antonio-anacleto) wrote :

Hello, I changed the code in the /server/bin/osv/fields.py and solved my problem

this was the function I changed:

    def _fnct_read(self, obj, cr, uid, ids, field_name, args, context=None):
        self._field_get2(cr, uid, obj, context)
        if not ids: return {}
        relation = obj._name
        res = {}.fromkeys(ids, False)
        objlst = obj.browse(cr, uid, ids)
        for data in objlst:
            if not data:
                continue
            t_data = data
            relation = obj._name
            for i in range(len(self.arg)):
                field_detail = self._relations[i]
                relation = field_detail['object']
                try:
                    if not t_data[self.arg[i]]:
                        t_data = False
                        break
                except:
                    t_data = False
                    break
                # Modificado por AMA para resolver o bug em que o one 2 many em related aparece apenas o ultimo valor
                if field_detail['type'] in ('one2many', 'many2many'):
                    all_t_data = t_data[self.arg[i]]
                    t_data_list=[]
                    for t_data in all_t_data:
                        t_data_list.append(t_data.id)
                else:
                    t_data = t_data[self.arg[i]]

            if type(t_data) == type(objlst[0]) and field_detail['type'] not in ('one2many', 'many2many'):
                res[data.id] = t_data.id
            else:
                res[data.id] = t_data

            if field_detail['type'] in ('one2many', 'many2many'):
                if type(t_data) == type(objlst[0]):
                    res[data.id] = t_data_list
                else:
                    res[data.id] = t_data

        if self._type=='many2one':
            ids = filter(None, res.values())
            if ids:
                ng = dict(obj.pool.get(self._obj).name_get(cr, uid, ids, context=context))
                for r in res:
                    if res[r]:
                        res[r] = (res[r], ng[res[r]])
        return res

Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) wrote :

Setting the big as "Won't fix" for stable as it is really not a blocking point.
Thanks for your participation.

summary: - [5.0] fields.related on many2many field always indicate (0)
+ fields.related on many2many field always indicate (0)
Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) wrote :

Need to investigate if its really fixed on trunk or not.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.