Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
990 Tampilan

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
Buang
Jawaban Terbai

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
Buang
Jawaban Terbai

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
Buang
Post Terkait Replies Tampilan Aktivitas
1
Nov 24
4497
1
Sep 24
1272
1
Sep 24
1158
2
Sep 24
1594
0
Jul 24
817