Skip to Content
Odoo मेन्यू
  • Sign in
  • मुफ़्त में आज़माएं
  • ऐप्लिकेशन
    फ़ाइनेंस
    • अकाउंटिंग
    • इनवॉइसिंग
    • एक्सपेंस
    • स्प्रेडशीट (बीआई)
    • डॉक्यूमेंट्स
    • साइन
    सेल्स
    • सीआरएम
    • सेल्स
    • पीओएस शॉप
    • पीओएस रेस्टोरेंट
    • सब्सक्रिप्शन
    • रेंटल
    वेबसाइट
    • वेबसाइट बिल्डर
    • ई-कॉमर्स
    • ब्लॉग
    • फ़ोरम
    • लाइव चैट
    • ई-लर्निंग
    सप्लाई चेन
    • इन्वेंट्री
    • मैन्युफ़ैक्चरिंग
    • पीएलएम
    • परचेज़
    • मेंटेनेंस
    • क्वालिटी
    मानव संसाधन
    • कर्मचारी
    • रिक्रूटमेंट
    • टाइम ऑफ़
    • अप्रेज़ल
    • रेफ़रल
    • फ़्लीट
    मार्केटिंग
    • सोशल मार्केटिंग
    • ईमेल मार्केटिंग
    • एसएमएस मार्केटिंग
    • इवेंट
    • मार्केटिंग ऑटोमेशन
    • सर्वे
    सेवाएं
    • प्रोजेक्ट
    • टाइमशीट
    • फ़ील्ड सर्विस
    • हेल्पडेस्क
    • प्लानिंग
    • अपॉइंटमेंट
    प्रॉडक्टिविटी
    • डिस्कस
    • अप्रूवल
    • आईओटी
    • वीओआईपी
    • नॉलेज
    • WhatsApp
    तीसरे पक्ष के ऐप्लिकेशन Odoo स्टूडियो Odoo क्लाउड प्लेटफ़ॉर्म
  • इंडस्ट्री
    रीटेल
    • बुक स्टोर
    • क्लोदिंग स्टोर
    • फ़र्नीचर स्टोर
    • ग्रॉसरी स्टोर
    • हार्डवेयर स्टोर
    • टॉय स्टोर
    Food & Hospitality
    • बार और पब
    • रेस्टोरेंट
    • फ़ास्ट फ़ूड
    • Guest House
    • बेवरिज डिस्ट्रीब्यूटर
    • होटल
    रियल एस्टेट
    • Real Estate Agency
    • आर्किटेक्चर फ़र्म
    • कंसट्रक्शन
    • एस्टेट मैनेजमेंट
    • गार्ड्निंग
    • प्रॉपर्टी ओनर असोसिएशन
    कंसल्टिंग
    • अकाउंटिंग फ़र्म
    • Odoo पार्टनर
    • मार्केटिंग एजेंसी
    • लॉ फ़र्म
    • टैलेंट ऐक्विज़िशन
    • ऑडिट & सर्टिफ़िकेशन
    मैन्युफ़ैक्चरिंग
    • टेक्सटाइल
    • Metal
    • फ़र्नीचर
    • फ़ूड
    • Brewery
    • कॉर्पोरेट गिफ़्ट
    हेल्थ & फिटनेस
    • स्पोर्ट्स क्लब
    • आईवियर स्टोर
    • फिटनेस सेंटर
    • वेलनेस प्रैक्टिशनर
    • फॉर्मेसी
    • हेयर सैलून
    Trades
    • Handyman
    • आईटी हॉर्डवेयर और सपोर्ट
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    अन्य
    • Nonprofit Organization
    • एन्वायरमेंटल एजेंसी
    • बिलबोर्ड रेंटल
    • फ़ोटोग्राफी
    • बाइक लीजिंग
    • सॉफ़्टवेयर रीसेलर
    Browse all Industries
  • कम्यूनिटी
    सीखें
    • ट्यूटोरियल्स
    • दस्तावेज़
    • सर्टिफ़िकेशन
    • ट्रेनिंग
    • ब्लॉग
    • पॉडकास्ट
    शिक्षा को बढ़ावा दें
    • एजुकेशन प्रोग्राम
    • स्केल अप! बिजनेस गेम
    • Odoo के ऑफ़िस में आएं
    सॉफ़्टवेयर पाएं
    • डाउनलोड
    • वर्शन की तुलना करें
    • रिलीज़
    साथ मिलकर काम करें
    • Github
    • फ़ोरम
    • इवेंट
    • अनुवाद
    • पार्टनर बनें
    • Services for Partners
    • अपना अकाउंटिंग फ़र्म रजिस्टर करें
    सेवाएं पाएं
    • पार्टनर ढूंढें
    • अकाउंटेंट खोजें
    • सलाहकार की मदद लें
    • इम्प्लिमेंटेशन सेवाएं
    • कस्टमर रेफ़रेंस
    • सहायता
    • अपग्रेड
    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
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
Help

