diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py index 7229f1d3364..b0ef5bc6641 100644 --- a/addons/account/__openerp__.py +++ b/addons/account/__openerp__.py @@ -119,7 +119,7 @@ module named account_voucher. 'project/project_demo.xml', 'project/analytic_account_demo.xml', 'demo/account_minimal.xml', - 'account_unit_test.xml', + #'account_unit_test.xml', ], 'test': [ 'test/account_customer_invoice.yml', @@ -131,6 +131,8 @@ module named account_voucher. 'test/account_use_model.yml', 'test/account_validate_account_move.yml', 'test/account_fiscalyear_close.yml', + 'test/account_bank_statement.yml', + 'test/account_cash_statement.yml', 'test/account_report.yml', ], 'installable': True, diff --git a/addons/account/account.py b/addons/account/account.py index 1520c4f0646..ea0b98e26bf 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -457,7 +457,9 @@ class account_account(osv.osv): if not ids: ids = self.search(cr, user, [('name', operator, name)]+ args, limit=limit) if not ids and len(name.split()) >= 2: - ids = self.search(cr, user, [('code', operator, name.split()[0]), ('name', operator, name.split()[1])]+ args, limit=limit) + #Separating code and name of account for searching + operand1,operand2 = name.split(' ',1) #name can contain spaces e.g. OpenERP S.A. + ids = self.search(cr, user, [('code', operator, operand1), ('name', operator, operand2)]+ args, limit=limit) else: ids = self.search(cr, user, args, context=context, limit=limit) return self.name_get(cr, user, ids, context=context) @@ -1105,7 +1107,7 @@ class account_move(osv.osv): help='All manually created new journal entry are usually in the state \'Unposted\', but you can set the option to skip that state on the related journal. In that case, they will be behave as journal entries automatically created by the system on document validation (invoices, bank statements...) and will be created in \'Posted\' state.'), 'line_id': fields.one2many('account.move.line', 'move_id', 'Entries', states={'posted':[('readonly',True)]}), 'to_check': fields.boolean('To Review', help='Check this box if you are unsure of that journal entry and if you want to note it as \'to be reviewed\' by an accounting expert.'), - 'partner_id': fields.related('line_id', 'partner_id', type="many2one", relation="res.partner", string="Partner"), + '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_compute=dp.get_precision('Account'), type='float', fnct_search=_search_amount), 'date': fields.date('Date', required=True, states={'posted':[('readonly',True)]}), 'narration':fields.text('Narration'), @@ -1215,7 +1217,8 @@ class account_move(osv.osv): # # TODO: Check if period is closed ! # - def create(self, cr, uid, vals, context={}): + def create(self, cr, uid, vals, context=None): + context = context or {} if 'line_id' in vals and context.get('copy'): for l in vals['line_id']: if not l[0]: @@ -1256,6 +1259,7 @@ class account_move(osv.osv): return result def copy(self, cr, uid, id, default={}, context={}): + context = context or {} default.update({ 'state':'draft', 'name':'/', @@ -1265,7 +1269,8 @@ class account_move(osv.osv): }) return super(account_move, self).copy(cr, uid, id, default, context) - def unlink(self, cr, uid, ids, context={}, check=True): + def unlink(self, cr, uid, ids, context=None, check=True): + context = context or {} toremove = [] obj_move_line = self.pool.get('account.move.line') for move in self.browse(cr, uid, ids, context): @@ -1605,7 +1610,7 @@ class account_tax_code(osv.osv): if isinstance(ids, (int, long)): ids = [ids] reads = self.read(cr, uid, ids, ['name','code'], context, load='_classic_write') - return [(x['id'], (x['code'] and x['code'] + ' - ' or '') + x['name']) \ + return [(x['id'], (x['code'] and (x['code'] + ' - ') or '') + x['name']) \ for x in reads] def _default_company(self, cr, uid, context={}): @@ -2019,7 +2024,7 @@ class account_model(osv.osv): } _defaults = { - 'legend': lambda self, cr, uid, context:_('You can specify year, month and date in the name of the model using the following labels:\n\n%(year)s : To Specify Year \n%(month)s : To Specify Month \n%(date)s : Current Date\n\ne.g. My model on %(date)s'), + 'legend': lambda self, cr, uid, context:_('You can specify year, month and date in the name of the model using the following labels:\n\n%(year)s: To Specify Year \n%(month)s: To Specify Month \n%(date)s: Current Date\n\ne.g. My model on %(date)s'), } def generate(self, cr, uid, ids, datas={}, context=None): move_ids = [] @@ -2221,7 +2226,7 @@ class account_subscription_line(osv.osv): account_subscription_line() # --------------------------------------------------------------- -# Account Templates : Account, Tax, Tax Code and chart. + Wizard +# Account Templates: Account, Tax, Tax Code and chart. + Wizard # --------------------------------------------------------------- class account_tax_template(osv.osv): @@ -2394,7 +2399,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 Profit/Loss 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'), + 'property_reserve_and_surplus_account': fields.many2one('account.account.template', 'Reserve and Profit/Loss 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() @@ -2537,16 +2542,39 @@ class wizard_multi_charts_accounts(osv.osv_memory): 'bank_accounts_id': fields.one2many('account.bank.accounts.wizard', 'bank_account_id', 'Bank Accounts', required=True), 'code_digits':fields.integer('# of Digits', required=True, help="No. of Digits to use for account code"), 'seq_journal':fields.boolean('Separated Journal Sequences', help="Check this box if you want to use a different sequence for each created journal. Otherwise, all will use the same sequence."), + "sale_tax": fields.many2one("account.tax.template", "Sale Tax"), + "purchase_tax": fields.many2one("account.tax.template", "Purchase Tax"), } + def onchange_chart_template_id(self, cr, uid, ids, chart_template_id=False, context=None): + res = {} + res['value'] = {} + res['value']["sale_tax"] = False + res['value']["purchase_tax"] = False + if chart_template_id: + ids = self.pool.get('account.tax.template').search(cr, uid, [("chart_template_id" + , "=", chart_template_id)], order="sequence") + if len(ids) > 0: + id=ids[0] + res['value']["sale_tax"] = id + res['value']["purchase_tax"] = id + return res def _get_chart(self, cr, uid, context={}): ids = self.pool.get('account.chart.template').search(cr, uid, [], context=context) if ids: return ids[0] return False + + def _get_default_accounts(self, cr, uid, context=None): + accounts = [{'acc_name':'Current','account_type':'bank'}, + {'acc_name':'Deposit','account_type':'bank'}, + {'acc_name':'Cash','account_type':'cash'}] + return accounts + _defaults = { 'company_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr, uid, [uid], c)[0].company_id.id, 'chart_template_id': _get_chart, + 'bank_accounts_id': _get_default_accounts, 'code_digits': 6, 'seq_journal': True } @@ -2591,6 +2619,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): tax_code_template_ref[tax_code_template.id] = new_tax_code #create all the tax + tax_template_to_tax = {} for tax in obj_multi.chart_template_id.tax_template_ids: #create it vals_tax = { @@ -2619,6 +2648,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): 'type_tax_use': tax.type_tax_use } new_tax = obj_acc_tax.create(cr, uid, vals_tax) + tax_template_to_tax[tax.id] = new_tax #as the accounts have not been created yet, we have to wait before filling these fields todo_dict[new_tax] = { 'account_collected_id': tax.account_collected_id and tax.account_collected_id.id or False, @@ -2843,6 +2873,12 @@ class wizard_multi_charts_accounts(osv.osv_memory): } obj_ac_fp.create(cr, uid, vals_acc) + ir_values = self.pool.get('ir.values') + ir_values.set(cr, uid, key='default', key2=False, name="taxes_id", company=obj_multi.company_id.id + , models =[('product.product',False)], value=[tax_template_to_tax[obj_multi.sale_tax.id]]) + ir_values.set(cr, uid, key='default', key2=False, name="supplier_taxes_id", company=obj_multi.company_id.id + , models =[('product.product',False)], value=[tax_template_to_tax[obj_multi.purchase_tax.id]]) + wizard_multi_charts_accounts() class account_bank_accounts_wizard(osv.osv_memory): diff --git a/addons/account/account_analytic_line.py b/addons/account/account_analytic_line.py index a982ca51182..633cb09d976 100644 --- a/addons/account/account_analytic_line.py +++ b/addons/account/account_analytic_line.py @@ -24,8 +24,6 @@ import time from osv import fields from osv import osv from tools.translate import _ -import tools -from tools import config class account_analytic_line(osv.osv): _inherit = 'account.analytic.line' @@ -82,12 +80,13 @@ class account_analytic_line(osv.osv): return {} product_obj = self.pool.get('product.product') analytic_journal_obj =self.pool.get('account.analytic.journal') + company_obj = self.pool.get('res.company') + product_price_type_obj = self.pool.get('product.price.type') j_id = analytic_journal_obj.browse(cr, uid, journal_id, context=context) prod = product_obj.browse(cr, uid, prod_id) if not company_id: company_id = j_id.company_id.id result = 0.0 - is_purchase = False if j_id.type <> 'sale': a = prod.product_tmpl_id.property_account_expense.id @@ -99,8 +98,6 @@ class account_analytic_line(osv.osv): 'for this product: "%s" (id:%d)') % \ (prod.name, prod.id,)) amount_unit = prod.price_get('standard_price', context)[prod.id] - is_purchase = True - else: a = prod.product_tmpl_id.property_account_income.id if not a: @@ -113,7 +110,7 @@ class account_analytic_line(osv.osv): amount_unit = prod.price_get('list_price', context)[prod_id] if not company_id: - company_id=company_obj._company_default_get(cr, uid, 'account.analytic.line', context) + company_id = company_obj._company_default_get(cr, uid, 'account.analytic.line', context=context) flag = False # Compute based on pricetype product_price_type_ids = product_price_type_obj.search(cr, uid, [('field','=','standard_price')], context) @@ -128,15 +125,14 @@ class account_analytic_line(osv.osv): if pricetype.field == 'list_price': flag = True amount_unit = prod.price_get(pricetype.field, context)[prod.id] - amount = amount_unit*unit_amount or 1.0 prec = self.pool.get('decimal.precision').precision_get(cr, uid, 'Account') - amount = amount_unit*unit_amount or 1.0 + amount = amount_unit*unit or 1.0 result = round(amount, prec) if not flag: result *= -1 - return {'value': { - 'amount': result, - 'general_account_id': a, + return {'value': { + 'amount': result, + 'general_account_id': a, } } diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index 0b240663943..ded29c27e89 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -38,12 +38,13 @@ class account_bank_statement(osv.osv): def write(self, cr, uid, ids, vals, context=None): res = super(account_bank_statement, self).write(cr, uid, ids, vals, context=context) + account_bank_statement_line_obj = self.pool.get('account.bank.statement.line') for statement in self.browse(cr, uid, ids, context): seq = 0 for line in statement.line_ids: seq += 1 if not line.sequence: - self.pool.get('account.bank.statement.line').write(cr, uid, [line.id], {'sequence': seq}, context=context) + account_bank_statement_line_obj.write(cr, uid, [line.id], {'sequence': seq}, context=context) return res def button_import_invoice(self, cr, uid, ids, context=None): @@ -86,7 +87,6 @@ class account_bank_statement(osv.osv): 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') - res = {} company_currency_id = res_users_obj.browse(cursor, user, user, @@ -216,10 +216,8 @@ class account_bank_statement(osv.osv): def create_move_from_st_line(self, cr, uid, st_line_id, company_currency_id, st_line_number, context=None): res_currency_obj = self.pool.get('res.currency') - res_users_obj = self.pool.get('res.users') account_move_obj = self.pool.get('account.move') account_move_line_obj = self.pool.get('account.move.line') - account_analytic_line_obj = self.pool.get('account.analytic.line') account_bank_statement_line_obj = self.pool.get('account.bank.statement.line') st_line = account_bank_statement_line_obj.browse(cr, uid, st_line_id, context) st = st_line.statement_id @@ -378,25 +376,24 @@ class account_bank_statement(osv.osv): self.create_move_from_st_line(cr, uid, st_line.id, company_currency_id, st_line_number, context) self.write(cr, uid, [st.id], {'name': st_number}, context=context) - self.log(cr, uid, st.id, 'Statement %s is confirmed and entries are created.' % st_number) + self.log(cr, uid, st.id, _('Statement %s is confirmed, journal items are created.') % (st_number,)) done.append(st.id) return self.write(cr, uid, ids, {'state':'confirm'}, context=context) def button_cancel(self, cr, uid, ids, context=None): done = [] + account_move_obj = self.pool.get('account.move') for st in self.browse(cr, uid, ids, context): if st.state=='draft': continue ids = [] for line in st.line_ids: ids += [x.id for x in line.move_ids] - self.pool.get('account.move').unlink(cr, uid, ids, context) + account_move_obj.unlink(cr, uid, ids, context) done.append(st.id) return self.write(cr, uid, done, {'state':'draft'}, context=context) def onchange_journal_id(self, cursor, user, statement_id, journal_id, context=None): - account_journal_obj = self.pool.get('account.journal') - res_users_obj = self.pool.get('res.users') cursor.execute('SELECT balance_end_real \ FROM account_bank_statement \ WHERE journal_id = %s AND NOT state = %s \ diff --git a/addons/account/account_cash_statement.py b/addons/account/account_cash_statement.py index 6431454b715..07767328a55 100644 --- a/addons/account/account_cash_statement.py +++ b/addons/account/account_cash_statement.py @@ -19,10 +19,10 @@ # along with this program. If not, see . # ############################################################################## + import time from osv import osv, fields -from decimal import Decimal from tools.translate import _ import decimal_precision as dp @@ -45,22 +45,23 @@ class account_cashbox_line(osv.osv): res[obj.id] = obj.pieces * obj.number return res - def on_change_sub(self, cr, uid, ids, pieces, number,*a): + def on_change_sub(self, cr, uid, ids, pieces, number, *a): """ Calculates Sub total on change of number @param pieces: Names of fields. @param number: """ - sub=pieces*number - return {'value':{'subtotal': sub or 0.0}} + sub = pieces * number + return {'value': {'subtotal': sub or 0.0}} _columns = { 'pieces': fields.float('Values', digits_compute=dp.get_precision('Account')), 'number': fields.integer('Number'), 'subtotal': fields.function(_sub_total, method=True, string='Sub Total', type='float', digits_compute=dp.get_precision('Account')), - 'starting_id': fields.many2one('account.bank.statement',ondelete='cascade'), - 'ending_id': fields.many2one('account.bank.statement',ondelete='cascade'), + 'starting_id': fields.many2one('account.bank.statement', ondelete='cascade'), + 'ending_id': fields.many2one('account.bank.statement', ondelete='cascade'), } + account_cashbox_line() class account_cash_statement(osv.osv): @@ -74,7 +75,7 @@ class account_cash_statement(osv.osv): @param arg: User defined arguments @return: Dictionary of values. """ - res ={} + res = {} for statement in self.browse(cr, uid, ids): amount_total = 0.0 @@ -84,7 +85,7 @@ class account_cash_statement(osv.osv): for line in statement.starting_details_ids: amount_total+= line.pieces * line.number res[statement.id] = { - 'balance_start':amount_total + 'balance_start': amount_total } return res @@ -96,10 +97,10 @@ class account_cash_statement(osv.osv): """ res ={} for statement in self.browse(cr, uid, ids): - amount_total=0.0 + amount_total = 0.0 for line in statement.ending_details_ids: - amount_total+= line.pieces * line.number - res[statement.id]=amount_total + 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): @@ -113,14 +114,13 @@ class account_cash_statement(osv.osv): for statement in self.browse(cr, uid, ids): encoding_total=0.0 for line in statement.line_ids: - encoding_total+= line.amount - res2[statement.id]=encoding_total + encoding_total += line.amount + res2[statement.id] = encoding_total return res2 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') - res = {} company_currency_id = res_users_obj.browse(cursor, user, user, @@ -165,13 +165,13 @@ class account_cash_statement(osv.osv): curr = [1, 2, 5, 10, 20, 50, 100, 500] for rs in curr: dct = { - 'pieces':rs, - 'number':0 + 'pieces': rs, + 'number': 0 } res.append(dct) - journal_ids = self.pool.get('account.journal').search(cr, uid, [('type','=','cash')], context=context) + journal_ids = self.pool.get('account.journal').search(cr, uid, [('type', '=', 'cash')], context=context) if journal_ids: - results = self.search(cr, uid, [('journal_id','in',journal_ids),('state','=','confirm')],context=context) + results = self.search(cr, uid, [('journal_id', 'in', journal_ids),('state', '=', 'confirm')], context=context) if results: cash_st = self.browse(cr, uid, results, context)[0] for cash_line in cash_st.ending_details_ids: @@ -185,8 +185,8 @@ class account_cash_statement(osv.osv): curr = [1, 2, 5, 10, 20, 50, 100, 500] for rs in curr: dct = { - 'pieces':rs, - 'number':0 + 'pieces': rs, + 'number': 0 } res.append(dct) return res @@ -196,10 +196,10 @@ class account_cash_statement(osv.osv): curr = [1, 2, 5, 10, 20, 50, 100, 500] for rs in curr: dct = { - 'pieces':rs, - 'number':0 + 'pieces': rs, + 'number': 0 } - res.append((0,0,dct)) + res.append((0, 0, dct)) return res def _get_cash_open_close_box_lines(self, cr, uid, context={}): @@ -209,39 +209,41 @@ class account_cash_statement(osv.osv): starting_details = self._get_cash_open_box_lines(cr, uid, context) ending_details = self._get_default_cash_close_box_lines(cr, uid, context) for start in starting_details: - start_l.append((0,0,start)) + start_l.append((0, 0, start)) for end in ending_details: - end_l.append((0,0,end)) + end_l.append((0, 0, end)) res['start'] = start_l res['end'] = end_l return res _columns = { - '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"), + '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', 'Closed'), ('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"), + '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"), 'balance_end': fields.function(_end_balance, method=True, store=True, string='Balance', help="Closing balance based on Starting Balance and Cash Transactions"), 'balance_end_cash': fields.function(_balance_end_cash, method=True, store=True, string='Balance', help="Closing balance based on cashBox"), 'starting_details_ids': fields.one2many('account.cashbox.line', 'starting_id', string='Opening Cashbox'), 'ending_details_ids': fields.one2many('account.cashbox.line', 'ending_id', string='Closing Cashbox'), 'name': fields.char('Name', size=64, required=True, states={'draft': [('readonly', False)]}, readonly=True, help='if you give the Name other then /, its created Accounting Entries Move will be with same name as statement name. This allows the statement entries to have the same references than the statement itself'), - 'user_id':fields.many2one('res.users', 'Responsible', required=False), + 'user_id': fields.many2one('res.users', 'Responsible', required=False), } _defaults = { - 'state': lambda *a: 'draft', - 'date': lambda *a:time.strftime("%Y-%m-%d %H:%M:%S"), + 'state': 'draft', + 'date': time.strftime("%Y-%m-%d %H:%M:%S"), 'user_id': lambda self, cr, uid, context=None: uid, - 'starting_details_ids':_get_cash_open_box_lines, - 'ending_details_ids':_get_default_cash_close_box_lines + 'starting_details_ids': _get_cash_open_box_lines, + 'ending_details_ids': _get_default_cash_close_box_lines } def create(self, cr, uid, vals, context=None): + if 'journal_id' not in vals: + raise osv.except_osv('Error', _('You cannot create a bank or cash register without a journal!')) sql = [ - ('journal_id', '=', vals['journal_id']), + ('journal_id', '=', vals.get('journal_id', False)), ('state', '=', 'open') ] open_jrnl = self.search(cr, uid, sql) @@ -250,20 +252,20 @@ class account_cash_statement(osv.osv): if self.pool.get('account.journal').browse(cr, uid, vals['journal_id']).type == 'cash': open_close = self._get_cash_open_close_box_lines(cr, uid, context) - if vals.get('starting_details_ids',False): + if vals.get('starting_details_ids', False): for start in vals.get('starting_details_ids'): dict_val = start[2] for end in open_close['end']: if end[2]['pieces'] == dict_val['pieces']: end[2]['number'] += dict_val['number'] vals.update({ - 'ending_details_ids':open_close['start'], - 'starting_details_ids':open_close['end'] +# 'ending_details_ids': open_close['start'], + 'starting_details_ids': open_close['end'] }) else: vals.update({ - 'ending_details_ids':False, - 'starting_details_ids':False + 'ending_details_ids': False, + 'starting_details_ids': False }) res_id = super(account_cash_statement, self).create(cr, uid, vals, context=context) self.write(cr, uid, [res_id], {}) @@ -295,10 +297,6 @@ class account_cash_statement(osv.osv): @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 @@ -307,8 +305,7 @@ class account_cash_statement(osv.osv): 'balance_start': balance_start }) return res - res = super(account_cash_statement, self).onchange_journal_id(cr, uid, statement_id, journal_id, context=context) - return res + return super(account_cash_statement, self).onchange_journal_id(cr, uid, statement_id, journal_id, context=context) def _equal_balance(self, cr, uid, cash_id, context=None): statement = self.browse(cr, uid, cash_id, context=context) @@ -319,36 +316,34 @@ class account_cash_statement(osv.osv): else: return True - def _user_allow(self, cr, uid, ids, statement, context={}): + def _user_allow(self, cr, uid, statement_id, context=None): return True def button_open(self, cr, uid, ids, context=None): - """ Changes statement state to Running. @return: True """ - cash_pool = self.pool.get('account.cashbox.line') + if context is None: + context = {} statement_pool = self.pool.get('account.bank.statement') + for statement in statement_pool.browse(cr, uid, ids, context=context): + vals = {} - statement = statement_pool.browse(cr, uid, ids[0]) - vals = {} + if not self._user_allow(cr, uid, statement.id, context=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 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 statement.name and statement.name == '/': - number = self.pool.get('ir.sequence').get(cr, uid, 'account.cash.statement') vals.update({ - 'name': number + 'date': time.strftime("%Y-%m-%d %H:%M:%S"), + 'state': 'open', + }) - - vals.update({ - 'date':time.strftime("%Y-%m-%d %H:%M:%S"), - 'state':'open', - - }) - - self.write(cr, uid, ids, vals) + self.write(cr, uid, [statement.id], vals) return True def balance_check(self, cr, uid, cash_id, journal_type='bank', context=None): @@ -363,7 +358,7 @@ class account_cash_statement(osv.osv): return super(account_cash_statement, self).statement_close(cr, uid, ids, journal_type, context) vals = { 'state':'confirm', - 'closing_date':time.strftime("%Y-%m-%d %H:%M:%S") + 'closing_date': time.strftime("%Y-%m-%d %H:%M:%S") } return self.write(cr, uid, ids, vals, context=context) @@ -374,14 +369,14 @@ class account_cash_statement(osv.osv): def button_confirm_cash(self, cr, uid, ids, context=None): super(account_cash_statement, self).button_confirm_bank(cr, uid, ids, context=context) - return self.write(cr, uid, ids, {'closing_date':time.strftime("%Y-%m-%d %H:%M:%S")}, context=context) + return self.write(cr, uid, ids, {'closing_date': time.strftime("%Y-%m-%d %H:%M:%S")}, context=context) def button_cancel(self, cr, uid, ids, context=None): cash_box_line_pool = self.pool.get('account.cashbox.line') super(account_cash_statement, self).button_cancel(cr, uid, ids, context=context) for st in self.browse(cr, uid, ids, context): for end in st.ending_details_ids: - cash_box_line_pool.write(cr, uid, [end.id], {'number':0}) + cash_box_line_pool.write(cr, uid, [end.id], {'number': 0}) return True account_cash_statement() diff --git a/addons/account/account_end_fy.xml b/addons/account/account_end_fy.xml index 76d40bc89dc..d0c966898d6 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" groups="base.group_extended"/> + sequence="0" groups="base.group_extended,group_account_manager,group_account_user"/> diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index 0825aad8831..4d4b0a3022f 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -1,7 +1,6 @@ - @@ -151,7 +150,7 @@ - +