Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ

Hi everyone,

I’m on Odoo 18 and I’m building a custom field “Remaining Budget” in Studio. The value should be:

Remaining Budget = Budgeted − Committed (or Achieved)

  • Budgeted is editable on the form.
  • Committed/Achieved are not editable; they’re updated automatically when we confirm Purchase Orders and post Vendor Bills.


I created an Automation Rule with the “On UI Change” or "On Save" trigger (watching Budgeted). It works when I manually edit Budgeted, but it doesn’t update when Committed/Achieved change in the backend after PO/Bill operations.

Questions:

  1. In Odoo 18 Studio, what’s the correct trigger so the rule also runs when Committed/Achieved change from backend processes?
    • Should I use “After last update” (and set Budgeted + Committed/Achieved as trigger fields)?
    • Or is the better practice to make Remaining Budget a computed (stored) field with dependencies on Budgeted and Committed/Achieved?


2. Any gotchas to avoid loops or unnecessary writes? If it matters, the field is Monetary.

What I tried:

  • On UI Change → updates only when I edit Budgeted manually.
  • Python code in an action
record.write({ "x_studio_remaining_budget": (record.budgeted_amount or 0.0) - (record.achieved_amount or 0.0)})


What I’d like to achieve:

Have Remaining Budget update reliably whether the change comes from UI (Budgeted) or backend (Committed/Achieved from PO/Bill), with minimal performance impact and no recursion.


Thanks in advance for any guidance on the best trigger in Odoo 18


Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 3 24
4008
1
thg 3 21
2865
2
thg 9 25
864
3
thg 8 25
1181
2
thg 8 25
531