From bd5d891417b6a32c1297fcaf82b82ffeafee12df Mon Sep 17 00:00:00 2001 From: "ARA (OpenERP)" Date: Tue, 26 Oct 2010 19:03:52 +0530 Subject: [PATCH] [IMP] account_voucher: code cleaning bzr revid: ara@tinyerp.com-20101026133352-0tb4fmrby1yv8vyg --- addons/account_voucher/__init__.py | 2 +- addons/account_voucher/account_voucher.py | 16 ++++++++++------ addons/account_voucher/report/account_voucher.py | 7 ++++--- .../wizard/account_statement_from_invoice.py | 1 + .../wizard/account_voucher_unreconcile.py | 10 +++++----- 5 files changed, 21 insertions(+), 15 deletions(-) diff --git a/addons/account_voucher/__init__.py b/addons/account_voucher/__init__.py index 2b1478d9fa0..9796f81d5e5 100644 --- a/addons/account_voucher/__init__.py +++ b/addons/account_voucher/__init__.py @@ -24,4 +24,4 @@ import invoice import report import wizard -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index 9dca6fdd9c6..a07e41ff000 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -573,6 +573,7 @@ class account_voucher(osv.osv): move_line_pool = self.pool.get('account.move.line') currency_pool = self.pool.get('res.currency') tax_obj = self.pool.get('account.tax') + seq_obj = self.pool.get('ir.sequence') for inv in self.browse(cr, uid, ids): if not inv.line_ids: raise osv.except_osv(_('No Lines !'), _('Please create some lines')) @@ -581,7 +582,7 @@ class account_voucher(osv.osv): if inv.number: name = inv.number elif inv.journal_id.sequence_id: - name = self.pool.get('ir.sequence').get_id(cr, uid, inv.journal_id.sequence_id.id) + name = seq_obj.get_id(cr, uid, inv.journal_id.sequence_id.id) else: raise osv.except_osv(_('Error !'), _('Please define a sequence on the journal !')) if not inv.reference: @@ -687,7 +688,7 @@ class account_voucher(osv.osv): rec_ids = [master_line, line.move_line_id.id] rec_list_ids.append(rec_ids) - if not self.pool.get('res.currency').is_zero(cr, uid, inv.currency_id, line_total): + if not currency_pool.is_zero(cr, uid, inv.currency_id, line_total): diff = line_total move_line = { 'name': name, @@ -854,17 +855,19 @@ class account_bank_statement(osv.osv): _inherit = 'account.bank.statement' def button_cancel(self, cr, uid, ids, context=None): + voucher_obj = self.pool.get('account.voucher') for st in self.browse(cr, uid, ids, context): voucher_ids = [] for line in st.line_ids: if line.voucher_id: voucher_ids.append(line.voucher_id.id) - self.pool.get('account.voucher').cancel_voucher(cr, uid, voucher_ids, context) + voucher_obj.cancel_voucher(cr, uid, voucher_ids, context) return super(account_bank_statement, self).button_cancel(cr, uid, ids, context=context) def create_move_from_st_line(self, cr, uid, st_line_id, company_currency_id, next_number, context=None): voucher_obj = self.pool.get('account.voucher') wf_service = netsvc.LocalService("workflow") + move_line_obj = self.pool.get('account.move.line') bank_st_line_obj = self.pool.get('account.bank.statement.line') st_line = bank_st_line_obj.browse(cr, uid, st_line_id, context=context) if st_line.voucher_id: @@ -878,7 +881,7 @@ class account_bank_statement(osv.osv): 'move_ids': [(4, v.move_id.id, False)] }) - return self.pool.get('account.move.line').write(cr, uid, [x.id for x in v.move_ids], {'statement_id': st_line.statement_id.id}, context=context) + return move_line_obj.write(cr, uid, [x.id for x in v.move_ids], {'statement_id': st_line.statement_id.id}, context=context) return super(account_bank_statement, self).create_move_from_st_line(cr, uid, st_line.id, company_currency_id, next_number, context=context) account_bank_statement() @@ -912,14 +915,15 @@ class account_bank_statement_line(osv.osv): } def unlink(self, cr, uid, ids, context=None): + voucher_obj = self.pool.get('account.voucher') statement_line = self.browse(cr, uid, ids, context) unlink_ids = [] for st_line in statement_line: if st_line.voucher_id: unlink_ids.append(st_line.voucher_id.id) - self.pool.get('account.voucher').unlink(cr, uid, unlink_ids, context=context) + voucher_obj.unlink(cr, uid, unlink_ids, context=context) return super(account_bank_statement_line, self).unlink(cr, uid, ids, context=context) account_bank_statement_line() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:======= +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/account_voucher/report/account_voucher.py b/addons/account_voucher/report/account_voucher.py index 7931daffbac..e44adee974e 100644 --- a/addons/account_voucher/report/account_voucher.py +++ b/addons/account_voucher/report/account_voucher.py @@ -32,7 +32,7 @@ class report_voucher(report_sxw.rml_parse): 'get_title': self.get_title, 'debit':self.debit, 'credit':self.credit, - 'get_ref' : self._get_ref + 'get_ref': self._get_ref }) def convert(self, amount, cur): @@ -58,9 +58,10 @@ class report_voucher(report_sxw.rml_parse): return credit def _get_ref(self, voucher_id, move_ids): - voucher_line = self.pool.get('account.voucher.line').search(self.cr, self.uid, [('partner_id', '=', move_ids.partner_id.id), ('voucher_id', '=', voucher_id)]) + voucher_line_obj = self.pool.get('account.voucher.line') + voucher_line = voucher_line_obj.search(self.cr, self.uid, [('partner_id', '=', move_ids.partner_id.id), ('voucher_id', '=', voucher_id)]) if voucher_line: - voucher = self.pool.get('account.voucher.line').browse(self.cr, self.uid, voucher_line)[0] + voucher = voucher_line_obj.browse(self.cr, self.uid, voucher_line)[0] return voucher.name else: return diff --git a/addons/account_voucher/wizard/account_statement_from_invoice.py b/addons/account_voucher/wizard/account_statement_from_invoice.py index 507fdcabffa..b4671ae208a 100644 --- a/addons/account_voucher/wizard/account_statement_from_invoice.py +++ b/addons/account_voucher/wizard/account_statement_from_invoice.py @@ -18,6 +18,7 @@ # along with this program. If not, see . # ############################################################################## + import time from osv import fields, osv diff --git a/addons/account_voucher/wizard/account_voucher_unreconcile.py b/addons/account_voucher/wizard/account_voucher_unreconcile.py index 71b4fbc8fb5..69aa6e1181d 100644 --- a/addons/account_voucher/wizard/account_voucher_unreconcile.py +++ b/addons/account_voucher/wizard/account_voucher_unreconcile.py @@ -25,15 +25,15 @@ from osv import fields class account_voucher_unreconcile(osv.osv_memory): _name = "account.voucher.unreconcile" _description = "Account voucher unreconcile" - + _columns = { 'remove':fields.boolean('Want to remove accounting entries too ?', required=False), } - + _defaults = { 'remove': True, } - + def trans_unrec(self, cr, uid, ids, context=None): # res = self.browse(cr, uid, ids[0]) if context is None: @@ -54,9 +54,9 @@ class account_voucher_unreconcile(osv.osv_memory): voucher_pool.cancel_voucher(cr, uid, [context.get('active_id')], context) # wf_service = netsvc.LocalService("workflow") # wf_service.trg_validate(uid, 'account.voucher', context.get('active_id'), 'cancel_voucher', cr) - + return {} account_voucher_unreconcile() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file