Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
I use a python library in the form:
def __init__(self, arg1, arg2): ... def fct1(self):
... return something
Directly in python:
x = SomeClass(arg1,arg2)
create an object alright.
I would like to do the same in Odoo. I tried the following:
def connect(self, arg1, arg2):
x = connect(arg1,arg2)
NameError: global name 'connect' is not defined
How should I use my python library?
x = self.connect(arg1,arg2)
when you call in SomeClass or (when SomeClass is instance)
x = SomeClass.connect(arg1,arg2)
_name = 'my.class'
MyClass = self.env['my.class'] # create instance
result = MyClass._test(2,3)
Example 2: myclass.py in folder myaddons
def __init__(self, name):
self.name = name
in other Odoo class:
from openerp.addons.myaddons.myclass import MyClass
x = MyClass('Hello')
y = x._test(2,3)
It works fine. Thank you a bunch for your help zbik!!
I thought that by declaring the code in the __init__.py code of that directory (models):
I could use it but it seem it is not the case and when importing it directly in the Odoo Class; the methods are available to be called.
About This Community
This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 11/25/16, 5:50 AM|
|Seen: 694 times|
|Last updated: 11/26/16, 3:07 AM|