Overslaan naar inhoud
Odoo Menu
  • Aanmelden
  • Probeer het gratis
  • Apps
    Financiën
    • Boekhouding
    • Facturatie
    • Onkosten
    • Spreadsheet (BI)
    • Documenten
    • Ondertekenen
    Verkoop
    • CRM
    • Verkoop
    • Kassasysteem winkel
    • Kassasysteem Restaurant
    • Abonnementen
    • Verhuur
    Websites
    • Websitebouwer
    • E-commerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Bevoorradingsketen
    • Voorraad
    • Productie
    • PLM
    • Inkoop
    • Onderhoud
    • Kwaliteit
    Personeelsbeheer
    • Werknemers
    • Werving & Selectie
    • Verlof
    • Evaluaties
    • Aanbevelingen
    • Wagenpark
    Marketing
    • Social media Marketing
    • E-mailmarketing
    • SMS Marketing
    • Evenementen
    • Marketingautomatisering
    • Enquêtes
    Diensten
    • Project
    • Urenstaten
    • Buitendienst
    • Helpdesk
    • Planning
    • Afspraken
    Productiviteit
    • Chat
    • Goedkeuringen
    • IoT
    • VoIP
    • Kennis
    • WhatsApp
    Apps van derden Odoo Studio Odoo Cloud Platform
  • Bedrijfstakken
    Detailhandel
    • Boekhandel
    • kledingwinkel
    • Meubelzaak
    • Supermarkt
    • Bouwmarkt
    • Speelgoedwinkel
    Food & Hospitality
    • Bar en Pub
    • Restaurant
    • Fastfood
    • Gastenverblijf
    • Drankenhandelaar
    • Hotel
    Vastgoed
    • Makelaarskantoor
    • Architectenbureau
    • Bouw
    • Vastgoedbeheer
    • Tuinieren
    • Vereniging van eigenaren
    Consulting
    • Accountantskantoor
    • Odoo Partner
    • Marketingbureau
    • Advocatenkantoor
    • Talentenwerving
    • Audit & Certificering
    Productie
    • Textiel
    • Metaal
    • Meubels
    • Eten
    • Brewery
    • Relatiegeschenken
    Gezondheid & Fitness
    • Sportclub
    • Opticien
    • Fitnesscentrum
    • Wellness-medewerkers
    • Apotheek
    • Kapper
    Trades
    • Klusjesman
    • IT-hardware & support
    • Zonne-energiesystemen
    • Schoenmaker
    • Schoonmaakdiensten
    • HVAC-diensten
    Andere
    • Non-profitorganisatie
    • Milieuagentschap
    • Verhuur van Billboards
    • Fotograaf
    • Fietsleasing
    • Softwareverkoper
    Browse all Industries
  • Community
    Leren
    • Tutorials
    • Documentatie
    • Certificeringen
    • Training
    • Blog
    • Podcast
    Versterk het onderwijs
    • Onderwijs- programma
    • Scale Up! Business Game
    • Bezoek Odoo
    Download de Software
    • Downloaden
    • Vergelijk edities
    • Releases
    Werk samen
    • Github
    • Forum
    • Evenementen
    • Vertalingen
    • Word een Partner
    • Services for Partners
    • Registreer je accountantskantoor
    Diensten
    • Vind een partner
    • Vind een boekhouder
    • Een adviseur ontmoeten
    • Implementatiediensten
    • Klantreferenties
    • Ondersteuning
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Vraag een demo aan
  • Prijzen
  • Help

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

  • CRM
  • e-Commerce
  • Boekhouding
  • Voorraad
  • PoS
  • Project
  • MRP
All apps
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Help

How to get the sum of field in a column?

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
python2.7openerp7
6275 Weergaven
Avatar
Anirudh Lou

I have this table student_resources and here are data that it hold:

p_id   p_name     res_code         tax       base_amt    date
2300  |A student |WC158 - EWT 1%  |133.93   |13392.86   |2015-07-01
2300  |A student |WC158 - EWT 1%  |62.50    |6250.00    |2015-07-01
901   |B student |WC158 - EWT 1%  |8.31     |830.58     |2015-06-09
2831  |C student |WC160 - EWT 2%  |2736.84  |136842.11  |2015-06-04
905   |D student |WC158 - EWT 1%  |31.25    |3125.00    |2015-06-16
905   |D student |WC158 - EWT 1%  |31.25    |3125.00    |2015-06-29
905   |D student |WC158 - EWT 1%  |31.25    |3125.00    |2015-06-29
905   |D student |WC158 - EWT 1%  |26.79    |2678.57    |2015-06-16
959   |G student |WC158 - EWT 1%  |114.29   |11428.57   |2015-01-10
959   |G student |WC158 - EWT 1%  |478.90   |47890.18   |2015-01-20
2424  |L student |WC158 - EWT 1%  |45.54    |4553.58    |2015-03-03 

and in my class student_resources_report i have this definition:

