• Courses
    Introduction LearnPress – LMS plugin

    Introduction LearnPress – LMS plugin

    Free
    อ่านเพิ่มเติม
  • Features
    • Membership
    • Portfolio
    • About Us
    • FAQs
    • Sidebar Shop
    • 404 Page
  • Events
  • Gallery
  • Blog
  • Contact
  • Shop
    มีคำถามเกี่ยวกับ odoo ?
    (063) 5525296
    info@odoothaidev.com
    Login
    Odoothaidev - We are Odoo professional in ThailandOdoothaidev - We are Odoo professional in Thailand
    • Courses
      Introduction LearnPress – LMS plugin

      Introduction LearnPress – LMS plugin

      Free
      อ่านเพิ่มเติม
    • Features
      • Membership
      • Portfolio
      • About Us
      • FAQs
      • Sidebar Shop
      • 404 Page
    • Events
    • Gallery
    • Blog
    • Contact
    • Shop

      Custom Fields

      • บ้าน
      • บล็อก
      • Custom Fields
      • How to Add Custom Fields to Existing Views in Odoo v12

      How to Add Custom Fields to Existing Views in Odoo v12

      • โพสโดย admin
      • หมวดหมู่ Custom Fields
      • วันที่ กรกฎาคม 20, 2019
      • ความคิดเห็น 0 ความคิดเห็น

      How to Add Custom Fields to Existing Views in Odoo v12

      In the pre-written blogs, I have discussed with you on varied yet connecting features such as how to create a new module, defining the views in the created module, adding the search view in the created module, etc. If you missed them or haven’t read about and is interested in knowing about, refer the following blog: How to Create a Module in Odoo 12
      In this blog,  we will be discussing how to add new fields to an existing model. To explain the blog, we will take the model sales order and see how one can add a custom field to the model and display the same in the sales order form view.
      So either you can create a new module or you can try the same in your existing custom modules. So let’s get started. Understand that our intention here is to add a new field of type: character to the sale order.
      Adding Custom field to the model:
      adding-custom-fields-to-existing-views-odoo-v12
      This is the sales order form we are holding presently. Now we will add a char field named additional_note below the field Confirmation date in the above form.
      For that,  we need to know the name of the corresponding model to which we are adding the fields. For those who don’t know about the model displayed in the view, they can go for it and easily be found out by activating the developer mode. After activating the developer mode, click on lady debugger button near the logged in user name in the top menu bar, and click on the Edit form view.
      adding-custom-fields-to-existing-views-odoo-v12
      Once you click there, you will get a pop up/wizard, in the pop up you can see the corresponding model name.
      adding-custom-fields-to-existing-views-odoo-v12
      So we get the model name ie, sale.order, so in our python file, we have to create a class and inherit this model.
      # -*- coding: utf-8 -*-
      from odoo import models, fields
      class SaleOrder(models.Model):
      	_inherit = 'sale.order'
      	additional_note = fields.Char(string='Additional Note')
      So if you look at the above code, you can see a class named SaleOrder is created. You can inherit the model named sale.order and add a new field.
      adding-custom-fields-to-existing-views-odoo-v12
      Now, we are done with the python side, do not forget to call the python file in the init file.
      Adding the field to the view:
      For adding the field to the view, we have to get the external id of the view to which we have to add the field. To get it, one has to do the same procedure that was done for getting the model name.
      adding-custom-fields-to-existing-views-odoo-v12
      So in the XML file, you can inherit this view and add the field we have created.
       <record id="view_order_form_inherit" model="ir.ui.view">
              	<field name="name">Sale Order Custom</field>
              	<field name="model">sale.order</field>
              	<field name="inherit_id" ref="sale.view_order_form"/>
              	<field name="arch" type="xml">
                  	<field name="confirmation_date" position="after">
                      		<field name="additional_note"/>
                  	</field>
              	</field>
      </record>
      Above code will add the additional_note field to the sale order form view, you can give the id and name for the record as per the wish, keep naming of the record related to what is done in the record so that it will be easier to understand.
      In the model and inherit_id field we have to specify the model as sale.order and in the inherit_id,  the external id of the form to which we are going to add the field has to be specified.
      adding-custom-fields-to-existing-views-odoo-v12
      After specifying the model and inherit_id, we have to specify the place where we have to add the new field. If you check the above image you can see that I have placed the new field name additional_note after the field named confirmation_date.
      To get the name of the existing field, you can just place the mouse over the field.
      So I just placed the mouse over the field named Confirmation date, to get the field name of it.
      adding-custom-fields-to-existing-views-odoo-v12
      <field name="arch" type="xml">
                  <field name="confirmation_date" position="after">
                   	<field name="additional_note"/>
                  </field>
      </field>
      Now, we are done with the XML, make sure that the corresponding XML file is called in the manifest file and upgrade the corresponding module.
      adding-custom-fields-to-existing-views-odoo-v12
      Once the custom code is upgraded or installed, one can see the newly added field in the sales order form.
      So this is all about adding a custom field to an existing view. You can try one of yours and see how it works.
      Thank you and Credit : https://www.cybrosys.com/blog/adding-custom-fields-to-existing-views-in-odoo-v12

      แท็ก:Custom Fields

      • แบ่งปัน:
      อวตารของผู้แต่ง
      admin

      โพสต์ก่อนหน้า

      How to Add Chatter to Form View in Odoo v12
      กรกฎาคม 20, 2019

      โพสต์ถัดไป

      How to Define Header, Statusbar, and Buttons in Odoo v12
      กรกฎาคม 20, 2019

      ทิ้งคำตอบไว้ ยกเลิกการตอบ

      อีเมลของคุณจะไม่แสดงให้คนอื่นเห็น

      Search

      หมวดหมู่

      • Accounting
      • Adobe XD
      • API
      • Blog
      • Business
      • Buttons
      • CRM
      • Custom Fields
      • Design / Branding
      • Django
      • ERP
      • Express
      • Form View
      • Frontend
      • Grant Chart
      • Header
      • iReport
      • Jasper Server & Server
      • Jaspersoft Studio
      • Java
      • JSON-RPC
      • Linux
      • MRP
      • NodeJS
      • Odoo 10
      • Odoo 12 Module
      • Odoo 13
      • Odoo 8
      • Odoo 9
      • Odoo API
      • Odoo Developer
      • Odoo Ebook
      • Odoo ERP
      • Odoo Event
      • Odoo Report
      • Open-office
      • OpenERP 7.0
      • PhantomJS
      • Postgres SQL
      • Programming Language
      • Project Management
      • Python
      • Qweb
      • Reporting ระบบรายงาน
      • RML Report
      • Search View and Filters
      • Statusbar
      • Ubuntu
      • Uncategorized
      • Voip & Call Center
      • Warehouse Management
      • WMS
      • XML-RPC
      • การ Implement
      • การเก็บข้อมูล Pre-Requirement
      • การเตรียมตัวเพื่อใช้งาน erp
      • ธีมเว็บไซต์ Odoo
      • ธุรกิจบริการ
      • ธุรกิจประเภทจัดอบรมสัมมนา
      • ธุรกิจสิ่งพิมพ์
      • ประเภทธุรกิจที่เหมาะกับ Odoo
      • ระบบบัญชี
      • ระบบเคลม

      หลักสูตรล่าสุด

      Introduction LearnPress – LMS plugin

      Introduction LearnPress – LMS plugin

      Free
      From Zero to Hero with Nodejs

      From Zero to Hero with Nodejs

      Free
      Learn Python – Interactive Python

      Learn Python – Interactive Python

      $69.00
      (00) 123 456 789
      hello@eduma.com
      Facebook
      Twitter
      Google-plus
      Pinterest

      Education WordPress Theme by ThimPress. Powered by WordPress.

      • Privacy
      • Terms
      • Sitemap
      • Purchase

      เข้าสู่ระบบด้วยบัญชีไซต์ของคุณ

      ลืมรหัสผ่าน?