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

update fields on write() method

اشتراك

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

لقد تم الإبلاغ عن هذا السؤال
createwrite
2 الردود
36669 أدوات العرض
الصورة الرمزية
philip

Hi all,

Take a look at my error please... in my model I have create() method to concatenate my first_name and last_name and fill into my name field and it works. I have also write() method to update if I have any changes to first_name, last_name and fill into my name field, but I got an errors below. someone can help me figure out to work my write() method, Thanks for the effort and answers

errors------

Server Traceback (most recent call last): File "/home/jp/ws/openerp/web/addons/web/session.py", line 89, in send return openerp.netsvc.dispatch_rpc(service_name, method, args) File "/home/jp/ws/openerp/server/openerp/netsvc.py", line 296, in dispatch_rpc result = ExportService.getService(service_name).dispatch(method, params) File "/home/jp/ws/openerp/server/openerp/service/web_services.py", line 626, in dispatch res = fn(db, uid, *params) File "/home/jp/ws/openerp/server/openerp/osv/osv.py", line 190, in execute_kw return self.execute(db, uid, obj, method, *args, **kw or {}) File "/home/jp/ws/openerp/server/openerp/osv/osv.py", line 132, in wrapper return f(self, dbname, *args, **kwargs) File "/home/jp/ws/openerp/server/openerp/osv/osv.py", line 199, in execute res = self.execute_cr(cr, uid, obj, method, *args, **kw) File "/home/jp/ws/openerp/server/openerp/osv/osv.py", line 187, in execute_cr return getattr(object, method)(cr, uid, *args, **kw) TypeError: write() got multiple values for keyword argument 'context'

python -----


    def create(self, cr, uid, vals, context=None):
        name = str(vals['first_name'] or '') + ' ' +str(vals['last_name'] or '')
        vals['name'] = name.title()
        return super(hr_employee, self).create(cr, uid, vals, context=context)

    def write(self, cr, uid, vals, context=None):
        name = str(vals['first_name'] or '') + ' ' +str(vals['last_name'] or '')
        vals['name'] = name
        return super(hr_employee, self).write(cr, uid, vals, context=context)

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

        if first_name:
            return {'value': {'first_name': first_name.title()}}
        return {'value':{}}

    def onchange_last_name(self, cr, uid, ids, last_name, context=None):
        if last_name:
            return {'value': {'last_name': last_name.title()}}
        return {'value':{}}

    def onchange_name(self, cr, uid, ids, last_name, context=None):
        if last_name:
            return {'value': {'last_name': last_name.title()}}
        return {'value':{}}
            
    _columns = {
        'name': fields.char('First Name', size=32),
        'date_start': fields.date('Start Date', required=True),
        'date_end': fields.date('End Date'),
        'attendance_ids' : fields.one2many('philcode.test', 'calendar_id', 'Working Time'),
        'first_name': fields.char('First Name', size=32, required=True),
        'last_name': fields.char('Last Name', size=32, required=True),
    }

xml -----

                        <label for="first_name"/>
                        <div>
                            <h1><field name="first_name" style="width: 50%%" on_change="onchange_first_name(first_name)"/></h1><br/>
                        </div>
                        <label for="last_name"/>
                        <div>
                            <h1><field name="last_name" style="width: 50%%" on_change="onchange_last_name(last_name)"/></h1>
                        </div>
                        <label for="name" String="Full Name"/>
                        <div>
                            <h1><field name="name" on_change="onchange_name(name)" style="width: 50%%"/></h1>

0
الصورة الرمزية
إهمال
الصورة الرمزية
Deepa Venkatesh
أفضل إجابة

parameter specified for Write method are wrong

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

Ids was not specified...

2
الصورة الرمزية
إهمال
philip
الكاتب

Thanks for the response, so what's right for the write method
and how to specify the ids?

OdooBot

U need not pass anything for Ids ... it is exclusively passed by openerp .....
It is d necessary syntax for it ... as it is orm method...

Sent from Yahoo! Mail on Android