Expected singleton ""ERROR"" Here is my code and Error log... Please Help me to solve the problem

Subscribe

Get notified when there's activity on this post

This question has been flagged
5 Replies
2655 Views
Avatar
joyanto

 @api.multi

    def sync_serviceman_family_push(self, isReload):

        

        synchronizer_configuration = self.env['synchronizer.configuration'].search([('id','=',1)])

        if synchronizer_configuration:

            base_url = synchronizer_configuration['base_url']

            

        url = base_url + "/get-ex-serviceman/family"

        response = requests.get(url, data="")


        if response:

            if response.status_code == 200 or response.status_code == 201:

                items = json.loads(json.dumps(response.json()['data']))

                if items:

                    counter = 0

                    for item in items:

                        

                        _sync_ref_id = 'family-' + str(item['id']) if item['id'] else '' 

                        _name = item['name'] if item['name'] else 'N/A'

                        _phone = item['mobile_number'] if item['mobile_number'] else ''

                        _nid = item['nid'] if item['nid'] else ''

                        _occupation = item['occupation'] if item['occupation'] else ''

                        

                        relation_sync_ref_id = item['relation_id'] if item['relation_id'] else ''

                        _relation_id = self.env['basb.relation'].search([('sync_ref_id','=',relation_sync_ref_id)]).id

                        if _relation_id == False: _relation_id = None 

                        

                        serviceman_sync_ref_id = item['serviceman_id'] if item['serviceman_id'] else ''

                        parent = self.env['res.partner'].search([('sync_ref_id','=',serviceman_sync_ref_id)])

                        

                        _parent_id = parent.id or False

                        if _parent_id == False: _parent_id = None 

                        

                        _dasb_id = None

                        if parent.dasb:

                            _dasb_id = parent.dasb.id or False

                            if _dasb_id == False: _dasb_id = None 


                        _date_of_birth = None

                        try:

                            _date_of_birth = item['date_of_birth'] if item['date_of_birth'] else ''

                            if not _date_of_birth: _date_of_birth = None  

                            else: _date_of_birth = datetime.datetime.strptime(_date_of_birth, '%Y-%M-%d')

                        except Exception:

                            _date_of_birth = None 

                            

                        # dead = item['dead'] if item['dead'] else ''

                        # _status = 'alive'

                        _active = True

                        # if dead == 1: 

                        #     _status = 'dead' 

                        #     _active = False       

                        

                        if _sync_ref_id:

                            

                            '''

                            update_record = self.env['res.partner'].search([('sync_ref_id','=',_sync_ref_id)])      

                            

                            if update_record:

                                update_record.write({

                                    'name': _name,

                                    'phone': _phone,

                                    'national_identification': _nid,

                                    'function': _occupation,

                                    'date_of_birth': _date_of_birth,

                                    'relation': _relation_id,

                                    'parent_id': _parent_id

                                })

                            else:

                                record = self.env['res.partner'].create({

                                    'name': _name,

                                    'sync_ref_id': str(_sync_ref_id),

                                    'phone': _phone,

                                    'national_identification': _nid,

                                    'function': _occupation,

                                    'date_of_birth': _date_of_birth,

                                    'relation': _relation_id,

                                    'parent_id': _parent_id,

                                    'customer': True, 

                                    'active': True, 

                                    'type': 'contact'

                                })

                            

                            '''

                            

                            is_exist = self.env['res.partner'].search([('sync_ref_id','=',_sync_ref_id)])


                            if is_exist:

                                try: 

                                    query = """ UPDATE res_partner

                                                SET name=%s,

                                                display_name=%s,

                                                dasb=%s,

                                                phone=%s, 

                                                national_identification=%s,

                                                function=%s,

                                                date_of_birth=%s,

                                                relation=%s,

                                                parent_id=%s, 

                                                commercial_partner_id=%s

                                                WHERE sync_ref_id=%s """

                                    params = (_name, _name, _dasb_id, _phone, _nid, _occupation, _date_of_birth, _relation_id, _parent_id, _parent_id, str(_sync_ref_id), )  

                                    self.env.cr.execute(query, params)

                                except Exception:

                                    print("Catch Exception ID: " + str(_sync_ref_id))

                            else:

                                try:  

                                    if _sync_ref_id is not None:

                                        query = """ INSERT INTO res_partner

                                                (name, display_name, sync_ref_id, dasb, phone, national_identification, function, date_of_birth, relation, parent_id, commercial_partner_id, customer, active, type)

                                                VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, True, %s, 'contact') """

                                        params = (_name, _name, str(_sync_ref_id), _dasb_id, _phone, _nid, _occupation, _date_of_birth, _relation_id, _parent_id, _parent_id, _active, )

                                        self.env.cr.execute(query, params)

                                except Exception:

                                    print("Catch Exception ID: " + str(_sync_ref_id))

                

                    if isReload:

                        return {'type': 'ir.actions.client', 'tag': 'reload'}

                else:

                    if isReload:

                        raise UserError("No data found to sync.")

        else:

            if isReload:

                raise UserError("No data found to sync.")

