Editing the form view

Now that we have added our fields to the model, we want to display them on the form. Fortunately, Odoo provides an editor that makes it easy to add the fields to your view. It would be beneficial to have experience using a text editor with XML here. 

The easiest way to edit a view, in this case the sale order form, is to go to the form you wish to edit. Simply pull up any sales order in Odoo and, from the debug menu, choose Edit FormView:

Edit FormView

This will bring up the actual XML code that makes up the sale order view. It may look somewhat intimidating to newcomers at first, but the changes we are going to make are very easy. Even better, you can copy and paste an existing field, so you don't have to type all the special characters and understand the syntax.

Now scroll down until you find the line that displays the payment terms on the sales order form. We will add our two custom fields directly below, as shown in the following screenshot:

Adding two custom fields

To simplify, you can copy and paste the payment_term_id line and then edit it to include the custom field you wish to add. Here, we have added the field for Date Required to our view:

Date Required

Notice that we have removed the options tag for the purposes of this example. Now you can save the form and refresh it.

As was warned early on in the chapter, changing and modifying Odoo in the database can be dangerous and can break your Odoo installation if you make mistakes.

Please be aware that you may have to hold down the Shift key when you refresh your browser to see the change:

As you can see, it is pretty easy to create new fields and then add those fields to views and forms.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.148.108.112