Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

Singleton issue while update MRR and NRR!

Odoberať

Get notified when there's activity on this post

This question has been flagged
crmcodequotesingletonissue
2 Replies
1079 Zobrazenia
Avatar
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
Avatar
Zrušiť
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Best Answer

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
Avatar
Zrušiť
Avatar
Christoph Farnleitner
Best Answer

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
Avatar
Zrušiť
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!

Registrácia
Related Posts Replies Zobrazenia Aktivita
Quote Customization
code quote reports
Avatar
0
máj 24
1472
How can I create a more complex quote calculi? Our service is charged on different considerations. Solved
crm quote quotation
Avatar
Avatar
1
dec 18
4223
Why do tests always fail?
crm code inherit mail.activity
Avatar
0
apr 23
2573
Opportunity name in sale order and invoice ?
crm invoice quote opportunity
Avatar
Avatar
1
apr 20
3923
Evaluation ERP for my business - Individual Offers with Pictures - AI-Supportetd
crm quote multilanguage ERP AI
Avatar
0
nov 25
162
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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