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

Routing conflicts (web controllers) - how to deal, how to solve, how to keep them clean?

اشتراك

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

لقد تم الإبلاغ عن هذا السؤال
routingwerkzeugroutesv15webcontroller
1 الرد
6256 أدوات العرض
الصورة الرمزية
Krys.Raj

I have questions for experienced developers:

I am trying to create new custom web controller route. But I do find some troubles here. Let me put down the example. Image this situation:

custom controller:

@http.route(['/<path:custom_path>/'], type='http', auth='public', website=True)
def render_new_template(self, **post):

is conflicting with basic controller:

@http.route('/', type='http', auth="public", website=True, sitemap=True)
def index(self, **kw):

The effect of above code is:

  • when I request website.com/custom_path/ URL - it works perfectly and renders my custom template
  • when I request a core page website.com/page URL - it starts to render it with my new custom template, which is not the effect I want

How to deal with routing in such situation? I do really want to have the same short URLs without additional path like following:

/additional_path/<path:custom_path>/

or even short one:

/c/<path:custom_path>/

I did some research as odoo web controller routing is based on werkzeug, so I found some recommendations but neither was precise enough for Odoo.

The following solutions were mentioned:

  • do it with custom converter
  • do it with Importing werkzeug.routing, creating own map implementation, changing werkzeug.routing.Map to own implementation
  • use "url_for" (probably only in case of Flask) which allows you to point to the

app.py:

app.route('/<path:pattern1>')
app.route('/<path:pattern1>/<path:pattern2>')
def catch_all(pattern1, pattern2=None):
return render_template('template.html', p1=pattern1, p2=pattern2)

app.route('/test')
def test_routing:
args = {'pattern1': 'Posts', 'pattern2': 'create'}
return render_template('test.html', args=args)

test.html:

click here

I know there is a url_for functionality in odoo but it is not doing exactly the same - it is pointing to the path not to the method of this route

I will be really grateful for help, and donate any guy that will help, explain and suggest kind of wise and pretty solution for my case.


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

You can get some idea of odoo controllers: https://learnopenerp.blogspot.com/search?q=controller

الصورة الرمزية
Jort de Vreeze
أفضل إجابة

A bit late, but nonetheless. I have been struggling with this issue a lot (especially with multi websites). I found a work-around which works, but probably is not ideal.

Custom Controller:

from odoo.http import request
from odoo.addons.website.controllers.main import Website

class Main(Website):

    @http.route('/<name>', auth='public', website=True)
    def custom_route(self, name, **kwargs):
        if name == 'custom_path':
        # Business logic here
    return request.render(
                'template', {
                    'key' : value,
                }
            )
        return super(Website, self).index(**kwargs)

If the path meets a specified criteria ('custom_path' in above example) use the custom route and render whatever it needs to render, otherwise use the default route.

I hope this answers your question.

3
الصورة الرمزية
إهمال
Paul YPI

Jort, Thanks for sharing; having a simple example that works really helped me.

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

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

تسجيل
المنشورات ذات الصلة الردود أدوات العرض النشاط
AttributeError: module 'werkzeug.routing' has no attribute 'NumberConverter' تم الحل
database routing werkzeug v15
الصورة الرمزية
الصورة الرمزية
الصورة الرمزية
2
نوفمبر 23
22033
V15 CE Buy or Make (Manufacture) تم الحل
routes v15
الصورة الرمزية
الصورة الرمزية
2
مايو 22
3039
Need hints on configuring production routes for my business case تم الحل
manufacturing routes v15
الصورة الرمزية
الصورة الرمزية
2
يناير 23
2660
AttributeError: module 'werkzeug.routing' has no attribute 'NumberConverter'
postgresql nginx werkzeug v15
الصورة الرمزية
الصورة الرمزية
الصورة الرمزية
الصورة الرمزية
3
يوليو 25
9838
How to automatically create a purchase order per sales order? تم الحل
inventory quickstart routes mto v15
الصورة الرمزية
الصورة الرمزية
2
أبريل 25
23466
المجتمع
  • دروس
  • التوثيق
  • المنتدى
مصدر مفتوح
  • تحميل
  • جيت هاب "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