为什么我的odoo xml记录数据没有更新

问题描述 投票:0回答:1

我继承了一个模块(招聘模块),然后尝试更新xml数据,但我所有的尝试都不起作用。

我尝试更新像 hr_recruitment.group_hr_recruitment_user 这样的组,但更新仍然无法正常工作。

查看我的代码: 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>

蟒蛇->

from odoo import models, fields, api, _

类 hrRecruitmentStageInherit(models.Model): _inherit = "hr.招聘.阶段"

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)

清单->

{
'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

],

}

我期待记录被存档

python xml record erp odoo-16
1个回答
0
投票

这些记录被标记为“不可更新”。您需要将

noupdate
设置为
False
,更新记录,然后将
noupdate
重置为
True

示例:

<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>
© www.soinside.com 2019 - 2024. All rights reserved.