diff --git a/addons/account/account.py b/addons/account/account.py index 5fc97a13697..17237211581 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -138,7 +138,6 @@ class account_payment_term_line(osv.osv): account_payment_term_line() - class account_account_type(osv.osv): _name = "account.account.type" _description = "Account Type" @@ -639,8 +638,8 @@ class account_journal(osv.osv): 'currency': fields.many2one('res.currency', 'Currency', help='The currency used to enter statement'), 'entry_posted': fields.boolean('Skip \'Draft\' State for Created Entries', help='Check this box if you don\'t want new account moves to pass through the \'draft\' state and instead goes directly to the \'posted state\' without any manual validation.'), 'company_id': fields.many2one('res.company', 'Company', required=True, select=1, help="Company related to this journal"), - 'invoice_sequence_id': fields.many2one('ir.sequence', 'Invoice Sequence', \ - help="The sequence used for invoice numbers in this journal."), +# 'invoice_sequence_id': fields.many2one('ir.sequence', 'Invoice Sequence', \ +# help="The sequence used for invoice numbers in this journal."), 'allow_date':fields.boolean('Check Date not in the Period', help= 'If set to True then do not accept the entry if the entry date is not into the period dates'), } @@ -648,7 +647,7 @@ class account_journal(osv.osv): 'user_id': lambda self,cr,uid,context: uid, 'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id, } - + def write(self, cr, uid, ids, vals, context=None): obj=[] if 'company_id' in vals: @@ -674,21 +673,21 @@ class account_journal(osv.osv): 'purchase_refund':'seq_out_refund', 'sale_refund':'seq_in_refund' } - + seq_pool = self.pool.get('ir.sequence') seq_typ_pool = self.pool.get('ir.sequence.type') date_pool = self.pool.get('ir.model.data') - + result = True - + journal = self.browse(cr, uid, ids[0], context) - code = journal.code.lower() + code = journal.code.lower() types = { 'name':journal.name, 'code':code } type_id = seq_typ_pool.create(cr, uid, types) - + seq = { 'name':journal.name, 'code':code, @@ -698,25 +697,25 @@ class account_journal(osv.osv): 'number_increment':1 } seq_id = seq_pool.create(cr, uid, seq) - + res = {} if not journal.sequence_id: res.update({ 'sequence_id':seq_id }) - if journal.type in journal_type and not journal.invoice_sequence_id: - res_ids = date_pool.search(cr, uid, [('model','=','ir.sequence'), ('name','=',journal_seq.get(journal.type, 'sale'))]) - inv_seq_id = date_pool.browse(cr, uid, res_ids[0]).res_id - inv_seq_id - res.update({ - 'invoice_sequence_id':inv_seq_id - }) - +# if journal.type in journal_type and not journal.invoice_sequence_id: +# res_ids = date_pool.search(cr, uid, [('model','=','ir.sequence'), ('name','=',journal_seq.get(journal.type, 'sale'))]) +# inv_seq_id = date_pool.browse(cr, uid, res_ids[0]).res_id +# inv_seq_id +# res.update({ +# 'invoice_sequence_id':inv_seq_id +# }) + result = self.write(cr, uid, [journal.id], res) - + return result - + def create(self, cr, uid, vals, context={}): journal_id = super(account_journal, self).create(cr, uid, vals, context) self.create_sequence(cr, uid, [journal_id], context) @@ -732,20 +731,26 @@ class account_journal(osv.osv): # }) return journal_id - def name_search(self, cr, user, name, args=None, operator='ilike', context={}, limit=100): + def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100): if not args: args = [] + if context is None: + context = {} ids = [] + if context.get('journal_type', False): + args += [('type','=',context.get('journal_type'))] if name: - ids = self.search(cr, user, [('code','ilike',name)]+ args, limit=limit, context=context) + ids = self.search(cr, user, [('code', 'ilike', name)]+ args, limit=limit, context=context) if not ids: - ids = self.search(cr, user, [('name',operator,name)]+ args, limit=limit, context=context) +# ids = self.search(cr, user, [('name', operator, name)]+ args, limit=limit, context=context) + ids = self.search(cr, user, [('name', 'ilike', name)]+ args, limit=limit, context=context)#fix it ilike should be replace with operator + return self.name_get(cr, user, ids, context=context) def onchange_type(self, cr, uid, ids, type, currency): data_pool = self.pool.get('ir.model.data') user_pool = self.pool.get('res.users') - + type_map = { 'sale':'account_sp_journal_view', 'sale_refund':'account_sp_refund_journal_view', @@ -757,23 +762,23 @@ class account_journal(osv.osv): 'general':'account_journal_view', 'situation':'account_journal_view' } - + res = {} - + view_id = type_map.get(type, 'general') - + user = user_pool.browse(cr, uid, uid) if type in ('cash', 'bank') and currency and user.company_id.currency_id.id != currency: view_id = 'account_journal_bank_view_multi' - + data_id = data_pool.search(cr, uid, [('model','=','account.journal.view'), ('name','=',view_id)]) data = data_pool.browse(cr, uid, data_id[0]) - + res.update({ 'centralisation':type == 'situation', 'view_id':data.res_id, }) - + return { 'value':res } @@ -850,9 +855,9 @@ class account_fiscalyear(osv.osv): context = {} ids = [] if name: - ids = self.search(cr, user, [('code','ilike',name)]+ args, limit=limit) + ids = self.search(cr, user, [('code', 'ilike', name)]+ args, limit=limit) if not ids: - ids = self.search(cr, user, [('name',operator,name)]+ args, limit=limit) + ids = self.search(cr, user, [('name', operator, name)]+ args, limit=limit) return self.name_get(cr, user, ids, context=context) account_fiscalyear() @@ -1031,18 +1036,18 @@ class account_move(osv.osv): """ Returns a list of tupples containing id, name, as internally it is called {def name_get} result format : {[(id, name), (id, name), ...]} - + @param cr: A database cursor @param user: ID of the user currently logged in - @param name: name to search + @param name: name to search @param args: other arguments @param operator: default operator is 'ilike', it can be changed @param context: context arguments, like lang, time zone @param limit: Returns first 'n' ids of complete result, default is 80. - + @return: Returns a list of tupples containing id and name """ - + if not args: args=[] if not context: @@ -1050,10 +1055,12 @@ class account_move(osv.osv): ids = [] if name: - ids += self.search(cr, user, [('state','=','draft'), ('id','=',name)], limit=limit) + ids += self.search(cr, user, [('name','=',name)], limit=limit) + if not ids: + ids += self.search(cr, user, [('id','=',name)], limit=limit) return self.name_get(cr, user, ids, context=context) - + def name_get(self, cursor, user, ids, context=None): if not len(ids): return [] @@ -1153,18 +1160,24 @@ class account_move(osv.osv): 'You cannot create entries on different periods/journals in the same move', ['line_id']), ] - + def post(self, cr, uid, ids, context=None): + invoice = context.get('invoice', False) 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: - c = {'fiscalyear_id': move.period_id.fiscalyear_id.id} - new_name = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id, context=c) + + if invoice and invoice.internal_number: + new_name = invoice.internal_number else: - raise osv.except_osv(_('Error'), _('No sequence defined in the journal !')) + if journal.sequence_id: + c = {'fiscalyear_id': move.period_id.fiscalyear_id.id} + new_name = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id, context=c) + else: + raise osv.except_osv(_('Error'), _('No sequence defined in the journal !')) + if new_name: self.write(cr, uid, [move.id], {'name':new_name}) @@ -1212,7 +1225,7 @@ class account_move(osv.osv): 'balance':False, 'account_tax_id':False, }) - + if 'journal_id' in vals and vals.get('journal_id', False): for l in vals['line_id']: if not l[0]: @@ -1661,15 +1674,15 @@ class account_tax(osv.osv): """ Returns a list of tupples containing id, name, as internally it is called {def name_get} result format : {[(id, name), (id, name), ...]} - + @param cr: A database cursor @param user: ID of the user currently logged in - @param name: name to search + @param name: name to search @param args: other arguments @param operator: default operator is 'ilike', it can be changed @param context: context arguments, like lang, time zone @param limit: Returns first 'n' ids of complete result, default is 80. - + @return: Returns a list of tupples containing id and name """ if not args: @@ -1679,10 +1692,10 @@ class account_tax(osv.osv): ids = [] ids = self.search(cr, user, args, limit=limit, context=context) return self.name_get(cr, user, ids, context=context) - + def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False): journal_pool = self.pool.get('account.journal') - + if context and context.has_key('type'): if context.get('type') in ('out_invoice','out_refund'): args += [('type_tax_use','in',['sale','all'])] @@ -1693,7 +1706,7 @@ class account_tax(osv.osv): journal = journal_pool.browse(cr, uid, context.get('journal_id')) if journal.type in ('sale', 'purchase'): args += [('type_tax_use','in',[journal.type,'all'])] - + return super(account_tax, self).search(cr, uid, args, offset, limit, order, context, count) def name_get(self, cr, uid, ids, context={}): @@ -1710,7 +1723,7 @@ class account_tax(osv.osv): if user.company_id: return user.company_id.id return self.pool.get('res.company').search(cr, uid, [('parent_id', '=', False)])[0] - + _defaults = { 'python_compute': lambda *a: '''# price_unit\n# address : res.partner.address object or False\n# product : product.product object or None\n# partner : res.partner object or None\n\nresult = price_unit * 0.10''', 'python_compute_inv': lambda *a: '''# price_unit\n# address : res.partner.address object or False\n# product : product.product object or False\n\nresult = price_unit * 0.10''', @@ -1830,11 +1843,11 @@ class account_tax(osv.osv): tin = self.compute_inv(cr, uid, tin, price_unit, quantity, address_id=address_id, product=product, partner=partner) for r in tin: totalex -= r['amount'] - totlex_qty=0.0 + totlex_qty=0.0 try: totlex_qty=totalex/quantity except: - pass + pass tex = self._compute(cr, uid, tex, totlex_qty, quantity, address_id=address_id, product=product, partner=partner) for r in tex: totalin += r['amount'] @@ -2140,11 +2153,10 @@ class account_subscription_line(osv.osv): 'date': fields.date('Date', required=True), 'move_id': fields.many2one('account.move', 'Entry'), } - _defaults = { - } - def move_create(self, cr, uid, ids, context={}): + + def move_create(self, cr, uid, ids, context=None): tocheck = {} - for line in self.browse(cr, uid, ids, context): + for line in self.browse(cr, uid, ids, context=context): datas = { 'date': line.date, } @@ -2153,7 +2165,8 @@ class account_subscription_line(osv.osv): self.write(cr, uid, [line.id], {'move_id':ids[0]}) if tocheck: self.pool.get('account.subscription').check(cr, uid, tocheck.keys(), context) - return True + return ids + _rec_name = 'date' account_subscription_line() @@ -2335,6 +2348,7 @@ class account_chart_template(osv.osv): 'property_account_income_categ': fields.many2one('account.account.template','Income Category Account'), 'property_account_expense': fields.many2one('account.account.template','Expense Account on Product Template'), 'property_account_income': fields.many2one('account.account.template','Income Account on Product Template'), + 'property_reserve_and_surplus_account': fields.many2one('account.account.template', 'Reserve and Surplus Account', domain=[('type', '=', 'payable')] , help='This Account is used for transferring Profit/Loss(If It is Profit : Amount will be added, Loss : Amount will be deducted.), Which is calculated from Profilt & Loss Report'), } account_chart_template() @@ -2616,7 +2630,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): data_id = data_pool.search(cr, uid, [('model','=','account.journal.view'), ('name','=','account_sp_journal_view')]) data = data_pool.browse(cr, uid, data_id[0]) view_id = data.res_id - + seq_id = obj_sequence.search(cr, uid, [('name','=','Account Journal')])[0] if obj_multi.seq_journal: @@ -2657,7 +2671,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): data_id = data_pool.search(cr, uid, [('model','=','account.journal.view'), ('name','=','account_journal_bank_view')]) data = data_pool.browse(cr, uid, data_id[0]) view_id_cash = data.res_id - + data_id = data_pool.search(cr, uid, [('model','=','account.journal.view'), ('name','=','account_journal_bank_view_multi')]) data = data_pool.browse(cr, uid, data_id[0]) ref_acc_bank = data.res_id @@ -2718,7 +2732,8 @@ class wizard_multi_charts_accounts(osv.osv_memory): ('property_account_expense_categ','product.category','account.account'), ('property_account_income_categ','product.category','account.account'), ('property_account_expense','product.template','account.account'), - ('property_account_income','product.template','account.account') + ('property_account_income','product.template','account.account'), + ('property_reserve_and_surplus_account','res.company','account.account') ] for record in todo_list: r = [] @@ -2731,6 +2746,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): 'fields_id': field[0], 'value': account and 'account.account,'+str(acc_template_ref[account.id]) or False, } + if r: #the property exist: modify it property_obj.write(cr, uid, r, vals) @@ -2767,15 +2783,15 @@ class wizard_multi_charts_accounts(osv.osv_memory): 'position_id' : new_fp, } obj_ac_fp.create(cr, uid, vals_acc) - + #fially inactive the demo chart of accounts data_id = data_pool.search(cr, uid, [('model','=','account.account'), ('name','=','chart0')]) if data_id: data = data_pool.browse(cr, uid, data_id[0]) account_id = data.res_id - if account_id: - cr.execute("update account_account set active='f' where id=%s" % (account_id)) - + acc_ids = obj_acc._get_children_and_consol(cr, uid, [account_id]) + if acc_ids: + cr.execute("update account_account set active='f' where id in " + str(tuple(acc_ids))) wizard_multi_charts_accounts() class account_bank_accounts_wizard(osv.osv_memory): diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index 59637edb546..8a8f5556aff 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -20,9 +20,9 @@ ############################################################################## import time + import netsvc from osv import fields, osv - from tools.misc import currency from tools.translate import _ import decimal_precision as dp @@ -52,13 +52,13 @@ class account_bank_statement(osv.osv): journal_pool = self.pool.get('account.journal') journal_type = context.get('journal_type', False) journal_id = False - + if journal_type: ids = journal_pool.search(cr, uid, [('type', '=', journal_type)]) if ids: journal_id = ids[0] - - return journal_id + + return journal_id def _default_balance_start(self, cr, uid, context={}): cr.execute('select id from account_bank_statement where journal_id=%s order by date desc limit 1', (1,)) @@ -126,7 +126,7 @@ class account_bank_statement(osv.osv): currency_id = res[statement_id] res[statement_id] = (currency_id, currency_names[currency_id]) return res - + _order = "date desc" _name = "account.bank.statement" _description = "Bank Statement" @@ -185,7 +185,7 @@ class account_bank_statement(osv.osv): context.update({ 'period_id':pids[0] }) - + return { 'value':res, 'context':context, @@ -194,7 +194,7 @@ class account_bank_statement(osv.osv): def button_dummy(self, cr, uid, ids, context={}): self.write(cr, uid, ids, {}, context) return True - + def button_confirm_bank(self, cr, uid, ids, context={}): done = [] res_currency_obj = self.pool.get('res.currency') @@ -370,7 +370,7 @@ class account_bank_statement(osv.osv): if st.journal_id.entry_posted: account_move_obj.write(cr, uid, [move_id], {'state':'posted'}) - + self.log(cr, uid, st.id, 'Statement %s is confirmed and entries are created.' % st.name) done.append(st.id) @@ -610,45 +610,22 @@ account_bank_statement_reconcile_line() class account_bank_statement_line(osv.osv): - def onchange_partner_id(self, cursor, user, line_id, partner_id, type, currency_id, context={}): + def onchange_partner_id(self, cursor, user, line_id, partner_id, type, currency_id, context=None): res = {'value': {}} - + obj_partner = self.pool.get('res.partner') + if context is None: + context = {} if not partner_id: return res + line = self.browse(cursor, user, line_id) - if not line or (line and not line[0].account_id): - part = self.pool.get('res.partner').browse(cursor, user, partner_id, - context=context) + part = obj_partner.browse(cursor, user, partner_id, context=context) if type == 'supplier': account_id = part.property_account_payable.id else: account_id = part.property_account_receivable.id res['value']['account_id'] = account_id - - if not line or (line and not line[0].amount): - res_users_obj = self.pool.get('res.users') - res_currency_obj = self.pool.get('res.currency') - company_currency_id = res_users_obj.browse(cursor, user, user, - context=context).company_id.currency_id.id - if not currency_id: - currency_id = company_currency_id - - cursor.execute('SELECT sum(debit-credit) \ - FROM account_move_line \ - WHERE (reconcile_id is null) \ - AND partner_id = %s \ - AND account_id=%s', (partner_id, account_id)) - pgres = cursor.fetchone() - balance = pgres and pgres[0] or 0.0 - - balance = res_currency_obj.compute(cursor, user, company_currency_id, - currency_id, balance, context=context) - res['value']['amount'] = balance - - if context.get('amount', 0) > 0: - res['value']['amount'] = context.get('amount') - return res def _reconcile_amount(self, cursor, user, ids, name, args, context=None): @@ -707,7 +684,4 @@ class account_bank_statement_line(osv.osv): 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/account_cash_statement.py b/addons/account/account_cash_statement.py index e5298fa2f9d..572144ccf6c 100644 --- a/addons/account/account_cash_statement.py +++ b/addons/account/account_cash_statement.py @@ -28,14 +28,14 @@ from tools.translate import _ import decimal_precision as dp class account_cashbox_line(osv.osv): - + """ Cash Box Details """ - + _name = 'account.cashbox.line' _description = 'CashBox Line' def _sub_total(self, cr, uid, ids, name, arg, context=None): - + """ Calculates Sub total @param name: Names of fields. @param arg: User defined arguments @@ -51,7 +51,7 @@ class account_cashbox_line(osv.osv): """ Calculates Sub total on change of number @param pieces: Names of fields. @param number: - """ + """ sub=pieces*number return {'value':{'subtotal': sub or 0.0}} @@ -65,9 +65,9 @@ class account_cashbox_line(osv.osv): account_cashbox_line() class account_cash_statement(osv.osv): - + _inherit = 'account.bank.statement' - + def _get_starting_balance(self, cr, uid, ids, context=None): """ Find starting balance @@ -78,23 +78,23 @@ class account_cash_statement(osv.osv): res ={} for statement in self.browse(cr, uid, ids): amount_total=0.0 - + if statement.journal_id.type not in('cash'): continue - + for line in statement.starting_details_ids: amount_total+= line.pieces * line.number res[statement.id] = { 'balance_start':amount_total } return res - + def _balance_end_cash(self, cr, uid, ids, name, arg, context=None): """ Find ending balance " @param name: Names of fields. @param arg: User defined arguments @return: Dictionary of values. - """ + """ res ={} for statement in self.browse(cr, uid, ids): amount_total=0.0 @@ -102,7 +102,7 @@ class account_cash_statement(osv.osv): amount_total+= line.pieces * line.number res[statement.id]=amount_total return res - + def _get_sum_entry_encoding(self, cr, uid, ids, name, arg, context=None): """ Find encoding total of statements " @@ -120,9 +120,9 @@ class account_cash_statement(osv.osv): # def _default_journal_id(self, cr, uid, context={}): -# """ To get default journal for the object" +# """ To get default journal for the object" # @param name: Names of fields. -# @return: journal +# @return: journal # """ # company_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.id # journal = self.pool.get('account.journal').search(cr, uid, [('type', '=', 'cash'), ('company_id', '=', company_id)]) @@ -130,7 +130,7 @@ class account_cash_statement(osv.osv): # return journal[0] # else: # return False - + def _end_balance(self, cursor, user, ids, name, attr, context=None): res_currency_obj = self.pool.get('res.currency') res_users_obj = self.pool.get('res.users') @@ -163,7 +163,7 @@ class account_cash_statement(osv.osv): for r in res: res[r] = round(res[r], 2) return res - + def _get_company(self, cr, uid, ids, context={}): user_pool = self.pool.get('res.users') company_pool = self.pool.get('res.company') @@ -171,7 +171,7 @@ class account_cash_statement(osv.osv): company_id = user.company_id and user.company_id.id if not company_id: company_id = company_pool.search(cr, uid, [])[0] - + return company_id def _get_cash_open_box_lines(self, cr, uid, ids, context={}): @@ -195,14 +195,14 @@ class account_cash_statement(osv.osv): } res.append((0, 0, dct)) return res - + _columns = { 'company_id':fields.many2one('res.company', 'Company', required=False), 'journal_id': fields.many2one('account.journal', 'Journal', required=True, states={'confirm': [('readonly', True)]}, domain=[('type', '=', 'cash')]), 'balance_end_real': fields.float('Closing Balance', digits_compute=dp.get_precision('Account'), states={'confirm':[('readonly', True)]}, help="closing balance entered by the cashbox verifier"), 'state': fields.selection( [('draft', 'Draft'), - ('confirm', 'Confirm'), + ('confirm', 'Confirmed'), ('open','Open')], 'State', required=True, states={'confirm': [('readonly', True)]}, readonly="1"), 'total_entry_encoding':fields.function(_get_sum_entry_encoding, method=True, store=True, string="Cash Transaction", help="Total cash transactions"), 'closing_date':fields.datetime("Closed On"), @@ -226,8 +226,8 @@ class account_cash_statement(osv.osv): company_id = vals and vals.get('company_id',False) if company_id: sql = [ - ('company_id', '=', vals['company_id']), - ('journal_id', '=', vals['journal_id']), + ('company_id', '=', vals['company_id']), + ('journal_id', '=', vals['journal_id']), ('state', '=', 'open') ] open_jrnl = self.search(cr, uid, sql) @@ -247,112 +247,112 @@ class account_cash_statement(osv.osv): res_id = super(account_cash_statement, self).create(cr, uid, vals, context=context) self.write(cr, uid, [res_id], {}) return res_id - + def write(self, cr, uid, ids, vals, context=None): """ Update redord(s) comes in {ids}, with new value comes as {vals} return True on success, False otherwise - + @param cr: cursor to database @param user: id of current user @param ids: list of record ids to be update @param vals: dict of new values to be set @param context: context arguments, like lang, time zone - + @return: True on success, False otherwise """ - + super(account_cash_statement, self).write(cr, uid, ids, vals) res = self._get_starting_balance(cr, uid, ids) for rs in res: super(account_cash_statement, self).write(cr, uid, rs, res.get(rs)) return True - + def onchange_journal_id(self, cr, uid, statement_id, journal_id, context={}): - """ Changes balance start and starting details if journal_id changes" + """ Changes balance start and starting details if journal_id changes" @param statement_id: Changed statement_id @param journal_id: Changed journal_id @return: Dictionary of changed values """ - + cash_pool = self.pool.get('account.cashbox.line') statement_pool = self.pool.get('account.bank.statement') res = {} balance_start = 0.0 - + if not journal_id: res.update({ 'balance_start': balance_start }) return res - - + + res = super(account_cash_statement, self).onchange_journal_id(cr, uid, statement_id, journal_id, context) return res - + def _equal_balance(self, cr, uid, ids, statement, context={}): if statement.balance_end != statement.balance_end_cash: return False else: return True - + def _user_allow(self, cr, uid, ids, statement, context={}): return True - + def button_open(self, cr, uid, ids, context=None): - + """ Changes statement state to Running. - @return: True + @return: True """ cash_pool = self.pool.get('account.cashbox.line') statement_pool = self.pool.get('account.bank.statement') statement = statement_pool.browse(cr, uid, ids[0]) vals = {} - + if not self._user_allow(cr, uid, ids, statement, context={}): raise osv.except_osv(_('Error !'), _('User %s does not have rights to access %s journal !' % (statement.user_id.name, statement.journal_id.name))) - + if statement.name and statement.name == '/': number = self.pool.get('ir.sequence').get(cr, uid, 'account.cash.statement') vals.update({ 'name':number }) - -# if len(statement.starting_details_ids) > 0: -# sid = [] -# for line in statement.starting_details_ids: -# sid.append(line.id) -# cash_pool.unlink(cr, uid, sid) -# -# cr.execute("select id from account_bank_statement where journal_id=%s and user_id=%s and state=%s order by id desc limit 1", (statement.journal_id.id, uid, 'confirm')) -# rs = cr.fetchone() -# rs = rs and rs[0] or None -# if rs: -# statement = statement_pool.browse(cr, uid, rs) -# balance_start = statement.balance_end_real or 0.0 -# open_ids = cash_pool.search(cr, uid, [('ending_id','=',statement.id)]) -# for sid in open_ids: -# default = { -# 'ending_id': False, -# 'starting_id':ids[0] -# } -# cash_pool.copy(cr, uid, sid, default) -# + + cr.execute("select id from account_bank_statement where journal_id=%s and user_id=%s and state=%s order by id desc limit 1", (statement.journal_id.id, uid, 'confirm')) + rs = cr.fetchone() + rs = rs and rs[0] or None + if rs: + if len(statement.starting_details_ids) > 0: + sid = [] + for line in statement.starting_details_ids: + sid.append(line.id) + cash_pool.unlink(cr, uid, sid) + + statement = statement_pool.browse(cr, uid, rs) + balance_start = statement.balance_end_real or 0.0 + open_ids = cash_pool.search(cr, uid, [('ending_id','=',statement.id)]) + for sid in open_ids: + default = { + 'ending_id': False, + 'starting_id':ids[0] + } + cash_pool.copy(cr, uid, sid, default) + vals.update({ - 'date':time.strftime("%Y-%m-%d %H:%M:%S"), + 'date':time.strftime("%Y-%m-%d %H:%M:%S"), 'state':'open', - + }) - + self.write(cr, uid, ids, vals) return True def button_confirm_cash(self, cr, uid, ids, context={}): - - """ Check the starting and ending detail of statement - @return: True + + """ Check the starting and ending detail of statement + @return: True """ done = [] res_currency_obj = self.pool.get('res.currency') @@ -360,20 +360,20 @@ class account_cash_statement(osv.osv): account_move_obj = self.pool.get('account.move') account_move_line_obj = self.pool.get('account.move.line') account_bank_statement_line_obj = self.pool.get('account.bank.statement.line') - + company_currency_id = res_users_obj.browse(cr, uid, uid, context=context).company_id.currency_id.id for st in self.browse(cr, uid, ids, context): - + self.write(cr, uid, [st.id], {'balance_end_real':st.balance_end}) st.balance_end_real = st.balance_end - + if not st.state == 'open': continue - + if not self._equal_balance(cr, uid, ids, st, context): raise osv.except_osv(_('Error !'), _('CashBox Balance is not matching with Calculated Balance !')) - + # if not (abs((st.balance_end or 0.0) - st.balance_end_real) < 0.0001): # raise osv.except_osv(_('Error !'), # _('The statement balance is incorrect !\n') + @@ -519,7 +519,7 @@ class account_cash_statement(osv.osv): if st.journal_id.entry_posted: account_move_obj.write(cr, uid, [move_id], {'state':'posted'}) done.append(st.id) - + vals = { 'state':'confirm', 'closing_date':time.strftime("%Y-%m-%d %H:%M:%S") diff --git a/addons/account/account_demo.xml b/addons/account/account_demo.xml index a8a1d1405cd..5ef0ee4992d 100644 --- a/addons/account/account_demo.xml +++ b/addons/account/account_demo.xml @@ -1,10 +1,10 @@ - + + Fiscal year + --> @@ -15,11 +15,12 @@ + Fiscal Periods + --> - + + @@ -27,7 +28,8 @@ - + + @@ -35,7 +37,8 @@ - + + @@ -43,7 +46,8 @@ - + + @@ -51,7 +55,8 @@ - + + @@ -59,7 +64,8 @@ - + + @@ -67,7 +73,8 @@ - + + @@ -75,7 +82,8 @@ - + + @@ -83,7 +91,8 @@ - + + @@ -91,7 +100,8 @@ - + + @@ -99,7 +109,8 @@ - + + @@ -107,7 +118,8 @@ - + + diff --git a/addons/account/account_end_fy.xml b/addons/account/account_end_fy.xml index fe7b6e682fe..a33544ffacc 100644 --- a/addons/account/account_end_fy.xml +++ b/addons/account/account_end_fy.xml @@ -14,7 +14,7 @@ action="action_account_period_tree" id="menu_action_account_period_close_tree" parent="account.menu_account_end_year_treatments" - sequence="0"/> + sequence="0" groups="base.group_extended"/> diff --git a/addons/account/account_installer.xml b/addons/account/account_installer.xml index 5b57ab130fd..6d067a31a9f 100644 --- a/addons/account/account_installer.xml +++ b/addons/account/account_installer.xml @@ -1,143 +1,139 @@ - - - account.installer.form - account.installer - form - - - -
- Accounting System Configuration -
+ + + account.installer.form + account.installer + form + + + +
+ Accounting System Configuration +
+ + Configure Your Accounting System + + + From this screen, you can configure your accounting system. Choose a Chart of Account matched to your accounting system or the Generic Chart of Account which allows you to configure which suit your needs. + + + Configure + + + 23 + + + + + + + + + + + + + + +
+ + + + + + + + + + +
+ + + + +
+
+
+
+
- - Configure Your Accounting System - - - From this screen, you can configure your accounting system. Choose a Chart of Account matched to your accounting system or the Generic Chart of Account which allows you to configure which suit your needs. - - - Configure - - - 23 - - - - - - - - - - - - - - -
- - - + + account.installer.modules.form + account.installer.modules + form + + + + + Extra Accounting Modules Installation - - - - - - -
- - - - -
-
-
-
-
+ + Install Extra Accounting Modules In Your Accounting System + + + From this screen, you can install extra accounting modules in your accounting system. Select the modules to directly install them. If you do not think you need any of these right now, you can easily install them later. + + + 23 + + + + + + + + + + + + + +
+ + - - account.installer.modules.form - account.installer.modules - form - - - -
- Extra Accounting Modules Installation -
- - Install Extra Accounting Modules In Your Accounting System - - - From this screen, you can install extra accounting modules in your accounting system. Select the modules to directly install them. If you do not think you need any of these right now, you can easily install them later. - - - 23 - - - - - - - - - - - -
-
-
+ + Accounting Chart Configuration + ir.actions.act_window + account.installer + + form + form + new + - - Accounting Chart Configuration - ir.actions.act_window - account.installer - - form - form - new - + + Accounting Modules Installation + ir.actions.act_window + account.installer.modules + + form + form + new + - - Accounting Modules Installation - ir.actions.act_window - account.installer.modules - - form - form - new - + + + 3 + onskip + - - - 3 - onskip - + + + 5 + always + - - - 5 - always - - - - ir.actions.todo - account_installer_action_replace - tree - - - -