How to resolve this error

The code I have done is followed below:

    is_beneficiary = fields.Function(fields.Boolean(
        'Is Beneficiary'), 'on_change_is_beneficiary')
    @fields.depends('is_beneficiary', 'bank_branch')
    def on_change_is_beneficiary(self, name=None):
        if self.is_beneficiary:
            if (self.bank_branch is None):
                self.raise_user_error('Bank Details Need to be Filled')
                return self.is_beneficiary

On executing the above code error is showing:
RecursionError: maximum recursion depth exceeded while calling a Python object

It better to separate on_change with the function method.

Using get_is_beneficianry will be better.

And you may consider for the bank details field using states to check boolean if true then required. It will be much more simpler

1 Like

The problem is you are using “is_beneficiary” value in the method that computes “is_beneficiary” value. So it gets on an infinite loop.

1 Like

Also you can not raise error in an on_change* method.

1 Like