diff --git a/addons/account/account.py b/addons/account/account.py index 837edaae195..6512a9c1c1a 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -648,7 +648,7 @@ class account_move(osv.osv): data_move = self.pool.get('account.move').browse(cursor,user,ids) for move in data_move: if move.state=='draft': - name = '*' + move.name + name = '*' + str(move.id) else: name = move.name res.append((move.id, name)) @@ -671,7 +671,7 @@ class account_move(osv.osv): return result _columns = { - 'name': fields.char('Entry Name', size=64, required=True), + 'name': fields.char('Entry Number', size=64, required=True), 'ref': fields.char('Ref', size=64), 'period_id': fields.many2one('account.period', 'Period', required=True, states={'posted':[('readonly',True)]}), 'journal_id': fields.many2one('account.journal', 'Journal', required=True, states={'posted':[('readonly',True)]}), @@ -680,10 +680,22 @@ class account_move(osv.osv): 'to_check': fields.boolean('To Be Verified'), 'partner_id': fields.related('line_id', 'partner_id', type="many2one", relation="res.partner", string="Partner", store=True), 'amount': fields.function(_amount_compute, method=True, string='Amount', digits=(16,2), store=True), + 'type': fields.selection([ + ('pay_voucher','Cash Payment'), + ('bank_pay_voucher','Bank Payment'), + ('rec_voucher','Cash Receipt'), + ('bank_rec_voucher','Bank Receipt'), + ('cont_voucher','Contra'), + ('journal_sale_vou','Journal Sale'), + ('journal_pur_voucher','Journal Purchase'), + ('journal_voucher','Journal Voucher'), + ],'Type', readonly=True, select=True, states={'draft':[('readonly',False)]}), } _defaults = { + 'name': lambda *a: '/', 'state': lambda *a: 'draft', 'period_id': _get_period, + 'type' : lambda *a : 'journal_voucher', } def _check_centralisation(self, cursor, user, ids): @@ -716,6 +728,17 @@ class account_move(osv.osv): ] def post(self, cr, uid, ids, context=None): if self.validate(cr, uid, ids, context) and len(ids): + for move in self.browse(cr, uid, ids): + if move.name =='/': + new_name = False + journal = move.journal_id + if journal.sequence_id: + new_name = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id) + else: + raise osv.except_osv(_('Error'), _('No sequence defined in the journal !')) + if new_name: + self.write(cr, uid, [move.id], {'name':new_name}) + cr.execute('update account_move set state=%s where id in ('+','.join(map(str,ids))+')', ('posted',)) else: raise osv.except_osv(_('Integrity Error !'), _('You can not validate a non balanced entry !')) @@ -761,12 +784,6 @@ class account_move(osv.osv): l[2]['period_id'] = default_period context['period_id'] = default_period - if not 'name' in vals: - journal = self.pool.get('account.journal').browse(cr, uid, context.get('journal_id', vals.get('journal_id', False))) - if journal.sequence_id: - vals['name'] = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id) - else: - raise osv.except_osv(_('Error'), _('No sequence defined in the journal !')) accnt_journal = self.pool.get('account.journal').browse(cr, uid, vals['journal_id']) if 'line_id' in vals: c = context.copy() @@ -777,6 +794,13 @@ class account_move(osv.osv): result = super(account_move, self).create(cr, uid, vals, context) return result + def copy(self, cr, uid, id, default=None, context=None): + if default is None: + default = {} + default = default.copy() + default.update({'state':'draft', 'name':'/',}) + return super(account_move, self).copy(cr, uid, id, default, context) + def unlink(self, cr, uid, ids, context={}, check=True): toremove = [] for move in self.browse(cr, uid, ids, context): diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 697d961e17e..5eb03163c51 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -797,7 +797,8 @@ - + + @@ -812,13 +813,12 @@
+ - - - + @@ -854,8 +854,8 @@ - - + + diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 5c887064f1e..23544989049 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -191,6 +191,7 @@ class account_invoice(osv.osv): 'move_lines':fields.function(_get_lines , method=True,type='many2many' , relation='account.move.line',string='Move Lines'), 'residual': fields.function(_amount_residual, method=True, digits=(16,2),string='Residual', store=True, help="Remaining amount due."), 'payment_ids': fields.function(_compute_lines, method=True, relation='account.move.line', type="many2many", string='Payments'), + 'move_name': fields.char('Account Move', size=64), } _defaults = { 'type': _get_type, @@ -323,7 +324,7 @@ class account_invoice(osv.osv): if default is None: default = {} default = default.copy() - default.update({'state':'draft', 'number':False, 'move_id':False}) + default.update({'state':'draft', 'number':False, 'move_id':False, 'move_name':False,}) if 'date_invoice' not in default: default['date_invoice'] = False if 'date_due' not in default: @@ -568,8 +569,10 @@ class account_invoice(osv.osv): journal_id = inv.journal_id.id #self._get_journal(cr, uid, {'type': inv['type']}) journal = self.pool.get('account.journal').browse(cr, uid, journal_id) - if journal.sequence_id: + if journal.sequence_id and not inv.move_name: name = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id) + else: + name = inv.move_name if journal.centralisation: raise osv.except_osv(_('UserError'), _('Can not create invoice move on centralized journal')) @@ -585,8 +588,9 @@ class account_invoice(osv.osv): for i in line: i[2]['period_id'] = period_id move_id = self.pool.get('account.move').create(cr, uid, move) + new_move_name = self.pool.get('account.move').browse(cr, uid, move_id).name # make the invoice point to that move - self.write(cr, uid, [inv.id], {'move_id': move_id,'period_id':period_id}) + self.write(cr, uid, [inv.id], {'move_id': move_id,'period_id':period_id, 'move_name':new_move_name}) self.pool.get('account.move').post(cr, uid, [move_id]) self._log_event(cr, uid, ids) return True diff --git a/addons/account/report/account_balance.py b/addons/account/report/account_balance.py index 7cb47e3e198..d26c116a9e6 100755 --- a/addons/account/report/account_balance.py +++ b/addons/account/report/account_balance.py @@ -39,7 +39,6 @@ class account_balance(report_sxw.rml_parse): self.localcontext.update({ 'time': time, 'lines': self.lines, - 'moveline':self.moveline, 'sum_debit': self._sum_debit, 'sum_credit': self._sum_credit, 'get_fiscalyear':self.get_fiscalyear, @@ -134,27 +133,16 @@ class account_balance(report_sxw.rml_parse): self.transform_both_into_date_array(form) elif form['state'] == 'none' : self.transform_none_into_date_array(form) -# ctx['date_from'] = form['date_from'] -# ctx['date_to'] = form['date_to'] accounts = self.pool.get('account.account').browse(self.cr, self.uid, ids, ctx) def cmp_code(x, y): return cmp(x.code, y.code) accounts.sort(cmp_code) for account in accounts: - if account.id in done: continue done[account.id] = 1 res = { -# 'lid' :'', -# 'date':'', -# 'jname':'', -# 'ref':'', -# 'lname':'', -# 'debit1':'', -# 'credit1':'', -# 'balance1' :'', 'id' : account.id, 'type' : account.type, 'code': account.code, @@ -168,15 +156,12 @@ class account_balance(report_sxw.rml_parse): } self.sum_debit += account.debit self.sum_credit += account.credit -# if not (res['credit'] or res['debit']) and not account.child_id: -# continue - if account.child_id: def _check_rec(account): if not account.child_id: return bool(account.credit or account.debit) for c in account.child_id: - if not _check_rec(c): + if not _check_rec(c) or _check_rec(c): return True return False if not _check_rec(account) : @@ -191,57 +176,18 @@ class account_balance(report_sxw.rml_parse): result_acc.append(res) else: result_acc.append(res) - - - - res1 = self.moveline(form, account.id,res['level']) - if res1: - for r in res1: - result_acc.append(r) -# if account.code=='0': -# result_acc.pop(-1) if account.child_id: - ids2 = [(x.code,x.id) for x in account.child_id] - ids2.sort() - result_acc += self.lines(form, [x[1] for x in ids2], done, level+1) - + acc_id = [acc.id for acc in account.child_id] + lst_string = '' + lst_string = '\'' + '\',\''.join(map(str,acc_id)) + '\'' + self.cr.execute("select code,id from account_account where id IN (%s)"%(lst_string)) + a_id = self.cr.fetchall() + a_id.sort() + ids2 = [x[1] for x in a_id] + + result_acc += self.lines(form, ids2, done, level+1) return result_acc - def moveline(self,form,ids,level): - res={} - - self.date_lst_string = '\'' + '\',\''.join(map(str,self.date_lst)) + '\'' - self.cr.execute( - "SELECT l.id as lid,l.date,j.code as jname, l.ref, l.name as lname, l.debit as debit1, l.credit as credit1 " \ - "FROM account_move_line l " \ - "LEFT JOIN account_journal j " \ - "ON (l.journal_id = j.id) " \ - "WHERE l.account_id = '"+str(ids)+"' " \ - "AND l.date >= '"+self.date_lst[0]+"' " \ - "AND l.date <= '"+self.date_lst[-1]+"' " \ - "ORDER BY l.id") - - res = self.cr.dictfetchall() - - sum = 0.0 - for r in res: - sum = r['debit1'] - r['credit1'] - r['balance1'] = sum - r['type']= '' - r['id'] ='' - r['code']= '' - r['name']='' - r['level']=level - r['debit']='' - r['credit']='' - r['balance']='' - r['leef']='' - if sum >= 0.0: - r['bal_type']=" Dr." - else: - r['bal_type']=" Cr." - return res or '' - def date_range(self,start,end): start = datetime.date.fromtimestamp(time.mktime(time.strptime(start,"%Y-%m-%d"))) end = datetime.date.fromtimestamp(time.mktime(time.strptime(end,"%Y-%m-%d"))) diff --git a/addons/account/report/partner_balance.py b/addons/account/report/partner_balance.py index 22cb2479c87..0e286d61805 100644 --- a/addons/account/report/partner_balance.py +++ b/addons/account/report/partner_balance.py @@ -345,8 +345,6 @@ class partner_balance(report_sxw.rml_parse): tot_scredit = r['scredit'] tot_sdebit = r['sdebit'] tot_enlitige = (r['enlitige'] or 0.0) - - # ## new_header = {} @@ -362,7 +360,7 @@ class partner_balance(report_sxw.rml_parse): new_header['type'] = 3 ## ## - + completearray.append(new_header) ## # @@ -371,7 +369,7 @@ class partner_balance(report_sxw.rml_parse): r['balance'] = float(r['sdebit']) - float(r['scredit']) # - + print "=========r",r completearray.append(r) if cleanarray[i]['account_id'] == cleanarray[i-1]['account_id']: @@ -403,6 +401,7 @@ class partner_balance(report_sxw.rml_parse): # r['balance'] = float(r['sdebit']) - float(r['scredit']) # + completearray.append(r) i = i + 1 @@ -604,4 +603,4 @@ class partner_balance(report_sxw.rml_parse): report_sxw.report_sxw('report.account.partner.balance', 'res.partner', 'account/report/partner_balance.rml',parser=partner_balance, - header=False) \ No newline at end of file + header=False) diff --git a/addons/account/report/partner_balance.rml b/addons/account/report/partner_balance.rml index 32cea05fc3a..1548831e22a 100644 --- a/addons/account/report/partner_balance.rml +++ b/addons/account/report/partner_balance.rml @@ -381,4 +381,4 @@ - + \ No newline at end of file diff --git a/addons/account/wizard/wizard_account_balance_report.py b/addons/account/wizard/wizard_account_balance_report.py index c730ec53685..6b40d57df51 100644 --- a/addons/account/wizard/wizard_account_balance_report.py +++ b/addons/account/wizard/wizard_account_balance_report.py @@ -54,7 +54,7 @@ period_fields = { 'string':"Date/Period Filter", 'type':'selection', 'selection':[('bydate','By Date'),('byperiod','By Period'),('all','By Date and Period'),('none','No Filter')], - 'default': lambda *a:'bydate' + 'default': lambda *a:'none' }, 'fiscalyear': { 'string':'Fiscal year', @@ -63,8 +63,8 @@ period_fields = { 'help':'Keep empty for all open fiscal year' }, 'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty'}, - 'display_account':{'string':"Display accounts ",'type':'selection','selection':[('bal_mouvement','With Movements'),('bal_solde','With Balance != 0'),('bal_all','All')]}, - 'date_from': {'string':" Start date",'type':'date','required':True ,'default': lambda *a: time.strftime('%Y-01-01')}, + 'display_account':{'string':"Display accounts ",'type':'selection','selection':[('bal_mouvement','With movements'),('bal_all','All'),('bal_solde','With balance is not equal to 0')]}, + 'date_from': {'string':"Start date",'type':'date','required':True ,'default': lambda *a: time.strftime('%Y-01-01')}, 'date_to': {'string':"End date",'type':'date','required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')}, } @@ -89,6 +89,7 @@ class wizard_report(wizard.interface): periods_obj=pooler.get_pool(cr.dbname).get('account.period') data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid) data['form']['periods'] =periods_obj.search(cr, uid, [('fiscalyear_id','=',data['form']['fiscalyear'])]) + data['form']['fiscalyear'] = False data['form']['display_account']='bal_all' return data['form'] diff --git a/addons/account/wizard/wizard_aged_trial_balance.py b/addons/account/wizard/wizard_aged_trial_balance.py index 51c7994f9df..3de86d2653e 100755 --- a/addons/account/wizard/wizard_aged_trial_balance.py +++ b/addons/account/wizard/wizard_aged_trial_balance.py @@ -48,7 +48,7 @@ _aged_trial_fields = { 'type':'selection', 'selection':[('customer','Receivable'),('supplier','Payable'),('all','Receivable and Payable')], 'required':True, - 'default': lambda *a: 'customer', + 'default': lambda *a: 'all', }, 'direction_selection':{ 'string':"Analysis Direction", diff --git a/addons/account/wizard/wizard_general_ledger_report.py b/addons/account/wizard/wizard_general_ledger_report.py index 0f5c92fa9f4..1d5896204db 100644 --- a/addons/account/wizard/wizard_general_ledger_report.py +++ b/addons/account/wizard/wizard_general_ledger_report.py @@ -100,7 +100,7 @@ period_fields = { 'string':"Date/Period Filter", 'type':'selection', 'selection':[('bydate','By Date'),('byperiod','By Period'),('all','By Date and Period'),('none','No Filter')], - 'default': lambda *a:'bydate' + 'default': lambda *a:'none' }, 'fiscalyear': {'string': 'Fiscal year', 'type': 'many2one', 'relation': 'account.fiscalyear', 'help': 'Keep empty for all open fiscal year'}, @@ -168,6 +168,7 @@ class wizard_report(wizard.interface): data['form']['sortbydate'] = 'sort_date' data['form']['display_account']='bal_all' data['form']['landscape']=True + data['form']['fiscalyear'] = False data['form']['amount_currency'] = True return data['form'] diff --git a/addons/account/wizard/wizard_partner_balance_report.py b/addons/account/wizard/wizard_partner_balance_report.py index 500e1dbb224..697b08fd16b 100644 --- a/addons/account/wizard/wizard_partner_balance_report.py +++ b/addons/account/wizard/wizard_partner_balance_report.py @@ -54,10 +54,11 @@ period_fields = { 'string':"Date/Period Filter", 'type':'selection', 'selection':[('bydate','By Date'),('byperiod','By Period'),('all','By Date and Period'),('none','No Filter')], - 'default': lambda *a:'bydate' + 'default': lambda *a:'none' }, 'fiscalyear': { 'string':'Fiscal year', 'type': 'many2one', 'relation': 'account.fiscalyear', + 'default': lambda *a:False, 'help': 'Keep empty for all open fiscal year' }, 'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty','states':{'none':[('readonly',True)],'bydate':[('readonly',True)]}}, @@ -87,6 +88,7 @@ class wizard_report(wizard.interface): data['form']['periods'] =periods_obj.search(cr, uid, [('fiscalyear_id','=',data['form']['fiscalyear'])]) data['form']['company_id'] = company_id data['form']['soldeinit'] = True + data['form']['fiscalyear'] = False data['form']['result_selection'] = 'all' return data['form'] diff --git a/addons/account/wizard/wizard_third_party_ledger.py b/addons/account/wizard/wizard_third_party_ledger.py index 6497958fee6..80827378e0f 100755 --- a/addons/account/wizard/wizard_third_party_ledger.py +++ b/addons/account/wizard/wizard_third_party_ledger.py @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# OpenERP, Open Source Management Solution +# OpenERP, Open Source Management Solution # Copyright (C) 2004-2008 Tiny SPRL (). All Rights Reserved # $Id$ # @@ -27,16 +27,16 @@ import pooler period_form = ''' - - + +