How to to Add New States to an Existing State Field in Odoo 17
CelineGeorge1
1,156 views
8 slides
Jun 26, 2024
Slide 1 of 8
1
2
3
4
5
6
7
8
About This Presentation
This slide will show how to add a new states in existing state field in odoo 17.
Size: 446.83 KB
Language: en
Added: Jun 26, 2024
Slides: 8 pages
Slide Content
How to to Add New States to an Existing State Field in Odoo 17 Enterprise
Introduction Enterpr ise This slide will show how to add a new states in existing state field in odoo 17.
Enterprise First we need to inherit the model Select the states field Then add the “selection_add” attribute to add new states into the existing states. Here taking sale.order model as an example Here the states field name is state and the selection values are Quotation , Quotation Send, Sale Order, Cancelled. Now let us add new states Open and Close
Enterprise class SaleOrder ( models . Model ): """Inheriting the sale order model and modify the field state to add open and close states""" _inherit = 'sale.order' state = fields . Selection ( selection_add = [( 'open' , 'Open' ), ( 'close' , 'Close' )])
Enterprise Inherit the form view of sale.order First, inherit the form view. In order to view the states in the form, we need to include the 'states' attribute along with the 'statusbar_visible' attribute. This is necessary because the default configuration of the 'sale.order' view sets the 'statusbar_visible' attribute.
Enterprise <?xml version="1.0" encoding="UTF-8" ?> < odoo > < record id = "view_order_form" model = "ir.ui.view" > < field name = "name" >view.order.form.inherit.sale.open.close</ field > < field name = "model" >sale.order</ field > < field name = "inherit_id" ref = "sale.view_order_form" /> < field name = "arch" type = "xml" > < xpath expr = "//header/field[@name='state']" position = "replace" > < field name = "state" widget = "statusbar" statusbar_visible = "draft,sent,sale,open,close" /> </ xpath > </ field > </ record > </ odoo >
Enterprise
For More Info. Check our company website for related blogs and Odoo book. Check our YouTube channel for functional and technical videos in Odoo. Enterprise www.cybrosys.com