Community Mailinglisten Archive

community@mail.odoo.com

Avatar

Iterating recordset with @api.multi and without.

durch
dxFactory EOOD, Dimitar Epitropov
- 22.11.2017 04:32:00

Hi community,

I would like to get a better feeling about when to use @api decorators and when not. I've read a lot about them, but I still don't have a good feeling. They are not very intuitive to me. I get the feeling that you have to use them on almost every method to control the behavior of self.
I am interested in the following example from account_invoice:

Here why don't we use @api.multi?

@api.onchange('amount_total')
def _onchange_amount_total(self):
    for inv in self:
        if inv.amount_total < 0:
            raise Warning(_('You cannot validate an invoice with a negative total amount. You should create a credit note instead.'))

Thanks,
Dimitar
--
Logo

Dimitar Epitropov | Odoo developer
+359 883 356 833

www.dXFactory.eu
Consulting | Project Outsourcing | Software Development

Mahnungen