This question has been flagged
2 Replies
3565 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

Avatar
Discard

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

How and where you call _get_total?

Author

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

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?

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

Avatar
Discard
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'

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

Avatar
Discard
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'

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

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

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

answer updated

Author

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

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

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 ?

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?

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

Author

data record in period