On 08/07/13 10:23 +0200, Guillem Barba Domingo wrote:
> Changes in products_by_location()
> =========================
> Add two more OPTIONAL params (maybe replacing the current product_ids
> param):
> 
> - grouping_filters: a dictionary with Grouping elements in keys and list of ID
> in values. It's not required to have all the keys that are in 'grouping'
> param.

I propose to use a list of list instead of a dict:


compute_quantities(cls, locations, grouping=('product',), filter=(),
    with_childs=False)


>   For examples:
>     - products_by_location(..., grouping=('product', 'lot'),
> grouping_filters={'product':
> [1, 2, 3], lot=[2, 5, 6]})


compute_quantities(locations, grouping=('product', 'lot'),
    filter=([1, 2, 3], [2, 5, 6]))

>     - products_by_location(..., grouping=('product', 'lot'),
> grouping_filters={'product':
> [1, 2, 3]})

compute_quantities(locations, grouping=('product', 'lot'),
    filter=([1, 2, 3],))

>     - products_by_location(..., grouping=('product', 'lot'),
> grouping_filters={lot=[2,
> 5, 6]})


compute_quantities(locations, grouping=('product', 'lot'),
    filter=(None, [2, 5, 6]))

>   The implementation will ensure that all grouping_filters keys are in 
> grouping
> and then, will do what currently do for product_ids param (only the part
> where product_ids has values) but for all grouping_filters items.

Here no need to ensure about keys.

> - quantity_domain (or other name...): a 2-tuple with the operator in first 
> item
> and operand in second (if it is called from searcher of some quantity field,
> it could be called using the searcher domain param as: domain[1:])
>   The implementation will add a HAVING clause over SUM(quantity).
> Previously, it ensure that supplied domain make sense to be applied to
> quantity (like it is done in _search_quantity_eval_domain() function).

I don't like too much having a kind of half domain here.
I would prefer to use a SQL statement that will be changed into a
python-sql instance in the future.

> To be more flexible, the values of 'grouping_filters' could also be a
> domain, or directly replace 'grouping_filters' by a domain... but I think
> it would do the implementation more complicated.

Agreed.

-- 
Cédric Krier

B2CK SPRL
Rue de Rotterdam, 4
4000 Liège
Belgium
Tel: +32 472 54 46 59
Email/Jabber: [email protected]
Website: http://www.b2ck.com/

Attachment: pgp9mFjBUhaSX.pgp
Description: PGP signature

Reply via email to