From: philip <johnpaul@ictsecuritygroup.org>;
To: deep <deepa4lok@yahoo.com>;
Subject: Re: False
Sent: Mon, Sep 8, 2014 12:29:54 PM

Thanks for the response, so what's right for the write method
and how to specify the ids?

--
philip
Sent by OpenERP S.A. using Odoo about Forum Post False
الصورة الرمزية
Mariusz Mizgier
أفضل إجابة

You don't provide additional parameter for the write method, which is ids of the written record. If OpenERP has to write, it needs to know to which record it should write to.

1
الصورة الرمزية
إهمال
philip
الكاتب

I tried to put ids in my function but I got error mesaage:
name = str(vals['first_name'] or '') + ' ' +str(vals['last_name'] or '') KeyError: 'last_name'
python code def write(self, cr, uid, vals, context=None): name = str(vals['first_name'] or '') + ' ' +str(vals['last_name'] or '') vals['name'] = name return super(hr_employee, self).write(cr, uid, vals, context=context)

philip
الكاتب

here is my python code

def write(self, cr, uid, ids, vals, context=None): name = str(vals['first_name'] or '') + ' ' +str(vals['last_name'] or '') vals['name'] = name return super(hr_employee, self).write(cr, uid, ids, vals, context=context)

can you point me to the right direction, I don't have any idea on write() method.

Thanks for the response

Mariusz Mizgier

It means, that you don't have key of 'last_name' in your vals dictionary - you should first do the check for whether first_name or last_name are the values that are changing on the current record and based on that then create name you want to put, ie. if 'first_name' in vals and 'last_name' in vals: name = str(vals['first_name'] + str(vals['last_name']) if 'first_name' in vals and 'last_name' not in vals: do something.... (like check if record has got already its last name and you have to do your text operation on new first name, but old last name)

philip
الكاتب

can you fix the code

def write(self, cr, uid, vals, context=None):
name = str(vals['first_name'] or '') + ' ' +str(vals['last_name'] or '')
vals['name'] = name
return super(hr_employee, self).write(cr, uid, vals, context=context)

Thank really appreciate all your help

Mariusz Mizgier

Try this: def write(self, cr, uid, ids, vals, context=None): employee_data = self.pool.get('hr.employee').browse(cr, uid, ids) if vals['first_name'] and vals['last_name']: name = str(vals['first_name']) + ' ' +str(vals['last_name']) vals['name'] = name return super(hr_employee, self).write(cr, uid, vals, context=context) if vals['first_name']: name = str(vals['first_name']) + ' ' +str(employee_data.last_name or '') vals['name'] = name return super(hr_employee, self).write(cr, uid, vals, context=context) if vals['second_name']: employee_data = self.pool.get('hr.employee').browse(cr, uid, ids) name = str(employee_data.first_name or '') + ' ' +str(vals['second_name']) vals['name'] = name return super(hr_employee, self).write(cr, uid, vals, context=context)

philip
الكاتب

Thanks will try this later, is this indentation is right?
def write(self, cr, uid, ids, vals, context=None):
----employee_data = self.pool.get('hr.employee').browse(cr, uid, ids)
----if vals['first_name'] and vals['last_name']:
----name = str(vals['first_name']) + ' ' +str(vals['last_name']) vals['name'] = name
----return super(hr_employee, self).write(cr, uid, vals, context=context) if vals['first_name']:
----name = str(vals['first_name']) + ' ' +str(employee_data.last_name or '') vals['name'] = name
----return super(hr_employee, self).write(cr, uid, vals, context=context) if vals['second_name']:
----employee_data = self.pool.get('hr.employee').browse(cr, uid, ids)
----name = str(employee_data.first_name or '') + ' ' +str(vals['second_name'])
----vals['name'] = name return super(hr_employee, self).write(cr, uid, vals, context=context)

Mariusz Mizgier

