From fd65d126806f5a3b31cdb3f21e10dfb054aa8694 Mon Sep 17 00:00:00 2001 From: "nicolas.bessi@camptocamp.com" <> Date: Fri, 22 Oct 2010 15:34:02 +0200 Subject: [PATCH 01/36] [FIX] RC2 fix of image embeeding, possibilit to have tmp file name in same milisecond, imporvement of multi header support when cusomizing report, fix of translation getter retunr scr if no translation available bzr revid: nicolas.bessi@camptocamp.com-20101022133402-bme1hmy4mtd7maa8 --- addons/report_webkit/report_helper.py | 2 +- addons/report_webkit/webkit_report.py | 34 ++++++++++++++++----------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/addons/report_webkit/report_helper.py b/addons/report_webkit/report_helper.py index 80896fa4ba2..db0c1c372fc 100644 --- a/addons/report_webkit/report_helper.py +++ b/addons/report_webkit/report_helper.py @@ -51,7 +51,7 @@ class WebKitHelper(object): height = 'width="%spx"'%(height) else : height = ' ' - toreturn = ''%( + toreturn = ''%( width, height, type, diff --git a/addons/report_webkit/webkit_report.py b/addons/report_webkit/webkit_report.py index 3dd768128fb..5bdea865cde 100644 --- a/addons/report_webkit/webkit_report.py +++ b/addons/report_webkit/webkit_report.py @@ -84,8 +84,10 @@ class WebKitParser(report_sxw): _('path to Wkhtmltopdf is not absolute'), 'for path %s'%(path) ) - def generate_pdf(self, comm_path, report_xml, header, footer, html_list): + def generate_pdf(self, comm_path, report_xml, header, footer, html_list, webkit_header=False): """Call webkit in order to generate pdf""" + if not webkit_header: + webkit_header = report_xml.webkit_header tmp_dir = tempfile.gettempdir() out = report_xml.name+str(time.time())+'.pdf' out = os.path.join(tmp_dir, out.replace(' ','')) @@ -120,20 +122,22 @@ class WebKitParser(report_sxw): file_to_del.append(foot_file.name) command.append("--footer-html '%s'"%(foot_file.name)) - if report_xml.webkit_header.margin_top : - command.append('--margin-top %s'%(report_xml.webkit_header.margin_top)) - if report_xml.webkit_header.margin_bottom : - command.append('--margin-bottom %s'%(report_xml.webkit_header.margin_bottom)) - if report_xml.webkit_header.margin_left : - command.append('--margin-left %s'%(report_xml.webkit_header.margin_left)) - if report_xml.webkit_header.margin_right : - command.append('--margin-right %s'%(report_xml.webkit_header.margin_right)) - if report_xml.webkit_header.orientation : - command.append("--orientation '%s'"%(report_xml.webkit_header.orientation)) - if report_xml.webkit_header.format : - command.append(" --page-size '%s'"%(report_xml.webkit_header.format)) + if webkit_header.margin_top : + command.append('--margin-top %s'%(webkit_header.margin_top)) + if webkit_header.margin_bottom : + command.append('--margin-bottom %s'%(webkit_header.margin_bottom)) + if webkit_header.margin_left : + command.append('--margin-left %s'%(webkit_header.margin_left)) + if webkit_header.margin_right : + command.append('--margin-right %s'%(webkit_header.margin_right)) + if webkit_header.orientation : + command.append("--orientation '%s'"%(webkit_header.orientation)) + if webkit_header.format : + command.append(" --page-size '%s'"%(webkit_header.format)) + count = 0 for html in html_list : - html_file = file(os.path.join(tmp_dir, str(time.time()) + '.body.html'), 'w') + html_file = file(os.path.join(tmp_dir, str(time.time()) + str(count) +'.body.html'), 'w') + count += 1 html_file.write(html) html_file.close() file_to_del.append(html_file.name) @@ -168,6 +172,8 @@ class WebKitParser(report_sxw): """Translate String.""" ir_translation = self.pool.get('ir.translation') res = ir_translation._get_source(self.parser_instance.cr, self.parser_instance.uid, self.name, 'report', self.localcontext.get('lang', 'en_US'), src) + if not res : + return src return res def formatLang(self, value, digits=None, date=False, date_time=False, grouping=True, monetary=False): From cdaef22f14104878cf21aba391c444cfe83e1abb Mon Sep 17 00:00:00 2001 From: "nicolas.bessi@camptocamp.com" <> Date: Mon, 15 Nov 2010 11:17:59 +0100 Subject: [PATCH 02/36] [IMP] better debug-error message$ bzr revid: nicolas.bessi@camptocamp.com-20101115101759-vt2b1j03c9upbubn --- addons/report_webkit/webkit_report.py | 82 +++++++++++++++------------ 1 file changed, 47 insertions(+), 35 deletions(-) diff --git a/addons/report_webkit/webkit_report.py b/addons/report_webkit/webkit_report.py index cce410a9dc6..e05c8e5c437 100644 --- a/addons/report_webkit/webkit_report.py +++ b/addons/report_webkit/webkit_report.py @@ -35,7 +35,7 @@ import report import tempfile import time from mako.template import Template - +from mako import exceptions import netsvc import pooler from report_helper import WebKitHelper @@ -278,45 +278,57 @@ class WebKitParser(report_sxw): #default_filters=['unicode', 'entity'] can be used to set global filter body_mako_tpl = Template(template ,input_encoding='utf-8') helper = WebKitHelper(cursor, uid, report_xml.id, context) - html = body_mako_tpl.render( helper=helper, - css=css, - _=self.translate_call, - **self.parser_instance.localcontext - ) + try : + html = body_mako_tpl.render( helper=helper, + css=css, + _=self.translate_call, + **self.parser_instance.localcontext + ) + except : + raise Exception(exceptions.html_error_template().render()) head_mako_tpl = Template(header, input_encoding='utf-8') - head = head_mako_tpl.render( - company=company, - time=time, - helper=helper, - css=css, - formatLang=self.formatLang, - setLang=self.setLang, - _=self.translate_call, - _debug=False - ) + try : + head = head_mako_tpl.render( + company=company, + time=time, + helper=helper, + css=css, + formatLang=self.formatLang, + setLang=self.setLang, + _=self.translate_call, + _debug=False + ) + except : + raise Exception(exceptions.html_error_template().render()) foot = False if footer : foot_mako_tpl = Template(footer ,input_encoding='utf-8') - foot = foot_mako_tpl.render( - company=company, - time=time, - helper=helper, - css=css, - formatLang=self.formatLang, - setLang=self.setLang, - _=self.translate_call, - ) + try : + foot = foot_mako_tpl.render( + company=company, + time=time, + helper=helper, + css=css, + formatLang=self.formatLang, + setLang=self.setLang, + _=self.translate_call, + ) + except: + raise Exception(exceptions.html_error_template().render()) if report_xml.webkit_debug : - deb = head_mako_tpl.render( - company=company, - time=time, - helper=helper, - css=css, - _debug=html, - formatLang=self.formatLang, - setLang=self.setLang, - _=self.translate_call, - ) + try : + deb = head_mako_tpl.render( + company=company, + time=time, + helper=helper, + css=css, + _debug=html, + formatLang=self.formatLang, + setLang=self.setLang, + _=self.translate_call, + ) + except : + raise Exception(exceptions.html_error_template().render()) return (deb, 'html') bin = self.get_lib(cursor, uid, company.id) pdf = self.generate_pdf(bin, report_xml, head, foot, [html]) From f4ebea2992d16e862ac75a0e5709a6ebac4163bf Mon Sep 17 00:00:00 2001 From: "ksa (Open ERP)" Date: Tue, 23 Nov 2010 18:54:34 +0530 Subject: [PATCH 03/36] [IMP]: Apply removing changes when merge branch bzr revid: ksa@tinyerp.co.in-20101123132434-fm0u05iasfpt0c3p --- addons/mrp/mrp.py | 22 ++++++++++++++++++++-- addons/mrp/mrp_view.xml | 15 ++++++++------- addons/mrp/wizard/mrp_price.py | 2 +- addons/product/product.py | 3 ++- addons/stock/stock.py | 16 ++++++++++++++-- addons/stock/wizard/stock_splitinto.py | 4 ++-- 6 files changed, 47 insertions(+), 15 deletions(-) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 4f5b8f24e14..b42d3797b2f 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -53,11 +53,23 @@ class mrp_workcenter(osv.osv): 'costs_journal_id': fields.many2one('account.analytic.journal', 'Analytic Journal'), 'costs_general_account_id': fields.many2one('account.account', 'General Account', domain=[('type','<>','view')]), 'resource_id': fields.many2one('resource.resource','Resource', ondelete='cascade', required=True), + 'product_id': fields.many2one('product.product','Product'), } _defaults = { 'capacity_per_cycle': 1.0, 'resource_type': 'material', } + + def on_change_product_cost(self, cr, uid, ids, product_id, context=None): + if context is None: + context = {} + res = {'value':{}} + + if product_id: + cost = self.pool.get('product.product').browse(cr, uid, product_id, context=context) + res = {'value' : {'costs_hour' :cost.standard_price }} + return res + mrp_workcenter() @@ -737,7 +749,10 @@ class mrp_production(osv.osv): 'account_id': account, 'general_account_id': wc.costs_general_account_id.id, 'journal_id': wc.costs_journal_id.id, - 'code': wc.code + 'ref': wc.code, + 'product_id': wc.product_id.id, + 'unit_amount': wc.costs_hour * wc.time_cycle, + 'product_uom_id': wc.product_id.uom_id.id } ) if wc.costs_journal_id and wc.costs_general_account_id: value = wc_line.cycle * wc.costs_cycle @@ -750,7 +765,10 @@ class mrp_production(osv.osv): 'account_id': account, 'general_account_id': wc.costs_general_account_id.id, 'journal_id': wc.costs_journal_id.id, - 'code': wc.code, + 'ref': wc.code, + 'product_id': wc.product_id.id, + 'unit_amount': wc.costs_hour * wc.time_cycle, + 'product_uom_id': wc.product_id.uom_id.id } ) return amount diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml index 4f6f0c88d54..ea85940d451 100644 --- a/addons/mrp/mrp_view.xml +++ b/addons/mrp/mrp_view.xml @@ -160,12 +160,13 @@ + - - + + @@ -649,9 +650,9 @@ -