Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
3 Risposte
6040 Visualizzazioni

Is there anything wrong with using AbstractModel instead of Model when I want "static class" functionality? 

I've read that AbstractModels are just like Models, just without the ORM. But, I've also read that they are not meant to be used directly, which is why I am hesitant and ask this question.

My use case is this:

I'm calling Odoo functionality from PHP through XMLRPC. I'm only calling Odoo model methods which do various tasks. These Odoo models don't really need do store anything in its own db table, I just want to use their methods to do something with other models. In other languages this functionality is "static classes".

Avatar
Abbandona
Risposta migliore

There is no issue to use AbstractModel actually main purpose of the AbstractModel to satisfied this kind requirement where we do not need any kind of DB schema change but fetch data and manipulate data from the various models/tables.

There are lots of examples available where AbstractModel used, mostly for dynamic report generation where data fetch and manipulate from various objects.

AbstractModel name is quite missing leading. in general abstract class means you could not directly use it's just blueprinted and have to inherit for used it but in odoo you can use AbstractModel directly :)

Avatar
Abbandona
Risposta migliore

Hello, 

https://www.odoo.com/documentation/12.0/webservices/odoo.html

Try this link, it has example of how you can make PHP xmlrpc call in odoo. 

you will get to know there you can use model name on which you want to perform some operation. 

There small example of create partner in odoo.

$id = $models->execute_kw($db, $uid, $password,
    'res.partner', 'create',
    array(array('name'=>"New Partner")));


Avatar
Abbandona
Autore

Yes, I know how to make PHP talk to Odoo, this is not the question though.. I want to have all functionality in 1 model, and wonder if this model can be abstract..

Post correlati Risposte Visualizzazioni Attività
1
ago 25
288
1
ago 25
582
2
lug 25
3036
3
lug 25
746
1
giu 25
2250