odoo exceptions cachemiss error on update module with computed field

淺唱寂寞╮ 提交于 2021-02-11 14:47:39

问题


I update an odoo module after adding one field that should be computed, after restart the server it works fine but when add the field in the xml view file I receive this error

odoo.exceptions.CacheMiss: ('rental.contract(13,).current_balance_amount', None)
...
...
...
ValueError: Expected singleton: rental.contract(13, 16, 17, 18, 19, 20, 21, 22, 23, 24, 

Here is below the python code

current_balance_amount = fields.Float(string='Current Balance Amount', default=0, compute='compute_rental_amounts')

@api.model
def compute_rental_amounts(self):
        # Get the paid and remaining amounts from invoices
        invoice = self.env['account.invoice'].search([('origin', '=', self.name)])
        if invoice:
            for item in invoice:
                if item.amount_total:
                    total_invoiced_amount += item.amount_total
                if item.state == 'open':
                    total_paid_amount = total_invoiced_amount - item.residual
            total_balance -= total_paid_amount
        self.current_balance_amount = total_current_balance_amount - total_paid_amount

来源:https://stackoverflow.com/questions/60128007/odoo-exceptions-cachemiss-error-on-update-module-with-computed-field

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!