[Erp5-dev] Predicates magic - property similar to price

Romain Courteaud romain at nexedi.com
Mon Nov 27 16:30:18 CET 2006


* ??ukasz Nowak [2006-11-27 16:12:47 +0100]:

> Hello,
> 
> Price can be defined on resource by default_supply_line or using Sale
> Supply. It's copied using Predicate (predicated?) do Sale Order Line.
> 
> In our case we have very similar property, trade_name. It shall be used
> same as price. For now I was using interaction_workflow, but now I want
> to move to Predicate.
> 
> In my PropertySheet/Shufla.py I've got trade_name property. That PS is
> associated with portal_types:
> 
>  * Product
>  * Sale Supply Line
>  * Sale Supply Cell
>  * Supply Line
>  * Supply Cell
>  * Sale Order Line
> 
> I've modified SaleSupplyLine_init script's setMappedValuePropertyList()
> list and added 'trade_name'.
> 
> So all this portal_types do have accessors *TradeName. And they are
> working. But as price is copied to Sale Order Line without problems my
> own field isn't. Such snippet:
> ===
> print context,context.getUrl()
> print context.portal_domains.searchPredicateList(context)
> print \
> context.portal_domains.generateMappedValue(context).getProperty('discount_ratio')
> print \
> context.portal_domains.generateMappedValue(context).getProperty('trade_name')
> print context.portal_domains.generateMappedValue(context).getTradeName()
> print context.portal_domains.generateMappedValue(context).getBasePrice()
> return printed
> ===
> run on Sale Order Line gives me:
> ===
> <OrderLine at 5> /erp5/sale_order_module/1/5
> [<SupplyLine at /erp5/sale_supply_module/1/1>]
> 0.05
> Sale Supply Line: Trade Name
> Sale Supply Line: Trade Name
> 100.0
> ===
> 
> Well... As I see predicate works. Am I wrong? Right? Where now shall I
> do my investigation? What I'm doing wrong? I'm using
> http://wiki.erp5.org/TechnicalNoteOnPredicates all the time, but for now
> I'm stucked... I'd like any suggestion, tip, idea. I'll then put my path
> of resolving this, I think common, problem on wiki.

Hello Luke,

The accessor getPrice is surcharged for movement.
http://svn.erp5.org/erp5/trunk/products/ERP5/Document/Movement.py?view=markup

Romain



More information about the Erp5-dev mailing list