【问题标题】:Odoo V10 - Retrieve a value a previous record for same modelOdoo V10 - 检索相同模型的先前记录的值
【发布时间】:2018-10-12 09:52:43
【问题描述】:

这是我的计算字段函数:

# Fonction qui récupère la valeur du champs booléen inscription de l'année précédente
    @api.depends('half_pension')
    def _retrieve_halfpension_previous(self):
        for record in self:
            if record.half_pension:
                record.half_pension_previous = record.half_pension

这里是我的字段:

half_pension = fields.Boolean(string='Catering', copy=False)
half_pension_previous = fields.Boolean(string='previously registered', copy=False, store=False,
                                       compute='_retrieve_halfpension_previous')

这是我的看法:

<!-- Vue Tree enfants scolarisés cantine-->
    <record model="ir.ui.view" id="halfpension_view_tree">
        <field name="name">halfpension.view.tree</field>
        <field name="model">ecole.partner.school</field>
        <field name="arch" type="xml">
            <tree editable="bottom" default_order="half_pension_id" string="school_halfpension_tree">
                <field name="partner_id" readonly="1" />
                <field name="half_pension" />
                <field name="half_pension_id" />
                <field name="school_name_id" />
                <field name="half_pension_begin_date" />
                <field name="half_pension_end_date" />
                <field name="half_pension_text" />
                <field name="half_pension_previous" />
                <field name="default_school_year" invisible="1" />
            </tree>
        </field>
    </record>

目前,我在字段“”中获得了相同的“”值。但是,我想检索同一合作伙伴的前一条记录的值,而不是当前记录。怎么做 ?谢谢

【问题讨论】:

    标签: python odoo


    【解决方案1】:

    您可以将记录保存到合作伙伴字段中,以便能够跟踪该合作伙伴的最后一条记录。您将需要根据您想要的事件更改合作伙伴中的记录。例如,在通过覆盖 ecole.partner.school 模型的 create 方法创建的新记录上,将创建的记录附加为合作伙伴的最后一条记录。

    然后根据合作伙伴附加记录 half_pension 字段解析 half_pension_previous 字段的值

    【讨论】:

      猜你喜欢
      • 2020-01-31
      • 2016-04-28
      • 1970-01-01
      • 1970-01-01
      • 2023-03-27
      • 2019-02-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多