On 2017-06-29 10:50, Ariel Stilman wrote:
> thanks. I get it. Let me ask you what type of Formulas can be input ?

Any valid Python expression.

> I´m trying to set a formula to calculate the selling price including a 
> Margin % over cost_price.
> I notice Formulas are set using python expressions yet an error occurs 
> alerting  product.cost_price

You can not browse instance. We use a restricted evaluator for security
purpose (see https://github.com/danthedeckie/simpleeval)

> or cost_price are not defined

Not by default.

> I can use unit_price*1.10 to add 10% onver price BUT I cant use 
> cost_price/(1-0.20) to add 20% margin formula over cost.

Yep the cost_price is not in the default context.
We do not put the cost price because a product can be configured to have
an average cost method and so in this case the computed price will
always change.

> I also cant use 
> Decimal(round(product.cost_price*1.10,2)) to add 10% with 2 decimals.

round is neither in the context but you should be able to use
Decimal.quantize (which is more precise)

> So which formulas can I use? Which variables are acceptable for price, 
> cost, quantity etc.

By default only 'unit_price' is defined, but the module is designed to
allow extention to add more names and functions to the simpleeval
context.
The design of Tryton is to have simple default but easy extensibility.


PS: Please do no top-post on this mailing list, see
https://groups.tryton.org/netiquette
-- 
Cédric Krier - B2CK SPRL
Email/Jabber: cedric.kr...@b2ck.com
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/

-- 
You received this message because you are subscribed to the Google Groups 
"tryton" group.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tryton/20170629185144.GB25145%40kei.

Reply via email to