تخطي للذهاب إلى المحتوى
أودو القائمة
  • تسجيل الدخول
  • جرب مجاناً
  • التطبيقات
    المالية
    • المحاسبة
    • فوترة
    • النفقات
    • جدول البيانات (BI)
    • المستندات
    • توقيع إلكتروني
    المبيعات
    • إدارة علاقات العملاء
    • المبيعات
    • نقطة البيع للمتاجر
    • نقطة البيع للمطاعم
    • الاشتراكات
    • تأجير
    المواقع الإلكترونية
    • أداة بناء المواقع الإلكترونية
    • متاجر إلكترونية
    • مدونة
    • المنتدى
    • دردشة مباشرة
    • التعليم الإلكتروني
    سلسلة التوريد
    • المستودعات
    • التصنيع
    • إدارة دورة حياة المنتج
    • المشتريات
    • الصيانة
    • الجودة
    الموارد البشرية
    • موظفون
    • التوظيف
    • إجازة عمل
    • التقييمات
    • الإحالات
    • تطبيق الأسطول
    التسويق
    • التسويق الإجتماعي
    • التسويق عبر البريد الإلكتروني
    • التسويق عبر الرسائل النصية
    • فعاليات
    • أتمتة التسويق
    • الاستطلاعات
    الخدمات
    • المشاريع
    • الجداول الزمنية
    • الخدمة الميدانية
    • مكتب المساعدة
    • التخطيط
    • مواعيد
    اﻹنتاجية
    • مناقشة
    • الموافقات
    • إنترنت الأشياء "IoT"
    • بروتوكول ربط المحادثات الصوتية عبر الإنترنت
    • المعرفة
    • WhatsApp
    التطبيقات الخارجية ستوديو أودو منصة أودو السحابية
  • قطاعات الأعمال
    البيع بالتجزئة
    • متجر كتب
    • متجر ملابس
    • متجر أثاث
    • متجر بقالة
    • متجر معدات
    • متجر ألعاب
    الطعام والضيافة
    • بار وحانة
    • المطعم
    • مطعم للوجبات السريعة
    • نزل للضيوف
    • موزّع مشروبات
    • فندق
    العقارات
    • وكالة عقارات
    • شركة هندسة معمارية
    • البناء
    • إدارة العقارات
    • العناية بالحدائق
    • اتحاد مُلاّك العقارات
    استشارة
    • مؤسسة محاسبية
    • شريك أودو
    • وكالة تسويقية
    • منشأة قانونية
    • استقطاب المواهب
    • التدقيق والتوثيق
    التصنيع
    • الأقمشة
    • معدني
    • الأثاث
    • الطعام
    • مصنع خمور
    • هدايا الشركات
    الصحة واللياقة البدنية
    • نادي رياضي
    • متجر نظارات
    • مركز لياقة بدنية
    • الممارسون الصحيون
    • صيدلية
    • صالون تصفيف الشعر
    التجارة
    • عامل صيانة
    • الأجهزة والمعدات التقنية ودعمها
    • أنظمة الطاقة الشمسية
    • صانع أحذية
    • خدمات التنظيف
    • خدمات التكييف (HVAC)
    غير ذلك
    • منظمة غير ربحية
    • وكالة بيئية
    • تأجير لوحات إعلانية
    • تصوير
    • تأجير دراجات
    • بائع وسيط للبرمجيات
    تصفح كافة قطاعات الأعمال
  • مجتمع أودو
    تعلم
    • دروس
    • التوثيق
    • شهادات
    • التدريب
    • مدونة
    • بودكاست
    قم بتعزيز التعليم
    • برنامج تعليم
    • Scale UP! لعبة الأعمال
    • قم بزيارة أودو
    احصل على البرنامج
    • تحميل
    • قارنْ الإصدارات
    • إطلاق
    تعاون
    • جيت هاب "Github"
    • المنتدى
    • فعاليات
    • الترجمات
    • كنْ شريكاً
    • خدمات الشركاء
    • سجل مكتب المحاسبة الخاص بك
    احصل على الخدمات
    • اعثر على شريك
    • اعثر على محاسب
    • قابل أحد مرشدي الأعمال
    • خدمات التنفيذ
    • مراجع العملاء
    • الدعم
    • الترقيات
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    الحصول على عرض توضيحي
  • الأسعار
  • المساعدة

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • إدارة علاقات العملاء
  • e-Commerce
  • المحاسبة
  • المخزون
  • PoS
  • المشروع
  • MRP
