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

Making use of Old API style method in Odoo 10.0

اشتراك

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

لقد تم الإبلاغ عن هذا السؤال
Odoo10.0BridgingOldAPINewAPIFunctionCall
3 الردود
7403 أدوات العرض
الصورة الرمزية
Komala Kiran Kumar. Parepalli

Hi Guys,

As per the Odoo documentation given at https://www.odoo.com/documentation/10.0/reference/orm.html#compatibility-between-new-api-and-old-api, it specifies I can make use of the old style method in Odoo 10.0 and the Odoo itself will decorate it appropriately (Automatic Bridging).

But I couldn't quite get it right. I have written a sample class with 2 methods one with Old API style and the Other with new API style, but I was unable to make a call to the old method successfully.


Here is the sample code I was using:

from odoo import models, fields, api

class SampleModule(models.Model):
_name = 'sample.module'

column_one = fields.Char("Column One")
column_two = fields.Char("Column Two")
column_three = fields.Char("Column Three")

def old_method(self, cr, uid, ids):
print self, cr, uid, ids
return True

def new_method(self):
return self.old_method()

Note: I even tried decorating the Old method with @api.cr_uid_ids

When I make a call to the new_method() from a button it is always returning with an error saying old_method requires 4 arguments but only 2 given.

File "/var/www/electrickiwi-nest/www/odoo/addons/web/controllers/main.py", line 889, in call_button
    action = self._call_kw(model, method, args, {})
  File "/var/www/electrickiwi-nest/www/odoo/addons/web/controllers/main.py", line 877, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "/var/www/electrickiwi-nest/www/odoo/api.py", line 682, in call_kw
    return call_kw_multi(method, model, args, kwargs)
  File "/var/www/electrickiwi-nest/www/odoo/api.py", line 673, in call_kw_multi
    result = method(recs, *args, **kwargs)
TypeError: old_method() takes exactly 4 arguments (2 given)


Can someone please help me with this. Not sure if I am missing anything here.

Thanks in advance.


0
الصورة الرمزية
إهمال
Esther Martín

I dont know which method is, but you should try api.multi, if that doesnt work it should be api.model

Komala Kiran Kumar. Parepalli
الكاتب

Hi Esther, Thanks for the suggestion.

As per my understanding on the Odoo documentation api.Model & api.Multi are to decorate on the new_method to make it callable from Old_method. (Call New API method from an Old API method). Not sure if I am missing anything but certainly I can try.

Thank you once again.

Raaj Mishra

Hi Kiran, if you find any solution for this pls update, as I also need the implement somthing like that, I am also trying the same from myside.

Raaj Mishra

I reviewed the doc and saw somthing like which we can try:

odoo.api.v8(method_v8)

Decorate a method that supports the new-style api only. An old-style api may be provided by redefining a method with the same name and decorated with v7():

@api.v8

def foo(self):

...

@api.v7

def foo(self, cr, uid, ids, context=None):

Komala Kiran Kumar. Parepalli
الكاتب

Hi Raaj, I actually tried this but didn't find it useful. As far as I understand it will be useful to have the same function with 2 different styles (Old & New API). But this is not useful if you want to have a function just in Old API style of coding.

Cheers.

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

Hey,

If you don't use any decorator for your old method to pass the values (in case you utilize an already existing method), try to pass the required parameteres directly through the environment (env):

self.old_method(cr=self.env.cr, uid=self.env.user.id, ids=seld.ids)
1
الصورة الرمزية
إهمال
Raaj Mishra

Yes it working thanks..just one spell mistake...ids=seld.ids it should be self.ids

Komala Kiran Kumar. Parepalli
الكاتب

Hey, thanks for the suggestion. But the question here is its not given in the documentation like that and the whole intention is to call an Old API style method using a button from the form.

If I want to use as you said then I need to write a wrapper method in New API style to call the old method for each method I want to make use of.

In the way, you suggested you are making them be treated as the explicit arguments/user defined arguments but not framework default arguments.

Anyways thanks for the suggestion.

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

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

تسجيل
المنشورات ذات الصلة الردود أدوات العرض النشاط
Is there any dictionary/material to convert Old API to New API?
odoo7 odoo11 OldAPI NewAPI
الصورة الرمزية
الصورة الرمزية
1
نوفمبر 17
5070
Readonly field disappears when saved in odoo 10.
Odoo10.0
الصورة الرمزية
الصورة الرمزية
1
مارس 23
3269
How to pass a value from sale.order to stock.picking? تم الحل
Odoo10.0
الصورة الرمزية
الصورة الرمزية
الصورة الرمزية
الصورة الرمزية
3
أغسطس 19
14172
READONLY PRICE UNIT تم الحل
Odoo10.0
الصورة الرمزية
الصورة الرمزية
7
يوليو 19
5462
how to change font size entire odoo frontend without website depedancey module
Odoo10.0
الصورة الرمزية
0
يونيو 19
3987
المجتمع
  • دروس
  • التوثيق
  • المنتدى
مصدر مفتوح
  • تحميل
  • جيت هاب "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