Zum Inhalt springen
Odoo Menü
  • Anmelden
  • Jetzt gratis testen
  • Apps
    Finanzen
    • Buchhaltung
    • Rechnungsstellung
    • Spesenabrechnung
    • Tabellenkalkulation (BI)
    • Dokumente
    • E-Signatur
    Vertrieb
    • CRM
    • Vertrieb
    • Kassensystem – Shop
    • Kassensystem – Restaurant
    • Abonnements
    • Vermietung
    Websites
    • Website-Builder
    • E-Commerce
    • Blog
    • Forum
    • Livechat
    • E-Learning
    Lieferkette
    • Lager
    • Fertigung
    • PLM
    • Einkauf
    • Wartung
    • Qualität
    Personalwesen
    • Mitarbeiter
    • Personalbeschaffung
    • Abwesenheiten
    • Mitarbeiterbeurteilung
    • Personalempfehlungen
    • Fuhrpark
    Marketing
    • Social Marketing
    • E-Mail-Marketing
    • SMS-Marketing
    • Veranstaltungen
    • Marketing-Automatisierung
    • Umfragen
    Dienstleistungen
    • Projekte
    • Zeiterfassung
    • Außendienst
    • Kundendienst
    • Planung
    • Termine
    Produktivität
    • Dialog
    • Genehmigungen
    • IoT
    • VoIP
    • Wissensdatenbank
    • WhatsApp
    Apps von Drittanbietern Odoo Studio Odoo Cloud-Plattform
  • Branchen
    Einzelhandel
    • Buchladen
    • Kleidergeschäft
    • Möbelhaus
    • Lebensmittelgeschäft
    • Baumarkt
    • Spielwarengeschäft
    Essen & Gastgewerbe
    • Bar und Kneipe
    • Restaurant
    • Fast Food
    • Gästehaus
    • Getränkehändler
    • Hotel
    Immobilien
    • Immobilienagentur
    • Architekturbüro
    • Baugewerbe
    • Immobilienverwaltung
    • Gartenarbeit
    • Eigentümervereinigung
    Beratung
    • Buchhaltungsfirma
    • Odoo-Partner
    • Marketingagentur
    • Anwaltskanzlei
    • Talentakquise
    • Prüfung & Zertifizierung
    Fertigung
    • Textil
    • Metall
    • Möbel
    • Speisen
    • Brauerei
    • Firmengeschenke
    Gesundheit & Fitness
    • Sportklub
    • Brillengeschäft
    • Fitnessstudio
    • Therapeut
    • Apotheke
    • Friseursalon
    Handel
    • Handyman
    • IT-Hardware & -Support
    • Solarenergiesysteme
    • Schuster
    • Reinigungsdienstleistungen
    • HLK-Dienstleistungen
    Sonstiges
    • Gemeinnützige Organisation
    • Umweltschutzagentur
    • Plakatwandvermietung
    • Fotostudio
    • Fahrrad-Leasing
    • Software-Händler
    Alle Branchen ansehen
  • Community
    Lernen
    • Tutorials
    • Dokumentation
    • Zertifizierungen
    • Schulung
    • Blog
    • Podcast
    Bildung fördern
    • Bildungsprogramm
    • Scale-Up! Planspiel
    • Odoo besuchen
    Software anfragen
    • Herunterladen
    • Editionen vergleichen
    • Releases
    Zusammenarbeiten
    • Github
    • Forum
    • Veranstaltungen
    • Übersetzungen
    • Partner werden
    • Dienstleistungen für Partner
    • Buchhaltungsfirma registrieren
    Services anfragen
    • Partner finden
    • Buchhalter finden
    • Einen Experten treffen
    • Implementierungsservices
    • Kundenreferenzen
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Eine Demo erhalten
  • Preiskalkulation
  • Hilfe

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

  • CRM
  • e-Commerce
  • Buchhaltung
  • Lager
  • PoS
  • Projekte
  • MRP
All apps
Sie müssen registriert sein, um mit der Community zu interagieren.
Alle Beiträge Personen Abzeichen
Stichwörter (Alle anzeigen)
odoo accounting v14 pos v15
Über dieses Forum
Sie müssen registriert sein, um mit der Community zu interagieren.
Alle Beiträge Personen Abzeichen
Stichwörter (Alle anzeigen)
odoo accounting v14 pos v15
Über dieses Forum
Hilfe

calculate the sum of collection values many2one