No, it is not right - comments are not working well with the indents: ----def write(self, cr, uid, ids, vals, context=None): --------employee_data = self.pool.get('hr.employee').browse(cr, uid, ids) --------if vals['first_name'] and vals['last_name']: ------------name = str(vals['first_name']) + ' ' +str(vals['last_name']) vals['name'] = name ------------return super(hr_employee, self).write(cr, uid, vals, context=context) --------if vals['first_name']: ------------name = str(vals['first_name']) + ' ' +str(employee_data.last_name or '') ------------vals['name'] = name ------------return super(hr_employee, self).write(cr, uid, vals, context=context) --------if vals['second_name']: ------------name = str(employee_data.first_name or '') + ' ' +str(vals['second_name']) ------------vals['name'] = name ------------return super(hr_employee, self).write(cr, uid, vals, context=context) --------else: ------------return super(hr_employee, self).write(cr, uid, vals, context=context)

philip
الكاتب

Thanks will try later. thanks for your response

philip
الكاتب

PYTHON-----
----def write(self, cr, uid, ids, vals, context=None):
--------employee_data = self.pool.get('hr.employee').browse(cr, uid, ids)
--------if vals['first_name'] and vals['last_name']:
------------name = str(vals['first_name']) + ' ' +str(vals['last_name'])
------------vals['name'] = name
------------return super(hr_employee, self).write(cr, uid, vals, context=context)
--------if vals['first_name']:
------------name = str(vals['first_name']) + ' ' +str(employee_data.last_name or '')
------------vals['name'] = name
------------return super(hr_employee, self).write(cr, uid, vals, context=context)
--------if vals['second_name']:
------------name = str(employee_data.first_name or '') + ' ' +str(vals['second_name'])
------------vals['name'] = name
------------return super(hr_employee, self).write(cr, uid, vals, context=context)
--------else:
------------return super(hr_employee, self).write(cr, uid, vals, context=context)


ERRORS------ Server Traceback (most recent call last):
--File "/home/jp/ws/openerp/web/addons/web/session.py", line 89, in send
----return openerp.netsvc.dispatch_rpc(service_name, method, args)
--File "/home/jp/ws/openerp/server/openerp/netsvc.py", line 296, in dispatch_rpc
----result = ExportService.getService(service_name).dispatch(method, params)
--File "/home/jp/ws/openerp/server/openerp/service/web_services.py", line 626, in dispatch
----res = fn(db, uid, *params)
--File "/home/jp/ws/openerp/server/openerp/osv/osv.py", line 190, in execute_kw
----return self.execute(db, uid, obj, method, *args, **kw or {})
--File "/home/jp/ws/openerp/server/openerp/osv/osv.py", line 132, in wrapper
----return f(self, dbname, *args, **kwargs)
--File "/home/jp/ws/openerp/server/openerp/osv/osv.py", line 199, in execute
----res = self.execute_cr(cr, uid, obj, method, *args, **kw)
--File "/home/jp/ws/openerp/server/openerp/osv/osv.py", line 187, in execute_cr
----return getattr(object, method)(cr, uid, *args, **kw)
--File "/home/jp/ws/openerp/my_addons/for_development/philcode_test.py", line 15, in write
----name = str(vals['first_name']) + ' ' +str(vals['last_name'])
KeyError: 'last_name'

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

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

تسجيل
المنشورات ذات الصلة الردود أدوات العرض النشاط
launch a wizard before saving a record
wizard create write
الصورة الرمزية
الصورة الرمزية
1
أغسطس 20
5577
Odoo 13 Create() Write() stores old values
create write 13.0
الصورة الرمزية
الصورة الرمزية
1
أبريل 20
6079
How to create and write multiple records by overriding create and write method of odoo12 تم الحل
create write odoo12
الصورة الرمزية
الصورة الرمزية
1
سبتمبر 19
9749
Creating a record or editing an existing record? How to know?
create write odoo12.0
الصورة الرمزية
الصورة الرمزية
الصورة الرمزية
الصورة الرمزية
3
فبراير 19
10209
how to override create or write method تم الحل
one2many create write
الصورة الرمزية
الصورة الرمزية
الصورة الرمزية
3
يوليو 17
12683
المجتمع
  • دروس
  • التوثيق
  • المنتدى
مصدر مفتوح
  • تحميل
  • جيت هاب "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