Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
6 ตอบกลับ
30496 มุมมอง

Hello,

I just add a fields.function(_myfunc, .... , store=True) on one OpenERP V7 model. This instance allready has some value in database.

How can I force openERP to compute the value for this field ? New data are ok (set when write method is launch) but for existing one nothing ...!

Note:

If a change store=True with store=False, my data are ok, but I need to add this field on search filters.

thanks for your help,

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

I recently came across this kind of problem (needed to update computed values) and I created a module to add 2 methods to the ORM (compute and compute_all).

You can find it here if you want, and if you ever get a chance to test if on Odoo 8+, let me know (I'm using OpenERP 7.0)

https://github.com/H-Max/odoo-orm-recompute

Hope this helps.

อวตาร
ละทิ้ง

Thanks Henri! It works for v8 in my case!

คำตอบที่ดีที่สุด

You could remove the column from database, for example, for field 'margin' at sale.order model you could execute next SQL with psql:

your_database=> alter table sale_order drop column if exists margin;

Then update the addon in Configuration > Local modules

If you look at Odoo log file you will see one line like:

openerp.models: Storing computed values of sale.order fields margin

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Export the model records, then import them.

This will trigger the write and the values for the functional field will be computed and stored.

อวตาร
ละทิ้ง
ผู้เขียน

If I trigger a write method all my value will be updated ?

Hy, is this the only way to do this? Isn't it possible to generate a write trigger during installation process?

The best answer I found is here : http://forum.openerp.com/forum/topic30196.html

Related Posts ตอบกลับ มุมมอง กิจกรรม
3
มี.ค. 15
5795
3
พ.ค. 25
1348
1
เม.ย. 25
1051
one2one relational field แก้ไขแล้ว
3
ก.ย. 24
13785
2
ก.พ. 24
2231