fields.reference browse

Bug #496549 reported by Frédéric (Ferme du Sart)
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Fix Released
Undecided
Unassigned

Bug Description

- browsing a fields.reference returns an 'object,id' string instead of browsing into record
- one2many should accept a fields.reference field as _fields_id

Revision history for this message
Nicolas DS (zyphos) wrote :

- The aim of browsing is... browsing. To retrieve the id simply use <reference_field_name>.id
- It's not the aim of a one2many field.
I think that you have a misconception in your project.
What are you trying to do ? Or what kind of relation are you seeking ?
Many2many ?

I am also working on a super many2many relation (many2many between any kind of resource).
https://blueprints.launchpad.net/openobject-server/+spec/many-resource2one

Changed in openobject-server:
status: New → Invalid
Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote :

Hi !

I agree with Nicolas DS.

Regards,

Revision history for this message
Frédéric (Ferme du Sart) (frederic-declercq) wrote :

Nicolas DS:
"The aim of browsing is... browsing. To retrieve the id simply use <reference_field_name>.id"

We can't do it. When browsing, we have to do:
res_mode, res_id = <reference_field_name.split(',')
res_id = long(res_id)
res = self.pool.get(res_model).browse(cr, uid, res_id, context=context)

This problem has been exposed to OpenERP team last week. Olivier (Domy???) has asked to OpenERP coders, then answered me that it was a real bug to transmit.

I've coded the corrective on https://code.launchpad.net/~frederic-declercq/openobject-server/server-fu-reference_browse. This BUG was just created to explain correction.

During the corrective, I saw that browsing references allows using fields.related based on reference. And few code lines allowed to use reference as one2many.

ie:
- Treasury (money) can come from sale.order, pos.order, account.invoice, purchase.order (diposit)... payments made can be linked to any resource by having field.reference on account.treasury.line, and treasury_ids on destinations.
- Product/partner/supplierinfo special fields (vintage, microbiotics, caliber, origin, EC number...) may be usefull for some products/partners... but not for an HR product (hour for an employee). Specifications required fields can be created depending on product's category and seen in a one2many list to complete, stored in a products specification table, but editable into objects views (product/partner/supplierinfo...)

Changed in openobject-server:
status: Invalid → Confirmed
Changed in openobject-server:
assignee: nobody → Jay (Open ERP) (jvo-openerp)
Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) wrote :

Hello Fredric,

Would you please demonstrate a module which uses this facilty?

And a point to note, the one2many should NEVER accept a fields.reference field as _fields_id.

Thanks.

Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

Browsing through reference fields has been implemented in v6 and was already released in 6.0 RC1 I think, marking as Fix Released.

For the second point, using a reference field instead of a many2one as the implementation for a one2many (i.e _fields_id) is not acceptable, as the database can't maintain the integrity of the foreign keys. If you really need this you must implement the one2many yourself with a function field or by inheriting fields.one2many, but we won't allow this in the core ORM, it introduces too many potential issues.

Thanks!

Changed in openobject-server:
assignee: Jay (OpenERP) (jvo-openerp) → nobody
milestone: none → 6.0-rc2
status: Confirmed → Fix Released
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.