Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
3911 Vistas

Can anyone help me to add a new status in the existing status bar in the quotation. I am using odoo version 14 enterprise edition.

Many thanks.

Avatar
Descartar
Mejor respuesta

You can use the selection_add property in a field definition for achieving this.

state = fields.Selection(selection_add=[('new_status', 'New Status')]

You can add the above code in a new module and also need to add it in the form view by inheriting it.


You need to create a new module for doing the above. You can check the official documentation for getting started with Odoo module development( Module development ). Then inside your module you need to inherit the "sale.order" model and add the field as suggested above. After that you need to add it in the form view of sales order(in an XML file) to see the field in the UI. You can check the documentation for inheritance here Inheritance


Detailed:

Create a folder inside your addons(or create a folder outside of it naming 'custom_addons' and add it in your addons_path) naming 'sale_order_new_status'. Inside that folder add an __init__.py file and __manifest__.py file. In the __initt__.py file you need to import the python files you are going to use for the new module. In the manifest file you can specify the module details and also add the XML files (Manifest File). Then add two folders naming 'models' and 'views' inside your module.

Inside the models folder add two python files naming __init__.py and sale.py. In the '__init__.py' file inside your module add the following line:

from . import models

Then in the __init__.py file inside models folder add the following line:

from . import sale

Then in the sale.py file add the following:

from odoo import fields, models
class SaleOrder(models.Model):
    _inherit = "sale.order"
    state = fields.Selection(selection_add=[('new_status', 'New Status')]


Then add the view inheritance in the sale_views file inside views directory and also mention the file name inside data section of the manifest file.


Then add the file to the manifest file(data section). Then you can go to "Update apps list" inside the Apps menu and then search for your module and install it. You may also need to add python methods for the transition from and to the new status added.

Avatar
Descartar
Autor

Since I am new to odoo can you help me where we can put the code and how to inherit it?

I have updated the answer. Hope you can use it to add the new status.

Mejor respuesta

Inherit model sale.order

then add state=fields.Selection(selection_add=[('new_status', 'New Status')]  in .py 

Inherit the form view sale.view_order_form and add the new status inside the statusbar_visible

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
2
may 22
2441
1
abr 22
2346
2
abr 25
1000
0
ene 24
169
1
oct 21
4631