Skip ke Konten
Odoo Menu
  • Login
  • Uji coba gratis
  • Aplikasi
    Keuangan
    • Akuntansi
    • Faktur
    • Pengeluaran
    • Spreadsheet (BI)
    • Dokumen
    • Tanda Tangan
    Sales
    • CRM
    • Sales
    • POS Toko
    • POS Restoran
    • Langganan
    • Rental
    Website
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Rantai Pasokan
    • Inventaris
    • Manufaktur
    • PLM
    • Purchase
    • Maintenance
    • Kualitas
    Sumber Daya Manusia
    • Karyawan
    • Rekrutmen
    • Cuti
    • Appraisal
    • Referensi
    • Armada
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Acara
    • Otomatisasi Marketing
    • Survei
    Layanan
    • Project
    • Timesheet
    • Layanan Lapangan
    • Meja Bantuan
    • Planning
    • Appointment
    Produktivitas
    • Diskusi
    • Approval
    • IoT
    • VoIP
    • Pengetahuan
    • WhatsApp
    Aplikasi pihak ketiga Odoo Studio Platform Odoo Cloud
  • Industri-Industri
    Retail
    • Toko Buku
    • Toko Baju
    • Toko Furnitur
    • Toko Kelontong
    • Toko Hardware
    • Toko Mainan
    Makanan & Hospitality
    • Bar dan Pub
    • Restoran
    • Fast Food
    • Rumah Tamu
    • Distributor Minuman
    • Hotel
    Real Estate
    • Agensi Real Estate
    • Firma Arsitektur
    • Konstruksi
    • Estate Management
    • Perkebunan
    • Asosiasi Pemilik Properti
    Konsultansi
    • Firma Akuntansi
    • Mitra Odoo
    • Agensi Marketing
    • Firma huku
    • Talent Acquisition
    • Audit & Sertifikasi
    Manufaktur
    • Tekstil
    • Logam
    • Perabotan
    • Makanan
    • Brewery
    • Corporate Gift
    Kesehatan & Fitness
    • Sports Club
    • Toko Kacamata
    • Fitness Center
    • Wellness Practitioners
    • Farmasi
    • Salon Rambut
    Perdagangan
    • Handyman
    • IT Hardware & Support
    • Sistem-Sistem Energi Surya
    • Pembuat Sepatu
    • Cleaning Service
    • Layanan HVAC
    Lainnya
    • Organisasi Nirlaba
    • Agen Lingkungan
    • Rental Billboard
    • Fotografi
    • Penyewaan Sepeda
    • Reseller Software
    Browse semua Industri
  • Komunitas
    Belajar
    • Tutorial-tutorial
    • Dokumentasi
    • Sertifikasi
    • Pelatihan
    • Blog
    • Podcast
    Empower Education
    • Program Edukasi
    • Game Bisnis 'Scale Up!'
    • Kunjungi Odoo
    Dapatkan Softwarenya
    • Download
    • Bandingkan Edisi
    • Daftar Rilis
    Kolaborasi
    • Github
    • Forum
    • Acara
    • Terjemahan
    • Menjadi Partner
    • Layanan untuk Partner
    • Daftarkan perusahaan Akuntansi Anda.
    Dapatkan Layanan
    • Temukan Mitra
    • Temukan Akuntan
    • Temui penasihat
    • Layanan Implementasi
    • Referensi Pelanggan
    • Bantuan
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dapatkan demo
  • Harga
  • Bantuan

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Akuntansi
  • Inventaris
  • PoS
  • Project
  • MRP
All apps
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Help

Expected singleton: hr.emp.travel.location(62, 63)

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
odoo12.0
2 Replies
1917 Tampilan
Avatar
jenan soliman

Hi,


class EmployeeTravelReqest(models.Model):
_name = 'hr.emp.travel.request'
_description = "Travel Request"
_inherit = ['mail.thread', 'mail.activity.mixin']

@api.multi
def hr_manager_user_ids_get(self):
self.ensure_one()
hr_group_ids = self.env.ref('hr.group_hr_manager').users.ids
self.hr_manager_user_ids = [(6, 0, hr_group_ids)]

user_id = fields.Many2one('res.users')
hr_manager_user_ids = fields.Many2many('res.users', compute="hr_manager_user_ids_get")

