Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
3 Ответы
16531 Представления

I am using OdooV10. I need to know how to get list of methods in models, both custom and default. So i can know the purpose of each models by looking on the list without searching it manually.

Is anyone have any idea ?

Thanks

Аватар
Отменить
Лучший ответ

Go in debug mode the go back i setting, under database, you got models, there you have the list of models (and much more info)


Аватар
Отменить

unfortunately, this is not exactly what was the poster was asking

Лучший ответ

Hello Ajeng,

In the database you can't see method list in the UI, because methods does not store in database.

You have to manually search them into the source code. 

Аватар
Отменить
Лучший ответ

Keep in mind, that you are dealing with python objects, therefore you could use object inspection easily.

The simplest method is to use the Shell in odoo:

#starts the odoo shell

/odoo/src/odoo-bin shell -c /odoo/odoo.conf -d db -r <dbusername> -w <dbpassword> 

dir()

from odoo.service import db

db.list_dbs()

model = self.env['res.partner']

#define a function to return the information about the methods

# http://www.diveintopython.net/power_of_introspection/index.html for more information 

def info(object, spacing=10, collapse=1): 1 2 3

    """Print methods and doc strings.

   

    Takes module, class, list, dictionary, or string."""

    methodList = [method for method in dir(object) if callable(getattr(object, method))]

    processFunc = collapse and (lambda s: " ".join(s.split())) or (lambda s: s)

    print "\n".join(["%s %s" %

                      (method.ljust(spacing),

                       processFunc(str(getattr(object, method).__doc__)))

                     for method in methodList])


info(model)


#result

#union Return the union of ``self`` with all the arguments (in linear time complexity, with first occurrence order preserved).

#unlink Override unlink to delete messages and followers. This cannot be cascaded, because link is done through (res_model, res_id).

#update Update the records in ``self`` with ``values``.

#... many more

Аватар
Отменить
Related Posts Ответы Просмотры Активность
1
июл. 25
391
Search a message Решено
1
февр. 25
1211
3
авг. 24
1581
0
сент. 23
2151
2
июн. 23
3910