İçereği Atla
Menü
Bu soru işaretlendi

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


Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
3
Mar 24
3438
1
Mar 21
2681
2
Ağu 25
351
2
Tem 25
793
0
Haz 25
571