[Erp5-dev] catalog usage in listboxes

Łukasz Nowak lukasz.nowak at ventis.com.pl
Mon Oct 29 12:06:19 CET 2007


Hello,

On 2007-10-16, 19:00:55
Jérome Perrin <jerome at nexedi.com> wrote:

> Ł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).

Huh, very nice trick, I've configured listbox to have editable column
'simulation_state', and set translated_simulation_state_title on
listbox's column list and configued field
listbox_translated_simulation_state_title. I dunno why but it works :)

> >  * 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.

I've used: movement.source_title, movement_source_title and
source_title. While using movement.source_title log is saying me:

2007-10-29T12:01:04 PROBLEM(100) SQLCatalog buildSQLQuery could not
build sort index (movement.destination_title -> None)

I *think* I'll have to configure something in catalog, but for now it
is quite cryptic for me. I'll try to resolve this issue when I have
more time.

> > 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.

Ok. In practise I'll try to avoid using custom queries as much as
possible. But also in practise I've got some quirks with configuring
related keys (in my context). But I'll try to figure out it
as best as possible.

> > 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).

As I'm on early steps in finding out how portal_catalog works I'd be
glad to see some improvements on wiki pages :)

Thanks again for tips.

Regards,
Luke

-- 
Łukasz Nowak R&D Ventis http://www.ventis.com.pl/
tel: +48 32 768 16 85 fax: +48 32 392 10 61
``Use the Source, Luke...'' I am only craftsman.



More information about the Erp5-dev mailing list