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

Singleton issue while update MRR and NRR!

Abonare

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

Această întrebare a fost marcată
crmcodequotesingletonissue
2 Răspunsuri
1078 Vizualizări
Imagine profil
Vikas Maharana

Hi All,

I have created a boolean field in sale order. 

is_primary_quotation = fields.Boolean(string='Primary Quotation', default=False) 
and in crm model have a realtionship. 

sale_order_ids = fields.One2many('sale.order', 'opportunity_id', string='Sales Orders') 

and I add below addition logic 




File "D:\odoo-18.0+e.20250604(New)\odoo\fields.py", line 1232, in __get__ record.ensure_one() File "D:\odoo-18.0+e.20250604(New)\odoo\models.py", line 6255, in ensure_one raise ValueError("Expected singleton: %s" % self) ValueError: Expected singleton: sale.order(68, 59).

how to solve this error so that I'll geting MRR and NRR value is the quote is primay quote of the lead?

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

Hi,


Try the following code.


@api.depends('sale_order_ids.non_recurring_total', 'sale_order_ids.is_primary_quotation')

def _compute_expected_revenue(self):

    for lead in self:

        primary_orders = lead.sale_order_ids.filtered(lambda o: o.is_primary_quotation)

        lead.expected_revenue = sum(order.non_recurring_total for order in primary_orders)



@api.depends('sale_order_ids.recurring_monthly', 'sale_order_ids.is_primary_quotation')

def _compute_recurring_revenue(self):

    for lead in self:

        primary_orders = lead.sale_order_ids.filtered(lambda o: o.is_primary_quotation)

        lead.recurring_revenue = sum(order.recurring_monthly for order in primary_orders)


Hope it helps

0
Imagine profil
Abandonează
Imagine profil
Christoph Farnleitner
Cel mai bun răspuns

sale_order_ids in your if conditions

if lead.sale_order_ids.is_primary_quotation

is not a single Sale Order, because 

  1. sale_order_ids = fields.One2many() - thus either no record, one record or many records
  2. you've probably never told sale_order_ids to be one specific record, i.e. by applying an actual search domain

See the domain attribute for One2many https://www.odoo.com/documentation/18.0/developer/reference/backend/orm.html#odoo.fields.One2many or compute the field.

Apart from that I don't think much can be said since your source doesn't really add up - to me at least. is_primary_quotation implies to me that there should be a single primary Sale Order only - but primary in regard to what? The Lead, a Customer, ...? You probably want to apply some logic that actually enforces is_primary_quotation to be possible to be set only once for any given sale.order linked to a crm.lead, i.e. by checking in create() and write() of sale.order whether any lead_id.sale_order_ids.filtered(lambda so: so.is_primary_quotation) is there already.

0
Imagine profil
Abandonează
Vikas Maharana
Autor

I want to update MRR and NRR for one quote, for that I create a boolean fields that will mark as primary quote.
If it is primary quote, then only it should update MRR and NRR in the respective lead.
I added the is_primary_quotation boolean field to identify and update the MRR and NRR in the lead.

My error is still not resolved bcz we can generate multiple quote from a lead.

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
Quote Customization
code quote reports
Imagine profil
0
mai 24
1472
How can I create a more complex quote calculi? Our service is charged on different considerations. Rezolvat
crm quote quotation
Imagine profil
Imagine profil
1
dec. 18
4222
Why do tests always fail?
crm code inherit mail.activity
Imagine profil
0
apr. 23
2572
Opportunity name in sale order and invoice ?
crm invoice quote opportunity
Imagine profil
Imagine profil
1
apr. 20
3923
Evaluation ERP for my business - Individual Offers with Pictures - AI-Supportetd
crm quote multilanguage ERP AI
Imagine profil
0
nov. 25
161
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