[Erp5-dev] catalog usage in listboxes

Jérome Perrin jerome at nexedi.com
Tue Oct 16 19:00:55 CEST 2007


Łukasz Nowak a écrit :
> Hello,
> 
> I'm preparing few reports in our system. Listbox is defined like this:
> 
> Portal Type: Sale Packing List Line
> List Method: portal_catalog

Hi,
first a short note, you may want to use getMovementHistoryList for this
kind of reports (but I'm not sure it supports searching/sorting very well).

>  * translated_simulation_state_title is not shown; if I use
> simulation_state then it is shown

line.getProperty('translated_simulation_state_title') prints nothing 
because accessors are not acquired in getProperty, and
getTranslatedSimulationStateTitle is on packing list, not on line.
'simulation_state' works just because getSimulationState method exists
on DeliveryLine. I don't know why it exists here though (maybe it was 
added for indexing).

I don't know if it's the best way, but you can add a
listbox_translated_simulation_state_title editable field that has
'cell/getTranslatedSimulationStateTitle' in its 'default' TALES, this 
way you can search & sort, because the listbox column is named
translated_simulation_state_title, which will be used as a catalog key 
(using getTranslatedSimulationStateTitle as columns name displays the 
value correctly, but searching won't work).

>  * I'm not able to search/sort on source/destination
> 
> I've tried to use parent.source_title, movement.source_title - but none
> of those works (if I set it explicitly in sortable/search-able columns
> it won't help me...).

Look at generated query, and
portal_catalog/erp5_mysql_innodb/z_catalog_movement_category_list : 
acquired categories are not catalogued for movements (this is an 
optimisation).
With related keys, like "movement_source_title" that joins on source_uid 
column from movement table, searching / sorting should work.

> Additionaly I really do not know why translated_simulation_state_title
> hasn't shown.
> Is it possible to use portal_catalog list method or shall I create my
> own set of scripts/zsqlmethods which will be attached to those listbox
> (like as in accounting module listbox)?

I don't recommend writing custom Z SQL Method, because of maintenance
cost. Most of erp5_accounting now uses portal_catalog / Inventory API 
instead of many SQL methods.
With portal_catalog, you can always use related keys and editable fields
or scripts, so in theory you can do anything.

> How to enable more verbose/debug output about catalog problems? Right
> now if something is wrong LOGs are silent (eg. above -
> translated_simulation_state_title is not showing - I cannot figure out
> why (maybe it is somewhere on wiki - but so indirect, that I wasn't
> able to figure out - my suspicion isn't enough to give me any sense
> conclusion)).
> 
> By the way - is it possible to extend/create information about
> portal_catalog, its limitations, best usages, etc?
> HowToSearchPortalCatalog[1] is nice, but do not explain more advanced
> usage (when I spot something, I'm trying to add it, but my progress is
> quite slow).

Yes, we can use the wiki page you mentionned. Having well written unit 
tests can also be a way to demonstrate an API (better than nothing, and 
at least always up to date).

Jérome



More information about the Erp5-dev mailing list