تخطي للذهاب إلى المحتوى
أودو القائمة
  • تسجيل الدخول
  • جرب مجاناً
  • التطبيقات
    المالية
    • المحاسبة
    • فوترة
    • النفقات
    • جدول البيانات (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
حول هذا المنتدى
المساعدة

Is there a way to get the location to your Odoo and to create new files in your custom module?

اشتراك

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

لقد تم الإبلاغ عن هذا السؤال
locationfilesodoo8.0odoo-location
4 الردود
43617 أدوات العرض
الصورة الرمزية
Yenthe Van Ginneken (Mainframe Monkey)

Hi guys,

Rather specific question: Is there any way to find out where the Odoo is installed on Ubuntu (for example /odoo/odoo-server) and then get the addon path? I want to get the full path to my module in order to create a new file in this module.
I couldn't find any model / field that stores this..
The second thing that I am wondering is if there is any 'guideline' about creating new files inside an Odoo module? I want to create a script inside my module which will be generated and executed after some action in Odoo. Where is the best way to create a new file inside the custom module without the Odoo complaining?

Any ideas / tips?
Yenthe

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

Please check the following link for custom module:

https://youtu.be/Xya_fCNr6tw

Thanks & Regards

الصورة الرمزية
Yenthe Van Ginneken (Mainframe Monkey)
الكاتب أفضل إجابة

Hi guys,

Turns out there is a very basic statement for this. You can get the location of the Python file that is being executed so from there on you know the whole path. The code:

os.path.dirname(os.path.realpath(__file__)) 

If your Odoo is under /odoo/odoo-server and your addon is named auto_installer it will build the path /odoo/odoo-server/addons/auto_installer and from there on it is as simple as navigating to the folder and adding files.

6
الصورة الرمزية
إهمال
CARLOS ALBERTO GARCIA BRIZUELA

Excellent!

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

if you've full control over the odoo installation and you can make sure that module folder is writable, or using this as private solution, then creating files in the module directory is ok. But, if you're going to ship module, then it's NOT guaranteed that the module directory will be writable for odoo server instance. most probably, often it will not. for example for security reasons or when installed from .deb package... whereas, there is a "Data Directory", which is guaranteed to be writable to odoo server instance. Inside your module code, you can gather path of data directory as follows:

from openerp.tools import config

path_to_data_directory = config['data_dir']

Under Data Directory, there is a folder named "filestore" which is used to store files uploaded/stored with "ir.attachment" model (BTW, it's also option to use ir.attachment model in order to store new files, if applicable it's recommended to use it, there is nice implementation of filestore, avoiding duplicated files, etc, etc...). Conventionally we can add another folder, say "custom_filestore". also it may be meaningful to use database names under it, as it's under filestore directory, and module name as well(?)... then, path to a directory where we can save files, may be acquired like:

@api.model
def get_custom_data_dir(self):
    return os.path.join(config['data_dir'], "custom_filestore", "module_name", self.env.cr.dbname)

this way, you'll have separated folders in case of multiple databases. also, target directory will be always writable (worth to note, that directory itself may not exist for the moment, but the location will be always writable to the odoo server instance, whereas it's not guaranteed for module directory itself).

take look at how is filestore path calculated in original filestore implementation, you can see here


2
الصورة الرمزية
إهمال
Yenthe Van Ginneken (Mainframe Monkey)
الكاتب

Thanks for the detailed information Temur! I can't work from the filestore/database itself so I need to write the file inside the module. But that is no problem since the user running the Odoo service has access to the module that is being added, so that works out fine. I like the ideas and tips though, so +1!

الصورة الرمزية
Tarek Mohamed Ibrahim
أفضل إجابة

I'm Windows, but I decided to try.

I searched the source and tried the following code and got the home path of the odoo 

    def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
        import os
        dirpath = os.environ.get('HOME') or os.getcwd()

I just put it under the fields_view_get to run it immediately. Pls try this under the Ubuntu and I think it will help.

for the 2nd question, you now have the home path of your installation, you can now create any code and call it from say the create method and see.

1
الصورة الرمزية
إهمال
Yenthe Van Ginneken (Mainframe Monkey)
الكاتب

This will get you the first folder but it will not get you to the correct Odoo path if it is nested deeper in to folders though, which can happen.

Yenthe Van Ginneken (Mainframe Monkey)
الكاتب

I did give you an upvote since it put me in the right idea though! :)

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

There are function from odoo core 

from odoo.modules.module import get_resource_path
get_resource_path('base_einvoice', 'static/src', 'watermark.pdf')

it's have 3 parameters module name (required), folder_name in module (optional), file_name optionally also

0
الصورة الرمزية
إهمال
هل أعجبك النقاش؟ لا تكن مستمعاً فقط. شاركنا!

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

تسجيل
المنشورات ذات الصلة الردود أدوات العرض النشاط
In what files can I find the code of the top part of Odoo/OpenERP? Part with the search bar تم الحل
location files searchbar
الصورة الرمزية
الصورة الرمزية
2
أغسطس 15
4651
how to implement joint piece in odoo 8 in one view
odoo8.0
الصورة الرمزية
0
أبريل 24
2769
what is the reason behind extra move? in stock
odoo8.0
الصورة الرمزية
الصورة الرمزية
الصورة الرمزية
الصورة الرمزية
4
نوفمبر 23
6944
How to solve fields.function issue in odoo 8
odoo8.0
الصورة الرمزية
0
أكتوبر 23
2789
how to restrict create and delete access in one2many field tree view
odoo8.0
الصورة الرمزية
0
ديسمبر 22
3520
المجتمع
  • دروس
  • التوثيق
  • المنتدى
مصدر مفتوح
  • تحميل
  • جيت هاب "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