openerp-community team mailing list archive
-
openerp-community team
-
Mailing list archive
-
Message #04544
Re: [Bug 1087033] Re: Inventory lines should be sorted on screen and print documents
On 01/22/2014 09:38 AM, Lionel Sausin - Numérigraphe wrote:
Thank you for the link Ferdinand.
I couldn't test the printing of inventories on the new WMS yet but we should file a separate but report for that if it still needed in v8.
the "unsorted" o2m fields are a major and long term (2008) outstanding
problem.
https://blueprints.launchpad.net/openobject-server/+spec/sorted-output
https://blueprints.launchpad.net/openobject-server/+spec/sorted-lists
https://developer.gnome.org/hig-book/stable/controls-lists.html.en#controls-lists-sortable
users are only capable to "sort" (find) data in short lists (up to 3-10
records)
everything else must be sorted using a user friendly key.
that's why we have created
http://bazaar.launchpad.net/~camptocamp/c2c-rd-addons/7.0/files/head:/one2many_sorted/
and implemented it throughout c2c-rd-addons
I also want to emphasize that the _order clause in the class
specification is NOT sufficient if
* the resource has multiple "natural" keys
or
* if the resource has to be (NLS) sorted using a foreign key only
reachable via (multiple) m2o fields.
using sequences is a valid option, but usually needs user interaction to
define the sequence order and is often not necessary if a natural key is
used as default.
Variant of field type one2many for sorted associations
Usage:
| import one2many_sorted
| ...
| _columns =\
| { 'partner_ids' : one2many_sorted.one2many_sorted
| ( 'res.partner'
| , 'parent_id'
| , 'Sorted Partner List'
| , order='name.upper(), title'
| , search=[('is_company', '=', 'False')]
| , set={'is_company' : False}
| )
| }
| ...
In the example above, the primary sort criteria is "name" (not case-sensitive), the secondary is "title".
Only partners that are physical persons (not is_company) are selected - and only those can be added.
Another possibility is to define a text-property with naming convention "<obj>.<field>.order"
(in the example above this would be "res.partner.parent_id.order").
The value of this property is the sort criteria.
The advantage of properties is, that they can by company-individual.
A third possibility is to hand over a "context" key named "one2many_sorted_order" that contains the name of a property.
If no "context" key is found, then the property with the naming convention is taken.
If no property is defined, the programmed sort order is taken.
Otherwise no sorting takes place.
many2many_sorted has a similar syntax but without search feature.
Note that it works on translated term, not only the text stored in the DB !
--
Beste Grüße
Ferdiand Gassauer
ChriCar Bet. und Ber. GmbH