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

BUTTON performing QUERY with POSTGRESQL

اشتراك

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

لقد تم الإبلاغ عن هذا السؤال
functionmodulefieldsql
2 الردود
9196 أدوات العرض
الصورة الرمزية
Lakay lakay

Hi. im just new in Odoo, please guide me thanks

here is my scenario:

1.) I made a module name 'Shipping information' module here is my .py code

from openerp.osv import osv,fields

class si(osv.osv):

        _name='si'
        _columns ={
        'addr':fields.char('Shipping Address',size=100,required=True),
        'current':fields.boolean('Current'),
}
si()

as you can see it has 2 fields 1.) Shipping Address(char) which the user will input his address, 2.) Current (boolean), each address contains 'current' field  wherein it is with a 'button'.. if the user clicks the button it will toggle the boolean field of a certain record to 'true'.. here is my xml (just a snippet, dont worry it has no defect)

 here is the image to better appreciate : http://postimg.org/image/k0gjwlmcj/

<record model="ir.ui.view" id="view_si_tree">
        <field name="name">si.tree</field>
        <field name="model">si</field>
        <field name="type">tree</field>
        <field name="arch" type="xml">
            <tree string="Shipping Information">
                <field name="addr" />

                <button name="btnSet" string="Set" type="object"/>
            </tree>
        </field>

    </record>

as you can see i use type='object' (or am i wrong? ) because i will call a function which contains the query, im planning to make this function and add to .py file, unfortunately im not able to do that because the function is not finish yet.. can you help me? i want that when the button is pressed it will toggle the boolean variable to 'true' of that certain id.. how can i link this to the button i have made in the xml? 

def set_current_addr(self,cr,uid,ids,name,arg,context=None):

        res={}             #is this necessary? i just saw it in other sites
        cr.execute("""UPDATE si SET current='true' where id=ids;""")

        return res        #is this necessary? i just saw it in other sites

Please guide me so that i can continue my learning in odoo.

also is 'uid' in the function there the create_id i and the 'ids' the id n openerp?

 

0
الصورة الرمزية
إهمال
Emipro Technologies Pvt. Ltd.

Hey ! I hope you got the answer from the below. If yes then please accept it. Thanks.

الصورة الرمزية
Emipro Technologies Pvt. Ltd.
أفضل إجابة

Lakay,

It's so easy !

Your method should look like,

def set_current_addr(self,cr,uid,ids,name,arg,context=None):

   self.write(cr,uid,ids,{'current':True},context=context)

   return True

Here by calling write method it is itself applying update query and your current record will be updated. It is adviceable that don't write queries, instead of that use ORM functions. Write is one of the core methods of OpenERP framework. Still if you want to do by query then below is the code.

def set_current_addr(self,cr,uid,ids,name,arg,context=None):

   cr.execute('UPDATE si SET current='true' where id=ids[0]")

   return True

No need of res = {} and return res as per your code.

Hope this helps,

 

 

 

1
الصورة الرمزية
إهمال
Emipro Technologies Pvt. Ltd.

in "ids" argument you will find the current record's id in "Array".

Lakay lakay
الكاتب

Hi, itried your solution, but it gives me error ProgrammingError: column "ids" does not exist LINE 1: UPDATE si SET current='true' where id=ids[0] here is my code class si(osv.osv): def btnSet(self,cr,uid,ids,context=None): self.write(cr,uid,ids,{'current':True},context=context) cr.execute("UPDATE si SET current='true' where id=ids[0]") return True _name='si' _columns ={ 'addr':fields.char('Shipping Address',size=100,required=True), 'current':fields.boolean('Current'), } si()

Lakay lakay
الكاتب

Thanks Hiren, I figured it out, so its easy to use ORM functions instead of querying! i learned it!! thanks!! this is my code def btnSet(self,cr,uid,ids,values,context=None): self.write(cr,uid,ids,{'current':'true'}) return True thanks man!!

Lakay lakay
الكاتب

Thanks Hiren, I figured it out, so its easy to use ORM functions instead of querying! i learned it!! thanks!! this is my code def btnSet(self,cr,uid,ids,values,context=None): self.write(cr,uid,ids,{'current':'true'}) return True thanks man!!

الصورة الرمزية
Emipro Technologies Pvt. Ltd.
أفضل إجابة

<button name="btnSet" string="Set" type="object"/>

This button will call the method name "btnSet" of the class "si". So, you have to defind one method with the name "btnSet" as like below.

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

    #Perform your code This is comment.

    self.write(cr,uid,ids, {'current':True}, context=context) #It will write the true value into 'current' field for the record on which button is pressed.

    # you can write here more code as your requirement.

    return True #You can return anything from here.

0
الصورة الرمزية
إهمال
Lakay lakay
الكاتب

thanks dude. i learned from Hiren that there is an alternative way (easier way) to modify data in database by using ORM functions such as write.. thanks for giving me solution on how to link the function in .py to button in .xml! thanks man!

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

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

تسجيل
المنشورات ذات الصلة الردود أدوات العرض النشاط
Can you check a code of my module : filed. function
function field
الصورة الرمزية
الصورة الرمزية
2
مارس 15
5351
Function field issue
function field
الصورة الرمزية
الصورة الرمزية
1
مارس 15
4818
Purchase Order Function Field Issue
function field
الصورة الرمزية
0
مارس 15
4479
Why I get this 'str' object is not callable error with my new function field? تم الحل
function error field
الصورة الرمزية
الصورة الرمزية
2
فبراير 17
8536
Is there a way to connect to SQL Server Database from an odoo module? تم الحل
module sql connect
الصورة الرمزية
الصورة الرمزية
2
أبريل 15
16063
المجتمع
  • دروس
  • التوثيق
  • المنتدى
مصدر مفتوح
  • تحميل
  • جيت هاب "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