Abonnieren

Erhalten Sie eine Benachrichtigung, wenn es eine Aktivität zu diesem Beitrag gibt

Diese Frage wurde gekennzeichnet
2 Antworten
5181 Ansichten
Avatar
Salama Sidna

Hi 

I have those two classes

First

class my_participation(models.Model):

_name = "participation.participation"

_name = "participation.participation" 

_description = "participation"
_rec_name="participation_num"

solde = fields.Integer(string="Solde")
fidelite = fields.Many2one("fidelite.fidelite", "Fidelite ", ondelete="cascade", required="true")


Seconde

class my_fidelite(models.Model):

_name = "fidelite.fidelite"
_description = "fidelite"
_rec_name="fidelite_num"

fidelite_num = fields.Char(string='Code de fidelite', required="true")
_sql_constraints = [ ('fidelite_c_unique', 'unique (fidelite_num)', 'Ce code EXIST ')]
participation_ids = fields.One2many("participation.participation", "fidelite", "Participations concernees")

sum_participations_solde = fields.Integer(string='Solde of fidelite')

my question is how can i calculate  sum_participations_solde that presents the sum of all soldes of participations that correspond to this fidelite ?

THANK YOU

0
Avatar
Verwerfen
Avatar
Salama Sidna
Autor Beste Antwort

I worked with this code


sum_participation_soldes = fields.Integer(string="Solde totale de fildelite de ce mois ", compute='fidelite_total_solde', store=True)
#@api.depends('participation_ids')
def fidelite_total_solde(self):
total = 0
for r in self.participation_ids:
     total += r.solde
self.sum_participation_soldes = total


there is no error but it doesnt fuction the sum_participation_soldes not counted always 0 its not adding 

thank you

0
Avatar
Verwerfen
Your Dad

self.sum_participation_soldes = sum(line.solde for line in self.participation_ids)

Salama Sidna
Autor

If you mean like this it doesnt function too but no error

@api.depends('participation_ids')

def fidelite_total_solde(self):

for r in self.participation_ids:

self.sum_participation_soldes = sum(line.solde for line in self.participation_ids)

Your Dad

@api.depends('participation_ids')

def fidelite_total_solde(self):

self.sum_participation_soldes = sum(line.solde for line in self.participation_ids)

Salama Sidna
Autor

Hi bouth of those doesnt function always 0

@api.depends('participation_ids')

def fidelite_total_solde(self):

for r in self:

r.sum_participation_soldes = sum(line.solde for line in r.participation_ids)

#@api.depends('participation_ids')

#def fidelite_total_solde(self):

# self.sum_participation_soldes = sum(line.solde for line in self.participation_ids)

Avatar
Niyas Raphy (Walnut Software Solutions)
Beste Antwort

Hi,

You can make it as a compute field and compute the sum into the field.

sum_participations_solde = fields.Integer(string='Solde of fidelite', compute='get_total_sum')

Now you have to write the function in the given name.

def get_total_sum(self):

    total = 0

    for rec in self.participation_ids:

          total += rec.solde

    self.sum_participations_solde = total

 The code is not tested, you can follow the same procedure, if the above is not working see how the amount of the sale order is calculated. There is a function to compute the total amount.


Thanks

0
Avatar
Verwerfen
Diskutieren Sie gerne? Treten Sie bei, statt nur zu lesen!

Erstellen Sie heute ein Konto, um exklusive Funktionen zu nutzen und mit unserer tollen Community zu interagieren!

Registrieren
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Herunterladen
  • Github
  • Runbot
  • Übersetzungen
Dienstleistungen
  • Odoo.sh-Hosting
  • Support
  • Upgrade
  • Individuelle Entwicklungen
  • Bildung
  • Buchhalter finden
  • Partner finden
  • Partner werden
Über uns
  • Unsere Firma
  • Markenwerte
  • Kontakt
  • Karriere
  • Veranstaltungen
  • Podcast
  • Blog
  • Kunden
  • Rechtliches • Datenschutz
  • Sicherheit
الْعَرَبيّة 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 ist eine Suite von Open-Source-Betriebsanwendungen, die alle Bedürfnisse Ihres Unternehmens abdecken: CRM, E-Commerce, Buchhaltung, Lager, Kassensystem, Projektmanagement etc.

Das einzigartige Wertversprechen von Odoo ist, dass es gleichzeitig sehr einfach zu bedienen und voll integriert ist.

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