Skip to Content
Menu
This question has been flagged
5 Replies
6731 Views

I'm following directions from a book Odoo 12  Dev essentials 

Chapter 1
I have successfully gone through :
*Adding a field to a Model

and now at 

*Adding a field to a form view

"...A pop-up window, Create Views which inherit from this one, will be shown, and we should fill it with the following values: "

View Name: Contacts - Custom "Is Work Team" flag

Architecture: Use the following XML:

<field name="category_id" position="after">

  <field name="x_is_work_team" />

</field>

then the book goes on to state "...the other important fields, such as the Model, View Type, and Inherited View, already have the correct default values..."

Default values?? they are empty

moving on...

The above code does not work...
it breaks  until I fill in the values like so

View Type -> Form 

Model-> res.partner  

and change the Architecture to

<form string="Partners">

  <field name="category_id" position="after">

      <field name="x_is_work_team" />

  </field>

</form>

then save and reload but nothing happens

whats the right approach of adding a simple boolean field  to a preexisting view

this is the link of what Im following
https://subscription.packtpub.com/book/business/9781789532470/1/ch01lvl1sec14/modifying-an-existing-model-to-add-a-field 





Avatar
Discard
Author

It does work!!!

I was reading the book "Odoo 12 development essentials " trying to get up to speed AFAP

but I'm really disappointed I spent so much time trying to figure out what was wrong...

Could you recommend me a reliable source to learn this

Thanks

Best Answer

Hi,
First of all activate the debug mode and navigate to Settings -> Technical -> Database Structure -> Models and search the model where you want to add the field. Open the corresponding model, let it be sale.order , using add an item in the Fields page inside the models form view, create a new field,



Once you add the field in the model, we have to add it in the view also, for that go to Settings -> Technical -> User Interface -> Views, click create button and create a new view with following values as shown in below image,



Now we have added the field to views, now refresh the screen and see the corresponding form, now the sale order form will be like this, it will have a new Boolean field after the custom field.



If you like you can have a look at this Video: How To Add custom field from UI Without Code


XML Code:

<data>
  <xpath expr="//field[@name='partner_id']" position="after">
    <field name="x_test_bool" string="Test Bool"/>
  </xpath>
</data>


Thanks


Avatar
Discard
Author

It does work!!!

I was reading the book "Odoo 12 development essentials " trying to get up to speed AFAP

but I'm really disappointed I spent so much time trying to figure out what was wrong...

Could you recommend me a reliable source to learn this

Thanks

Related Posts Replies Views Activity
1
Feb 19
5470
1
Aug 24
631
3
Oct 23
5973
1
Sep 23
1962
1
May 23
1000