Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

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

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

Method Subtotal

Subscribe

Get notified when there's activity on this post

This question has been flagged
2 Replies
4413 Views
Avatar
yusuf

hi all,

I have a problem hearts Making subtotal method , the method for Only thing I can last column displays the data in Saja NOT want to add BETWEEN column 1 and column 2 , I 've Tried differences Only the results are still the same and this is the method that I created

 

def _get_total(self,a):
        total =0
        for o in a :
            total +=(o['cost_spare_part'] *o['jumlah'])
            print "ini total=================>>>>>>>>>>",total

        return total

0
Avatar
Discard
Akhil P Sivan

Hi Akhil P Sivan [1] A variable is the name of the table on parts_lines or a = parts_lines in this parts_lines table I want to take the price of spare parts and the number but when I took the price ( standard_price ) that are on the object , but when I took my product.product standard_price even error a ={'jumlah': 2.0, 'asset_name': u'Kendaraan', 'plat_no': u'A 2338 AB', 'asset_no': u'1.11 Asset', 'tindakan': False, 'pelaksana': False, 'satuan': u'Unit(s)', 'permasalahan': u'as', 'spare_part': u'ban', 'tanggal': '2015-01-28 06:55:11', 'cost_spare_part': 50000.0} of the answer that you gave no error occurs, the error like this : for o in self : TypeError: 'history_maintenance' object is not iterable [1] https://www.odoo.com/forum/help-1/user/336884

Zbik

How and where you call _get_total?

yusuf
Author

The method to call formatLang (get_total (o)) and this for at RML (report)

Akhil P Sivan

Hi Yusuf, I made a change in the answer. Please try like that. Are you can calling the 'part_lines' field as one2many from any other object? Where you want to get the 'total_cost' value returning from the function?

Avatar
Akhil P Sivan
Best Answer

Hi Yusuf,

 

Try like this:

 

def _get_total(self,a):
        total =0
        total += a.cost_spare_part * a.jumlah
        print "ini total=================>>>>>>>>>>",total

   return total

2
Avatar
Discard
yusuf
Author

Hi Akhil P Sivan, I already use the method that you created but in the method you created there is an error and this error mean what ? and this error : total +=a.cost_spare_part * a.jumlah AttributeError: 'dict' object has no attribute 'cost_spare_part'

Avatar
Zbik
Best Answer

If call is formatLang (get_total (o)), then o is main object of report, in this case you try:

for line in a.part_lines :
  total +=line.cost_spare_part * line.jumlah

What is your o? and how you use and define parts_lines in model and report?

UPDATE:

Try this, in RML;

formatLang (get_total (line(data))

and in code:

for line in a:
  total +=line.cost_spare_part * line.jumlah

or....  total +=line['cost_spare_part'] * line['jumlah']

0
Avatar
Discard
yusuf
Author

Hi zbik, I already use the method that you created but in the method you created there is an error and this error mean what ? and this error : for line in a.part_lines : AttributeError: 'dict' object has no attribute 'part_lines'

yusuf
Author

this is rml in subtotal

[[repeatIn(line(data) ,'o')]] [[ no_urut() ]] [[ formatLang(o['tanggal'], date=True) ]] [ [[ o['asset_no'] ]] ] [[ o['asset_name'] ]] [[ o['plat_no'] ]] [[ o['permasalahan'] ]] [[ o['tindakan'] ]] [[ o['spare_part'] ]] [[ formatLang(o['cost_spare_part']) ]] [[ o['jumlah'] ]] [[ o['satuan'] ]] [[ formatLang(get_biaya(o)) ]] [[ o['pelaksana'] ]]
Subtotal [[ formatLang(get_total(o)) ]] .

Zbik

[[repeatIn(line(data) ,'o')]] ..... in this case "o" is only one line. It can not work. A list "o" is needed. What is the structure of the variable "data"?

yusuf
Author

How to " o " could work because our time line in the loop for o.parts_lines then there is an error for the line in o.parts_lines object has no attribute Parts_lines

Zbik

answer updated

yusuf
Author

how because I 've had some time messing about with " for " the result is still the same

Zbik

If line(data) return list? and in RML you use formatLang (get_total(line(data)) it should work.

yusuf
Author

Hi zbik, thank you for helping me and the advice you give it turns out to work and once again I thank you , if I may be asked for your email ?

yusuf
Author

Hi zbik, I have questions about the report in Excel, this is the case if we take the data period 1 then naturally arises automatically period to 1 but if you want to choose the period to 2 then automatically also the emergence of the period to 2, if for example, want to bring up the data period 1 in period 2?

Zbik

My email: darek@krokus.com.pl. I do not understand the last issue and additionaly what is the structure of your code and data.

yusuf
Author

data record in period

Enjoying the discussion? Don't just read, join in!

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

Sign up
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة 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