All apps
يجب أن تكون مسجلاً حتى تتفاعل مع المجتمع.
كافة المنشورات الأفراد الشارات
علامات التصنيف (عرض الكل)
odoo accounting v14 pos v15
حول هذا المنتدى
يجب أن تكون مسجلاً حتى تتفاعل مع المجتمع.
كافة المنشورات الأفراد الشارات
علامات التصنيف (عرض الكل)
odoo accounting v14 pos v15
حول هذا المنتدى
المساعدة

How to import odoo module?

اشتراك

تسلم الإشعارات عندما يكون هناك نشاط في هذا المنشور

لقد تم الإبلاغ عن هذا السؤال
pythonmoduleimportinheritancewiki
21 الردود
39221 أدوات العرض
الصورة الرمزية
Temur

In order to extend or override controller function in odoo, it's necessary to extend it as normal python class (see controllers reference ). To do so, we'll need to import the original module of controller class, but normally odoo modules are not on the sys.path... so we can't import them directly. How to import then odoo module in order to override a controller in our module?

3
الصورة الرمزية
إهمال
الصورة الرمزية
Axel Mendoza
أفضل إجابة

all the Odoo modules are added to the openerp.addons package, your controller A in the module testx could be imported in the module testy like:

from openerp.addons.testx.controllers.main import A
...
class my_controller(A):
@api.route()
def controller_func(self,**kw):
result = super(my_controller,self).controller_func(**kw)
       # your stuff here....
       return result

 

3
الصورة الرمزية
إهمال
Temur
الكاتب

@Alex, your box is too small :D What about community modules? they surely are outside of openerp.addons package? As I suggest in my answer, openerp.conf.addons_paths way guarantees to include any module path (community or custom) and so, import them successfully. And if you have any custom module, it's not a recommended way to add your odoo modules to the original module folder of odoo. What about custom odoo modules, at custom path? You should ask me about, if you had some doubts buddy, I just listed 2 cases where your answer can't work... you'd better mark my answer as accepted instead of inaccurate downvote

Temur
الكاتب

Do you know where community modules are stored as you install them in Odoo?

Axel Mendoza

Odoo add every module that get loaded into the package openerp.addons, take a look at:

def initialize_sys_path(): 
""" Setup an import-hook to be able to import OpenERP addons from the different addons paths. This ensures something like ``import crm`` (or even ``import openerp.addons.crm``) works even if the addons are not in the PYTHONPATH. """
Temur
الكاتب

It does not worked for me in case of community module. You think I've not tried simple "import module" statement before going to this workaround?

Axel Mendoza

I not mean:

import module
I mean:
import openerp.addons.module
Axel Mendoza

Odoo do this:

sys.modules['openerp.addons.' + module_part] = mod
for every module that need to be loaded
Temur
الكاتب

Nice, "import openerp.addons.module" is a much simpler then a workaround I found, I'll try it. But, it's not intuitive to me, to use "openerp.addons.module" for a python module that is actually far away from addons directory.

Axel Mendoza

It joins all the addons modules found in all the addons_paths in that package(that not means that odoo copy the module to the /openerp/addons folder) so a module with the same name of one in the get replaced the original one.

Temur
الكاتب

quote: "This ensures something like ``import crm`` (or even ``import openerp.addons.crm``) " means "import module" should work as well, and "import openerp.addons.module" indicated as an additional functionality to this...

