Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

ValueError: Expected singleton: Models_name(38, 39)

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
errorodoosingleton
3 Răspunsuri
7467 Vizualizări
Imagine profil
Chaanto

Here is The problems


class Purchase(models.Model):

    _name = 'purchase'

    name = fields.Char(string="name")

    orderDate = fields.Date(string="Order Date")

    salesPerson = fields.Char(string="Sales Person", required=True)

    expiredDate = fields.Date(string="Expired Date", required=True)

    company = fields.Char(string="Company", related="customer_id.company", readonly=True)

    tax = fields.Float(string ="Tax")

    unTax = fields.Float(string="Untaxed", compute="_total_price")

    amount_total =  fields.Float(compute='_compute_amount_total', string="Total")

    orderNumber = fields.Char(string="Order Number")

    subpurchase_ids = fields.One2many('subpurchase', 'purchase_id', string="Purchase Lines")

    customer_id = fields.Many2one('customer', string='partner', required=True)

   

    

    state = fields.Selection([

            ('new', 'New'), 

            ('draft', 'Draft'),

            ('validate', 'Validated'),

            ('cancel', 'Cancelled')], 

            string='Status', required=False, readonly=True, copy=False, default='new')

    

    @api.onchange('tax', 'unTax')       

    @api.multi

    def _compute_amount_total(self):

        self.amount_total = self.unTax + self.tax

        

    @api.depends('subpurchase_ids', 'subpurchase_ids.amount') #tambah kalo butuh relasi tambahan

    @api.multi

    def _total_price(self):

        for purchase in self :

            total_price = 0

            for subpurchase in purchase.subpurchase_ids:

                total_price += subpurchase.amount

            purchase.unTax = total_price


class SubPurchase(models.Model):
    _name = 'subpurchase'

    category = fields.Char(string="Category", related="product_id.category", readonly=True)
    amount = fields.Float(compute='_compute_amount', string="Amount")
    quantity = fields.Integer(string="Quantity")
    codeItem = fields.Char(string="Code Item", readonly=True, related="product_id.codeItem")
    price = fields.Float(string="Item Price", readonly=True, related="product_id.price")
    sequence = fields.Char(string="Sequence")
    purchase_id = fields.Many2one('purchase', string="Customer")

 
    @api.multi
    @api.onchange('quantity', 'price')
    def _compute_amount(self):
        self.amount = self.quantity * self.price


i have an order lines so when i want add an item 2 or more the error come out ? how to fix this ?
example in order line i add an item Mouse 1 and save <= OKEY but when i add another item mouse 2 so there have a 2 item when i save this error come out 
1
Imagine profil
Abandonează
Sudhir Arya (ERP Harbor Consulting Services)

Thanks to you all for answer this question

Imagine profil
Sudhir Arya (ERP Harbor Consulting Services)
Cel mai bun răspuns

I think you need to use a for loop in `_compute_amount_total` and `_compute_amount` methods.

Just give it a try and if this does not solve the issue, please post the traceback.

7
Imagine profil
Abandonează
Imagine profil
Cybrosys Techno Solutions Pvt.Ltd
Cel mai bun răspuns

Hi,

The Single ton error can be sorted out by iterating the self over a for loop or by using self.ensure_one() . In your code, at a first glance everything seems to be fine, you have iterated the self and the one2many lines. So will suggest you to cross check the code by putting the print statements in the code and see.

Suppose if any of the variables is getting the value as sale.order(38, 39), just a sample, then make sure that the value is then iterated over the loop such a way that we will get sale.order(38) and sale.order(39).

If you have the added the fields amount and amount_total in the Tree views, make sure that the corresponding compute function is also iterated over the for loop.


@api.onchange('tax', 'unTax')       
@api.multi
def _compute_amount_total(self):
for rec in self:
rec.amount_total = rec.unTax + rec.tax


Thanks

2
Imagine profil
Abandonează
Enjoying the discussion? Don't just read, join in!

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

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
Error on Odoo setup
error odoo
Imagine profil
Imagine profil
Imagine profil
2
feb. 23
8999
odoo server error
error odoo
Imagine profil
0
sept. 20
4045
Error while starting openerp-server ??
error odoo
Imagine profil
Imagine profil
2
mar. 15
6745
How can i change my odoo domain name ? Rezolvat
error odoo domainname
Imagine profil
Imagine profil
Imagine profil
Imagine profil
3
sept. 25
2798
problem backup Rezolvat
error backup odoo
Imagine profil
Imagine profil
Imagine profil
3
iun. 24
7509
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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