tinyerp / erppeek

A versatile tool for Odoo / OpenERP. *** Forked as Odooly ⟶
https://github.com/tinyerp/odooly
Other
171 stars 99 forks source link

onchange methods with new api not called correctly #88

Open esciara opened 8 years ago

esciara commented 8 years ago

While trying to solve #85 I came across the following problem.

Where as calling the onchange_sale_price method (with argument 'fixed', 'percentage' or 'formula') on a sale.config.settings transient object works fine, calling the onchange_company_id method (with an int company id as argument) on an account.config.settings transient object does not. It returns a TypeError: onchange_company_id() takes exactly 1 argument (5 given)

The only reason I could see for this to happen is that where as the first one is written with the old api:

    def onchange_sale_price(self, cr, uid, ids, sale_pricelist_setting, context=None):

where as the second one is written with the new api:

    @api.onchange('company_id')
    def onchange_company_id(self):

Do you confirm this analysis? Does this mean that erppeek does not support the new api correctly yet? Or should I call that method differently?

For information, this is how I call the first one:

    config_model = erppeek_client.model('account.config.settings')
    defaults = config_model.default_get(config_model.keys())
    config_transient_object = config_model.create(defaults)
    config_transient_object.onchange_company_id(config_transient_object.company_id.id)
    [..]

and this is how I call the second:

    config_model = erppeek_client.model('sale.config.settings')
    defaults = config_model.default_get(config_model.keys())
    config_transient_object = config_model.create(defaults)
    config_transient_object.onchange_sale_price('formula')
    [..]