Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Method Subtotal

By
yusuf
on 2/1/15, 11:36 AM 723 views

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

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

yusuf
on 2/2/15, 5:55 AM

How and where you call _get_total?

zbik
on 2/2/15, 6:04 AM

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

yusuf
on 2/2/15, 7:23 AM

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?

Akhil P Sivan
on 2/2/15, 11:44 AM
2

Akhil P Sivan

--Akhil P Sivan--
3423
| 5 3 6
Kochi, India
--Akhil P Sivan--

Interested in exploring Odoo both technically & functionality wise.

email-id : akhilpsivan01@gmail.com

Akhil P Sivan
On 2/1/15, 5:13 PM

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

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'

yusuf
on 2/3/15, 7:27 AM
0

zbik

--zbik--
5941
| 6 4 7
Lodz, Poland
--zbik--


zbik
On 2/2/15, 11:47 AM

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']

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
on 2/3/15, 7:24 AM

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)) ]] .

yusuf
on 2/3/15, 7:29 AM

[[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"?

zbik
on 2/3/15, 9:10 AM

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

yusuf
on 2/4/15, 3:23 AM

answer updated

zbik
on 2/4/15, 4:07 AM

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

yusuf
on 2/4/15, 4:17 AM

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

zbik
on 2/4/15, 5:47 AM

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
on 2/4/15, 8:18 AM

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?

yusuf
on 2/4/15, 8:40 AM

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

zbik
on 2/4/15, 9:33 AM

data record in period

yusuf
on 2/4/15, 10:58 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 2/1/15, 11:36 AM
Seen: 723 times
Last updated: 3/16/15, 8:10 AM