Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
12018 Lượt xem

I have custom field like this:
​https://i.imgur.com/RlZdW2i.png

I would like to update its value every time when company_ids inside Users changes.
I've read that when it is marked as "stored" it calculates only once when record is created and then everytime when Dependencies change.

But I don't know what to put inside Dependencies. I think I need to put there a company_ids somehow but I don't know how. Something like this does not work:
env['res.users'].company_ids

I've also tried to make automated action like this:
https://i.imgur.com/EceKzdz.png
But it does not work as well

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi Andrzej: You will need to do this through an automated action since you want the Contacts model to be updated from updates to the Users model. Remove the code in the field definition and update your automated action to look like this and it will work.

https://imgur.com/a/EVKLEi2

Ảnh đại diện
Huỷ bỏ
Tác giả

It worked, thanks!

Câu trả lời hay nhất

Hi, could you help me?

It worked for me for one record but not for several

I tried this but it gives me an error:

for record in records.productos_ids:

  movimiento = env['stock.picking'].search([('name', '=', record.productos_ids.name)])

  if movimiento:

    movimiento['liquidado'] = True

Error:File "/home/odoo/src/odoo/odoo/http.py", line 315, in _handle_exception
    raise exception.with_traceback(None) from new_cause
ValueError: <class 'AttributeError'>: "'stock.picking' object has no attribute 'productos_ids'" while evaluating
"# Available variables:\n#
Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
Input in HTML field Đã xử lý
2
thg 8 23
5884
1
thg 6 25
15237
3
thg 4 25
5371
Compute Fields Đã xử lý
2
thg 7 24
2262
1
thg 1 24
1714