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

Hello,

I started odoo addons development (and python) 6 months ago.

What are best practices regarding code re use ?

Here is my scenario :

  • I need to write an helper class for calling external APIs

  • I need to instanciate this class in several addons, and/or in several models inside the same addon.

What would be your recommendation ?

  • Writing a python library, and install it on the server ?

  • Make the helper classes part of a 'technical' addon, and make other addons depend on this 'technical' addon ?

  • other ?

Thanks for any advice.

- Chris.

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

By inheriting model and views: https://goo.gl/fGNfBY

Лучший ответ

Hi,

You can do a similar implementation like mail.thread class in Odoo, where all the mail related functionalities is added and based on the need user can inherit this model into his class.

So in the same module or in different module, you can add your common functionalities in a model/class and later inherit it to the models you need and re use it.


Thanks

Аватар
Отменить
Related Posts Ответы Просмотры Активность
2
авг. 24
1447
2
февр. 25
1246
0
дек. 24
910
1
мар. 15
4172
1
мар. 15
25996