Temur
الكاتب

And I can confirm that for "import module" that's NOT a case, you can't import community or custom module with just "import module" way (regardless of the comment quoted from odoo code), and if one does not investigates code as does @Alex, then it's not intuitive to use "import openerp.addons.module" for other modules then modules really located in odoo addons folder. I read once again my question post on this thread and I do not find anything wrong with it, all the details provided in my question post are exact and accurate, and it's downvoted, I do not get you buddies. And this question makes sense, because of existence of community modules and custom modules, outside of default addons path, what was actual problem for me (to be exact, the community one), and my answer here was perhaps ugly but complete and working solution, downvoted as well (relatively acceptable downvote compared to downvote of the question above). Your answer @Alex provide us with much more elegant way to solve the problem, so I'll mark it as accepted, I want to have marked as accepted the best answers on my questions, counting that I do not always get one. Thanks

Temur
الكاتب

* @Axel, not Alex :)

Axel Mendoza

it's a valid question, I upvote it to get it > 0

Temur
الكاتب

Thanks @Axel :) BTW I figured out that I've some mysterious fan on this forum, it's Dr Obx, it was he, who downvoted my question above. He is very interesting person, first he downvoted question and I got -1, then he took back his downvote and the -1 turned in zero(but it leaves effect of -1 in this forum). He've also downvoted few other questions/answers and I've got 6 negative vote from him, by now his votes some are -1, some are 0 (0 means he took back his vote, either negative or positive, but on this post I've seen that it was negative), but not even one +1... Perhaps as a being human I happen to write bad Q/A sometimes, but not always I think... and there is other interesting pattern in his behavior as well, he generally downvotes already upvoted posts (for example this one), so his downvote stays invisible, downvote to this post was an exception to this pattern, but it was part of another, he takes back his downvotes, when it's no more invisible. For now, he is author of about half negative votes I ever got on this forum (in contrast of being far from authoring half of positive votes), and all of -1 are invisible according his pattern, he first show his face on this post. I simply interested if I gave him any vote, and that's a case, I upvoted +1 his post once, in addition to helping him and accompanying him down to the solution, and that's all my votes to him. For now, I understand his behavior and when and how and according which patterns he follows me, but I do not yet understand why, because all his downvotes are far from being honest :) of course I'm not going to do same to him, as he will run out of the necessary carma to post anything here, and so, I'll stay with no fans, now at least I have interesting one :)

Temur
الكاتب
maybe he'll respond there? He may have some original idea though... who knows...
Axel Mendoza

Sorry to hear that. Maybe he could bring a light to his behavior

Temur
الكاتب

No, you have not to be, We have not to be sorry... he's just exception fortunately, "Dr Dislike", most of people are cool out there... Only thing I'm sorry about is that I spent too much time to investigate his behavior on this forum... But it was interesting anyway, as a new thing :) Next time I'll ignore such cases if any...

Temur
الكاتب

for anyone interested, this way was posted somewhere on this forum, you can put it into the browser console:

var get_likes_by_post = function(post_id) {
    openerp.jsonRpc('/web/dataset/call_kw', 'call', {
        model: 'forum.post.vote',
        method: 'search_read',
        args: [[['post_id','=',post_id]], ['user_id', 'vote']],
        kwargs: { context: openerp.website.get_context()}
    }).then(function(result) { 
        function vote(x) { 
            this.user_name = x.user_id[1];
            this.user_id = x.user_id[0];
            this.vote = parseInt(x.vote);
        }
        res = [];
        _.forEach(result, function(x){ res.push(new vote(x)); }); 
        console.table(res, ['vote','user_id','user_name']);
    })
}
for this question post, it'll like:
get_likes_by_post(87139)
Axel Mendoza

In the case that you need it, I migrate that script to Odoo Forum v9, see it at:
https://www.odoo.com/es_ES/forum/help-1/question/how-to-know-who-vote-for-your-questions-or-answers-in-odoo-forum-v9-script-update-94628

