Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Aplikacije
    Finance
    • Knjigovodstvo
    • Obračun
    • Stroški
    • Spreadsheet (BI)
    • Dokumenti
    • Podpisovanje
    Prodaja
    • CRM
    • Prodaja
    • POS Shop
    • POS Restaurant
    • Naročnine
    • Najem
    Spletne strani
    • Website Builder
    • Spletna trgovina
    • Blog
    • Forum
    • Pogovor v živo
    • eUčenje
    Dobavna veriga
    • Zaloga
    • Proizvodnja
    • PLM
    • Nabava
    • Vzdrževanje
    • Kakovost
    Kadri
    • Kadri
    • Kadrovanje
    • Odsotnost
    • Ocenjevanja
    • Priporočila
    • Vozni park
    Marketing
    • Družbeno Trženje
    • Email Marketing
    • SMS Marketing
    • Dogodki
    • Avtomatizacija trženja
    • Ankete
    Storitve
    • Projekt
    • Časovnice
    • Storitve na terenu
    • Služba za pomoč
    • Načrtovanje
    • Termini
    Produktivnost
    • Razprave
    • Odobritve
    • IoT
    • Voip
    • Znanje
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industrije
    Trgovina na drobno
    • Book Store
    • Trgovina z oblačili
    • Trgovina s pohištvom
    • Grocery Store
    • Trgovina s strojno opremo računalnikov
    • Trgovina z igračami
    Food & Hospitality
    • Bar and Pub
    • Restavracija
    • Hitra hrana
    • Guest House
    • Beverage Distributor
    • Hotel
    Nepremičnine
    • Real Estate Agency
    • Arhitekturno podjetje
    • Gradbeništvo
    • Estate Management
    • Vrtnarjenje
    • Združenje lastnikov nepremičnin
    Svetovanje
    • Računovodsko podjetje
    • Odoo Partner
    • Marketinška agencija
    • Law firm
    • Pridobivanje talentov
    • Audit & Certification
    Proizvodnja
    • Tekstil
    • Metal
    • Pohištvo
    • Hrana
    • Brewery
    • Poslovna darila
    Health & Fitness
    • Športni klub
    • Trgovina z očali
    • Fitnes center
    • Wellness Practitioners
    • Lekarna
    • Frizerski salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Sistemi sončne energije
    • Izdelovalec čevljev
    • Čistilne storitve
    • HVAC Services
    Ostali
    • Neprofitna organizacija
    • Agencija za okolje
    • Najem oglasnih panojev
    • Fotografija
    • Najem koles
    • Prodajalec programske opreme
    Browse all Industries
  • Skupnost
    Learn
    • Tutorials
    • Dokumentacija
    • Certifikati
    • Šolanje
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Prenesi
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Dogodki
    • Prevodi
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Sklici kupca
    • Podpora
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Določanje cen
  • Pomoč

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

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

How to get the sum of field in a column?

Naroči se

Get notified when there's activity on this post

This question has been flagged
python2.7openerp7
6282 Prikazi
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
Opusti
Enjoying the discussion? Don't just read, join in!

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

Prijavi
Related Posts Odgovori Prikazi Aktivnost
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
6288
Hide edit button according to status in openerp
python2.7 openerp7
Avatar
0
feb. 16
4363
How to show two fields from the same table whith on change
python2.7 openerp7
Avatar
Avatar
1
mar. 15
1217
Currency by defaults Solved
python2.7 openerp7
Avatar
Avatar
Avatar
3
mar. 15
1004
How to fixed problem in import and export button?
python2.7 openerp7
Avatar
Avatar
1
mar. 15
5349
Community
  • Tutorials
  • Dokumentacija
  • Forum
Open Source
  • Prenesi
  • Github
  • Runbot
  • Prevodi
Services
  • Odoo.sh Hosting
  • Podpora
  • Nadgradnja
  • Custom Developments
  • Izobraževanje
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Sredstva blagovne znamke
  • Kontakt
  • Zaposlitve
  • Dogodki
  • Podcast
  • Blog
  • Stranke
  • Pravno • Zasebnost
  • Varnost
الْعَرَبيّة 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 a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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