From 322d3dd3409cb61b5898a771dd954ed5f0ada8b2 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Thu, 26 May 2011 18:45:51 +0530 Subject: [PATCH 01/72] [FIX] add noupdate=1 in ir.rule Record. bzr revid: ysa@tinyerp.com-20110526131551-nvt6tgyrh2ddsctp --- .../addons/base/security/base_security.xml | 44 ++++++++++--------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/openerp/addons/base/security/base_security.xml b/openerp/addons/base/security/base_security.xml index 0caf21e5196..4d04ac105c4 100644 --- a/openerp/addons/base/security/base_security.xml +++ b/openerp/addons/base/security/base_security.xml @@ -40,28 +40,32 @@ - - res.widget.user rule - - - ['|', ('user_id','=',user.id),('user_id','=',False)] - + - - res.partner company - - - - ['|','|',('company_id.child_ids','child_of',[user.company_id.id]),('company_id','child_of',[user.company_id.id]),('company_id','=',False)] - + - - Multi_company_default company - - - [('company_id','child_of',[user.company_id.id])] - + + res.widget.user rule + + + ['|', ('user_id','=',user.id),('user_id','=',False)] + + + + res.partner company + + + + ['|','|',('company_id.child_ids','child_of',[user.company_id.id]),('company_id','child_of',[user.company_id.id]),('company_id','=',False)] + + + + Multi_company_default company + + + [('company_id','child_of',[user.company_id.id])] + From dd673b080f90af4d3cb71e98b5afc8a7379bbb8d Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Fri, 27 May 2011 14:28:41 +0530 Subject: [PATCH 02/72] [USABILITY] change string of tab allowed companies instead of companies in user form. bzr revid: ysa@tinyerp.com-20110527085841-4yjchpazj0m6d5gu --- openerp/addons/base/base_update.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openerp/addons/base/base_update.xml b/openerp/addons/base/base_update.xml index 7432018fd94..f3adbf4179e 100644 --- a/openerp/addons/base/base_update.xml +++ b/openerp/addons/base/base_update.xml @@ -146,7 +146,7 @@ - + From fe230bbb6d569c6af3abbd79d4664be844fc5b42 Mon Sep 17 00:00:00 2001 From: "Nimesh (Open ERP)" Date: Mon, 30 May 2011 14:33:35 +0530 Subject: [PATCH 03/72] [fix] improvement in trml2pdf.py for the image bzr revid: nco@tinyerp.com-20110530090335-7lamm1fbnalkrhlh --- openerp/report/render/rml2pdf/trml2pdf.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/openerp/report/render/rml2pdf/trml2pdf.py b/openerp/report/render/rml2pdf/trml2pdf.py index e083062e302..e3afa872fbd 100644 --- a/openerp/report/render/rml2pdf/trml2pdf.py +++ b/openerp/report/render/rml2pdf/trml2pdf.py @@ -447,14 +447,14 @@ class _rml_canvas(object): self._logger.debug("Image %s used", node.get('name')) s = StringIO(image_data) else: + newtext = node.text if self.localcontext: - res = utils._regex.findall(node.text) + res = utils._regex.findall(newtext) for key in res: - newtext = eval(key, {}, self.localcontext) - node.text = newtext or '' + newtext = eval(key, {}, self.localcontext) or '' image_data = None - if node.text: - image_data = base64.decodestring(node.text) + if newtext: + image_data = base64.decodestring(newtext) if image_data: s = StringIO(image_data) else: From a5a07e49933d0f21958940e3c7339130aaf5e0d7 Mon Sep 17 00:00:00 2001 From: "Nimesh (Open ERP)" Date: Tue, 26 Jul 2011 18:51:37 +0530 Subject: [PATCH 04/72] Add missing unique keys lp bug: https://launchpad.net/bugs/789019 fixed bzr revid: nco@tinyerp.com-20110726132137-h8go2l62xkn8pdme --- openerp/addons/base/ir/ir_model.py | 4 +++- openerp/addons/base/res/partner/partner.py | 2 +- openerp/addons/base/res/res_company.py | 3 +++ openerp/addons/base/res/res_currency.py | 3 +++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/openerp/addons/base/ir/ir_model.py b/openerp/addons/base/ir/ir_model.py index d3dfd987638..add19f62078 100644 --- a/openerp/addons/base/ir/ir_model.py +++ b/openerp/addons/base/ir/ir_model.py @@ -97,7 +97,9 @@ class ir_model(osv.osv): 'modules': fields.function(_in_modules, method=True, type='char', size=128, string='In modules', help='List of modules in which the object is defined or inherited'), 'view_ids': fields.function(_view_ids, method=True, type='one2many', obj='ir.ui.view', string='Views'), } - + _sql_constraints = [ + ('obj_name_uniq', 'unique (name)', 'The object name must be unique !'), + ] _defaults = { 'model': lambda *a: 'x_', 'state': lambda self,cr,uid,ctx=None: (ctx and ctx.get('manual',False)) and 'manual' or 'base', diff --git a/openerp/addons/base/res/partner/partner.py b/openerp/addons/base/res/partner/partner.py index 091927f126d..0eed895e404 100644 --- a/openerp/addons/base/res/partner/partner.py +++ b/openerp/addons/base/res/partner/partner.py @@ -434,7 +434,7 @@ class res_partner_bank(osv.osv): 'state_id': lambda obj, cursor, user, context: obj._default_value( cursor, user, 'state_id', context=context), } - + def fields_get(self, cr, uid, fields=None, context=None): res = super(res_partner_bank, self).fields_get(cr, uid, fields, context) bank_type_obj = self.pool.get('res.partner.bank.type') diff --git a/openerp/addons/base/res/res_company.py b/openerp/addons/base/res/res_company.py index 14ef53199d5..3e31401ec49 100644 --- a/openerp/addons/base/res/res_company.py +++ b/openerp/addons/base/res/res_company.py @@ -127,6 +127,9 @@ class res_company(osv.osv): 'email': fields.function(_get_address_data, fnct_inv=_set_address_data, size=64, type='char', string="Email", multi='address'), 'phone': fields.function(_get_address_data, fnct_inv=_set_address_data, size=64, type='char', string="Phone", multi='address'), } + _sql_constraints = [ + ('com_name_uniq', 'unique (name)', 'The company name must be unique !') + ] def _search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False, access_rights_uid=None): diff --git a/openerp/addons/base/res/res_currency.py b/openerp/addons/base/res/res_currency.py index d81248a735d..6005ea8dd97 100644 --- a/openerp/addons/base/res/res_currency.py +++ b/openerp/addons/base/res/res_currency.py @@ -65,6 +65,9 @@ class res_currency(osv.osv): 'active': lambda *a: 1, 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'res.currency', context=c) } + _sql_constraints = [ + ('currency_name_uniq', 'unique (name, company_id)', 'The currency code must be unique !'), + ] _order = "name" def read(self, cr, user, ids, fields=None, context=None, load='_classic_read'): From 2632bb3d0439f2f8798e05ab5f0605da1eceeafe Mon Sep 17 00:00:00 2001 From: Boris Timokhin Date: Sun, 31 Jul 2011 22:17:24 +0400 Subject: [PATCH 05/72] base_module_import fix crash for not zip files, better module_name detection, codestyling lp bug: https://launchpad.net/bugs/818951 fixed bzr revid: qoqenator@gmail.com-20110731181724-6l35g3tqog79gi2m --- .../base/module/wizard/base_module_import.py | 45 +++++++++++-------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/openerp/addons/base/module/wizard/base_module_import.py b/openerp/addons/base/module/wizard/base_module_import.py index 05c3b18198d..3ef9132af0e 100644 --- a/openerp/addons/base/module/wizard/base_module_import.py +++ b/openerp/addons/base/module/wizard/base_module_import.py @@ -28,6 +28,8 @@ import base64 from tools.translate import _ from osv import osv, fields +ADDONS_PATH = tools.config['addons_path'].split(",")[-1] + class base_module_import(osv.osv_memory): """ Import Module """ @@ -37,7 +39,8 @@ class base_module_import(osv.osv_memory): _columns = { 'module_file': fields.binary('Module .ZIP file', required=True), - 'state':fields.selection([('init','init'),('done','done')], 'state', readonly=True), + 'state':fields.selection([('init','init'),('done','done')], + 'state', readonly=True), 'module_name': fields.char('Module Name', size=128), } @@ -48,26 +51,30 @@ class base_module_import(osv.osv_memory): def importzip(self, cr, uid, ids, context): (data,) = self.browse(cr, uid, ids , context=context) module_data = data.module_file - - val = base64.decodestring(module_data) + zip_data = base64.decodestring(module_data) fp = StringIO() - fp.write(val) - fdata = zipfile.ZipFile(fp, 'r') - fname = fdata.namelist()[0] - module_name = os.path.split(fname)[0] - - ad = tools.config['addons_path'].split(",")[-1] - - fname = os.path.join(ad, module_name+'.zip') + fp.write(zip_data) try: - fp = file(fname, 'wb') - fp.write(val) - fp.close() - except IOError: - raise osv.except_osv(_('Error !'), _('Can not create the module file: %s !') % (fname,) ) + file_data = zipfile.ZipFile(fp, 'r') + except zipfile.BadZipfile: + raise osv.except_osv(_('Error !'), _('File is not a zip file!')) + init_file_name = sorted(file_data.namelist())[0] + module_name = os.path.split(init_file_name)[0] - self.pool.get('ir.module.module').update_list(cr, uid, {'module_name': module_name,}) - self.write(cr, uid, ids, {'state':'done', 'module_name': module_name}, context) + file_path = os.path.join(ADDONS_PATH, '%s.zip' % module_name) + try: + zip_file = open(file_path, 'wb') + except IOError: + raise osv.except_osv(_('Error !'), + _('Can not create the module file: %s !') % \ + (file_path,) ) + zip_file.write(zip_data) + zip_file.close() + + self.pool.get('ir.module.module').update_list(cr, uid, + {'module_name': module_name,}) + self.write(cr, uid, ids, {'state':'done', 'module_name': module_name}, + context) return False def action_module_open(self, cr, uid, ids, context): @@ -84,4 +91,4 @@ class base_module_import(osv.osv_memory): base_module_import() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From c761404086f02cb014d7f4fcc342a27d7d78ab8c Mon Sep 17 00:00:00 2001 From: gpa Date: Wed, 3 Aug 2011 16:35:59 +0530 Subject: [PATCH 06/72] [FIX] Fixed error of non-ascii charcter in label, remove by default condition True and display group lp bug: https://launchpad.net/bugs/727263 fixed bzr revid: gpa@tinyerp.com-20110803110559-83xiqnjtb510w8ka --- openerp/addons/base/ir/ir_ui_view.py | 4 ++-- openerp/addons/base/ir/workflow/workflow.py | 24 +++++++++---------- .../addons/base/ir/workflow/workflow_view.xml | 8 +++---- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/openerp/addons/base/ir/ir_ui_view.py b/openerp/addons/base/ir/ir_ui_view.py index ee23a2f52f1..84a065fe356 100644 --- a/openerp/addons/base/ir/ir_ui_view.py +++ b/openerp/addons/base/ir/ir_ui_view.py @@ -158,10 +158,10 @@ class view(osv.osv): label_string = "" if label: for lbl in eval(label): - if t.has_key(str(lbl)) and str(t[lbl])=='False': + if t.has_key(tools.ustr(lbl)) and tools.ustr(t[lbl])=='False': label_string = label_string + ' ' else: - label_string = label_string + " " + t[lbl] + label_string = label_string + " " + tools.ustr(t[lbl]) labels[str(t['id'])] = (a['id'],label_string) g = graph(nodes, transitions, no_ancester) g.process(start) diff --git a/openerp/addons/base/ir/workflow/workflow.py b/openerp/addons/base/ir/workflow/workflow.py index c638855aacf..414420d6c81 100644 --- a/openerp/addons/base/ir/workflow/workflow.py +++ b/openerp/addons/base/ir/workflow/workflow.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -46,21 +46,21 @@ class workflow(osv.osv): return super(workflow, self).write(cr, user, ids, vals, context=context) def get_active_workitems(self, cr, uid, res, res_id, context={}): - + cr.execute('select * from wkf where osv=%s limit 1',(res,)) wkfinfo = cr.dictfetchone() workitems = [] - + if wkfinfo: cr.execute('SELECT id FROM wkf_instance \ WHERE res_id=%s AND wkf_id=%s \ ORDER BY state LIMIT 1', (res_id, wkfinfo['id'])) inst_id = cr.fetchone() - + cr.execute('select act_id,count(*) from wkf_workitem where inst_id=%s group by act_id', (inst_id,)) - workitems = dict(cr.fetchall()) - + workitems = dict(cr.fetchall()) + return {'wkf': wkfinfo, 'workitems': workitems} @@ -148,12 +148,12 @@ class wkf_transition(osv.osv): _columns = { 'trigger_model': fields.char('Trigger Object', size=128), 'trigger_expr_id': fields.char('Trigger Expression', size=128), - 'signal': fields.char('Signal (button Name)', size=64, + 'signal': fields.char('Signal (button Name)', size=64, help="When the operation of transition comes from a button pressed in the client form, "\ "signal tests the name of the pressed button. If signal is NULL, no button is necessary to validate this transition."), - 'group_id': fields.many2one('res.groups', 'Group Required', + 'group_id': fields.many2one('res.groups', 'Group Required', help="The group that a user must have to be authorized to validate this transition."), - 'condition': fields.char('Condition', required=True, size=128, + 'condition': fields.char('Condition', size=128, help="Expression to be satisfied if we want the transition done."), 'act_from': fields.many2one('workflow.activity', 'Source Activity', required=True, select=True, ondelete='cascade', help="Source activity. When this activity is over, the condition is tested to determine if we can start the ACT_TO activity."), @@ -161,9 +161,7 @@ class wkf_transition(osv.osv): help="The destination activity."), 'wkf_id': fields.related('act_from','wkf_id', type='many2one', relation='workflow', string='Workflow', select=True), } - _defaults = { - 'condition': lambda *a: 'True', - } + wkf_transition() class wkf_instance(osv.osv): diff --git a/openerp/addons/base/ir/workflow/workflow_view.xml b/openerp/addons/base/ir/workflow/workflow_view.xml index 5866b81a25e..2d6d2d1e753 100644 --- a/openerp/addons/base/ir/workflow/workflow_view.xml +++ b/openerp/addons/base/ir/workflow/workflow_view.xml @@ -52,7 +52,7 @@ - + @@ -329,7 +329,7 @@ form
- + @@ -343,7 +343,7 @@ tree - + @@ -359,7 +359,7 @@ - + From 3e5e4dce7c391c1b985be33b146e7b4ec800c283 Mon Sep 17 00:00:00 2001 From: gpa Date: Wed, 3 Aug 2011 17:23:48 +0530 Subject: [PATCH 07/72] [IMP]Improvement in code bzr revid: gpa@tinyerp.com-20110803115348-kg6lhy40ylk4hnvq --- openerp/addons/base/ir/workflow/workflow.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/openerp/addons/base/ir/workflow/workflow.py b/openerp/addons/base/ir/workflow/workflow.py index 414420d6c81..36102878c20 100644 --- a/openerp/addons/base/ir/workflow/workflow.py +++ b/openerp/addons/base/ir/workflow/workflow.py @@ -153,7 +153,7 @@ class wkf_transition(osv.osv): "signal tests the name of the pressed button. If signal is NULL, no button is necessary to validate this transition."), 'group_id': fields.many2one('res.groups', 'Group Required', help="The group that a user must have to be authorized to validate this transition."), - 'condition': fields.char('Condition', size=128, + 'condition': fields.char('Condition', required=True, size=128, help="Expression to be satisfied if we want the transition done."), 'act_from': fields.many2one('workflow.activity', 'Source Activity', required=True, select=True, ondelete='cascade', help="Source activity. When this activity is over, the condition is tested to determine if we can start the ACT_TO activity."), @@ -162,6 +162,10 @@ class wkf_transition(osv.osv): 'wkf_id': fields.related('act_from','wkf_id', type='many2one', relation='workflow', string='Workflow', select=True), } + _defaults = { + 'condition': lambda *a: 'False', + } + wkf_transition() class wkf_instance(osv.osv): From 27a0a2c059e3cf5cbca02700b9f4ffb8c30150d0 Mon Sep 17 00:00:00 2001 From: "Ujjvala Collins (OpenERP)" Date: Thu, 11 Aug 2011 16:38:47 +0530 Subject: [PATCH 08/72] [ADD] account: Added new object account.report for printing reports. bzr revid: uco@tinyerp.com-20110811110847-telg63rtz0bshdry --- addons/account/__openerp__.py | 1 + addons/account/wizard/__init__.py | 1 + addons/account/wizard/account_report.py | 45 +++++++++++++++ addons/account/wizard/account_report_view.xml | 56 +++++++++++++++++++ 4 files changed, 103 insertions(+) create mode 100644 addons/account/wizard/account_report.py create mode 100644 addons/account/wizard/account_report_view.xml diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py index 23846183ddf..93270889657 100644 --- a/addons/account/__openerp__.py +++ b/addons/account/__openerp__.py @@ -98,6 +98,7 @@ module named account_voucher. 'wizard/account_reconcile_view.xml', 'wizard/account_reconcile_partner_process_view.xml', 'wizard/account_automatic_reconcile_view.xml', + 'wizard/account_report_view.xml', 'project/wizard/project_account_analytic_line_view.xml', 'account_end_fy.xml', 'account_invoice_view.xml', diff --git a/addons/account/wizard/__init__.py b/addons/account/wizard/__init__.py index caed6fc3977..f6090539b73 100644 --- a/addons/account/wizard/__init__.py +++ b/addons/account/wizard/__init__.py @@ -47,6 +47,7 @@ import account_open_closed_fiscalyear import account_invoice_state import account_chart import account_tax_chart +import account_report #TODO: remove this file no moe used # also remove related view fiel diff --git a/addons/account/wizard/account_report.py b/addons/account/wizard/account_report.py new file mode 100644 index 00000000000..3cd3b06be44 --- /dev/null +++ b/addons/account/wizard/account_report.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from osv import fields, osv + +class account_report(osv.osv_memory): + _name = "account.report" + _inherit = "account.common.report" + _description = "Account Report" + + _columns = { + 'parent_id': fields.many2one('account.report', 'Report'), + 'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of invoice tax."), + 'type': fields.selection([ + ('sum','Sum'), + ('accounts','Accounts'), + ('account_report','Account Report'), + ],'Type'), + 'account_ids': fields.many2many('account.account', 'account_account_report', 'report_line_id', 'account_id', 'Accounts'), + 'note': fields.text('Notes'), + 'account_report_id': fields.many2one('account.report', 'Account Reports'), + 'enable_comparison': fields.boolean('Enable Comparison'), + } + +account_report() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/account_report_view.xml b/addons/account/wizard/account_report_view.xml new file mode 100644 index 00000000000..0b326626ee2 --- /dev/null +++ b/addons/account/wizard/account_report_view.xml @@ -0,0 +1,56 @@ + + + + + + Account Report + account.report + form + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Mail Report + account.report + ir.actions.act_window + form + form + + new + + + + + + From aeec03e7ebc622a7f10adc7d2d73bd9405e46691 Mon Sep 17 00:00:00 2001 From: gpa Date: Thu, 11 Aug 2011 18:51:48 +0530 Subject: [PATCH 09/72] [FIX]Added missing pg_path, to solve the problem of backup and restore of database lp bug: https://launchpad.net/bugs/723424 fixed bzr revid: gpa@tinyerp.com-20110811132148-xhje7bwwhzzty4vp --- setup.nsi | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.nsi b/setup.nsi index f9c962ae383..79e7903f6a3 100644 --- a/setup.nsi +++ b/setup.nsi @@ -210,6 +210,7 @@ Section OpenERP_Server SectionOpenERP_Server WriteIniStr "$INSTDIR\openerp-server.conf" "options" "db_user" $TextPostgreSQLUsername WriteIniStr "$INSTDIR\openerp-server.conf" "options" "db_password" $TextPostgreSQLPassword WriteIniStr "$INSTDIR\openerp-server.conf" "options" "db_port" $TextPostgreSQLPort + WriteIniStr "$INSTDIR\Server\openerp-server.conf" "options" "pg_path" "$INSTDIR\PostgreSQL\bin" nsExec::Exec '"$INSTDIR\openerp-server.exe" --stop-after-init --logfile "$INSTDIR\openerp-server.log" -s' nsExec::Exec '"$INSTDIR\service\OpenERPServerService.exe" -auto -install' From feffc1cb33559fbcbe9bdc583c59765f0071b96c Mon Sep 17 00:00:00 2001 From: gpa Date: Thu, 11 Aug 2011 18:58:15 +0530 Subject: [PATCH 10/72] [IMP]Improvement in code bzr revid: gpa@tinyerp.com-20110811132815-q37jxu29v6p368cr --- setup.nsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.nsi b/setup.nsi index 79e7903f6a3..0ea37b0f9e6 100644 --- a/setup.nsi +++ b/setup.nsi @@ -210,7 +210,7 @@ Section OpenERP_Server SectionOpenERP_Server WriteIniStr "$INSTDIR\openerp-server.conf" "options" "db_user" $TextPostgreSQLUsername WriteIniStr "$INSTDIR\openerp-server.conf" "options" "db_password" $TextPostgreSQLPassword WriteIniStr "$INSTDIR\openerp-server.conf" "options" "db_port" $TextPostgreSQLPort - WriteIniStr "$INSTDIR\Server\openerp-server.conf" "options" "pg_path" "$INSTDIR\PostgreSQL\bin" + WriteIniStr "$INSTDIR\openerp-server.conf" "options" "pg_path" "$INSTDIR\PostgreSQL\bin" nsExec::Exec '"$INSTDIR\openerp-server.exe" --stop-after-init --logfile "$INSTDIR\openerp-server.log" -s' nsExec::Exec '"$INSTDIR\service\OpenERPServerService.exe" -auto -install' From d4ee49e658a90657da2dc848c40e2dd31d5cd71d Mon Sep 17 00:00:00 2001 From: "Ujjvala Collins (OpenERP)" Date: Fri, 12 Aug 2011 16:53:21 +0530 Subject: [PATCH 11/72] [IMP] account: Improved report. bzr revid: uco@tinyerp.com-20110812112321-3q1vfylgojz0s91h --- addons/account/account.py | 28 ++- addons/account/account_menuitem.xml | 1 + addons/account/account_view.xml | 49 +++++ addons/account/report/__init__.py | 1 + .../account/report/account_report_common.py | 83 ++++++++ .../account/report/account_report_common.rml | 187 ++++++++++++++++++ addons/account/wizard/account_report.py | 28 +-- addons/account/wizard/account_report_view.xml | 24 +-- 8 files changed, 371 insertions(+), 30 deletions(-) create mode 100644 addons/account/report/account_report_common.py create mode 100644 addons/account/report/account_report_common.rml diff --git a/addons/account/account.py b/addons/account/account.py index 72208314ed9..ec72237c897 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -1331,7 +1331,7 @@ class account_move(osv.osv): def _centralise(self, cr, uid, move, mode, context=None): assert mode in ('debit', 'credit'), 'Invalid Mode' #to prevent sql injection - currency_obj = self.pool.get('res.currency') + currency_obj = self.pool.get('res.currency') if context is None: context = {} @@ -1593,7 +1593,7 @@ class account_tax_code(osv.osv): (parent_ids,) + where_params) res=dict(cr.fetchall()) obj_precision = self.pool.get('decimal.precision') - res2 = {} + res2 = {} for record in self.browse(cr, uid, ids, context=context): def _rec_get(record): amount = res.get(record.id, 0.0) @@ -2607,6 +2607,30 @@ class account_fiscal_position_account_template(osv.osv): account_fiscal_position_account_template() +class account_report(osv.osv): + _name = "account.report" + _description = "Account Report" + + _columns = { + 'name': fields.char('Report Name', size=64, required=True), + 'parent_id': fields.many2one('account.report', 'Parent Report'), + 'sequence': fields.integer('Sequence'), + 'type': fields.selection([ + ('sum','Sum'), + ('accounts','Accounts'), + ('account_report','Account Report'), + ],'Type'), + 'account_ids': fields.many2many('account.account', 'account_account_report', 'report_line_id', 'account_id', 'Accounts'), + 'note': fields.text('Notes'), + 'account_report_id': fields.many2one('account.report', 'Account Report'), + } + + _defaults = { + 'type': 'sum', + } + +account_report() + # Multi charts of Accounts wizard class wizard_multi_charts_accounts(osv.osv_memory): diff --git a/addons/account/account_menuitem.xml b/addons/account/account_menuitem.xml index 062e1f6382b..48fe424e7fb 100644 --- a/addons/account/account_menuitem.xml +++ b/addons/account/account_menuitem.xml @@ -30,6 +30,7 @@ + + + + + account.report.form + account.report + form + + + + + + + + + + + + + + + + + account.report.tree + account.report + tree + + + + + + + + + + + + + Account Reports + ir.actions.act_window + account.report + form + tree,form + + + + + diff --git a/addons/account/report/__init__.py b/addons/account/report/__init__.py index 7c09027f3ca..86c13a85582 100644 --- a/addons/account/report/__init__.py +++ b/addons/account/report/__init__.py @@ -42,6 +42,7 @@ import account_analytic_entries_report import account_balance_sheet import account_profit_loss import account_treasury_report +import account_report_common # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/report/account_report_common.py b/addons/account/report/account_report_common.py new file mode 100644 index 00000000000..a2dbf62e7fa --- /dev/null +++ b/addons/account/report/account_report_common.py @@ -0,0 +1,83 @@ +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +import time +import pooler +from report import report_sxw +from common_report_header import common_report_header +from tools.translate import _ + +class report_account_common(report_sxw.rml_parse, common_report_header): + + def __init__(self, cr, uid, name, context=None): + super(report_account_common, self).__init__(cr, uid, name, context=context) + self.localcontext.update( { + 'time': time, + 'get_report_name': self._get_report_name, + 'get_fiscalyear': self._get_fiscalyear, + 'get_account': self._get_account, + 'get_start_period': self.get_start_period, + 'get_end_period': self.get_end_period, + 'get_sortby': self._get_sortby, + 'get_filter': self._get_filter, + 'get_start_date':self._get_start_date, + 'get_end_date':self._get_end_date, + 'get_company':self._get_company, + 'get_account_details': self.get_account_details, + }) + self.context = context + + def set_context(self, objects, data, ids, report_type=None): + new_ids = ids + if (data['model'] == 'ir.ui.menu'): + new_ids = 'chart_account_id' in data['form'] and [data['form']['chart_account_id']] or [] + objects = self.pool.get('account.account').browse(self.cr, self.uid, new_ids) + return super(report_account_common, self).set_context(objects, data, new_ids, report_type=report_type) + + def _get_report_name(self, data): + cr, uid = self.cr, self.uid + db_pool = pooler.get_pool(self.cr.dbname) + + report_obj = db_pool.get('account.report') + children = [] + name = data['form'].get('account_report_id') and data['form']['account_report_id'][1] or '' + report_id = data['form'].get('account_report_id') and data['form']['account_report_id'][0] or False + children.append({'id': report_id, 'name': name}) + if report_id: + child_ids = report_obj.search(cr, uid, [('parent_id','=',report_id)]) + for chld in report_obj.browse(cr, uid, child_ids): + children.append({'id': chld.id, 'name': chld.name}) + return children + + def get_account_details(self, acc_id): + cr, uid = self.cr, self.uid + db_pool = pooler.get_pool(self.cr.dbname) + + report_obj = db_pool.get('account.report') + accounts = [] + if acc_id: + for rpt in report_obj.browse(cr, uid, [acc_id]): + for acc in rpt.account_ids: + accounts.append({'code': acc.code, 'name': acc.name, 'bal': acc.balance}) + return accounts + +report_sxw.report_sxw('report.account.common', 'account.account', + 'addons/account/report/account_report_common.rml', parser=report_account_common, header='internal') + diff --git a/addons/account/report/account_report_common.rml b/addons/account/report/account_report_common.rml new file mode 100644 index 00000000000..c0864862fbf --- /dev/null +++ b/addons/account/report/account_report_common.rml @@ -0,0 +1,187 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Chart of Account + + + Fiscal Year + + + Filters By [[ get_filter(data)!='No Filter' and get_filter(data) ]] + + + + + [[ get_account(data) or '' ]] + + + [[ get_fiscalyear(data) or '' ]] + + + + + + [[ get_filter(data)=='Date' or removeParentNode('blockTable') ]] + Start Date + + + End Date + + + + + [[ get_start_date(data) ]] + + + [[ get_end_date(data) ]] + + + + + + + [[ get_filter(data)=='Periods' or removeParentNode('blockTable')]] + ]]Start Period + + + End Period + + + + + [[ get_start_period(data) or removeParentNode('para') ]] + + + [[ get_end_period(data) or removeParentNode('para') ]] + + + + + + + + + + + + + + [[ repeatIn(get_report_name(data),'r') ]] + + + [[ r['name'] ]] + + + + Account Details + + + + + + + Code + + + Name + + + Balance + + + + + + [[ repeatIn(get_account_details(r['id']), 'a') ]] [[ a['code'] ]] + + + + + [[ a['name'] ]] + + + + + [[ a['bal'] ]] + + + + + + + + + + + + diff --git a/addons/account/wizard/account_report.py b/addons/account/wizard/account_report.py index 3cd3b06be44..784c1e03a7b 100644 --- a/addons/account/wizard/account_report.py +++ b/addons/account/wizard/account_report.py @@ -21,25 +21,27 @@ from osv import fields, osv -class account_report(osv.osv_memory): - _name = "account.report" +class accounting_report(osv.osv_memory): + _name = "accounting.report" _inherit = "account.common.report" _description = "Account Report" _columns = { - 'parent_id': fields.many2one('account.report', 'Report'), - 'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of invoice tax."), - 'type': fields.selection([ - ('sum','Sum'), - ('accounts','Accounts'), - ('account_report','Account Report'), - ],'Type'), - 'account_ids': fields.many2many('account.account', 'account_account_report', 'report_line_id', 'account_id', 'Accounts'), - 'note': fields.text('Notes'), - 'account_report_id': fields.many2one('account.report', 'Account Reports'), 'enable_comparison': fields.boolean('Enable Comparison'), + 'display_details_per_account': fields.boolean('Display Details per Account'), + 'account_report_id': fields.many2one('account.report', 'Account Reports', required=True), } -account_report() + def _print_report(self, cr, uid, ids, data, context=None): + if context is None: + context = {} + data['form'].update(self.read(cr, uid, ids, ['account_report_id'], context=context)[0]) + return { + 'type': 'ir.actions.report.xml', + 'report_name': 'account.common', + 'datas': data, + } + +accounting_report() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/account_report_view.xml b/addons/account/wizard/account_report_view.xml index 0b326626ee2..119b1d7f1bd 100644 --- a/addons/account/wizard/account_report_view.xml +++ b/addons/account/wizard/account_report_view.xml @@ -2,19 +2,16 @@ - + Account Report - account.report + accounting.report form - - - - - - + + + @@ -28,25 +25,22 @@ - - - - Mail Report - account.report + Report + accounting.report ir.actions.act_window form form - + new Date: Fri, 12 Aug 2011 17:52:34 +0530 Subject: [PATCH 12/72] [IMP] account: Improved report. bzr revid: uco@tinyerp.com-20110812122234-rkh36ya1zzmonpnt --- .../account/report/account_report_common.py | 28 +++++++++++++++---- .../account/report/account_report_common.rml | 24 ++++++++++++++-- 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/addons/account/report/account_report_common.py b/addons/account/report/account_report_common.py index a2dbf62e7fa..69b5668bdbe 100644 --- a/addons/account/report/account_report_common.py +++ b/addons/account/report/account_report_common.py @@ -30,7 +30,7 @@ class report_account_common(report_sxw.rml_parse, common_report_header): super(report_account_common, self).__init__(cr, uid, name, context=context) self.localcontext.update( { 'time': time, - 'get_report_name': self._get_report_name, + 'get_report_details': self._get_report_details, 'get_fiscalyear': self._get_fiscalyear, 'get_account': self._get_account, 'get_start_period': self.get_start_period, @@ -51,20 +51,32 @@ class report_account_common(report_sxw.rml_parse, common_report_header): objects = self.pool.get('account.account').browse(self.cr, self.uid, new_ids) return super(report_account_common, self).set_context(objects, data, new_ids, report_type=report_type) - def _get_report_name(self, data): + def _get_report_details(self, data): cr, uid = self.cr, self.uid db_pool = pooler.get_pool(self.cr.dbname) report_obj = db_pool.get('account.report') - children = [] + datas = [] + balance = 0.0 name = data['form'].get('account_report_id') and data['form']['account_report_id'][1] or '' report_id = data['form'].get('account_report_id') and data['form']['account_report_id'][0] or False - children.append({'id': report_id, 'name': name}) + datas.append({'id': report_id}) if report_id: child_ids = report_obj.search(cr, uid, [('parent_id','=',report_id)]) + child_ids.append(datas[0]['id']) for chld in report_obj.browse(cr, uid, child_ids): - children.append({'id': chld.id, 'name': chld.name}) - return children + if chld.type == 'accounts': + for a in chld.account_ids: + balance += a.balance + if chld.type == 'account_report': + pass # TDDO: it's the balance of the linked account.report (so it means it's only a way to reuse figures coming from another report) + if chld.type == 'sum': + pass # TDDO: it's the sum of balance of the children of this account.report (if there isn't, then it's 0.0) + if chld.id == datas[0]['id']: + datas[0].update({'name': chld.name, 'balance': balance}) + else: + datas.append({'id': chld.id, 'name': chld.name, 'balance': balance}) + return datas def get_account_details(self, acc_id): cr, uid = self.cr, self.uid @@ -78,6 +90,10 @@ class report_account_common(report_sxw.rml_parse, common_report_header): accounts.append({'code': acc.code, 'name': acc.name, 'bal': acc.balance}) return accounts + def get_report_balance(self): + balance = 0.0 + return balance + report_sxw.report_sxw('report.account.common', 'account.account', 'addons/account/report/account_report_common.rml', parser=report_account_common, header='internal') diff --git a/addons/account/report/account_report_common.rml b/addons/account/report/account_report_common.rml index c0864862fbf..9918ad0ee18 100644 --- a/addons/account/report/account_report_common.rml +++ b/addons/account/report/account_report_common.rml @@ -136,10 +136,30 @@ - [[ repeatIn(get_report_name(data),'r') ]] + [[ repeatIn(get_report_details(data),'r') ]] - [[ r['name'] ]] + + + + Report Name + + + Report Balance + + + + + [[ r['name'] ]] + + + [[ r['balance'] ]] + + + + + + From 56ca812f04f110a84c67d7ae643914bccf1c71ff Mon Sep 17 00:00:00 2001 From: "Purnendu Singh (OpenERP)" Date: Wed, 17 Aug 2011 17:32:19 +0530 Subject: [PATCH 13/72] [IMP] account: Improve the code so it will consider the check box display_details_per_account, improve rml, and some logic bzr revid: psi@tinyerp.com-20110817120219-39eg41ofgeyniyk1 --- .../account/report/account_report_common.py | 37 +++-- .../account/report/account_report_common.rml | 152 ++++++------------ addons/account/wizard/account_report.py | 6 +- 3 files changed, 72 insertions(+), 123 deletions(-) diff --git a/addons/account/report/account_report_common.py b/addons/account/report/account_report_common.py index 69b5668bdbe..57a97f8ab4e 100644 --- a/addons/account/report/account_report_common.py +++ b/addons/account/report/account_report_common.py @@ -19,7 +19,7 @@ ############################################################################## import time -import pooler + from report import report_sxw from common_report_header import common_report_header from tools.translate import _ @@ -53,9 +53,8 @@ class report_account_common(report_sxw.rml_parse, common_report_header): def _get_report_details(self, data): cr, uid = self.cr, self.uid - db_pool = pooler.get_pool(self.cr.dbname) - report_obj = db_pool.get('account.report') + report_obj = self.pool.get('account.report') datas = [] balance = 0.0 name = data['form'].get('account_report_id') and data['form']['account_report_id'][1] or '' @@ -64,27 +63,31 @@ class report_account_common(report_sxw.rml_parse, common_report_header): if report_id: child_ids = report_obj.search(cr, uid, [('parent_id','=',report_id)]) child_ids.append(datas[0]['id']) - for chld in report_obj.browse(cr, uid, child_ids): - if chld.type == 'accounts': - for a in chld.account_ids: + for child in report_obj.browse(cr, uid, child_ids): + if child.type == 'accounts': + for a in child.account_ids: balance += a.balance - if chld.type == 'account_report': - pass # TDDO: it's the balance of the linked account.report (so it means it's only a way to reuse figures coming from another report) - if chld.type == 'sum': - pass # TDDO: it's the sum of balance of the children of this account.report (if there isn't, then it's 0.0) - if chld.id == datas[0]['id']: - datas[0].update({'name': chld.name, 'balance': balance}) + # it's the balance of the linked account.report (so it means it's only a way to reuse figures coming from another report) + if child.type == 'account_report' and child.account_report_id: + for a in child.account_report_id.account_ids: + balance +=a.balance + #it's the sum of balance of the children of this account.report (if there isn't, then it's 0.0) + if child.type == 'sum': + for child in report_obj.browse(cr, uid, child_ids): + for a in child.account_ids: + balance += a.balance + if child.id == datas[0]['id']: + datas[0].update({'name': child.name, 'balance': balance}) else: - datas.append({'id': chld.id, 'name': chld.name, 'balance': balance}) + datas.append({'id': child.id, 'name': child.name, 'balance': balance}) return datas - def get_account_details(self, acc_id): + def get_account_details(self, acc_id, data): cr, uid = self.cr, self.uid - db_pool = pooler.get_pool(self.cr.dbname) - report_obj = db_pool.get('account.report') + report_obj = self.pool.get('account.report') accounts = [] - if acc_id: + if acc_id and data['form'].get('display_details_per_account', False): for rpt in report_obj.browse(cr, uid, [acc_id]): for acc in rpt.account_ids: accounts.append({'code': acc.code, 'name': acc.name, 'bal': acc.balance}) diff --git a/addons/account/report/account_report_common.rml b/addons/account/report/account_report_common.rml index 9918ad0ee18..602f072f47d 100644 --- a/addons/account/report/account_report_common.rml +++ b/addons/account/report/account_report_common.rml @@ -59,6 +59,7 @@ + @@ -68,133 +69,74 @@ - + - - Chart of Account - - - Fiscal Year - - - Filters By [[ get_filter(data)!='No Filter' and get_filter(data) ]] - + Chart of Account + Fiscal Year + Filter By [[ get_filter(data)!='No Filter' and '' or removeParentNode('font') ]] - - - [[ get_account(data) or '' ]] + + [[ get_account(data) or removeParentNode('para') ]] + [[ get_fiscalyear(data) or '' ]] + [[ get_filter(data)=='No Filter' and get_filter(data) or removeParentNode('para') ]] + [[ get_filter(data)=='Date' or removeParentNode('blockTable') ]] + + Start Date + End Date + + + [[ formatLang(get_start_date(data),date=True) ]] + [[ formatLang(get_end_date(data),date=True) ]] + + + [[ get_filter(data)=='Periods' or removeParentNode('blockTable') ]] + + Start Period + End Period + + + [[ get_start_period(data) or removeParentNode('para') ]] + [[ get_end_period(data) or removeParentNode('para') ]] + + - - [[ get_fiscalyear(data) or '' ]] - - - - - - [[ get_filter(data)=='Date' or removeParentNode('blockTable') ]] - Start Date - - - End Date - - - - - [[ get_start_date(data) ]] - - - [[ get_end_date(data) ]] - - - - - - - [[ get_filter(data)=='Periods' or removeParentNode('blockTable')]] - ]]Start Period - - - End Period - - - - - [[ get_start_period(data) or removeParentNode('para') ]] - - - [[ get_end_period(data) or removeParentNode('para') ]] - - - - - - - - + - - - + + + [[ repeatIn(get_report_details(data),'r') ]] - + - - Report Name - - - Report Balance - + Report Name + Report Balance - - [[ r['name'] ]] - - - [[ r['balance'] ]] - + [[ r['name'] ]] + [[ r['balance'] ]] - + - - Account Details - + Account Details - + - - Code - - - Name - - - Balance - + Code + Name + Balance - - - [[ repeatIn(get_account_details(r['id']), 'a') ]] [[ a['code'] ]] - - - - - [[ a['name'] ]] - - - - - [[ a['bal'] ]] - - + [[ repeatIn(get_account_details(r['id'], data), 'a') ]] [[ a['code'] ]] + [[ a['name'] ]] + [[ a['bal'] ]] diff --git a/addons/account/wizard/account_report.py b/addons/account/wizard/account_report.py index 784c1e03a7b..064c9bb723e 100644 --- a/addons/account/wizard/account_report.py +++ b/addons/account/wizard/account_report.py @@ -32,10 +32,14 @@ class accounting_report(osv.osv_memory): 'account_report_id': fields.many2one('account.report', 'Account Reports', required=True), } + _defaults={ + 'enable_comparison': False, + 'display_details_per_account': False, + } def _print_report(self, cr, uid, ids, data, context=None): if context is None: context = {} - data['form'].update(self.read(cr, uid, ids, ['account_report_id'], context=context)[0]) + data['form'].update(self.read(cr, uid, ids, ['account_report_id', 'enable_comparison', 'display_details_per_account'], context=context)[0]) return { 'type': 'ir.actions.report.xml', 'report_name': 'account.common', From 2854c3091ed8c4a507a29b5768951213ced8c6b7 Mon Sep 17 00:00:00 2001 From: "Mustufa Rangwala (OpenERP)" Date: Thu, 18 Aug 2011 11:10:26 +0530 Subject: [PATCH 14/72] [IMP] Code clean bzr revid: mra@tinyerp.com-20110818054026-1c8295185zn9vmp4 --- addons/account/account.py | 4 ++-- addons/account/report/account_report_common.py | 2 -- addons/account/wizard/account_report.py | 9 +-------- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index f58f478b5fd..ba8cdbcd9a2 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -2612,8 +2612,8 @@ class account_report(osv.osv): _description = "Account Report" _columns = { - 'name': fields.char('Report Name', size=64, required=True), - 'parent_id': fields.many2one('account.report', 'Parent Report'), + 'name': fields.char('Report Name', size=32, required=True), + 'parent_id': fields.many2one('account.report', 'Parent'), 'sequence': fields.integer('Sequence'), 'type': fields.selection([ ('sum','Sum'), diff --git a/addons/account/report/account_report_common.py b/addons/account/report/account_report_common.py index 57a97f8ab4e..c8b899e5311 100644 --- a/addons/account/report/account_report_common.py +++ b/addons/account/report/account_report_common.py @@ -53,7 +53,6 @@ class report_account_common(report_sxw.rml_parse, common_report_header): def _get_report_details(self, data): cr, uid = self.cr, self.uid - report_obj = self.pool.get('account.report') datas = [] balance = 0.0 @@ -84,7 +83,6 @@ class report_account_common(report_sxw.rml_parse, common_report_header): def get_account_details(self, acc_id, data): cr, uid = self.cr, self.uid - report_obj = self.pool.get('account.report') accounts = [] if acc_id and data['form'].get('display_details_per_account', False): diff --git a/addons/account/wizard/account_report.py b/addons/account/wizard/account_report.py index 064c9bb723e..1174fb04bfc 100644 --- a/addons/account/wizard/account_report.py +++ b/addons/account/wizard/account_report.py @@ -31,14 +31,7 @@ class accounting_report(osv.osv_memory): 'display_details_per_account': fields.boolean('Display Details per Account'), 'account_report_id': fields.many2one('account.report', 'Account Reports', required=True), } - - _defaults={ - 'enable_comparison': False, - 'display_details_per_account': False, - } def _print_report(self, cr, uid, ids, data, context=None): - if context is None: - context = {} data['form'].update(self.read(cr, uid, ids, ['account_report_id', 'enable_comparison', 'display_details_per_account'], context=context)[0]) return { 'type': 'ir.actions.report.xml', @@ -48,4 +41,4 @@ class accounting_report(osv.osv_memory): accounting_report() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file From b2415915cd8c1619f833dfe524103003b4102b11 Mon Sep 17 00:00:00 2001 From: gpa Date: Thu, 18 Aug 2011 11:53:26 +0530 Subject: [PATCH 15/72] [FIX] Fixed problem of import translation do not work after another import lp bug: https://launchpad.net/bugs/826623 fixed bzr revid: gpa@tinyerp.com-20110818062326-bc0ti49g2p6e6z7w --- .../base/module/wizard/base_import_language.py | 14 +++++++++++--- .../module/wizard/base_import_language_view.xml | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/openerp/addons/base/module/wizard/base_import_language.py b/openerp/addons/base/module/wizard/base_import_language.py index d73cd0864a6..f9587df1911 100644 --- a/openerp/addons/base/module/wizard/base_import_language.py +++ b/openerp/addons/base/module/wizard/base_import_language.py @@ -35,9 +35,13 @@ class base_language_import(osv.osv_memory): 'name': fields.char('Language Name',size=64 , required=True), 'code': fields.char('Code (eg:en__US)',size=5 , required=True), 'data': fields.binary('File', required=True), + 'overwrite': fields.boolean('Overwrite Existing Terms'), + } + _defaults = { + 'overwrite': False } - def import_lang(self, cr, uid, ids, context): + def import_lang(self, cr, uid, ids, context=None): """ Import Language @param cr: the current row, from the database cursor. @@ -45,8 +49,12 @@ class base_language_import(osv.osv_memory): @param ids: the ID or list of IDs @param context: A standard dictionary """ - + if context is None: + context = {} + import_data = self.browse(cr, uid, ids)[0] + if import_data.overwrite: + context = {'overwrite': True} fileobj = TemporaryFile('w+') fileobj.write(base64.decodestring(import_data.data)) @@ -56,7 +64,7 @@ class base_language_import(osv.osv_memory): fileformat = first_line.endswith("type,name,res_id,src,value") and 'csv' or 'po' fileobj.seek(0) - tools.trans_load_data(cr, fileobj, fileformat, import_data.code, lang_name=import_data.name) + tools.trans_load_data(cr, fileobj, fileformat, import_data.code, lang_name=import_data.name, context=context) tools.trans_update_res_ids(cr) fileobj.close() return {} diff --git a/openerp/addons/base/module/wizard/base_import_language_view.xml b/openerp/addons/base/module/wizard/base_import_language_view.xml index d313afc4080..4a1d7e5b758 100644 --- a/openerp/addons/base/module/wizard/base_import_language_view.xml +++ b/openerp/addons/base/module/wizard/base_import_language_view.xml @@ -27,6 +27,7 @@ + From e111108320459ca80a303126659ae13826d8e2a2 Mon Sep 17 00:00:00 2001 From: "Purnendu Singh (OpenERP)" Date: Fri, 19 Aug 2011 11:10:14 +0530 Subject: [PATCH 16/72] [IMP] accunt : small improvments like renaming variable bzr revid: psi@tinyerp.com-20110819054014-bh4cut8jd3d3nwv0 --- addons/account/report/account_report_common.rml | 10 +++++----- addons/account/wizard/account_report.py | 6 +++--- addons/account/wizard/account_report_view.xml | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/addons/account/report/account_report_common.rml b/addons/account/report/account_report_common.rml index 602f072f47d..130d903a62a 100644 --- a/addons/account/report/account_report_common.rml +++ b/addons/account/report/account_report_common.rml @@ -13,22 +13,22 @@ - + - + xtly - + - + @@ -37,7 +37,7 @@ - + diff --git a/addons/account/wizard/account_report.py b/addons/account/wizard/account_report.py index 064c9bb723e..1cc4e2d32c0 100644 --- a/addons/account/wizard/account_report.py +++ b/addons/account/wizard/account_report.py @@ -27,8 +27,8 @@ class accounting_report(osv.osv_memory): _description = "Account Report" _columns = { - 'enable_comparison': fields.boolean('Enable Comparison'), - 'display_details_per_account': fields.boolean('Display Details per Account'), + 'comparison': fields.boolean('Enable Comparison'), + 'account_details': fields.boolean('Details by Account'), 'account_report_id': fields.many2one('account.report', 'Account Reports', required=True), } @@ -39,7 +39,7 @@ class accounting_report(osv.osv_memory): def _print_report(self, cr, uid, ids, data, context=None): if context is None: context = {} - data['form'].update(self.read(cr, uid, ids, ['account_report_id', 'enable_comparison', 'display_details_per_account'], context=context)[0]) + data['form'].update(self.read(cr, uid, ids, ['account_report_id', 'comparison', 'account_details'], context=context)[0]) return { 'type': 'ir.actions.report.xml', 'report_name': 'account.common', diff --git a/addons/account/wizard/account_report_view.xml b/addons/account/wizard/account_report_view.xml index 119b1d7f1bd..6c436f97057 100644 --- a/addons/account/wizard/account_report_view.xml +++ b/addons/account/wizard/account_report_view.xml @@ -10,11 +10,11 @@ - - + + - + From 98cb234bf6e94dbafbabed6e782d7950b7d5dd93 Mon Sep 17 00:00:00 2001 From: "Ujjvala Collins (OpenERP)" Date: Fri, 19 Aug 2011 17:42:02 +0530 Subject: [PATCH 17/72] [IMP] account: Small improvements in formatting and improved some code. bzr revid: uco@tinyerp.com-20110819121202-i827lpb1yq8y5hyh --- .../account/report/account_report_common.py | 29 ++++++++++--------- .../account/report/account_report_common.rml | 16 +++++----- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/addons/account/report/account_report_common.py b/addons/account/report/account_report_common.py index c8b899e5311..21a1eb5f6e3 100644 --- a/addons/account/report/account_report_common.py +++ b/addons/account/report/account_report_common.py @@ -63,18 +63,7 @@ class report_account_common(report_sxw.rml_parse, common_report_header): child_ids = report_obj.search(cr, uid, [('parent_id','=',report_id)]) child_ids.append(datas[0]['id']) for child in report_obj.browse(cr, uid, child_ids): - if child.type == 'accounts': - for a in child.account_ids: - balance += a.balance - # it's the balance of the linked account.report (so it means it's only a way to reuse figures coming from another report) - if child.type == 'account_report' and child.account_report_id: - for a in child.account_report_id.account_ids: - balance +=a.balance - #it's the sum of balance of the children of this account.report (if there isn't, then it's 0.0) - if child.type == 'sum': - for child in report_obj.browse(cr, uid, child_ids): - for a in child.account_ids: - balance += a.balance + balance = self.get_report_balance(child) if child.id == datas[0]['id']: datas[0].update({'name': child.name, 'balance': balance}) else: @@ -85,14 +74,26 @@ class report_account_common(report_sxw.rml_parse, common_report_header): cr, uid = self.cr, self.uid report_obj = self.pool.get('account.report') accounts = [] - if acc_id and data['form'].get('display_details_per_account', False): + if acc_id and data['form'].get('account_details', False): for rpt in report_obj.browse(cr, uid, [acc_id]): for acc in rpt.account_ids: accounts.append({'code': acc.code, 'name': acc.name, 'bal': acc.balance}) return accounts - def get_report_balance(self): + def get_report_balance(self, child): balance = 0.0 + if child.type == 'accounts': + for a in child.account_ids: + balance += a.balance + # it's the balance of the linked account.report (so it means it's only a way to reuse figures coming from another report) + if child.type == 'account_report' and child.account_report_id: + for a in child.account_report_id.account_ids: + balance += a.balance + #it's the sum of balance of the children of this account.report (if there isn't, then it's 0.0) + if child.type == 'sum': + for child in report_obj.browse(cr, uid, child_ids): + for a in child.account_ids: + balance += a.balance return balance report_sxw.report_sxw('report.account.common', 'account.account', diff --git a/addons/account/report/account_report_common.rml b/addons/account/report/account_report_common.rml index 130d903a62a..44edd762bdb 100644 --- a/addons/account/report/account_report_common.rml +++ b/addons/account/report/account_report_common.rml @@ -105,29 +105,31 @@ - + [[ repeatIn(get_report_details(data),'r') ]] - + Report Name Report Balance [[ r['name'] ]] - [[ r['balance'] ]] + [[ formatLang(r['balance']) ]] - + - Account Details + + Account Details + - + Code Name @@ -136,7 +138,7 @@ [[ repeatIn(get_account_details(r['id'], data), 'a') ]] [[ a['code'] ]] [[ a['name'] ]] - [[ a['bal'] ]] + [[ formatLang(a['bal']) ]] From 5989085e5ad751454a769236c7b307fe2d1d223f Mon Sep 17 00:00:00 2001 From: "Ujjvala Collins (OpenERP)" Date: Tue, 23 Aug 2011 15:05:25 +0530 Subject: [PATCH 18/72] [IMP] account: Improved account report. bzr revid: uco@tinyerp.com-20110823093525-me84x0jpndcmc5po --- .../account/report/account_report_common.py | 30 +- .../account/report/account_report_common.rml | 349 ++++++++++++------ addons/account/wizard/account_report_view.xml | 2 +- 3 files changed, 257 insertions(+), 124 deletions(-) diff --git a/addons/account/report/account_report_common.py b/addons/account/report/account_report_common.py index 21a1eb5f6e3..05a4049ee30 100644 --- a/addons/account/report/account_report_common.py +++ b/addons/account/report/account_report_common.py @@ -35,11 +35,9 @@ class report_account_common(report_sxw.rml_parse, common_report_header): 'get_account': self._get_account, 'get_start_period': self.get_start_period, 'get_end_period': self.get_end_period, - 'get_sortby': self._get_sortby, 'get_filter': self._get_filter, 'get_start_date':self._get_start_date, 'get_end_date':self._get_end_date, - 'get_company':self._get_company, 'get_account_details': self.get_account_details, }) self.context = context @@ -59,11 +57,12 @@ class report_account_common(report_sxw.rml_parse, common_report_header): name = data['form'].get('account_report_id') and data['form']['account_report_id'][1] or '' report_id = data['form'].get('account_report_id') and data['form']['account_report_id'][0] or False datas.append({'id': report_id}) + ctx = self.context.copy() if report_id: child_ids = report_obj.search(cr, uid, [('parent_id','=',report_id)]) child_ids.append(datas[0]['id']) - for child in report_obj.browse(cr, uid, child_ids): - balance = self.get_report_balance(child) + for child in report_obj.browse(cr, uid, child_ids, context=ctx): + balance = self.get_report_balance(child, child_ids, ctx) if child.id == datas[0]['id']: datas[0].update({'name': child.name, 'balance': balance}) else: @@ -74,14 +73,27 @@ class report_account_common(report_sxw.rml_parse, common_report_header): cr, uid = self.cr, self.uid report_obj = self.pool.get('account.report') accounts = [] + + ctx = self.context.copy() + ctx['fiscalyear'] = data['form'].get('fiscalyear_id', False) + + if data['form']['filter'] == 'filter_period': + ctx['period_from'] = data['form'].get('period_from', False) + ctx['period_to'] = data['form'].get('period_to', False) + elif data['form']['filter'] == 'filter_date': + ctx['date_from'] = data['form'].get('date_from', False) + ctx['date_to'] = data['form'].get('date_to', False) + if acc_id and data['form'].get('account_details', False): - for rpt in report_obj.browse(cr, uid, [acc_id]): - for acc in rpt.account_ids: - accounts.append({'code': acc.code, 'name': acc.name, 'bal': acc.balance}) + for rpt in report_obj.browse(cr, uid, [acc_id], context=ctx): + accounts = [acc for acc in rpt.account_ids if acc.level != 0] return accounts - def get_report_balance(self, child): + def get_report_balance(self, child, child_ids, context=None): + cr, uid = self.cr, self.uid + report_obj = self.pool.get('account.report') balance = 0.0 + # it's the sum of balance of the linked accounts if child.type == 'accounts': for a in child.account_ids: balance += a.balance @@ -91,7 +103,7 @@ class report_account_common(report_sxw.rml_parse, common_report_header): balance += a.balance #it's the sum of balance of the children of this account.report (if there isn't, then it's 0.0) if child.type == 'sum': - for child in report_obj.browse(cr, uid, child_ids): + for child in report_obj.browse(cr, uid, child_ids, context=context): for a in child.account_ids: balance += a.balance return balance diff --git a/addons/account/report/account_report_common.rml b/addons/account/report/account_report_common.rml index 44edd762bdb..adc751f9cab 100644 --- a/addons/account/report/account_report_common.rml +++ b/addons/account/report/account_report_common.rml @@ -1,8 +1,8 @@ -