mustafa

It doesn't work for me!, i can't import a custom module, i just need to put my custom module or the community module under /odoo/openerp/addons/ directory so that i can use import from openerp.addons.mymodule

Axel Mendoza

Hi Mustafa, seems that your modules are not loaded correctly because you don't set correctly the addons_path option in the config or command-line

الصورة الرمزية
Temur
الكاتب أفضل إجابة

Adding those modules to sys.path just before importing it in our python code may be a solution if we know/find path to the imported module, but such code may NOT be portable in some cases. fortunately there is pretty nice solution if we consider to use configuration entry inside the odoo: openerp.conf.addons_paths, using value of this config we can find/import odoo module as follows:

from openerp import conf
import imp

fp, pathname, description = imp.find_module('odoo_module_to_import',conf.addons_paths)
module_mod = imp.load_module('odoo_module_to_import', fp, pathname, description)

that's it. in the module_mod we have imported odoo module named "odoo_module_to_import". If we imagine that odoo modules are on the sys.path and we can import them directly, then the above code should be equivalent of :

import odoo_module_to_import as module_mod

now you can use module_mod in order to inherit your own controller from it and override/extend functions in the parent controller, for example:

class my_controller(module_mod.controllers.parent_controller):
@api.route()
def controller_func(self,**kw):
result = super(my_controller,self).controller_func(**kw)
# your stuff here....
return result

1
الصورة الرمزية
إهمال
mustafa

This solution worked for me

الصورة الرمزية
omar bahri
أفضل إجابة

i create page has 3 classes and every class inherit from model

it is work for first time then show to me Key error

0
الصورة الرمزية
إهمال
Axel Mendoza

I don't see anything related, could you explain a little more your issue? or post a question with your code so someone could help you to fix your issue

هل أعجبك النقاش؟ لا تكن مستمعاً فقط. شاركنا!

أنشئ حساباً اليوم لتستمتع بالخصائص الحصرية، وتفاعل مع مجتمعنا الرائع!

تسجيل
المنشورات ذات الصلة الردود أدوات العرض النشاط
ImportError: No module named wizard تم الحل
module import
الصورة الرمزية
الصورة الرمزية
1
ديسمبر 22
17740
How to Change the property of inherited field in OpenERP?
python inheritance
الصورة الرمزية
0
مارس 15
6046
create a module through interface?
python module
الصورة الرمزية
الصورة الرمزية
1
مارس 15
5219
Error In Open Erp when create new module
python module
الصورة الرمزية
0
مارس 15
4815
How to override a method and continue using the same method variables? v16 تم الحل
import inheritance V16
الصورة الرمزية
الصورة الرمزية
1
يونيو 24
2767
المجتمع
  • دروس
  • التوثيق
  • المنتدى
مصدر مفتوح
  • تحميل
  • جيت هاب "Github"
  • المشغل الآلي رنبوت
  • الترجمات
خدماتنا
  • استضافة أودو إس إتش
  • الدعم
  • الترقية
  • التطويرات المخصصة
  • التعليم
  • اعثر على محاسب
  • اعثر على شريك
  • كنْ شريكاً
معلومات عنا
  • شركتنا
  • أصول العلامة التجارية
  • اتصلْ بنا
  • الوظائف
  • فعاليات
  • بودكاست
  • مدونة
  • عملاء
  • قانوني • الخصوصية
  • الحماية
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

أودو هو عبارة عن مجموعة من تطبيقات الأعمال مفتوحة المصدر التي تغطي جميع احتياجات شركتك، مثل: إدارة علاقات العملاء والتجارة الإلكترونية والمحاسبة والمخزون ونقاط البيع وإدارة المشاريع وما إلى ذلك.

ما يجعل من أودو مميزاً هو هدفه بأن يكون سهل الاستخدام للغاية ومتكاملاً تمامًا في الوقت ذاته.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now