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

Expected singleton Error

اشتراك

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

لقد تم الإبلاغ عن هذا السؤال
errror
5 الردود
7415 أدوات العرض
الصورة الرمزية
Miria

Please help! I've got an error in my model and I don't know how to solve it.

Here is all of my codes. I got this error after adding the smart button.

from openerp import models, fields, api

class HrWarning(models.Model):
_name = 'hr.warning'
employee_id = fields.Many2one('hr.employee', "Employee")
warning_reason = fields.Text('Warning Reason')
date = fields.Datetime('Date')
department_id = fields.Many2one('hr.department','Department')
job_id = fields.Many2one('hr.job','Job Title')
parent_id = fields.Many2one('hr.employee','Managed By')


state = fields.Selection([
('submit', 'To Submit'),
('first_warning', 'First Warning'),
('second_warning', 'Second Warning'),
('terminate', 'Termination'),
],default='submit')

@api.one
def submit_progressbar(self):
self.write({
'state': 'submit',
})

@api.one
def first_warning_progressbar(self):
self.write({
'state': 'first_warning'
})

@api.one
def second_warning_progressbar(self):
self.write({
'state': 'second_warning'
})

@api.one
def terminate_progressbar(self):
self.write({
'state': 'terminate',
})
employee_obj = self.env['hr.employee'].search([('id', '=', self.employee_id.id)])
employee_obj.write({'active': False})

@api.multi
def report_button(self):
print 'report_button call me'
inv = self.ids
if inv:
url = 'http://localhost:8080/WebViewerExample/frameset?__report=warning_report.rptdesign&Warning Form ID=' + str(self.ids[0])
if url:
return {
'type' : 'ir.actions.act_url',
'url' : url,
'target' : 'new',
}
else:
raise ValidationError('Not Found')
return True

class hr_employee(models.Model):
_inherit = 'hr.employee'


@api.one
 def warning_button(self):
return {
'name' : ['Warning'],
'domain' : [('employee_id','=',self.id)],
'view_type' : 'form',
'res_model' : 'hr.warning',
'view_mode' : 'tree,form',
'type' : 'ir.actions.act.window',
}


warning_count = fields.Integer(string=' ',compute='get_warning_count')


def get_warning_count(self):
count = self.env['hr.warning'].search_count([('employee_id','=',self.id)])


And I got an error like this:

raise except_orm("ValueError", "Expected singleton: %s" % self)
except_orm: ('ValueError', 'Expected singleton: hr.employee(2, 12)')

0
الصورة الرمزية
إهمال
Waleed Ali Mohsen

Your methods use api.one so it expected single value and you call it for more than record. Check the log to know the line which raise this error.

alvinadjie

Hi Miria could you show us the log so we can know which line that caused this error

Miria
الكاتب

This is my log

2019-12-30 04:00:00,532 9020 INFO testing werkzeug: 127.0.0.1 - - [30/Dec/2019 04:00:00] "POST /web/dataset/call_kw/hr.employee/fields_view_get HTTP/1.1" 200 -

2019-12-30 04:00:00,855 9020 INFO ? werkzeug: 127.0.0.1 - - [30/Dec/2019 04:00:00] "GET /web/static/src/img/form_sheetbg.png HTTP/1.1" 200 -

2019-12-30 04:00:00,855 9020 INFO ? werkzeug: 127.0.0.1 - - [30/Dec/2019 04:00:00] "GET /web/static/lib/jquery.ui.bootstrap/css/custom-theme/images/ui-bg_glass_75_ffffff_1x400.png HTTP/1.1" 200 -

2019-12-30 04:00:01,476 9020 ERROR testing openerp.http: Exception during JSON request handling.

Traceback (most recent call last):

File "C:\Users\ASUS\Desktop\odoo-8.0\openerp\http.py", line 546, in _handle_exception

return super(JsonRequest, self)._handle_exception(exception)

File "C:\Users\ASUS\Desktop\odoo-8.0\openerp\http.py", line 583, in dispatch

result = self._call_function(**self.params)

File "C:\Users\ASUS\Desktop\odoo-8.0\openerp\http.py", line 319, in _call_function

return checked_call(self.db, *args, **kwargs)

File "C:\Users\ASUS\Desktop\odoo-8.0\openerp\service\model.py", line 118, in wrapper

return f(dbname, *args, **kwargs)

File "C:\Users\ASUS\Desktop\odoo-8.0\openerp\http.py", line 316, in checked_call

return self.endpoint(*a, **kw)

File "C:\Users\ASUS\Desktop\odoo-8.0\openerp\http.py", line 812, in __call__

return self.method(*args, **kw)

File "C:\Users\ASUS\Desktop\odoo-8.0\openerp\http.py", line 412, in response_wrap

response = f(*args, **kw)

File "C:\Users\ASUS\Desktop\odoo-8.0\addons\web\controllers\main.py", line 944, in call_kw