...        
atc_code = nature = ''
_logger.info("\n\t\t\tI was called. My method name is %s"%(str('generate_student_resource_report')))
base = amount = percent = 0.00
for ewt in self.browse(cr,uid,ids,context):
old_history = stud_re_report_line_obj.search(cr, uid, [('parent_id','=',ewt.id)],context=context)
if old_history:
stud_re_report_line_obj.unlink(cr, uid, old_history,context=context)

lines = student_resource_obj.search(cr, uid,[('date', '>=', ewt.date_from),('date', '<=', ewt.date_to)])

for resource in student_resource_obj.browse(cr,uid,lines,context=context):
if 'WC158' in resource.name:
atc_code = 'WC158'
nature = 'NOTBOOK'
seq = 1
base += resource.base_amount
amount += resource.tax_amount
elif 'WC160' in resource.name:
atc_code = 'WC160'
nature = 'BACKPACK'
base += resource.base_amount
amount += resource.tax_amount
seq = 2
elif 'WC010' in resource.name:
atc_code = 'WC010'
nature = 'COLOR'
base += resource.base_amount
amount += resource.tax_amount
seq = 3
elif 'WC140' in ait.name:
atc_code = 'WC140'
nature = 'BOOKS'
base += resource.base_amount
amount += resource.tax_amount
seq = 4
percent = self._get_percentage(cr, uid, ids, resource.name, context=context)
partner_id = resource.partner_id.id
dictionary = {
'name' : ewt.id,
'parent_id' : ewt.id,
'partner_id' : partner_id,
'atc_code' : atc_code,
'nature' : nature,
'base_amt' : base,
'percent' : percent,
'tax_amt' : amount,
'seq' : seq,
}
stud_re_report_line_obj.create(cr, uid, dictionary, context=context)
list = stud_re_report_line_obj.search(cr,uid,[('parent_id','=',ewt.id)])
lines = [line.id if line.id else False for line in stud_re_report_line_obj.browse(cr,uid,list,context=context)]
value = {
"value" : {
'name' : 'Student Resource Report',
"ewt_line" : lines
}
}
return value


What i can't understand is that when my view is being rendered it output only looks like this:



Seq Stud Code Nature Base Amt Percent Tax 1 B student WC158 NOTEBOOK 830.58 1.0 8.31 1 D student WC158 NOTEBOOK 3509.15 1.0 35.10 ---> (it adds 2678.57 and 830.58, which must not because it's p_id(student) is not the same (I don't know why)) 2 C student WC160 BACKPACK 136842.11 2.0 2736.84

What i expected was the figure below and this is my desired output, that is to get the sum of all base_amt and tax_amt of particular student :

Seq Stud        Code    Nature      Base Amt   Percent  Tax
1   B student   WC158   NOTEBOOK    830.58     1.0     8.31
1   D student   WC158   NOTEBOOK    12053.57   1.0     120.54  ----> since (3125.00+3125.00+3125.00+2678.57) = 12053.57 and (31.25+31.25+31.25+26.79) =  120.54
2   C student   WC160   BACKPACK    136842.11  2.0     2736.84


Actually, this is somehow related with my 2 previous questions, but used sql statement instead and i get another error.

Any help/suggestions/comments is very much appreciated


0
Avatar
Annuleer
Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!

Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!

Aanmelden
Gerelateerde posts Antwoorden Weergaven Activiteit
How do I create a message box/ dialog box in openerp 7 with 'Ok' and 'Cancel' buttons in it
python2.7 openerp7
Avatar
Avatar
3
sep. 18
6282
Hide edit button according to status in openerp
python2.7 openerp7
Avatar
0
feb. 16
4355
How to show two fields from the same table whith on change
python2.7 openerp7
Avatar
Avatar
1
mrt. 15
1208
Currency by defaults Opgelost
python2.7 openerp7
Avatar
Avatar
Avatar
3
mrt. 15
1001
How to fixed problem in import and export button?
python2.7 openerp7
Avatar
Avatar
1
mrt. 15
5331
Community
  • Tutorials
  • Documentatie
  • Forum
Open Source
  • Downloaden
  • Github
  • Runbot
  • Vertalingen
Diensten
  • Odoo.sh Hosting
  • Ondersteuning
  • Upgrade
  • Gepersonaliseerde ontwikkelingen
  • Onderwijs
  • Vind een boekhouder
  • Vind een partner
  • Word een Partner
Over ons
  • Ons bedrijf
  • Merkelementen
  • Neem contact met ons op
  • Vacatures
  • Evenementen
  • Podcast
  • Blog
  • Klanten
  • Juridisch • Privacy
  • Beveiliging
الْعَرَبيّة 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 is een suite van open source zakelijke apps die aan al je bedrijfsbehoeften voldoet: CRM, E-commerce, boekhouding, inventaris, kassasysteem, projectbeheer, enz.

Odoo's unieke waardepropositie is om tegelijkertijd zeer gebruiksvriendelijk en volledig geïntegreerd te zijn.

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