Discussion:
[Erp5-dev] Predicates magic - property similar to price
Łukasz Nowak
2006-11-27 15:12:47 UTC
Permalink
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.

Thanks in advance!

Bye,
Luke
--
?ukasz Nowak R&D Ventis http://www.ventis.com.pl/
tel: +48 32 392 10 60 int 37 fax: +48 32 392 10 61
https://ssl.ventis.com.pl/keys/lukasz.nowak.pub.asc
``Use the Source, Luke...''
Romain Courteaud
2006-11-27 15:30:18 UTC
Permalink
Post by Łukasz Nowak
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
* 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
===
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
===
===
<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
Łukasz Nowak
2006-11-28 12:30:59 UTC
Permalink
Hi,

Dnia 27-11-2006, pon o godzinie 16:30 +0100, Romain Courteaud
Post by Romain Courteaud
Hello Luke,
The accessor getPrice is surcharged for movement.
http://svn.erp5.org/erp5/trunk/products/ERP5/Document/Movement.py?view=markup
Well. Ok. I accept it :)

But right now I have another question. As I shown above I managed to
getProperty('trade_name') using predicate in Sale Order Line context.
And right now, I wonder when/where/how shall I apply this value:

* using TALES:Default python:
here.getProperty('trade_name',here.portal_domains.generateMappedValue
(here).getTradeName()) (in such case I'll have to restrict me from
'None' generateMappedValue)

* somewhere in object Document/OrderLine.py by overriding accessor
_setTradeName?

Well, I'd like to have same behaviour as price is set.

Thanks,
Luke
--
?ukasz Nowak R&D Ventis http://www.ventis.com.pl/
tel: +48 32 392 10 60 int 37 fax: +48 32 392 10 61
https://ssl.ventis.com.pl/keys/lukasz.nowak.pub.asc
``Use the Source, Luke...''
Loading...