0

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

0 Answers0