default cost and list price

73 views
Skip to first unread message

Francisco Maria Moyano Casco

unread,
Apr 21, 2018, 6:12:50 PM4/21/18
to tryton
Hi,
I am trying to put a default cost and list price, but had no success.

The code am working on is the next one:

............
@staticmethod
def default_list_price():
return 1.0
..............

I know that both fields are Property fields, and that is why my code doesn't work.

I am inventoring all my assets, and I need to have some defaults values on the product.template

Regards.
Francisco

Sergi Almacellas Abellana

unread,
Apr 23, 2018, 3:25:03 AM4/23/18
to try...@googlegroups.com
El 22/04/18 a les 00:12, Francisco Maria Moyano Casco ha escrit:
Property fields have their default on the Property table. You should
create a record with the field and not related to any record and this
will be used as default value.


--
Sergi Almacellas Abellana
www.koolpi.com
Twitter: @pokoli_srk

Francisco Maria Moyano Casco

unread,
Apr 23, 2018, 11:17:33 AM4/23/18
to tryton
Sorry for bothering again. Is there any example on any module I could use?
I understand your reply, but I am not sure how to use it.

Thanks
Francisco

Sergi Almacellas Abellana

unread,
Apr 25, 2018, 4:55:53 AM4/25/18
to try...@googlegroups.com
El 23/04/18 a les 17:17, Francisco Maria Moyano Casco ha escrit:
You should create a record on the ir.property model. There is an example
on the product module:

http://hg.tryton.org/modules/product/file/4.2/configuration.xml#l32

Just adapt the field search and the value. For the value make sure to
use , as prefix which is required by design.
Message has been deleted

Francisco Maria Moyano Casco

unread,
Sep 29, 2018, 11:45:15 AM9/29/18
to tryton
Thank you so much Sergi! That really works. Sorry for spend so much time for thank you.

The solution was

<data noupdate="1">
<record model="ir.property" id="property_cost_price">
<field name="field"
search="[('model.model', '=', 'product.template'),
('name', '=', 'cost_price')]"/>
<field name="value">,0</field>
</record>
</data>

Same for list_price

One more time, thank you!
Francisco

Reply all
Reply to author
Forward
0 new messages