return self._call_kw(model, method, args, kwargs)

File "C:\Users\ASUS\Desktop\odoo-8.0\addons\web\controllers\main.py", line 936, in _call_kw

return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)

File "C:\Users\ASUS\Desktop\odoo-8.0\openerp\api.py", line 268, in wrapper

return old_api(self, *args, **kwargs)

File "C:\Users\ASUS\Desktop\odoo-8.0\openerp\models.py", line 3148, in read

result = BaseModel.read(records, fields, load=load)

File "C:\Users\ASUS\Desktop\odoo-8.0\openerp\api.py", line 266, in wrapper

return new_api(self, *args, **kwargs)

File "C:\Users\ASUS\Desktop\odoo-8.0\openerp\models.py", line 3194, in read

values[name] = field.convert_to_read(record[name], use_name_get)

File "C:\Users\ASUS\Desktop\odoo-8.0\openerp\models.py", line 5654, in __getitem__

return self._fields[key].__get__(self, type(self))

File "C:\Users\ASUS\Desktop\odoo-8.0\openerp\fields.py", line 835, in __get__

self.determine_value(record)

File "C:\Users\ASUS\Desktop\odoo-8.0\openerp\fields.py", line 937, in determine_value

self.compute_value(recs)

File "C:\Users\ASUS\Desktop\odoo-8.0\openerp\fields.py", line 893, in compute_value

self._compute_value(records)

File "C:\Users\ASUS\Desktop\odoo-8.0\openerp\fields.py", line 885, in _compute_value

self.compute(records)

File "C:\Users\ASUS\Desktop\odoo-8.0\custom_addons\hr_warning\hr_warning_model.py", line 82, in get_warning_count

count = self.env['hr.warning'].search_count([('employee_id','=',self.id)])

File "C:\Users\ASUS\Desktop\odoo-8.0\openerp\fields.py", line 1909, in __get__

return record.ensure_one()._ids[0]

File "C:\Users\ASUS\Desktop\odoo-8.0\openerp\models.py", line 5320, in ensure_one

raise except_orm("ValueError", "Expected singleton: %s" % self)

except_orm: ('ValueError', 'Expected singleton: hr.employee(2, 12)')

2019-12-30 04:00:01,607 9020 INFO testing werkzeug: 127.0.0.1 - - [30/Dec/2019 04:00:01] "POST /web/dataset/call_kw/hr.employee/read HTTP/1.1" 200 -

2019-12-30 04:00:01,655 9020 INFO ? werkzeug: 127.0.0.1 - - [30/Dec/2019 04:00:01] "GET /web/static/src/img/warning.png HTTP/1.1" 200 -

2019-12-30 04:00:38,003 9020 INFO testing werkzeug: 127.0.0.1 - - [30/Dec/2019 04:00:38] "POST /longpolling/poll HTTP/1.1" 200 -

2019-12-30 04:01:28,065 9020 INFO testing werkzeug: 127.0.0.1 - - [30/Dec/2019 04:01:28] "POST /longpolling/poll HTTP/1.1" 200 -

الصورة الرمزية
Niyas Raphy (Walnut Software Solutions)
أفضل إجابة

Hi,

Update these lines,

employee_obj = self.env['hr.employee'].search([('id', '=', self.employee_id.id)])
employee_obj.write({'active': False})

to

employee_obj = self.env['hr.employee'].search([('id', '=', self.employee_id.id)])

for emp in employee_obj:
     emp.write({'active': False})

or

employee_obj = self.env['hr.employee'].search([('id', '=', self.employee_id.id)], limit=1)
employee_obj.write({'active': False})

Thanks

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

Try change your code

@api.one

def terminate_progressbar(self):

    self.write({

      'state':'terminate', 

   })

    employee_obj = self.env['hr.employee'].search([('id', '=', self.employee_id.id)])

    for emp in employee_obj:

        emp.write({'active':False})


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

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

تسجيل
المنشورات ذات الصلة الردود أدوات العرض النشاط
jsonb_path_query_array error تم الحل
errror
الصورة الرمزية
الصورة الرمزية
1
يونيو 24
4427
[object with reference: name - name] v10
errror
الصورة الرمزية
الصورة الرمزية
2
أبريل 17
7936
How do I deal with error related to "Manual Reconciliation"?
errror
الصورة الرمزية
الصورة الرمزية
1
مارس 15
5317
RPC_ERROR Odoo Server Error odoo online
installation errror
الصورة الرمزية
الصورة الرمزية
الصورة الرمزية
2
فبراير 24
1741
I got a website edit error
errror Website
الصورة الرمزية
الصورة الرمزية
1
أغسطس 23
3500
المجتمع
  • دروس
  • التوثيق
  • المنتدى
مصدر مفتوح
  • تحميل
  • جيت هاب "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