Se rendre au contenu
Menu
Cette question a été signalée
3 Réponses
6012 Vues

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
Ignorer
Meilleure réponse

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
Ignorer
Meilleure réponse

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
Ignorer
Auteur

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..

Publications associées Réponses Vues Activité
0
août 25
156
1
août 25
497
2
juil. 25
2954
3
juil. 25
700
1
juin 25
2189