From 96b3dc9cb7ec4b90af44a057659aa2512f8ff64d Mon Sep 17 00:00:00 2001 From: apa-tiny Date: Thu, 16 Sep 2010 17:35:21 +0530 Subject: [PATCH] [mrp]:Product Cost Structure:use formatLang function for changes date and amount according to lang. bzr revid: apa@tinyerp.com-20100916120521-215fcw96iz7f1zqt --- addons/mrp/report/price.py | 82 +++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 45 deletions(-) diff --git a/addons/mrp/report/price.py b/addons/mrp/report/price.py index 762d1e4b2a6..38e65e0446f 100644 --- a/addons/mrp/report/price.py +++ b/addons/mrp/report/price.py @@ -23,7 +23,9 @@ import ir import pooler from report.interface import report_rml from report.interface import toxml - +from tools import to_xml +from report import report_sxw +from datetime import datetime from tools.translate import _ @@ -38,6 +40,9 @@ class report_custom(report_rml): workcenter_pool = pool.get('mrp.workcenter') user_pool = pool.get('res.users') bom_pool = pool.get('mrp.bom') + rml_obj=report_sxw.rml_parse(cr, uid, product_pool._name,context) + rml_obj.localcontext.update({'lang':context.get('lang',False)}) + company_currency = user_pool.browse(cr, uid, uid).company_id.currency_id def process_bom(bom, currency_id, factor=1): xml = '' sum = 0 @@ -55,7 +60,7 @@ class report_custom(report_rml): main_sp_name = "%s\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 = '%.2f\r\n' %(price) + main_sp_price = """"""+rml_obj.formatLang(price)+' '+ company_currency.symbol+"""\r\n""" 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' @@ -64,13 +69,12 @@ class report_custom(report_rml): sellers += '- '+ seller_id.name.name +'\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 += """%.2f\r\n"""%(price) - xml += """ %s - %s - %.2f - %s - %.2f - %s'"""%(prod_name,main_sp_name + sellers ,prod_qtty, product_uom.name,float(main_strd_price),main_sp_price + sellers_price) + sellers_price += """"""+rml_obj.formatLang(price) +' '+ company_currency.symbol +"""\r\n""" + xml += """ """+ prod_name +""" + """+ main_sp_name + sellers + """ + """+ rml_obj.formatLang(prod_qtty) +' '+ product_uom.name +""" + """+ rml_obj.formatLang(float(main_strd_price)) +' '+ company_currency.symbol +""" + """ + main_sp_price + sellers_price + """'""" xml += '' return xml, sum, sum_strd @@ -83,10 +87,9 @@ class report_custom(report_rml): xml = '' xml += "" + workcenter.name + '' xml += "" - xml += "" - xml += """%.2f"""%(cost_cycle) - xml += """%.2f"""%(cost_hour) - xml += """%.2f"""%(cost_hour + cost_cycle) + xml += """"""+rml_obj.formatLang(cost_cycle)+' '+ company_currency.symbol + """""" + xml += """"""+rml_obj.formatLang(cost_hour)+' '+ company_currency.symbol + """""" + xml += """"""+rml_obj.formatLang(cost_hour + cost_cycle)+' '+ company_currency.symbol + """""" xml += '' return xml, total @@ -95,13 +98,13 @@ class report_custom(report_rml): xml = '' config_start = """ - %s + """ + to_xml(rml_obj.formatLang(datetime.now().strftime('%Y-%m-%d %H:%M:%S'),date_time=True)) + """ %s 210.00mm,297.00mm 595.27 841.88 - 55.00mm,55.00mm, 20.00mm, 22.00mm, 22.00mm, 25.00mm - """ % (time.strftime('%m/%d/%Y %H:%M'),user_pool.browse(cr, uid, uid).company_id.name) + 55.00mm,58.00mm,29.00mm,29.00mm,29.00mm + """ % (user_pool.browse(cr, uid, uid).company_id.name) config_stop = """ Generated by OpenERP @@ -111,14 +114,13 @@ class report_custom(report_rml): %s - %s %s %s - """ % (_('Work Center name'), _('Cycles Cost'), _('Hourly Cost'),_('Work Cost')) + """ % (_('Work Center name'), _('Cycles Cost')+'('+company_currency.code+')', _('Hourly Cost')+'('+company_currency.code+')',_('Work Cost')+'('+company_currency.code+')') prod_header = """ %s @@ -126,11 +128,9 @@ class report_custom(report_rml): %s %s %s - %s - """ % (_('Component'), _('Component suppliers'), _('Quantity'), _('Uom'), _('Cost Price per Uom'), _('Supplier Price per Uom')) + """ % (_('Component'), _('Component suppliers'), _('Quantity'),_('Cost Price per Uom')+'('+company_currency.code+')', _('Supplier Price per Uom')+'('+company_currency.code+')') - company_currency = user_pool.browse(cr, uid, uid).company_id.currency_id.id for product in product_pool.browse(cr, uid, ids, context=context): bom_id = bom_pool._bom_find(cr, uid, product.id, product.uom_id.id) title = "%s" %(_("Cost Structure")) @@ -145,16 +145,14 @@ class report_custom(report_rml): - - - - - """ xml += """ - %s %s %s %s : - + """ + _('Total Cost ') + _('of ') + str(number) +' '+ product.uom_id.name +'('+company_currency.code+')'+ """: - %.2f - %.2f - '"""%(_('Total Cost'), _('of'), str(number), product.uom_id.name, total_strd, total) + """+ rml_obj.formatLang(total_strd) +' '+ company_currency.symbol + """ + """+ rml_obj.formatLang(total) +' '+ company_currency.symbol + """ + '""" else: bom = bom_pool.browse(cr, uid, bom_id, context=context) factor = number * product.uom_id.factor / bom.product_uom.factor @@ -169,20 +167,19 @@ class report_custom(report_rml): } xml_tmp = '' for sub_bom in (sub_boms and sub_boms[0]) or [parent_bom]: - txt, sum, sum_strd = process_bom(sub_bom, company_currency) + txt, sum, sum_strd = process_bom(sub_bom, company_currency.id) xml_tmp += txt total += sum total_strd += sum_strd xml += "" + xml_tmp + '' xml += """ - %s %s %s %s : - + """ + _('Cost ') + _('of ') + str(number) +' '+ product.uom_id.name +'(' + company_currency.code +')'+ """: - %.2f - %.2f - '"""%(_('Cost'), _('of'), str(number), product.uom_id.name, total_strd, total) + """+ rml_obj.formatLang(total_strd) +' '+ company_currency.symbol + """ + """+ rml_obj.formatLang(total) +' '+ company_currency.symbol + """ + '""" total2 = 0 xml_tmp = '' @@ -194,27 +191,22 @@ class report_custom(report_rml): xml += workcenter_header xml += "" + xml_tmp + '' xml += """ - %s %s %s %s : + """ + _('Work Cost ') + _('of ') + str(number) +' '+ product.uom_id.name +'('+company_currency.code+')'+""": - - %.2f - '"""%(_('Work Cost'), _('of'), str(number), product.uom_id.name, total2) + """+ rml_obj.formatLang(total2) +' '+ company_currency.symbol +""" + '""" xml += """ - %s %s %s %s : - + """ + _('Total Cost ') + _('of ') + str(number) +' '+ product.uom_id.name +'('+company_currency.code+')'+ """: - %.2f - %.2f - '"""%(_('Total Cost'), _('of'), str(number), product.uom_id.name, total_strd+total2, total+total2) + """+ rml_obj.formatLang(total_strd+total2) +' '+ company_currency.symbol + """ + """+ rml_obj.formatLang(total+total2) +' '+ company_currency.symbol + """ + '""" xml = '' + config_start + config_stop + xml + '' return xml report_custom('report.product.price', 'product.product', '', 'addons/mrp/report/price.xsl') - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: -