[IMP]: Improve product cost structure - float 2 decimal point.

bzr revid: rch_open_erp-20100908113733-e1b2fidfov2ud7eg
This commit is contained in:
rch (Open ERP) 2010-09-08 17:07:33 +05:30
parent 63b2cc967d
commit 5d2506a8b4
1 changed files with 22 additions and 25 deletions

View File

@ -55,25 +55,22 @@ class report_custom(report_rml):
main_sp_name = "<b>%s</b>\r\n" %(prod.seller_id.name)
price = supplier_info_pool.price_get(cr, uid, prod.seller_id.id, prod.id, number*prod_qtty)[prod.seller_id.id]
price = product_uom_pool._compute_price(cr, uid, prod.uom_id.id, price, to_uom_id=product_uom.id)
main_sp_price = '<b>%s</b>\r\n' %(str(price))
main_sp_price = '<b>%.2f</b>\r\n' %(price)
sum += prod_qtty*price
std_price = product_uom_pool._compute_price(cr, uid, prod.uom_id.id, prod.standard_price, to_uom_id=product_uom.id)
main_strd_price = str(std_price) + '\r\n'
sum_strd = prod_qtty*std_price
for seller_id in prod.seller_ids:
sellers += '- <i>'+ seller_id.name.name +'</i>\r\n'
price = supplier_info_pool.price_get(cr, uid, seller_id.name.id, prod.id, number*prod_qtty)[seller_id.name.id]
price = product_uom_pool._compute_price(cr, uid, prod.uom_id.id, price, to_uom_id=product_uom.id)
sellers_price += '<i>' + str(price) + '</i>\r\n'
xml += "<col para='yes'>" + prod_name + '</col>'
xml += "<col para='yes'>" + main_sp_name + sellers + '</col>'
xml += "<col f='yes'>" + str(prod_qtty) + '</col>'
xml += "<col f='yes'>" + product_uom.name + '</col>'
xml += "<col f='yes'>" + main_strd_price + '</col>'
xml += "<col f='yes'>" + main_sp_price + sellers_price + '</col>'
sellers_price += """<i>%.2f</i>\r\n"""%(price)
xml += """<col para='yes'> %s </col>
<col para='yes'> %s </col>
<col f='yes'>%.2f</col>
<col f='yes'>%s</col>
<col f='yes'>%.2f</col>
<col f='yes'>%s</col>'"""%(prod_name,main_sp_name + sellers ,prod_qtty, product_uom.name,float(main_strd_price),main_sp_price + sellers_price)
xml += '</row>'
return xml, sum, sum_strd
@ -87,9 +84,9 @@ class report_custom(report_rml):
xml += "<col para='yes'>" + workcenter.name + '</col>'
xml += "<col/>"
xml += "<col/>"
xml += "<col f='yes'>" + str(cost_cycle) + '</col>'
xml += "<col f='yes'>" + str(cost_hour) + '</col>'
xml += "<col f='yes'>" + str(cost_hour + cost_cycle) + '</col>'
xml += """<col f='yes'>%.2f</col>"""%(cost_cycle)
xml += """<col f='yes'>%.2f</col>"""%(cost_hour)
xml += """<col f='yes'>%.2f</col>"""%(cost_hour + cost_cycle)
xml += '</row>'
return xml, total
@ -154,9 +151,9 @@ class report_custom(report_rml):
<col/>
<col/>
<col f='yes'/>
<col f='yes'>%s</col>
<col f='yes'>%s</col>
</row></lines>'"""%(_('Total Cost'), _('of'), str(number), product.uom_id.name, str(total_strd), str(total))
<col f='yes'>%.2f</col>
<col f='yes'>%.2f</col>
</row></lines>'"""%(_('Total Cost'), _('of'), str(number), product.uom_id.name, total_strd, total)
else:
bom = bom_pool.browse(cr, uid, bom_id, context=context)
factor = number * product.uom_id.factor / bom.product_uom.factor
@ -182,9 +179,9 @@ class report_custom(report_rml):
<col/>
<col/>
<col t='yes'/>
<col t='yes'>%s</col>
<col t='yes'>%s</col>
</row></lines>'"""%(_('Cost'), _('of'), str(number), product.uom_id.name, str(total_strd), str(total))
<col t='yes'>%.2f</col>
<col t='yes'>%.2f</col>
</row></lines>'"""%(_('Cost'), _('of'), str(number), product.uom_id.name, total_strd, total)
total2 = 0
xml_tmp = ''
@ -201,16 +198,16 @@ class report_custom(report_rml):
<col/>
<col/>
<col/>
<col t='yes'>%s</col>
</row></lines>'"""%(_('Work Cost'), _('of'), str(number), product.uom_id.name, str(total2))
<col t='yes'>%.2f</col>
</row></lines>'"""%(_('Work Cost'), _('of'), str(number), product.uom_id.name, total2)
xml += """<lines style='total'> <row>
<col>%s %s %s %s : </col>
<col/>
<col/>
<col t='yes'/>
<col t='yes'>%s</col>
<col t='yes'>%s</col>
</row></lines>'"""%(_('Total Cost'), _('of'), str(number), product.uom_id.name, str(total_strd+total2), str(total+total2))
<col t='yes'>%.2f</col>
<col t='yes'>%.2f</col>
</row></lines>'"""%(_('Total Cost'), _('of'), str(number), product.uom_id.name, total_strd+total2, total+total2)
xml = '<?xml version="1.0" ?><report>' + config_start + config_stop + xml + '</report>'