Search code examples
viewmodelodooadd-on

Odoo Model function override has no effect


What I'm trying to do:

Im developing a POS module for Odoo.

When creating a new payment method for odoo pos, theres a 'use payment terminal' section that has a list of all available payment terminals. This list is a computed field in the DB called 'use_payment_terminal'. I want to add my custom module to that selection.

What i've already done:

  1. The computed field is populated by a '_get_payment_terminal_selection' function that I overrodde:
def _get_payment_terminal_selection(self):
    return super(PosPaymentMethod, self)
             ._get_payment_terminal_selection() + [('xxx', 'xxx')] 
  1. I added a post init hook that tried to calls the above function directly, cause I wasn't sure want the problem was and assumed that the function wasn't being called when expected.

The problem:

Neither of these solutions has worked and the selection still doesn't display what I expect it to. Any suggestions on why that might be ?


Solution

  • Try this way :

    def _get_payment_terminal_selection(self):
       return super(PosPaymentMethod, self)._get_payment_terminal_selection() + [('xxx', 'xxx')]