İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
650 Görünümler

I AM USING ODOO STUDIO TO CUSTOMIZE A FUEL SALES APP. I HAVE CREATED TWO DECIMAL FIELDS FOR OPENING METER READING AND CLOSING METER READING CORRESPONDING TO A SHIFT. MY ISSUE IS THAT WHEN CREATING A NEW RECORD, I NEED THE PREVIOUS SHIFT'S CLOSING BALANCE TO AUTO FILL THE NEW OPENING BALANCE FOR THE NEW SHIFT.

KINDLY HELP PLEASE


Avatar
Vazgeç
En İyi Yanıt

To auto-fill the new shift's opening balance with the previous shift's closing balance in Odoo Studio, you'll need to use a combination of automated actions and custom code.
Go to Settings > Technical > Actions > Server Actions.
create new
# Find the previous shift record

previous_shift = env['your.model'].search([], order='shift_date desc', limit=1)

if previous_shift:

    # Set the opening balance to the previous shift's closing balance

    record.opening_meter_reading = previous_shift.closing_meter_reading
Go to Settings > Technical > Automation > Automated Actions.

Create a New Automated Action
Click Create.

Name: Provide a name (e.g., "Set Opening Balance on Record Creation").

Model: Select the model where this should apply.

Trigger: Choose On Creation.

Action to Do: Choose Execute Server Action and select the server action you created earlier.

Avatar
Vazgeç