AND THE ERROR SHOW IS DOWN


Error:

 Server Error


Traceback (most recent call last):

  File "/usr/lib/python3/dist-packages/odoo/http.py", line 656, in _handle_exception

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

  File "/usr/lib/python3/dist-packages/odoo/http.py", line 314, in _handle_exception

    raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])

  File "/usr/lib/python3/dist-packages/odoo/tools/pycompat.py", line 87, in reraise

    raise value

  File "/usr/lib/python3/dist-packages/odoo/http.py", line 698, in dispatch

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

  File "/usr/lib/python3/dist-packages/odoo/http.py", line 346, in _call_function

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

  File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 97, in wrapper

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

  File "/usr/lib/python3/dist-packages/odoo/http.py", line 339, in checked_call

    result = self.endpoint(*a, **kw)

  File "/usr/lib/python3/dist-packages/odoo/http.py", line 941, in __call__

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

  File "/usr/lib/python3/dist-packages/odoo/http.py", line 519, in response_wrap

    response = f(*args, **kw)

  File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 966, in call_button

    action = self._call_kw(model, method, args, {})

  File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 954, in _call_kw

    return call_kw(request.env[model], method, args, kwargs)

  File "/usr/lib/python3/dist-packages/odoo/api.py", line 759, in call_kw

    return _call_kw_multi(method, model, args, kwargs)

  File "/usr/lib/python3/dist-packages/odoo/api.py", line 746, in _call_kw_multi

    result = method(recs, *args, **kwargs)

  File "/mnt/extra-addons/meta_basb_offline/models/synchronizer_wizard.py", line 214, in sync

    self.sync_serviceman_family_push(False)

  File "/mnt/extra-addons/meta_basb_offline/models/synchronizer_wizard.py", line 674, in sync_serviceman_family_push

    _parent_id = parent.id or False

  File "/usr/lib/python3/dist-packages/odoo/fields.py", line 2863, in __get__

    raise ValueError("Expected singleton: %s" % record)

ValueError: Expected singleton: res.partner(13129, 100805)

0
Avatar
Discard
joyanto
Author
Thanks, I'll check it out. 

On Thu, Feb 20, 2020 at 10:59 AM Sehrish <sehrishnaz47@gmail.com> wrote:

You have to loop through from where you get singleton error....

Sent by Odoo S.A. using Odoo.

Avatar
Cybrosys Techno Solutions Pvt.Ltd
Best Answer

Hi,

You missing loops,check how many records are in parent if it's more than one , then you have to add the loop at next line.

parent = self.env['res.partner'].search([('sync_ref_id','=',serviceman_sync_ref_id)])

Try after looping the parent

Regards

1
Avatar
Discard
Avatar
tamysmithing
Best Answer


my name is TAMMY  please write through my  private email [ tammys15@yahoo.com ] i have something important to discuss with you through email,,,

0
Avatar
Discard
Avatar
Sehrish
Best Answer

You have to loop through from where you get singleton error....

0
Avatar
Discard
joyanto
Author

not found where is my problem please help

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
कम्यूनिटी
  • ट्यूटोरियल्स
  • दस्तावेज़
  • फ़ोरम
ओपन सोर्स
  • डाउनलोड
  • Github
  • रनबॉट
  • अनुवाद
सेवाएं
  • Odoo.sh Hosting
  • सहायता
  • अपग्रेड
  • कस्टम डेवलपमेंट्स
  • शिक्षा
  • अकाउंटेंट खोजें
  • पार्टनर ढूंढें
  • पार्टनर बनें
हमारे बारे में
  • हमारी कंपनी
  • ब्रांड ऐसेट
  • संपर्क करें
  • नौकरियां
  • इवेंट
  • पॉडकास्ट
  • ब्लॉग
  • ग्राहक
  • लीगल • गोपनीयता
  • सुरक्षा
الْعَرَبيّة 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

Odoo, बिज़नेस से जुड़े ऐप्लिकेशन का एक कलेक्शन है जो ओपन सोर्स पर आधारित है. इसमें आपकी कंपनी की हर ज़रूरत के लिए ऐप्लिकेशन हैं. जैसे, सीआरएम, ई-कॉमर्स, अकाउंटिंग, इन्वेंट्री, पॉइंट ऑफ़ सेल, प्रोजेक्ट मैनेजमेंट वगैरह.

Odoo की सबसे बड़ी खासियत है कि यह इस्तेमाल करने में बहुत आसान है और यह पूरी तरह से इंटिग्रेट किया हुआ है.

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