From 7f5ca0808e819d70a3a9f5ae55bbb422e76fa235 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Tue, 26 Jun 2007 13:28:51 +0000 Subject: [PATCH] Followup bugfix Account move line bugfix in control from journals bzr revid: fp@tinyerp.com-fb30c2bf337fe56762fb5c83b6c76432f6cd49ed --- addons/account/account.py | 13 +++++++++++++ addons/account/account_move_line.py | 13 +++++++++---- addons/account/wizard/wizard_pay_invoice.py | 10 ++++++---- addons/account_asset/account_asset_view.xml | 2 +- .../wizard/wizard_followup_print.py | 12 ++++++++++-- 5 files changed, 39 insertions(+), 11 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index e4122e36eb2..b286e890744 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -850,6 +850,19 @@ class account_tax_code(osv.osv): _defaults = { 'company_id': _default_company, } + #def _check_recursion(self, cr, uid, ids): + # level = 100 + # while len(ids): + # cr.execute('select distinct parent_id from account_account_rel where child_id in ('+','.join(map(str,ids))+')') + # ids = filter(None, map(lambda x:x[0], cr.fetchall())) + # if not level: + # return False + # level -= 1 + # return True + + #_constraints = [ + # (_check_recursion, 'Error ! You can not create recursive accounts.', ['parent_id']) + #] _order = 'name' account_tax_code() diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index b62f726bc6d..fecc06dbecf 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -167,7 +167,7 @@ class account_move_line(osv.osv): 'credit': fields.float('Credit', digits=(16,2), states={'reconciled':[('readonly',True)]}), 'account_id': fields.many2one('account.account', 'Account', required=True, ondelete="cascade", states={'reconciled':[('readonly',True)]}, domain=[('type','<>','view'), ('type', '<>', 'closed')]), - 'move_id': fields.many2one('account.move', 'Entry', required=True, ondelete="cascade", states={'reconciled':[('readonly',True)]}, help="The entry of this entry line.", select=2), + 'move_id': fields.many2one('account.move', 'Entry', ondelete="cascade", states={'reconciled':[('readonly',True)]}, help="The entry of this entry line.", select=2), 'ref': fields.char('Ref.', size=32), 'statement_id': fields.many2one('account.bank.statement', 'Statement', help="The bank statement used for bank reconciliation", select=True), @@ -480,15 +480,20 @@ class account_move_line(osv.osv): else: raise osv.except_osv('No piece number !', 'Can not create an automatic sequence for this piece !\n\nPut a sequence in the journal definition for automatic numbering or create a sequence manually for this piece.') + ok = not (journal.type_control_ids or journal.account_control_ids) if ('account_id' in vals) and journal.type_control_ids: type = self.pool.get('account.account').browse(cr, uid, vals['account_id']).type - ok = False for t in journal.type_control_ids: if type==t.code: ok = True break - if not ok: - raise osv.except_osv('Bad account !', 'You can not use this general account in this journal !') + if ('account_id' in vals) and journal.account_control_ids and not ok: + for a in journal.account_control_ids: + if a.id==vals['account_id']: + ok = True + break + if not ok: + raise osv.except_osv('Bad account !', 'You can not use this general account in this journal !') result = super(osv.osv, self).create(cr, uid, vals, context) if check: diff --git a/addons/account/wizard/wizard_pay_invoice.py b/addons/account/wizard/wizard_pay_invoice.py index f0e220b8a09..d766dcbb78d 100644 --- a/addons/account/wizard/wizard_pay_invoice.py +++ b/addons/account/wizard/wizard_pay_invoice.py @@ -32,15 +32,13 @@ import pooler pay_form = '''
- ''' pay_fields = { 'amount': {'string': 'Amount paid', 'type':'float', 'required':True}, - 'dest_account_id': {'string':'Payment to Account', 'type':'many2one', 'required':True, 'relation':'account.account', 'domain':[('type','=','cash')]}, - 'journal_id': {'string': 'Journal', 'type': 'many2one', 'relation':'account.journal', 'required':True}, + 'journal_id': {'string': 'Journal', 'type': 'many2one', 'relation':'account.journal', 'required':True, 'domain':[('type','=','cash')]}, 'period_id': {'string': 'Period', 'type': 'many2one', 'relation':'account.period', 'required':True}, } @@ -51,7 +49,11 @@ def _pay_and_reconcile(self, cr, uid, data, context): journal_id = form.get('journal_id', False) writeoff_account_id = form.get('writeoff_acc_id', False) writeoff_journal_id = form.get('writeoff_journal_id', False) - service.execute(cr.dbname, uid, 'account.invoice', 'pay_and_reconcile', [data['id']], form['amount'], form['dest_account_id'], period_id, journal_id, writeoff_account_id, period_id, writeoff_journal_id, context) + pool = pooler.get_pool(cr.dbname) + acc_id = pool.get('account.journal').browse(cr, uid, journal_id, context).default_credit_account_id.id + if not acc_id: + raise wizard.except_wizard('Error !', 'Your journal must have a default credit and debit account.') + service.execute(cr.dbname, uid, 'account.invoice', 'pay_and_reconcile', [data['id']], form['amount'], acc_id, period_id, journal_id, writeoff_account_id, period_id, writeoff_journal_id, context) return {} def _trans_reconcile(self, cr, uid, data, context): diff --git a/addons/account_asset/account_asset_view.xml b/addons/account_asset/account_asset_view.xml index 2737a717d69..9f44ea9119a 100644 --- a/addons/account_asset/account_asset_view.xml +++ b/addons/account_asset/account_asset_view.xml @@ -223,7 +223,7 @@ action="action_account_asset_asset_form"/> - Asset hyerarchy + Asset hierarchy account.asset.asset tree [('parent_id','=',False)] diff --git a/addons/account_followup/wizard/wizard_followup_print.py b/addons/account_followup/wizard/wizard_followup_print.py index 97f3d6e27b3..49e842c964b 100644 --- a/addons/account_followup/wizard/wizard_followup_print.py +++ b/addons/account_followup/wizard/wizard_followup_print.py @@ -85,7 +85,14 @@ Thanks, class followup_all_print(wizard.interface): def _get_partners(self, cr, uid, data, context): - cr.execute('select id from account_followup_stat') + cr.execute( + "SELECT distinct l.partner_id "\ + "FROM account_move_line AS l LEFT JOIN account_account AS a "\ + "ON (l.account_id=a.id) "\ + "WHERE (l.reconcile_id IS NULL) "\ + "AND (a.type='receivable') "\ + "AND (l.state<>'draft') "\ + "AND (l.reconcile_id is NULL) ") ids = map(lambda x: x[0], cr.fetchall()) return {'partner_ids': ids} @@ -97,8 +104,9 @@ class followup_all_print(wizard.interface): "FROM account_move_line AS l LEFT JOIN account_account AS a "\ "ON (l.account_id=a.id) "\ "WHERE (l.reconcile_id IS NULL) "\ - "AND (a.type='receivable') AND (l.debit > 0) "\ + "AND (a.type='receivable') "\ "AND (l.state<>'draft') "\ + "AND (l.reconcile_id is NULL) "\ "AND partner_id in ("+','.join(map(str,partner_ids))+") "\ "ORDER BY l.date") move_lines = cr.fetchall()