name = fields.Char(string="Name")
employee_id = fields.Many2one('hr.employee', string="Employee")
# related fields
department_id = fields.Many2one(related="employee_id.department_id", store=True)
company_id = fields.Many2one(related="employee_id.company_id", store=True)
parent_id = fields.Many2one(related="employee_id.parent_id", store=True)
job_id = fields.Many2one(related="employee_id.job_id", store=True)
grade_id = fields.Many2one(related="employee_id.grade_id", store=True)
currency_id = fields.Many2one(related="employee_id.company_id.currency_id", store=True)
# Travel Dates
from_date = fields.Date(string='From Date')
to_date = fields.Date(string='To Date')
expect_travel_days = fields.Integer(string="Days", compute="compute_days")
state = fields.Selection(
[('draft', 'Draft'), ('waiting', 'Waiting for confirmation'), ('confirmed', 'Confirmed'), ('approved', 'Approved'),
('closed', 'Closed'), ('rejected', 'Rejected'), ('canceled', 'Canceled')], default="draft", track_visibility="onchange")
# travel locations
travel_location_ids = fields.One2many('hr.emp.travel.location', 'travel_request_id_ref', required=True)
total_travel_days = fields.Integer(string="Days", compute="compute_days_travel_location")
# Expenses(proposed/actual)
expense_amount_ids = fields.One2many('hr.expense.amount', 'travel_request_id')
total_expense_amount = fields.Monetary(string="Grand Total", compute="compute_total_expense_amount", store=False)
ticket_book = fields.Boolean(string="Company Books ticket for You", track_visibility="onchange")
# Log
request_by = fields.Many2one('res.users', default=lambda self: self.env.uid)
approved_by = fields.Many2one('res.users')
rejected_by = fields.Many2one('res.users')
request_date = fields.Date(string="Requested Date", default=date.today())
approved_date = fields.Date()
rejected_date = fields.Date()
reject_reason = fields.Char("Reason For Reject")
# Reason
reason = fields.Text(string="Reason")
# Currency
currency_ids = fields.One2many('hr.travel.currency', 'travel_request_id')

# Expenses expenses_ids = fields.One2many('hr.expense', 'travel_request_id_ref'
@api.multi
def action_send_manager(self):
for rec in self:
if not rec.travel_location_ids:
raise Warning("Please enter the travel information before submit to manager")
else:
rec.state = 'waiting'

I get this error when I try to save more than one line in one2many field.


Thank you in advance for any help.



0
Avatar
Buang
Mehjabin Farsana

Instead of sharing whole code, please check log and see which section throws the error, and please share it.
To understand single ton error in odoo and to learn its solution see: https://www.youtube.com/watch?v=Rv44nFVn_5U

Murugan Chinnasamy

you can check with one2many class(hr.emp.travel.location) like function, search, domain etc.

Avatar
Cybrosys Techno Solutions Pvt.Ltd
Jawaban Terbai

Hi,

Singleton error occurs because somewhere in your code, a method that expects one record (self.ensure_one() is called) is being passed multiple records. In your case, it is happening with the One2many travel_location_ids when you try to save multiple lines.To fix this, avoid using ensure_one() in compute methods or methods that can be called on multiple records, and always loop over self when accessing fields like One2many or Many2many. For example, in the compute_days_travel_location method, you should iterate over each record in self and calculate the total travel days individually. Similarly, in the hr_manager_user_ids_get compute method, remove ensure_one() and loop over self to assign the HR manager users for each record. Also, make sure any button or action methods that work on multiple records, such as action_send_manager, use a loop to handle each record properly. Finally, review all methods that access One2many or Many2many fields to ensure they handle multiple records without assuming a single record. Following these steps will prevent singleton errors when saving multiple lines in the travel_location_ids field.


Hope it helps.

0
Avatar
Buang
Avatar
stomtkamesromt
Jawaban Terbai

The error usually happens when a method is written with ensure_one() but is called on multiple records at once, which leads to the singleton issue. You can fix it by adjusting the method to handle recordsets, or by making sure the compute field only runs on a single record at a time. Reviewing how the travel_location_ids field is triggered can help narrow it down. It’s a bit like planning reliable operations such as sallimoservice.com, where handling multiple requests smoothly requires structuring the process correctly. In this case, refining the method logic should resolve the conflict.

0
Avatar
Buang
Menikmati diskusi? Jangan hanya membaca, ikuti!

Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!

Daftar
Post Terkait Replies Tampilan Aktivitas
How to write Record Rule with domain based on the company_dependent Fields Diselesaikan
odoo12.0
Avatar
Avatar
Avatar
3
Okt 23
10553
loan request
odoo12.0
Avatar
Avatar
1
Sep 23
3941
sum Colum of based on id
odoo12.0
Avatar
Avatar
1
Mei 23
2905
How to make pagination that has a table in qweb
odoo12.0
Avatar
Avatar
2
Apr 23
3629
Inherit Element form kanban View Diselesaikan
odoo12.0
Avatar
Avatar
1
Mar 23
2828
Komunitas
  • Tutorial-tutorial
  • Dokumentasi
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Terjemahan
Layanan
  • Odoo.sh Hosting
  • Bantuan
  • Peningkatan
  • Custom Development
  • Pendidikan
  • Temukan Akuntan
  • Temukan Mitra
  • Menjadi Partner
Tentang Kami
  • Perusahaan kami
  • Aset Merek
  • Hubungi kami
  • Tugas
  • Acara
  • Podcast
  • Blog
  • Pelanggan
  • Hukum • Privasi
  • Keamanan
الْعَرَبيّة 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 adalah rangkaian aplikasi bisnis open source yang mencakup semua kebutuhan perusahaan Anda: CRM, eCommerce, akuntansi, inventaris, point of sale, manajemen project, dan seterusnya.

Mudah digunakan dan terintegrasi penuh pada saat yang sama adalah value proposition unik 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