Odoo 17’s Advanced Wizard Operations from Active Model
Within Odoo, wizards are crucial to enhancing user experiences. These dynamic components are constructed using the Transient Model class, which is well-known for its transient data storage and periodic deletion capabilities. Unlike permanent models, wizards are meant to act on data that is persistent. The commencement of a wizard is designated as ir_act_window, and it takes the user to a different popup window. Within this window, users will encounter several fields and button operations. It’s important to remember that the majority of users are authorized to communicate with wizards. This blog post delves into advanced wizard functions, showcasing the seamless integration of wizard button actions into the active model. Typically, a wizard’s button action is activated within its temporary model, providing an efficient and streamlined user experience. This wizard is called an account. move, allows you to create payment links and amounts from invoices.
This Form can be used to display the payment link and amount in this wizard to a specific field.
from odoo import models, fields
from odoo.tests import Form
class LinkInvoice(models.Model):
_inherit = 'account.move'
payment_link = fields.Char("Payment Link", compute='compute_payment_link')
amount = fields.Char(string="Amount")
We created a new field link within the account. move model, which is called by both an amount field and a calculation function. Within the calculate, the payment_link from payment.link.wizard is replaced with the account. move field. The form can be utilized to accomplish this; it is imported from Odoo. tests. It launches the Form and the temporary model created by the wizard, adding the with_context method and using active_id to identify the record from the active_model. The model that we plan to use to display the data is represented by the active_model.
Through the use of Form, we can record important changes made during “creation,” manage field settings revisions, handle defaults, and handle relevant changes about x2many fields.
Active_id: The record’s id that needs to show the value.
Active_model: the model in which the value needs to be shown
When this code is executed, it shows
The amount and payment link are shown in the field of the active_model form. The Payment_link and amount are displayed in the corresponding fields of the active_model form. In Odoo 17, we can also call up additional fields by using wizard button actions that are integrated into the wizard itself and appear as part of the active_model.
Temporary models act as temporary data repositories, regularly deleting data as needed. By utilizing these advanced methods in conjunction with the Form, we can transfer field values from the temporary model to our active model and related record.
"Unlock the Full Potential of Your Business with Odoo ERP!"
"Get a Cost Estimate for Your ERP Project, Absolutely FREE!"
Get a Free Quote