Search code examples
pythonxmlrecorderpodoo-16

Why is my odoo xml record data not updating


I inherited a module (Recruitment module) and then tried updating the xml data but all my attempt is not working.

I tried updating group like hr_recruitment.group_hr_recruitment_user but the update is not working still.

See my codes: xml ->

<?xml version='1.0' encoding='utf-8'?>
<odoo>
    <data noupdate="0">
    
        <record id="hr_recruitment.stage_job1" model="hr.recruitment.stage">
            <field name="active">0</field>
        </record>
        <record id="hr_recruitment.stage_job2" model="hr.recruitment.stage">
            <field name="active">0</field>
        </record>
        <record id="hr_recruitment.stage_job3" model="hr.recruitment.stage">
            <field name="active">0</field>
        </record>
        <record id="hr_recruitment.stage_job4" model="hr.recruitment.stage">
            <field name="active">0</field>
        </record>
        <record id="hr_recruitment.stage_job5" model="hr.recruitment.stage">
            <field name="active">0</field>
        </record>
    
    </data>
    
</odoo>

python ->

from odoo import models, fields, api, _

class hrRecruitmentStageInherit(models.Model): _inherit = "hr.recruitment.stage"

group_ids = fields.Many2many('res.groups')
stage_type = fields.Selection(
    selection=[
        ('initiation', 'Initiation'),
        ('interview', 'Interview'),
        ('selection_process', 'Selection Process'),
        ('documentation', 'Documentation'),
        ('audit', 'Audit'),
        ('accounts_finance', 'Accounts / finance'),
        ('background_checks', 'Background Checks')
    ],
    string='Stage Type'
)

active = fields.Boolean(default=True)

manifest ->

{
'name': "HR CBT Recruitment ",

'sequence': 10,

'depends': [
    'base',
    'hr_recruitment',
    'hr_recruitment_survey',
    'website_hr_recruitment',
     'hr_recruitment_sign',
],

'data': [
    'security/ir.model.access.csv',
    'security/security_view.xml',
    'views/hr_recruitment_stage_inherit.xml',
    'data/hr_recruitment_data.xml',  # Where the records are

],

}

I was expecting the records to be archived


Solution

  • In update mode, the record won't be updated if the data node explicitly opt-out using @noupdate="1". Those records are marked Non Updatable

    You need to set noupdate to False and update records (then reset the noupdate to True)

    Example:

    <function name="write" model="ir.model.data">
        <function name="search" model="ir.model.data">
            <value eval="[('name', '=like', 'stage_job_'), ('model', '=', 'hr.recruitment.stage')]"/>
        </function>
        <value eval="{'noupdate': False}"/>
    </function>
    
    <record id="hr_recruitment.stage_job1" model="hr.recruitment.stage">
        <field name="active">0</field>
    </record>
    <record id="hr_recruitment.stage_job2" model="hr.recruitment.stage">
        <field name="active">0</field>
    </record>
    <record id="hr_recruitment.stage_job3" model="hr.recruitment.stage">
        <field name="active">0</field>
    </record>
    <record id="hr_recruitment.stage_job4" model="hr.recruitment.stage">
        <field name="active">0</field>
    </record>
    <record id="hr_recruitment.stage_job5" model="hr.recruitment.stage">
        <field name="active">0</field>
    </record>
    
    <function name="write" model="ir.model.data">
        <function name="search" model="ir.model.data">
            <value eval="[('name', '=like', 'stage_job_'), ('model', '=', 'hr.recruitment.stage')]"/>
        </function>
        <value eval="{'noupdate': True}"/>
    </function>