【问题标题】:How to auto fill a field by previous record value?如何通过以前的记录值自动填充字段?
【发布时间】:2016-01-14 06:00:57
【问题描述】:

在我的自定义模块中,有一个名为 closing_balance 的 float 类型的字段。收盘余额由 total_credit - total_debit 计算。我想在该特定员工时将 float 类型的字段 opening_balance 自动填充为 closing_balance 的值创建下一条记录。

【问题讨论】:

    标签: openerp odoo-8 autofill


    【解决方案1】:

    您需要覆盖该对象的 default_get 方法。

    def default_get(self, cr, uid, fields, context=None):
        if context is None:
            context = {}
        res = super(hr_expense_expense, self).default_get(cr, uid, fields, context=context)
    
        #here is your logic
        opening_balance = 111 #do calculation as per your requirements
    
        #update opening balance field 
        res.update({'openning_balance_field_name': opening_balance})
    
        return res
    

    【讨论】:

    • 无需计算期初余额。期初余额应在员工创建下一条记录时自动填充上一个收尾余额的值。
    猜你喜欢
    • 2018-05-28
    • 1970-01-01
    • 1970-01-01
    • 2023-03-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多