Community mailing list archives

community@mail.odoo.com

Avatar

Re: Iterating recordset with @api.multi and without.

by
LITEX Service Sp. z o.o., Michał Węgrzynek
- 22/11/2017 06:31:34

Hi!

@api.multi is implied in this context AFAIK -- if you don't use another decorator, Odoo acts, as if you used @api.multi.

Regards,

Michał


W dniu 22.11.2017 o 10:35, Dimitar Epitropov pisze:

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

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe


Reference