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

I would like to add 1 or 2 more statuses in the repair module,


Currently by default they are;

New 

Confirmed

Under Repair

Repaired

Cancelled


I have tried to edit this throught the studio and get the following error message

Invalid Operation

Properties of base fields cannot be altered in this manner! Please modify them through Python code, preferably through a custom addon!

 

I am not a programer but can follow steps, can someone guide me through how to do this please.


It would be much appreciated.

Avatar
Descartar
Mejor respuesta

Hi, I'm afraid this could be only done with programming. Maybe an option for you would be separate field you can create in studio, that will store this info for you?

Avatar
Descartar
Mejor respuesta

Hi,


To add additional statuses, inherit the repair.order model and use selection_add to add new statuses:


# -- coding: utf-8 --

from odoo import fields, models


class RepairOrder(models.Model):

    _inherit = 'repair.order'


    state = fields.Selection(selection_add=[

        ('status1', 'Status 1'),

        ('status2', 'Status 2'),

    ])


You can replace status1 and status2 with the desired names.


Also, in the XML, modify the statusbar_visible attribute correctly to include the new statuses:

XML

<?xml version="1.0" encoding="utf-8"?>

<odoo>

    <record id="view_repair_order_form" model="ir.ui.view">

<field name="name">repair.order.form.inherit</field>

<field name="model">repair.order</field>

<field name="inherit_id" ref="repair.view_repair_order_form"/>

        <field name="arch" type="xml">

            <xpath expr="//field[@name='state']" position="attributes">

<attribute name="statusbar_visible">draft,confirmed,status1,status2,under_repair,done</attribute>

            </xpath>

        </field>

    </record>

</odoo>


Ensure these files are in the correct directory structure within your custom module. Update the __manifest__.py file to include the XML file path in the data list and add repair in the depends list.



Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
1
nov 24
4450
1
sept 24
1206
1
sept 24
1106
2
sept 24
1541
0
jul 24
802