Hello, Naz.
Você pode fazer o seguinte (eu fiz e deu certo):
01) With Studio, create a Date type field in account.move [x_studio_data_de_pagamento_1] (and make it visible only when the entry type is equal to "Vendor Invoice": move_type != "in_invoice");
02) Add it to the tree view;
03) Create an automation with python code in Base Automation so that we can take the value of the 'date' field in account.payment and assign it to this field created with Studio, as follows:
for record in records:
# Check if the payment state is 'not_paid'
if record.payment_state == 'not_paid':
# If the payment state is 'not_paid', clear the field 'x_studio_data_de_pagamento_1'
record.update({'x_studio_data_de_pagamento_1': False})
else:
# Check if the invoice has associated payments
if record.invoice_payments_widget:
payments = record.invoice_payments_widget.get('content')
dates = []
for payment_info in payments:
# Extract the payment date
payment = payment_info.get('date', '')
if payment: # Add the date only if it is present
# Check if 'payment' is of type datetime.date
if isinstance(payment, datetime.date):
# Format the date in D/M/Y (Day/Month/Year) for display
formatted_date = payment.strftime('%d/%m/%Y')
dates.append(formatted_date) # Use the formatted date
else:
# Otherwise, assume that 'payment' is a string in the format 'YYYY-MM-DD'
formatted_date = payment.split("-")
formatted_date = f"{formatted_date[2]}/{formatted_date[1]}/{formatted_date[0]}"
dates.append(formatted_date) # Use the formatted date
# Update the field 'x_studio_data_de_pagamento_1' with the first payment date
if dates: # Check if there are dates to update
# The first payment date (in 'DD/MM/YYYY' format) will be converted to 'Date' without using fields
first_payment_date_str = dates[0] # Example: "26/03/2025"
try:
# Converting the string 'DD/MM/YYYY' to the format 'YYYY-MM-DD'
day, month, year = first_payment_date_str.split('/')
first_payment_date = f"{year}-{month}-{day}" # Format 'YYYY-MM-DD'
record.update({'x_studio_data_de_pagamento_1': first_payment_date})
except ValueError:
# In case of conversion error, clear the field 'x_studio_data_de_pagamento_1'
record.update({'x_studio_data_de_pagamento_1': False})
else:
# If there are no dates, clear the field 'x_studio_data_de_pagamento_1'
record.update({'x_studio_data_de_pagamento_1': False})
In my case, I needed to convert the date presentation to the Brazilian format, but you do not need to include this part of the code in your automation.