diff --git a/addons/account/account.py b/addons/account/account.py index ecadfaf37f9..50b922d723b 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -458,7 +458,7 @@ class account_account(osv.osv): ids = self.search(cr, user, [('name', operator, name)]+ args, limit=limit) if not ids and len(name.split()) >= 2: #Separating code and name of account for searching - operand1,operand2 = name.split(' ',1) #name can contain spaces e.g. OpenERP S.A. + 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) @@ -2542,7 +2542,22 @@ 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) @@ -2604,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 = { @@ -2632,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, @@ -2856,6 +2873,14 @@ class wizard_multi_charts_accounts(osv.osv_memory): } obj_ac_fp.create(cr, uid, vals_acc) + ir_values = self.pool.get('ir.values') + if obj_multi.sale_tax: + 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]]) + if obj_multi.purchase_tax: + 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_bank_statement.py b/addons/account/account_bank_statement.py index c6548a36872..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): @@ -381,13 +382,14 @@ class account_bank_statement(osv.osv): 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) @@ -496,4 +498,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 f88d38734f2..13c6464f888 100644 --- a/addons/account/account_cash_statement.py +++ b/addons/account/account_cash_statement.py @@ -23,7 +23,6 @@ import time from osv import osv, fields -from decimal import Decimal from tools.translate import _ import decimal_precision as dp @@ -53,14 +52,14 @@ class account_cashbox_line(osv.osv): @param number: """ sub = pieces * number - return {'value':{'subtotal': sub or 0.0}} + 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() @@ -86,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 @@ -166,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: @@ -186,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 @@ -197,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={}): @@ -210,39 +209,39 @@ 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': '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): sql = [ - ('journal_id', '=', vals['journal_id']), + ('journal_id', '=', vals.get('journal_id', False)), ('state', '=', 'open') ] open_jrnl = self.search(cr, uid, sql) @@ -251,20 +250,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], {}) @@ -296,8 +295,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 @@ -317,34 +314,35 @@ 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') - statement = statement_pool.browse(cr, uid, ids[0]) - vals = {} + for statement in statement_pool.browse(cr, uid, ids, context=context): + 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 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 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', - - }) - return 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): if journal_type == 'bank': @@ -369,16 +367,16 @@ 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() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index af7771eaeac..ffea12170a2 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -177,7 +177,7 @@ class account_move_line(osv.osv): for item in i[2]: data[item] = i[2][item] if context['journal']: - journal_data = obj_journal.browse(cr, uid, context['journal']) + journal_data = journal_obj.browse(cr, uid, context['journal']) if journal_data.type == 'purchase': if total_new > 0: account = journal_data.default_credit_account_id @@ -293,6 +293,8 @@ class account_move_line(osv.osv): return data def on_create_write(self, cr, uid, id, context={}): + if not id: + return [] ml = self.browse(cr, uid, id, context) return map(lambda x: x.id, ml.move_id.line_id) @@ -363,7 +365,7 @@ class account_move_line(osv.osv): return [('id', '=', '0')] return [('id', 'in', [x[0] for x in res])] - def _invoice_search(self, cursor, user, obj, name, args, context): + def _invoice_search(self, cursor, user, obj, name, args, context=None): if not args: return [] invoice_obj = self.pool.get('account.invoice') @@ -408,7 +410,7 @@ class account_move_line(osv.osv): return [('id', '=', '0')] return [('id', 'in', [x[0] for x in res])] - def _get_move_lines(self, cr, uid, ids, context={}): + def _get_move_lines(self, cr, uid, ids, context=None): result = [] for move in self.pool.get('account.move').browse(cr, uid, ids, context=context): for line in move.line_id: @@ -458,7 +460,7 @@ class account_move_line(osv.osv): 'company_id': fields.related('account_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True) } - def _get_date(self, cr, uid, context): + def _get_date(self, cr, uid, context=None): period_obj = self.pool.get('account.period') dt = time.strftime('%Y-%m-%d') if ('journal_id' in context) and ('period_id' in context): @@ -474,7 +476,9 @@ class account_move_line(osv.osv): dt = period.date_start return dt - def _get_currency(self, cr, uid, context={}): + def _get_currency(self, cr, uid, context=None): + if context is None: + context = {} if not context.get('journal_id', False): return False cur = self.pool.get('account.journal').browse(cr, uid, context['journal_id']).currency @@ -1126,6 +1130,8 @@ class account_move_line(osv.osv): 'period_id': context['period_id'], 'journal_id': context['journal_id'] } + if vals.get('ref', ''): + v.update({'ref': vals['ref']}) move_id = move_obj.create(cr, uid, v, context) vals['move_id'] = move_id else: @@ -1243,4 +1249,4 @@ class account_move_line(osv.osv): account_move_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_view.xml b/addons/account/account_view.xml index 9232a53addb..922256dece6 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -1557,7 +1557,7 @@ @@ -2415,8 +2415,10 @@ - + + +
diff --git a/addons/account/i18n/es.po b/addons/account/i18n/es.po index 34706585b02..1e4fdb2bc94 100644 --- a/addons/account/i18n/es.po +++ b/addons/account/i18n/es.po @@ -7,13 +7,13 @@ msgstr "" "Project-Id-Version: OpenERP Server 6.0dev\n" "Report-Msgid-Bugs-To: support@openerp.com\n" "POT-Creation-Date: 2009-08-28 16:01+0000\n" -"PO-Revision-Date: 2010-10-24 21:56+0000\n" -"Last-Translator: Carlos @ smile.fr \n" +"PO-Revision-Date: 2010-10-25 07:09+0000\n" +"Last-Translator: Carlos-smile \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2010-10-25 04:39+0000\n" +"X-Launchpad-Export-Date: 2010-10-26 04:40+0000\n" "X-Generator: Launchpad (build Unknown)\n" #. module: account diff --git a/addons/account/i18n/es_EC.po b/addons/account/i18n/es_EC.po index d6551425629..9affb3cdd31 100644 --- a/addons/account/i18n/es_EC.po +++ b/addons/account/i18n/es_EC.po @@ -14,7 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2010-10-25 04:39+0000\n" +"X-Launchpad-Export-Date: 2010-10-26 04:40+0000\n" "X-Generator: Launchpad (build Unknown)\n" #. module: account diff --git a/addons/account/i18n/it.po b/addons/account/i18n/it.po index 8f7225d973c..0b82719a3b0 100644 --- a/addons/account/i18n/it.po +++ b/addons/account/i18n/it.po @@ -7,13 +7,13 @@ msgstr "" "Project-Id-Version: OpenERP Server 6.0dev\n" "Report-Msgid-Bugs-To: support@openerp.com\n" "POT-Creation-Date: 2009-08-28 16:01+0000\n" -"PO-Revision-Date: 2010-10-20 07:22+0000\n" -"Last-Translator: Lorenzo Battistini \n" +"PO-Revision-Date: 2010-10-25 21:04+0000\n" +"Last-Translator: Davide Corio - Domsense \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2010-10-21 05:02+0000\n" +"X-Launchpad-Export-Date: 2010-10-26 04:39+0000\n" "X-Generator: Launchpad (build Unknown)\n" #. module: account @@ -372,7 +372,7 @@ msgstr "Contabilità Analitica" #: field:account.tax,child_depend:0 #: field:account.tax.template,child_depend:0 msgid "Tax on Children" -msgstr "" +msgstr "Calcolo su tasse figlie" #. module: account #: rml:account.central.journal:0 @@ -416,7 +416,7 @@ msgstr "Riconciliazione dei pagamenti" #. module: account #: model:account.journal,name:account.expenses_journal msgid "Journal de frais" -msgstr "" +msgstr "Giornale Acquisti" #. module: account #: model:ir.actions.act_window,name:account.act_acc_analytic_acc_5_report_hr_timesheet_invoice_journal @@ -494,7 +494,7 @@ msgstr "Rif" #. module: account #: field:account.tax.template,type_tax_use:0 msgid "Tax Use In" -msgstr "" +msgstr "Tassa usata per" #. module: account #: help:account.tax.template,include_base_amount:0 @@ -572,7 +572,7 @@ msgstr "Linea" #. module: account #: rml:account.analytic.account.cost_ledger:0 msgid "J.C. or Move name" -msgstr "" +msgstr "J.C. o nome movimento" #. module: account #: selection:account.tax,applicable_type:0 @@ -634,7 +634,7 @@ msgstr "(Tenere vuoto per aprire la situazione corrente)" #. module: account #: model:ir.model,name:account.model_account_fiscal_position_account msgid "Accounts Fiscal Mapping" -msgstr "" +msgstr "Mappatura Posizioni Fiscali" #. module: account #: field:account.analytic.account,contact_id:0 @@ -666,7 +666,7 @@ msgstr "Sconto (%)" #: wizard_field:account.move.line.reconcile,init_full,writeoff:0 #: wizard_field:account.move.line.reconcile,init_partial,writeoff:0 msgid "Write-Off amount" -msgstr "" +msgstr "Conto per storno" #. module: account #: help:account.fiscalyear,company_id:0 diff --git a/addons/account/i18n/mn.po b/addons/account/i18n/mn.po index 63ac7694aec..55d3114fa94 100644 --- a/addons/account/i18n/mn.po +++ b/addons/account/i18n/mn.po @@ -8,13 +8,13 @@ msgstr "" "Project-Id-Version: openobject-addons\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2009-08-28 16:01+0000\n" -"PO-Revision-Date: 2010-10-21 09:08+0000\n" -"Last-Translator: OpenERP Administrators \n" +"PO-Revision-Date: 2010-10-26 04:01+0000\n" +"Last-Translator: sugi \n" "Language-Team: Mongolian \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2010-10-22 04:40+0000\n" +"X-Launchpad-Export-Date: 2010-10-26 04:39+0000\n" "X-Generator: Launchpad (build Unknown)\n" #. module: account @@ -5204,7 +5204,7 @@ msgstr "Дансны татварын кодны загвар" #. module: account #: view:account.subscription:0 msgid "Subscription Periods" -msgstr "" +msgstr "Баталгааны мөчлөгүүд" #. module: account #: model:process.node,name:account.process_node_manually0 @@ -5484,7 +5484,7 @@ msgstr "Баримтын бичилт" #: model:ir.actions.act_window,name:account.action_invoice_tree6 #: model:ir.ui.menu,name:account.menu_action_invoice_tree6 msgid "PRO-FORMA Customer Invoices" -msgstr "" +msgstr "Үйлчлүүлэгчийн нэхэмжлэл PRO-FORMA" #. module: account #: field:account.subscription,period_total:0 @@ -5609,7 +5609,7 @@ msgstr "Ажил гүйлгээ" #. module: account #: selection:account.invoice,state:0 msgid "Pro-forma" -msgstr "" +msgstr "Pro-forma" #. module: account #: model:ir.actions.act_window,name:account.action_account_form @@ -5647,7 +5647,7 @@ msgstr "Баримтын дугаараар" #. module: account #: rml:account.overdue:0 msgid "Total amount due:" -msgstr "" +msgstr "Нийт товлосон хэмжээ" #. module: account #: wizard_field:account.analytic.account.chart,init,to_date:0 @@ -5701,7 +5701,7 @@ msgstr "Загварууд" #. module: account #: wizard_button:account.vat.declaration,init,report:0 msgid "Print VAT Decl." -msgstr "" +msgstr "НӨАТ хэвлэх" #. module: account #: model:ir.actions.report.xml,name:account.account_intracom diff --git a/addons/account/i18n/ru.po b/addons/account/i18n/ru.po index cbc4a421440..a1019d56947 100644 --- a/addons/account/i18n/ru.po +++ b/addons/account/i18n/ru.po @@ -7,13 +7,13 @@ msgstr "" "Project-Id-Version: OpenERP Server 6.0dev\n" "Report-Msgid-Bugs-To: support@openerp.com\n" "POT-Creation-Date: 2009-08-28 16:01+0000\n" -"PO-Revision-Date: 2010-10-24 09:01+0000\n" +"PO-Revision-Date: 2010-10-25 07:13+0000\n" "Last-Translator: Chertykov Denis \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2010-10-25 04:39+0000\n" +"X-Launchpad-Export-Date: 2010-10-26 04:39+0000\n" "X-Generator: Launchpad (build Unknown)\n" #. module: account diff --git a/addons/account/i18n/sr.po b/addons/account/i18n/sr.po index e49ea2c9c9e..4cad5720c03 100644 --- a/addons/account/i18n/sr.po +++ b/addons/account/i18n/sr.po @@ -8,13 +8,13 @@ msgstr "" "Project-Id-Version: openobject-addons\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2009-08-28 16:01+0000\n" -"PO-Revision-Date: 2010-10-18 12:12+0000\n" -"Last-Translator: qdp (OpenERP) \n" +"PO-Revision-Date: 2010-10-25 21:56+0000\n" +"Last-Translator: zmmaj \n" "Language-Team: Serbian \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2010-10-20 04:55+0000\n" +"X-Launchpad-Export-Date: 2010-10-26 04:39+0000\n" "X-Generator: Launchpad (build Unknown)\n" #. module: account @@ -80,7 +80,7 @@ msgstr "" #. module: account #: help:account.invoice,period_id:0 msgid "Keep empty to use the period of the validation(invoice) date." -msgstr "" +msgstr "Ostavi prazno da bi koristio validacioni period ( racuna) datuma." #. module: account #: wizard_view:account.automatic.reconcile,reconcile:0 @@ -501,6 +501,8 @@ msgid "" "Set if the amount of tax must be included in the base amount before " "computing the next taxes." msgstr "" +"Postavi ovo ukoliko iznos ovog poreza mora biti ukljucen u osnovicu pre " +"izračuna sledećeg poreza." #. module: account #: model:ir.ui.menu,name:account.menu_finance_periodical_processing @@ -569,7 +571,7 @@ msgstr "Red" #. module: account #: rml:account.analytic.account.cost_ledger:0 msgid "J.C. or Move name" -msgstr "" +msgstr "J.C. ili pomeri ime" #. module: account #: selection:account.tax,applicable_type:0 @@ -589,7 +591,7 @@ msgstr "" #. module: account #: model:ir.model,name:account.model_account_tax msgid "account.tax" -msgstr "" +msgstr "account.tax" #. module: account #: rml:account.central.journal:0 @@ -599,13 +601,13 @@ msgstr "Datum štampe" #. module: account #: rml:account.general.ledger:0 msgid "Mvt" -msgstr "" +msgstr "Mvt" #. module: account #: model:ir.actions.wizard,name:account.wizard_aged_trial_balance #: model:ir.ui.menu,name:account.menu_aged_trial_balance msgid "Aged Partner Balance" -msgstr "" +msgstr "Godisnja potraživanja/obaveze partnera" #. module: account #: view:account.journal:0 @@ -618,6 +620,7 @@ msgid "" "The sequence field is used to order the resources from lower sequences to " "higher ones" msgstr "" +"Ovo polje se koristi da se odredi redosled resursa od najnizeg ka najvecem" #. module: account #: wizard_view:account.analytic.account.chart,init:0 @@ -726,12 +729,12 @@ msgstr "Ukupan iznos dugovanja kupca" #. module: account #: view:account.move.line:0 msgid "St." -msgstr "" +msgstr "St." #. module: account #: model:ir.actions.act_window,name:account.action_tax_code_line_open msgid "account.move.line" -msgstr "" +msgstr "account.move.line" #. module: account #: model:process.transition,name:account.process_transition_supplieranalyticcost0 @@ -773,7 +776,7 @@ msgstr "Delimično plaćanje" #. module: account #: wizard_view:account_use_models,create:0 msgid "Move Lines Created." -msgstr "" +msgstr "Kreirani redovi prenosa" #. module: account #: field:account.fiscalyear,state:0 @@ -920,6 +923,8 @@ msgid "" "If a default tax is given in the partner it only overrides taxes from " "accounts (or products) in the same group." msgstr "" +"Ako je dat podrazumevani porez partnera, on samo upisuje poreze iz naloga ( " +"ili proizvoda) iste grupe." #. module: account #: wizard_field:account.open_closed_fiscalyear,init,fyear_id:0 @@ -1024,7 +1029,7 @@ msgstr "Neto Ukupno" #: model:ir.model,name:account.model_account_fiscal_position #: field:res.partner,property_account_position:0 msgid "Fiscal Mapping" -msgstr "" +msgstr "Poreska mapiranja" #. module: account #: field:account.analytic.line,product_uom_id:0 @@ -1167,7 +1172,7 @@ msgstr "Iznos je predstavljen opciono u drugoj valuti" #: view:account.fiscal.position.template:0 #: field:account.fiscal.position.template,name:0 msgid "Fiscal Mapping Template" -msgstr "" +msgstr "Predlozak poreskog mapiranja" #. module: account #: field:account.payment.term,line_ids:0 @@ -1238,7 +1243,7 @@ msgstr "Valuta preduzeca" #. module: account #: model:ir.model,name:account.model_account_fiscal_position_account_template msgid "Template Account Fiscal Mapping" -msgstr "" +msgstr "Predlozak poreskog mapiranja konta" #. module: account #: field:account.analytic.account,parent_id:0 @@ -2023,7 +2028,7 @@ msgstr "Iznos poreza" #. module: account #: rml:account.analytic.account.quantity_cost_ledger:0 msgid "J.C./Move name" -msgstr "" +msgstr "J.C./Pomeri ime" #. module: account #: field:account.journal.period,name:0 @@ -2034,7 +2039,7 @@ msgstr "Naziv dnevnika-razdoblja" #: field:account.tax.code,name:0 #: field:account.tax.code.template,name:0 msgid "Tax Case Name" -msgstr "" +msgstr "Naziv pozicije PDV obrasca" #. module: account #: help:account.journal,entry_posted:0 @@ -2043,6 +2048,9 @@ msgid "" "'draft' state and instead goes directly to the 'posted state' without any " "manual validation." msgstr "" +"Cekirajte ovde ukoliko ne zelite da novi nalog ne prolazi \" pripremni " +"stadijum\" vec zelite da ode u \" zakljuceno stanje\" bez ikakve rucne " +"validacije" #. module: account #: field:account.bank.statement.line,partner_id:0 @@ -2104,7 +2112,7 @@ msgstr "Period početnog stanja" #: model:ir.actions.wizard,name:account.wizard_validate_account_moves_line #: model:ir.ui.menu,name:account.menu_validate_account_moves msgid "Validate Account Moves" -msgstr "" +msgstr "Potvrdi osnovice" #. module: account #: selection:account.subscription,period_type:0 @@ -2375,7 +2383,7 @@ msgstr "Predložak kontnog plana" #. module: account #: model:account.journal,name:account.refund_sales_journal msgid "Journal d'extourne" -msgstr "" +msgstr "Dnevnik povrata" #. module: account #: rml:account.journal.period.print:0 @@ -2469,7 +2477,7 @@ msgstr "Otvori dnevnik" #. module: account #: rml:account.analytic.account.journal:0 msgid "KI" -msgstr "" +msgstr "KI" #. module: account #: model:ir.actions.wizard,name:account.action_account_analytic_line @@ -3151,7 +3159,7 @@ msgstr "Osnova" #. module: account #: field:account.model,name:0 msgid "Model Name" -msgstr "" +msgstr "Naziv modela" #. module: account #: selection:account.account,type:0 @@ -3404,6 +3412,8 @@ msgid "" "This account will be used instead of the default one as the receivable " "account for the current partner" msgstr "" +"Ovaj ce se nalog koristiti umesto podrazumevanog kao prijemni nalog datog " +"partnera" #. module: account #: selection:account.tax,applicable_type:0 @@ -3490,6 +3500,7 @@ msgid "" "The amount expressed in an optional other currency if it is a multi-currency " "entry." msgstr "" +"Iznos troskova u drugoj opcionoj valuti ako je ovo multi-valutni sadrzaj" #. module: account #: field:account.tax,parent_id:0 @@ -3907,6 +3918,8 @@ msgid "" "This account will be used instead of the default one to value outgoing stock " "for the current product" msgstr "" +"Ovaj nalog ce se koristiti umesto podrazumevanog da potvrdi izlazni magacin " +"za dati prozivod" #. module: account #: model:process.node,note:account.process_node_manually0 @@ -4444,6 +4457,9 @@ msgid "" "to the higher ones. The order is important if you have a tax with several " "tax children. In this case, the evaluation order is important." msgstr "" +"Ovo polje se korosti da odredi redosled poreza od najmanjeg do najveceg. " +"Ovaj redosled je vazan ako imate porez sa nekoliko podporeza,\r\n" +"U tom slucaju, evolucioni poredak je jako vazan." #. module: account #: view:account.tax:0 @@ -4510,7 +4526,7 @@ msgstr "Opcione kolicine u stavkama" #: rml:account.third_party_ledger:0 #: rml:account.third_party_ledger_other:0 msgid "JNRL" -msgstr "" +msgstr "JNRL" #. module: account #: view:account.fiscalyear:0 @@ -5265,7 +5281,7 @@ msgstr "Predznak na izveštajima" #. module: account #: help:account.move.line,currency_id:0 msgid "The optional other currency if it is a multi-currency entry." -msgstr "" +msgstr "Opciona druga valuta ako je ovo multi-valutni sadrzaj" #. module: account #: view:account.invoice:0 @@ -5747,6 +5763,8 @@ msgid "" "This account will be used instead of the default one as the payable account " "for the current partner" msgstr "" +"Ovaj nalog ce se koristiti umesto podrazumevanog kao platni nalog za datog " +"partnera" #. module: account #: field:account.tax.code,code:0 @@ -6066,7 +6084,7 @@ msgstr "Dospela potraživanja" #. module: account #: model:ir.module.module,shortdesc:account.module_meta_information msgid "Board for accountant" -msgstr "" +msgstr "Tabla Naloga" #. module: account #: model:ir.actions.act_window,name:account.action_aged_income diff --git a/addons/account/installer.py b/addons/account/installer.py index 65c6738da12..83ddff6065d 100644 --- a/addons/account/installer.py +++ b/addons/account/installer.py @@ -35,19 +35,19 @@ class account_installer(osv.osv_memory): _inherit = 'res.config.installer' 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'}] + accounts = [{'acc_name': 'Current', 'account_type': 'bank'}, + {'acc_name': 'Deposit', 'account_type': 'bank'}, + {'acc_name': 'Cash', 'account_type': 'cash'}] return accounts def _get_charts(self, cr, uid, context=None): modules = self.pool.get('ir.module.module') - ids = modules.search(cr, uid, [('category_id','=','Account Charts')]) + ids = modules.search(cr, uid, [('category_id', '=', 'Account Charts')], context=context) charts = list( sorted(((m.name, m.shortdesc) for m in modules.browse(cr, uid, ids)), key=itemgetter(1))) - charts.insert(0,('configurable','Generic Chart Of Account')) + charts.insert(0, ('configurable', 'Generic Chart Of Account')) return charts _columns = { @@ -59,7 +59,7 @@ class account_installer(osv.osv_memory): "country."), 'date_start': fields.date('Start Date', required=True), 'date_stop': fields.date('End Date', required=True), - 'period': fields.selection([('month','Monthly'), ('3months','3 Monthly')], 'Periods', required=True), + 'period': fields.selection([('month', 'Monthly'), ('3months','3 Monthly')], 'Periods', required=True), 'bank_accounts_id': fields.one2many('account.bank.accounts.wizard', 'bank_account_id', 'Your Bank and Cash Accounts'), 'sale_tax': fields.float('Sale Tax(%)'), 'purchase_tax': fields.float('Purchase Tax(%)'), @@ -68,28 +68,26 @@ class account_installer(osv.osv_memory): def _default_company(self, cr, uid, context=None): user = self.pool.get('res.users').browse(cr, uid, uid, context=context) - if user.company_id: - return user.company_id.id - return False + return user.company_id and user.company_id.id or False def _get_default_charts(self, cr, uid, context=None): module_name = False company_id = self._default_company(cr, uid, context=context) - company = self.pool.get('res.company').browse(cr, uid, company_id) + company = self.pool.get('res.company').browse(cr, uid, company_id, context=context) address_id = self.pool.get('res.partner').address_get(cr, uid, [company.partner_id.id]) if address_id['default']: - address = self.pool.get('res.partner.address').browse(cr, uid, address_id['default']) + address = self.pool.get('res.partner.address').browse(cr, uid, address_id['default'], context=context) code = address.country_id.code module_name = (code and 'l10n_' + code.lower()) or False if module_name: - module_id = self.pool.get('ir.module.module').search(cr, uid, [('name', '=', module_name)]) + module_id = self.pool.get('ir.module.module').search(cr, uid, [('name', '=', module_name)], context=context) if module_id: return module_name return 'configurable' _defaults = { - 'date_start': lambda *a: time.strftime('%Y-01-01'), - 'date_stop': lambda *a: time.strftime('%Y-12-31'), + 'date_start': time.strftime('%Y-01-01'), + 'date_stop': time.strftime('%Y-12-31'), 'period': 'month', 'sale_tax': 0.0, 'purchase_tax': 0.0, @@ -105,29 +103,37 @@ class account_installer(osv.osv_memory): if start_date: start_date = datetime.datetime.strptime(start_date, "%Y-%m-%d") end_date = (start_date + relativedelta(months=12)) - relativedelta(days=1) - return {'value':{'date_stop':end_date.strftime('%Y-%m-%d')}} + return {'value': {'date_stop': end_date.strftime('%Y-%m-%d')}} return {} def generate_configurable_chart(self, cr, uid, ids, context=None): obj_acc = self.pool.get('account.account') obj_acc_tax = self.pool.get('account.tax') obj_journal = self.pool.get('account.journal') - obj_sequence = self.pool.get('ir.sequence') + obj_acc_tax_code = self.pool.get('account.tax.code') obj_acc_template = self.pool.get('account.account.template') + obj_acc_tax_template = self.pool.get('account.tax.code.template') obj_fiscal_position_template = self.pool.get('account.fiscal.position.template') obj_fiscal_position = self.pool.get('account.fiscal.position') - mod_obj = self.pool.get('ir.model.data') analytic_journal_obj = self.pool.get('account.analytic.journal') + obj_acc_chart_template = self.pool.get('account.chart.template') + obj_acc_journal_view = self.pool.get('account.journal.view') + mod_obj = self.pool.get('ir.model.data') + obj_sequence = self.pool.get('ir.sequence') + property_obj = self.pool.get('ir.property') + fields_obj = self.pool.get('ir.model.fields') + obj_tax_fp = self.pool.get('account.fiscal.position.tax') + obj_ac_fp = self.pool.get('account.fiscal.position.account') result = mod_obj._get_id(cr, uid, 'account', 'configurable_chart_template') - id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id'] - obj_multi = self.pool.get('account.chart.template').browse(cr, uid, id) + id = mod_obj.read(cr, uid, [result], ['res_id'], context=context)[0]['res_id'] + obj_multi = obj_acc_chart_template.browse(cr, uid, id, context=context) record = self.browse(cr, uid, ids, context=context)[0] if context is None: context = {} - company_id = self.browse(cr, uid, ids, context)[0].company_id + company_id = self.browse(cr, uid, ids, context=context)[0].company_id seq_journal = True # Creating Account @@ -141,10 +147,10 @@ class account_installer(osv.osv_memory): todo_dict = {} #create all the tax code - children_tax_code_template = self.pool.get('account.tax.code.template').search(cr, uid, [('parent_id','child_of',[tax_code_root_id])], order='id') + children_tax_code_template = obj_acc_tax_template.search(cr, uid, [('parent_id', 'child_of', [tax_code_root_id])], order='id') children_tax_code_template.sort() - for tax_code_template in self.pool.get('account.tax.code.template').browse(cr, uid, children_tax_code_template): - vals={ + for tax_code_template in obj_acc_tax_template.browse(cr, uid, children_tax_code_template, context=context): + vals = { 'name': (tax_code_root_id == tax_code_template.id) and company_id.name or tax_code_template.name, 'code': tax_code_template.code, 'info': tax_code_template.info, @@ -152,7 +158,7 @@ class account_installer(osv.osv_memory): 'company_id': company_id.id, 'sign': tax_code_template.sign, } - new_tax_code = self.pool.get('account.tax.code').create(cr, uid, vals) + new_tax_code = obj_acc_tax_code.create(cr, uid, vals, context=context) #recording the new tax code to do the mapping tax_code_template_ref[tax_code_template.id] = new_tax_code @@ -160,7 +166,7 @@ class account_installer(osv.osv_memory): for tax in obj_multi.tax_template_ids: #create it vals_tax = { - 'name':tax.name, + 'name': tax.name, 'sequence': tax.sequence, 'amount': tax.amount, 'type': tax.type, @@ -180,11 +186,11 @@ class account_installer(osv.osv_memory): 'ref_base_sign': tax.ref_base_sign, 'ref_tax_sign': tax.ref_tax_sign, 'include_base_amount': tax.include_base_amount, - 'description':tax.description, + 'description': tax.description, 'company_id': company_id.id, 'type_tax_use': tax.type_tax_use } - new_tax = obj_acc_tax.create(cr, uid, vals_tax) + new_tax = obj_acc_tax.create(cr, uid, vals_tax, context=context) #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, @@ -195,9 +201,9 @@ class account_installer(osv.osv_memory): #deactivate the parent_store functionnality on account_account for rapidity purpose self.pool._init = True - children_acc_template = obj_acc_template.search(cr, uid, [('parent_id','child_of',[obj_acc_root.id]),('nocreate','!=',True)]) + children_acc_template = obj_acc_template.search(cr, uid, [('parent_id', 'child_of', [obj_acc_root.id]), ('nocreate', '!=', True)], context=context) children_acc_template.sort() - for account_template in obj_acc_template.browse(cr, uid, children_acc_template): + for account_template in obj_acc_template.browse(cr, uid, children_acc_template, context=context): tax_ids = [] for tax in account_template.tax_ids: tax_ids.append(tax_template_ref[tax.id]) @@ -206,9 +212,9 @@ class account_installer(osv.osv_memory): dig = 6 code_main = account_template.code and len(account_template.code) or 0 code_acc = account_template.code or '' - if code_main>0 and code_main<=dig and account_template.type != 'view': - code_acc=str(code_acc) + (str('0'*(dig-code_main))) - vals={ + if code_main > 0 and code_main <= dig and account_template.type != 'view': + code_acc = str(code_acc) + (str('0'*(dig-code_main))) + vals = { 'name': (obj_acc_root.id == account_template.id) and company_id.name or account_template.name, #'sign': account_template.sign, 'currency_id': account_template.currency_id and account_template.currency_id.id or False, @@ -222,10 +228,10 @@ class account_installer(osv.osv_memory): 'tax_ids': [(6, 0, tax_ids)], 'company_id': company_id.id, } - new_account = obj_acc.create(cr, uid, vals) + new_account = obj_acc.create(cr, uid, vals, context=context) acc_template_ref[account_template.id] = new_account if account_template.name == 'Bank Current Account': - b_vals={ + b_vals = { 'name': 'Bank Accounts', 'code': '110500', 'type': 'view', @@ -236,47 +242,52 @@ class account_installer(osv.osv_memory): 'tax_ids': [(6,0,tax_ids)], 'company_id': company_id.id, } - bank_account = obj_acc.create(cr, uid, b_vals) + bank_account = obj_acc.create(cr, uid, b_vals, context=context) - view_id_cash = self.pool.get('account.journal.view').search(cr, uid, [('name', '=', 'Bank/Cash Journal View')])[0] #why fixed name here? - view_id_cur = self.pool.get('account.journal.view').search(cr, uid, [('name', '=', 'Bank/Cash Journal (Multi-Currency) View')])[0] #Why Fixed name here? + view_id_cash = obj_acc_journal_view.search(cr, uid, [('name', '=', 'Bank/Cash Journal View')], context=context)[0] #why fixed name here? + view_id_cur = obj_acc_journal_view.search(cr, uid, [('name', '=', 'Bank/Cash Journal (Multi-Currency) View')], context=context)[0] #Why Fixed name here? cash_result = mod_obj._get_id(cr, uid, 'account', 'conf_account_type_cash') - cash_type_id = mod_obj.read(cr, uid, [cash_result], ['res_id'])[0]['res_id'] + cash_type_id = mod_obj.read(cr, uid, [cash_result], ['res_id'], context=context)[0]['res_id'] bank_result = mod_obj._get_id(cr, uid, 'account', 'conf_account_type_bnk') - bank_type_id = mod_obj.read(cr, uid, [bank_result], ['res_id'])[0]['res_id'] + bank_type_id = mod_obj.read(cr, uid, [bank_result], ['res_id'], context=context)[0]['res_id'] check_result = mod_obj._get_id(cr, uid, 'account', 'conf_account_type_chk') - check_type_id = mod_obj.read(cr, uid, [check_result], ['res_id'])[0]['res_id'] + check_type_id = mod_obj.read(cr, uid, [check_result], ['res_id'], context=context)[0]['res_id'] # record = self.browse(cr, uid, ids, context=context)[0] code_cnt = 1 vals_seq = { - 'name': _('Bank Journal '), - 'code': 'account.journal', - 'prefix': 'BNK/%(year)s/', - 'padding': 5 - } - seq_id = obj_sequence.create(cr, uid, vals_seq) + 'name': _('Bank Journal '), + 'code': 'account.journal', + 'prefix': 'BNK/%(year)s/', + 'padding': 5 + } + seq_id = obj_sequence.create(cr, uid, vals_seq, context=context) #create the bank journals - analitical_bank_ids = analytic_journal_obj.search(cr, uid, [('type','=','situation')]) + analitical_bank_ids = analytic_journal_obj.search(cr, uid, [('type', '=', 'situation')], context=context) analitical_journal_bank = analitical_bank_ids and analitical_bank_ids[0] or False - vals_journal = {} - vals_journal['name'] = _('Bank Journal ') - vals_journal['code'] = _('BNK') - vals_journal['sequence_id'] = seq_id - vals_journal['type'] = 'bank' - vals_journal['analytic_journal_id'] = analitical_journal_bank + vals_journal = { + 'name': _('Bank Journal '), + 'code': _('BNK'), + 'sequence_id': seq_id, + 'type': 'bank', + 'analytic_journal_id': analitical_journal_bank + } if vals.get('currency_id', False): - vals_journal['view_id'] = view_id_cur - vals_journal['currency'] = vals.get('currency_id', False) + vals_journal.update({ + 'view_id': view_id_cur, + 'currency': vals.get('currency_id', False) + }) else: - vals_journal['view_id'] = view_id_cash - vals_journal['default_credit_account_id'] = new_account - vals_journal['default_debit_account_id'] = new_account - obj_journal.create(cr, uid, vals_journal) + vals_journal.update({'view_id': view_id_cash}) + vals_journal.update({ + 'default_credit_account_id': new_account, + 'default_debit_account_id': new_account, + }) + obj_journal.create(cr, uid, vals_journal, context=context) for val in record.bank_accounts_id: seq_padding = 5 @@ -290,44 +301,52 @@ class account_installer(osv.osv_memory): type = check_type_id seq_padding = None - vals_bnk = {'name': val.acc_name or '', + vals_bnk = { + 'name': val.acc_name or '', 'currency_id': val.currency_id.id or False, 'code': str(110500 + code_cnt), 'type': 'liquidity', 'user_type': type, - 'parent_id':bank_account, - 'company_id': company_id.id } - child_bnk_acc = obj_acc.create(cr, uid, vals_bnk) + 'parent_id': bank_account, + 'company_id': company_id.id + } + child_bnk_acc = obj_acc.create(cr, uid, vals_bnk, context=context) vals_seq_child = { 'name': _(vals_bnk['name'] + ' ' + 'Journal'), 'code': 'account.journal', 'prefix': _((vals_bnk['name'][:3].upper()) + '/%(year)s/'), 'padding': seq_padding - } - seq_id = obj_sequence.create(cr, uid, vals_seq_child) + } + seq_id = obj_sequence.create(cr, uid, vals_seq_child, context=context) #create the bank journal vals_journal = {} - vals_journal['name'] = vals_bnk['name'] + ' Journal' - vals_journal['code'] = _(vals_bnk['name'][:3]).upper() - vals_journal['sequence_id'] = seq_id - vals_journal['type'] = 'cash' + vals_journal = { + 'name': vals_bnk['name'] + _(' Journal'), + 'code': _(vals_bnk['name'][:3]).upper(), + 'sequence_id': seq_id, + 'type': 'cash', + } if vals.get('currency_id', False): - vals_journal['view_id'] = view_id_cur - vals_journal['currency'] = vals_bnk.get('currency_id', False) + vals_journal.update({ + 'view_id': view_id_cur, + 'currency': vals_bnk.get('currency_id', False), + }) else: - vals_journal['view_id'] = view_id_cash - vals_journal['default_credit_account_id'] = child_bnk_acc - vals_journal['default_debit_account_id'] = child_bnk_acc - vals_journal['analytic_journal_id'] = analitical_journal_bank - obj_journal.create(cr,uid,vals_journal) + vals_journal.update({'view_id': view_id_cash}) + vals_journal.update({ + 'default_credit_account_id': child_bnk_acc, + 'default_debit_account_id': child_bnk_acc, + 'analytic_journal_id': analitical_journal_bank + }) + obj_journal.create(cr, uid, vals_journal, context=context) code_cnt += 1 #reactivate the parent_store functionality on account_account self.pool._init = False - self.pool.get('account.account')._parent_store_compute(cr) + obj_acc._parent_store_compute(cr) - for key,value in todo_dict.items(): + for key, value in todo_dict.items(): if value['account_collected_id'] or value['account_paid_id']: obj_acc_tax.write(cr, uid, [key], { 'account_collected_id': acc_template_ref[value['account_collected_id']], @@ -335,42 +354,41 @@ class account_installer(osv.osv_memory): }) # Creating Journals Sales and Purchase - vals_journal={} - data_id = mod_obj.search(cr, uid, [('model','=','account.journal.view'), ('name','=','account_sp_journal_view')]) - data = mod_obj.browse(cr, uid, data_id[0]) + vals_journal = {} + data_id = mod_obj.search(cr, uid, [('model', '=', 'account.journal.view'), ('name', '=', 'account_sp_journal_view')], context=context) + data = mod_obj.browse(cr, uid, data_id[0], context=context) view_id = data.res_id - - seq_id = obj_sequence.search(cr,uid,[('name','=','Account Journal')])[0] + seq_id = obj_sequence.search(cr,uid,[('name', '=', 'Account Journal')], context=context)[0] if seq_journal: seq_sale = { - 'name': 'Sale Journal', - 'code': 'account.journal', - 'prefix': 'SAJ/%(year)s/', - 'padding': 3 - } - seq_id_sale = obj_sequence.create(cr, uid, seq_sale) + 'name': 'Sale Journal', + 'code': 'account.journal', + 'prefix': 'SAJ/%(year)s/', + 'padding': 3 + } + seq_id_sale = obj_sequence.create(cr, uid, seq_sale, context=context) seq_purchase = { - 'name': 'Purchase Journal', - 'code': 'account.journal', - 'prefix': 'EXJ/%(year)s/', - 'padding': 3 - } - seq_id_purchase = obj_sequence.create(cr, uid, seq_purchase) + 'name': 'Purchase Journal', + 'code': 'account.journal', + 'prefix': 'EXJ/%(year)s/', + 'padding': 3 + } + seq_id_purchase = obj_sequence.create(cr, uid, seq_purchase, context=context) seq_refund_sale = { - 'name': 'Sales Refund Journal', - 'code': 'account.journal', - 'prefix': 'SCNJ/%(year)s/', - 'padding': 3 - } - seq_id_sale_refund = obj_sequence.create(cr, uid, seq_refund_sale) + 'name': 'Sales Refund Journal', + 'code': 'account.journal', + 'prefix': 'SCNJ/%(year)s/', + 'padding': 3 + } + seq_id_sale_refund = obj_sequence.create(cr, uid, seq_refund_sale, context=context) seq_refund_purchase = { - 'name': 'Purchase Refund Journal', - 'code': 'account.journal', - 'prefix': 'ECNJ/%(year)s/', - 'padding': 3 - } - seq_id_purchase_refund = obj_sequence.create(cr, uid, seq_refund_purchase) + 'name': 'Purchase Refund Journal', + 'code': 'account.journal', + 'prefix': 'ECNJ/%(year)s/', + 'padding': 3 + } + seq_id_purchase_refund = obj_sequence.create(cr, uid, seq_refund_purchase, context=context) else: seq_id_sale = seq_id seq_id_purchase = seq_id @@ -380,83 +398,90 @@ class account_installer(osv.osv_memory): vals_journal['view_id'] = view_id #Sales Journal - analitical_sale_ids = analytic_journal_obj.search(cr,uid,[('type','=','sale')]) + analitical_sale_ids = analytic_journal_obj.search(cr, uid, [('type','=','sale')], context=context) analitical_journal_sale = analitical_sale_ids and analitical_sale_ids[0] or False - vals_journal['name'] = _('Sales Journal') - vals_journal['type'] = 'sale' - vals_journal['code'] = _('SAJ') - vals_journal['sequence_id'] = seq_id_sale - vals_journal['analytic_journal_id'] = analitical_journal_sale - + vals_journal.update({ + 'name': _('Sales Journal'), + 'type': 'sale', + 'code': _('SAJ'), + 'sequence_id': seq_id_sale, + 'analytic_journal_id': analitical_journal_sale + }) if obj_multi.property_account_receivable: - vals_journal['default_credit_account_id'] = acc_template_ref[obj_multi.property_account_income_categ.id] - vals_journal['default_debit_account_id'] = acc_template_ref[obj_multi.property_account_income_categ.id] - - obj_journal.create(cr,uid,vals_journal) + vals_journal.update({ + 'default_credit_account_id': acc_template_ref[obj_multi.property_account_income_categ.id], + 'default_debit_account_id': acc_template_ref[obj_multi.property_account_income_categ.id], + }) + obj_journal.create(cr, uid, vals_journal, context=context) # Purchase Journal - analitical_purchase_ids = analytic_journal_obj.search(cr, uid, [('type','=','purchase')]) + analitical_purchase_ids = analytic_journal_obj.search(cr, uid, [('type', '=', 'purchase')], context=context) analitical_journal_purchase = analitical_purchase_ids and analitical_purchase_ids[0] or False - vals_journal['name'] = _('Purchase Journal') - vals_journal['type'] = 'purchase' - vals_journal['code'] = _('EXJ') - vals_journal['sequence_id'] = seq_id_purchase - vals_journal['analytic_journal_id'] = analitical_journal_purchase + vals_journal.update({ + 'name': _('Purchase Journal'), + 'type': 'purchase', + 'code': _('EXJ'), + 'sequence_id': seq_id_purchase, + 'analytic_journal_id': analitical_journal_purchase + }) if obj_multi.property_account_payable: - vals_journal['default_credit_account_id'] = acc_template_ref[obj_multi.property_account_expense_categ.id] - vals_journal['default_debit_account_id'] = acc_template_ref[obj_multi.property_account_expense_categ.id] - - obj_journal.create(cr,uid,vals_journal) + vals_journal.update({ + 'default_credit_account_id': acc_template_ref[obj_multi.property_account_expense_categ.id], + 'default_debit_account_id': acc_template_ref[obj_multi.property_account_expense_categ.id] + }) + obj_journal.create(cr, uid, vals_journal, context=context) # Creating Journals Sales Refund and Purchase Refund - vals_journal={} - data_id = mod_obj.search(cr, uid, [('model','=','account.journal.view'), ('name','=','account_sp_refund_journal_view')]) - data = mod_obj.browse(cr, uid, data_id[0]) + vals_journal = {} + data_id = mod_obj.search(cr, uid, [('model', '=', 'account.journal.view'), ('name', '=', 'account_sp_refund_journal_view')], context=context) + data = mod_obj.browse(cr, uid, data_id[0], context=context) view_id = data.res_id - vals_journal['view_id'] = view_id - #Sales Refund Journal - vals_journal['name'] = _('Sales Refund Journal') - vals_journal['type'] = 'sale_refund' - vals_journal['refund_journal'] = True - vals_journal['code'] = _('SCNJ') - vals_journal['sequence_id'] = seq_id_sale_refund - vals_journal['analytic_journal_id'] = analitical_journal_sale - + vals_journal = { + 'view_id': view_id, + 'name': _('Sales Refund Journal'), + 'type': 'sale_refund', + 'refund_journal': True, + 'code': _('SCNJ'), + 'sequence_id': seq_id_sale_refund, + 'analytic_journal_id': analitical_journal_sale + } if obj_multi.property_account_receivable: - vals_journal['default_credit_account_id'] = acc_template_ref[obj_multi.property_account_income_categ.id] - vals_journal['default_debit_account_id'] = acc_template_ref[obj_multi.property_account_income_categ.id] + vals_journal.update({ + 'default_credit_account_id': acc_template_ref[obj_multi.property_account_income_categ.id], + 'default_debit_account_id': acc_template_ref[obj_multi.property_account_income_categ.id] + }) - obj_journal.create(cr,uid,vals_journal) + obj_journal.create(cr, uid, vals_journal, context=context) # Purchase Refund Journal - vals_journal['name'] = _('Purchase Refund Journal') - vals_journal['type'] = 'purchase_refund' - vals_journal['refund_journal'] = True - vals_journal['code'] = _('ECNJ') - vals_journal['sequence_id'] = seq_id_purchase_refund - vals_journal['analytic_journal_id'] = analitical_journal_purchase + vals_journal = { + 'view_id': view_id, + 'name': _('Purchase Refund Journal'), + 'type': 'purchase_refund', + 'refund_journal': True, + 'code': _('ECNJ'), + 'sequence_id': seq_id_purchase_refund, + 'analytic_journal_id': analitical_journal_purchase + } if obj_multi.property_account_payable: - vals_journal['default_credit_account_id'] = acc_template_ref[obj_multi.property_account_expense_categ.id] - vals_journal['default_debit_account_id'] = acc_template_ref[obj_multi.property_account_expense_categ.id] - - obj_journal.create(cr, uid, vals_journal) + vals_journal.update({ + 'default_credit_account_id': acc_template_ref[obj_multi.property_account_expense_categ.id], + 'default_debit_account_id': acc_template_ref[obj_multi.property_account_expense_categ.id] + }) + obj_journal.create(cr, uid, vals_journal, context=context) # Bank Journals - view_id_cash = self.pool.get('account.journal.view').search(cr, uid, [('name','=','Bank/Cash Journal View')])[0] #TOFIX: Why put fixed name ? - view_id_cur = self.pool.get('account.journal.view').search(cr, uid, [('name','=','Bank/Cash Journal (Multi-Currency) View')])[0] #TOFIX: why put fixed name? - + view_id_cash = obj_acc_journal_view.search(cr, uid, [('name', '=', 'Bank/Cash Journal View')], context=context)[0] #TOFIX: Why put fixed name ? + view_id_cur = obj_acc_journal_view.search(cr, uid, [('name', '=', 'Bank/Cash Journal (Multi-Currency) View')], context=context)[0] #TOFIX: why put fixed name? #create the properties - property_obj = self.pool.get('ir.property') - fields_obj = self.pool.get('ir.model.fields') - todo_list = [ ('property_account_receivable', 'res.partner', 'account.account'), ('property_account_payable', 'res.partner', 'account.account'), @@ -469,52 +494,45 @@ class account_installer(osv.osv_memory): for record in todo_list: r = [] - r = property_obj.search(cr, uid, [('name', '=', record[0]), ('company_id', '=', company_id.id)]) + r = property_obj.search(cr, uid, [('name', '=', record[0]), ('company_id', '=', company_id.id)], context=context) account = getattr(obj_multi, record[0]) - field = fields_obj.search(cr, uid, [('name', '=', record[0]), ('model', '=', record[1]), ('relation', '=', record[2])]) + field = fields_obj.search(cr, uid, [('name', '=', record[0]), ('model', '=', record[1]), ('relation', '=', record[2])], context=context) vals = { 'name': record[0], 'company_id': company_id.id, 'fields_id': field[0], - 'value': account and 'account.account,'+str(acc_template_ref[account.id]) or False, + '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) + property_obj.write(cr, uid, r, vals, context=context) else: #create the property - property_obj.create(cr, uid, vals) - - fp_ids = obj_fiscal_position_template.search(cr, uid,[('chart_template_id', '=', obj_multi.id)]) + property_obj.create(cr, uid, vals, context=context) + fp_ids = obj_fiscal_position_template.search(cr, uid, [('chart_template_id', '=', obj_multi.id)], context=context) if fp_ids: - for position in obj_fiscal_position_template.browse(cr, uid, fp_ids): - + for position in obj_fiscal_position_template.browse(cr, uid, fp_ids, context=context): vals_fp = { - 'company_id': company_id.id, - 'name': position.name, - } - new_fp = obj_fiscal_position.create(cr, uid, vals_fp) - - obj_tax_fp = self.pool.get('account.fiscal.position.tax') - obj_ac_fp = self.pool.get('account.fiscal.position.account') - + 'company_id': company_id.id, + 'name': position.name, + } + new_fp = obj_fiscal_position.create(cr, uid, vals_fp, context=context) for tax in position.tax_ids: vals_tax = { - 'tax_src_id': tax_template_ref[tax.tax_src_id.id], - 'tax_dest_id': tax.tax_dest_id and tax_template_ref[tax.tax_dest_id.id] or False, - 'position_id': new_fp, - } - obj_tax_fp.create(cr, uid, vals_tax) + 'tax_src_id': tax_template_ref[tax.tax_src_id.id], + 'tax_dest_id': tax.tax_dest_id and tax_template_ref[tax.tax_dest_id.id] or False, + 'position_id': new_fp, + } + obj_tax_fp.create(cr, uid, vals_tax, context=context) for acc in position.account_ids: vals_acc = { - 'account_src_id': acc_template_ref[acc.account_src_id.id], - 'account_dest_id': acc_template_ref[acc.account_dest_id.id], - 'position_id': new_fp, - } - obj_ac_fp.create(cr, uid, vals_acc) + 'account_src_id': acc_template_ref[acc.account_src_id.id], + 'account_dest_id': acc_template_ref[acc.account_dest_id.id], + 'position_id': new_fp, + } + obj_ac_fp.create(cr, uid, vals_acc, context=context) def execute(self, cr, uid, ids, context=None): if context is None: @@ -524,58 +542,58 @@ class account_installer(osv.osv_memory): obj_acc = self.pool.get('account.account') obj_tax_code = self.pool.get('account.tax.code') obj_temp_tax_code = self.pool.get('account.tax.code.template') + obj_tax = self.pool.get('account.tax') + obj_product = self.pool.get('product.product') + ir_values = self.pool.get('ir.values') super(account_installer, self).execute(cr, uid, ids, context=context) record = self.browse(cr, uid, ids, context=context)[0] company_id = record.company_id - for res in self.read(cr, uid, ids): + for res in self.read(cr, uid, ids, context=context): if record.charts == 'configurable': - fp = tools.file_open(opj('account','configurable_account_chart.xml')) - tools.convert_xml_import(cr, 'account', fp, {}, 'init',True, None) + fp = tools.file_open(opj('account', 'configurable_account_chart.xml')) + tools.convert_xml_import(cr, 'account', fp, {}, 'init', True, None) fp.close() self.generate_configurable_chart(cr, uid, ids, context=context) - obj_tax = self.pool.get('account.tax') - obj_product = self.pool.get('product.product') - ir_values = self.pool.get('ir.values') s_tax = (res.get('sale_tax', 0.0))/100 p_tax = (res.get('purchase_tax', 0.0))/100 tax_val = {} default_tax = [] pur_temp_tax = mod_obj._get_id(cr, uid, 'account', 'tax_code_base_purchases') - pur_temp_tax_id = mod_obj.read(cr, uid, [pur_temp_tax], ['res_id'])[0]['res_id'] - pur_temp_tax_names = obj_temp_tax_code.read(cr, uid, [pur_temp_tax_id], ['name']) + pur_temp_tax_id = mod_obj.read(cr, uid, [pur_temp_tax], ['res_id'], context=context)[0]['res_id'] + pur_temp_tax_names = obj_temp_tax_code.read(cr, uid, [pur_temp_tax_id], ['name'], context=context) pur_tax_parent_name = pur_temp_tax_names and pur_temp_tax_names[0]['name'] or False - pur_taxcode_parent_id = obj_tax_code.search(cr, uid, [('name', 'ilike', pur_tax_parent_name)]) + pur_taxcode_parent_id = obj_tax_code.search(cr, uid, [('name', 'ilike', pur_tax_parent_name)], context=context) if pur_taxcode_parent_id: pur_taxcode_parent_id = pur_taxcode_parent_id[0] else: pur_taxcode_parent_id = False pur_temp_tax_paid = mod_obj._get_id(cr, uid, 'account', 'tax_code_input') - pur_temp_tax_paid_id = mod_obj.read(cr, uid, [pur_temp_tax_paid], ['res_id'])[0]['res_id'] - pur_temp_tax_paid_names = obj_temp_tax_code.read(cr, uid, [pur_temp_tax_paid_id], ['name']) + pur_temp_tax_paid_id = mod_obj.read(cr, uid, [pur_temp_tax_paid], ['res_id'], context=context)[0]['res_id'] + pur_temp_tax_paid_names = obj_temp_tax_code.read(cr, uid, [pur_temp_tax_paid_id], ['name'], context=context) pur_tax_paid_parent_name = pur_temp_tax_names and pur_temp_tax_paid_names[0]['name'] or False - pur_taxcode_paid_parent_id = obj_tax_code.search(cr, uid, [('name', 'ilike', pur_tax_paid_parent_name)]) + pur_taxcode_paid_parent_id = obj_tax_code.search(cr, uid, [('name', 'ilike', pur_tax_paid_parent_name)], context=context) if pur_taxcode_paid_parent_id: pur_taxcode_paid_parent_id = pur_taxcode_paid_parent_id[0] else: pur_taxcode_paid_parent_id = False sale_temp_tax = mod_obj._get_id(cr, uid, 'account', 'tax_code_base_sales') - sale_temp_tax_id = mod_obj.read(cr, uid, [sale_temp_tax], ['res_id'])[0]['res_id'] - sale_temp_tax_names = obj_temp_tax_code.read(cr, uid, [sale_temp_tax_id], ['name']) + sale_temp_tax_id = mod_obj.read(cr, uid, [sale_temp_tax], ['res_id'], context=context)[0]['res_id'] + sale_temp_tax_names = obj_temp_tax_code.read(cr, uid, [sale_temp_tax_id], ['name'], context=context) sale_tax_parent_name = sale_temp_tax_names and sale_temp_tax_names[0]['name'] or False - sale_taxcode_parent_id = obj_tax_code.search(cr, uid, [('name', 'ilike', sale_tax_parent_name)]) + sale_taxcode_parent_id = obj_tax_code.search(cr, uid, [('name', 'ilike', sale_tax_parent_name)], context=context) if sale_taxcode_parent_id: sale_taxcode_parent_id = sale_taxcode_parent_id[0] else: sale_taxcode_parent_id = False sale_temp_tax_paid = mod_obj._get_id(cr, uid, 'account', 'tax_code_output') - sale_temp_tax_paid_id = mod_obj.read(cr, uid, [sale_temp_tax_paid], ['res_id'])[0]['res_id'] - sale_temp_tax_paid_names = obj_temp_tax_code.read(cr, uid, [sale_temp_tax_paid_id], ['name']) + sale_temp_tax_paid_id = mod_obj.read(cr, uid, [sale_temp_tax_paid], ['res_id'], context=context)[0]['res_id'] + sale_temp_tax_paid_names = obj_temp_tax_code.read(cr, uid, [sale_temp_tax_paid_id], ['name'], context=context) sale_tax_paid_parent_name = sale_temp_tax_paid_names and sale_temp_tax_paid_names[0]['name'] or False - sale_taxcode_paid_parent_id = obj_tax_code.search(cr, uid, [('name', 'ilike', sale_tax_paid_parent_name)]) + sale_taxcode_paid_parent_id = obj_tax_code.search(cr, uid, [('name', 'ilike', sale_tax_paid_parent_name)], context=context) if sale_taxcode_paid_parent_id: sale_taxcode_paid_parent_id = sale_taxcode_paid_parent_id[0] else: @@ -590,8 +608,8 @@ class account_installer(osv.osv_memory): 'company_id': company_id.id, 'sign': 1, 'parent_id': sale_taxcode_parent_id - } - new_tax_code = self.pool.get('account.tax.code').create(cr, uid, vals_tax_code) + } + new_tax_code = obj_tax_code.create(cr, uid, vals_tax_code, context=context) vals_paid_tax_code = { 'name': 'TAX Received %s%%'%(s_tax*100), @@ -600,20 +618,20 @@ class account_installer(osv.osv_memory): 'sign': 1, 'parent_id': sale_taxcode_paid_parent_id } - new_paid_tax_code = self.pool.get('account.tax.code').create(cr, uid, vals_paid_tax_code) + new_paid_tax_code = obj_tax_code.create(cr, uid, vals_paid_tax_code, context=context) sales_tax = obj_tax.create(cr, uid, - {'name':'TAX %s%%'%(s_tax*100), - 'amount':s_tax, - 'base_code_id':new_tax_code, - 'tax_code_id':new_paid_tax_code, - 'type_tax_use':'sale', - 'account_collected_id':sales_tax_account_id, - 'account_paid_id':sales_tax_account_id - }) - default_account_ids = obj_acc.search(cr, uid, [('name', '=', 'Product Sales')],context=context) + {'name': 'TAX %s%%'%(s_tax*100), + 'amount': s_tax, + 'base_code_id': new_tax_code, + 'tax_code_id': new_paid_tax_code, + 'type_tax_use': 'sale', + 'account_collected_id': sales_tax_account_id, + 'account_paid_id': sales_tax_account_id + }, context=context) + default_account_ids = obj_acc.search(cr, uid, [('name', '=', 'Product Sales')], context=context) if default_account_ids: - obj_acc.write(cr, uid, default_account_ids, {'tax_ids': [(6, 0, [sales_tax])]}) + obj_acc.write(cr, uid, default_account_ids, {'tax_ids': [(6, 0, [sales_tax])]}, context=context) tax_val.update({'taxes_id': [(6, 0, [sales_tax])]}) default_tax.append(('taxes_id', sales_tax)) if p_tax*100 > 0.0: @@ -626,8 +644,7 @@ class account_installer(osv.osv_memory): 'sign': 1, 'parent_id': pur_taxcode_parent_id } - new_tax_code = self.pool.get('account.tax.code').create(cr, uid, vals_tax_code) - + new_tax_code = obj_tax_code.create(cr, uid, vals_tax_code, context=context) vals_paid_tax_code = { 'name': 'TAX Paid %s%%'%(p_tax*100), 'code': 'TAX Paid %s%%'%(p_tax*100), @@ -635,7 +652,7 @@ class account_installer(osv.osv_memory): 'sign': 1, 'parent_id': pur_taxcode_paid_parent_id } - new_paid_tax_code = self.pool.get('account.tax.code').create(cr, uid, vals_paid_tax_code) + new_paid_tax_code = obj_tax_code.create(cr, uid, vals_paid_tax_code, context=context) purchase_tax = obj_tax.create(cr, uid, {'name': 'TAX%s%%'%(p_tax*100), @@ -646,32 +663,33 @@ class account_installer(osv.osv_memory): 'type_tax_use': 'purchase', 'account_collected_id': purchase_tax_account_id, 'account_paid_id': purchase_tax_account_id - }) + }, context=context) default_account_ids = obj_acc.search(cr, uid, [('name', '=', 'Expenses')], context=context) if default_account_ids: - obj_acc.write(cr, uid, default_account_ids, {'tax_ids': [(6, 0, [purchase_tax])]}) + obj_acc.write(cr, uid, default_account_ids, {'tax_ids': [(6, 0, [purchase_tax])]}, context=context) tax_val.update({'supplier_taxes_id': [(6 ,0, [purchase_tax])]}) default_tax.append(('supplier_taxes_id', purchase_tax)) if tax_val: - product_ids = obj_product.search(cr, uid, []) - for product in obj_product.browse(cr, uid, product_ids): - obj_product.write(cr, uid, product.id, tax_val) + product_ids = obj_product.search(cr, uid, [], context=context) + for product in obj_product.browse(cr, uid, product_ids, context=context): + obj_product.write(cr, uid, product.id, tax_val, context=context) for name, value in default_tax: - ir_values.set(cr, uid, key='default', key2=False, name=name, models =[('product.product',False)], value=[value]) + ir_values.set(cr, uid, key='default', key2=False, name=name, models =[('product.product', False)], value=[value]) if 'date_start' in res and 'date_stop' in res: - f_ids = fy_obj.search(cr, uid, [('date_start', '<=', res['date_start']), ('date_stop', '>=', res['date_stop']), ('company_id', '=', res['company_id'])]) + f_ids = fy_obj.search(cr, uid, [('date_start', '<=', res['date_start']), ('date_stop', '>=', res['date_stop']), ('company_id', '=', res['company_id'])], context=context) if not f_ids: name = code = res['date_start'][:4] if int(name) != int(res['date_stop'][:4]): name = res['date_start'][:4] +'-'+ res['date_stop'][:4] code = res['date_start'][2:4] +'-'+ res['date_stop'][2:4] - vals = {'name': name, - 'code': code, - 'date_start': res['date_start'], - 'date_stop': res['date_stop'], - 'company_id': res['company_id'] - } + vals = { + 'name': name, + 'code': code, + 'date_start': res['date_start'], + 'date_stop': res['date_stop'], + 'company_id': res['company_id'] + } fiscal_id = fy_obj.create(cr, uid, vals, context=context) if res['period'] == 'month': fy_obj.create_period(cr, uid, [fiscal_id]) @@ -698,11 +716,8 @@ class account_bank_accounts_wizard(osv.osv_memory): 'acc_name': fields.char('Account Name.', size=64, required=True), 'bank_account_id': fields.many2one('account.installer', 'Bank Account', required=True), 'currency_id': fields.many2one('res.currency', 'Secondary Currency', help="Forces all moves for this account to have this secondary currency."), - 'account_type': fields.selection([('cash','Cash'),('check','Check'),('bank','Bank')], 'Account Type', size=32), + 'account_type': fields.selection([('cash','Cash'), ('check','Check'), ('bank','Bank')], 'Account Type', size=32), } -# _defaults = { -# 'currency_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.currency_id.id, -# } account_bank_accounts_wizard() @@ -710,7 +725,6 @@ class account_installer_modules(osv.osv_memory): _name = 'account.installer.modules' _inherit = 'res.config.installer' _columns = { - # Accounting 'account_analytic_plans': fields.boolean('Multiple Analytic Plans', help="Allows invoice lines to impact multiple analytic accounts " "simultaneously."), @@ -727,9 +741,6 @@ class account_installer_modules(osv.osv_memory): 'account_anglo_saxon': fields.boolean('Anglo-Saxon Accounting', help="This module will support the Anglo-Saxons accounting methodology by " "changing the accounting logic with stock transactions."), -# 'account_voucher_payment':fields.boolean('Voucher and Reconcile Management', -# help="Extension Account Voucher module includes allows to link payment / receipt " -# "entries with voucher, also automatically reconcile during the payment and receipt entries."), } _defaults = { @@ -738,4 +749,4 @@ class account_installer_modules(osv.osv_memory): account_installer_modules() -# 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/invoice.py b/addons/account/invoice.py index dbac0fdd745..44ebafb9bbd 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -24,8 +24,8 @@ from lxml import etree import decimal_precision as dp import netsvc -from osv import fields, osv, orm import pooler +from osv import fields, osv, orm from tools.translate import _ class account_invoice(osv.osv): @@ -57,17 +57,13 @@ class account_invoice(osv.osv): ('company_id', '=', company_id), ('refund_journal', '=', refund_journal.get(type_inv, False))], limit=1) - if res: - return res[0] - else: - return False + return res and res[0] or False def _get_currency(self, cr, uid, context=None): user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, [uid])[0] if user.company_id: return user.company_id.currency_id.id - else: - return pooler.get_pool(cr.dbname).get('res.currency').search(cr, uid, [('rate','=',1.0)])[0] + return pooler.get_pool(cr.dbname).get('res.currency').search(cr, uid, [('rate','=', 1.0)])[0] def _get_journal_analytic(self, cr, uid, type_inv, context=None): type2journal = {'out_invoice': 'sale', 'in_invoice': 'purchase', 'out_refund': 'sale', 'in_refund': 'purchase'} @@ -134,7 +130,6 @@ class account_invoice(osv.osv): result = inv.amount_total - amount # Use is_zero function to avoid rounding trouble => should be fixed into ORM res[inv.id] = not self.pool.get('res.currency').is_zero(cr, uid, inv.company_id.currency_id, result) and result or 0.0 - return res # Give Journal Items related to the payment reconciled to this invoice @@ -359,12 +354,26 @@ class account_invoice(osv.osv): res['arch'] = etree.tostring(doc) return res + def get_log_context(self, cr, uid, context=None): + if context is None: + context = {} + mob_obj = self.pool.get('ir.model.data') + res = mob_obj.get_object_reference(cr, uid, 'account', 'invoice_form') or False + view_id = res and res[1] or False + context.update({'view_id': view_id}) + return context + def create(self, cr, uid, vals, context=None): + if context is None: + context = {} try: res = super(account_invoice, self).create(cr, uid, vals, context) for inv_id, name in self.name_get(cr, uid, [res], context=context): + ctx = context.copy() + if vals.get('type', 'in_invoice') in ('out_invoice', 'out_refund'): + ctx = self.get_log_context(cr, uid, context=ctx) message = _("Invoice '%s' is waiting for validation.") % name - self.log(cr, uid, inv_id, message) + self.log(cr, uid, inv_id, message, context=ctx) return res except Exception, e: if '"journal_id" viol' in e.args[0]: @@ -491,7 +500,6 @@ class account_invoice(osv.osv): res = {'value':{'date_due': pterm_list[-1]}} else: raise osv.except_osv(_('Data Insufficient !'), _('The Payment Term of Supplier does not have Payment Term Lines(Computation) defined !')) - return res def onchange_invoice_line(self, cr, uid, ids, lines): @@ -504,6 +512,8 @@ class account_invoice(osv.osv): val = {} dom = {} obj_journal = self.pool.get('account.journal') + account_obj = self.pool.get('account.account') + inv_line_obj = self.pool.get('account.invoice.line') if company_id and part_id and type: acc_id = False partner_obj = self.pool.get('res.partner').browse(cr,uid,part_id) @@ -528,7 +538,6 @@ class account_invoice(osv.osv): else: acc_id = pay_res_id val= {'account_id': acc_id} - account_obj = self.pool.get('account.account') if ids: if company_id: inv_obj = self.browse(cr,uid,ids) @@ -539,7 +548,7 @@ class account_invoice(osv.osv): if not result_id: raise osv.except_osv(_('Configuration Error !'), _('Can not find account chart for this company in invoice line account, Please Create account.')) - self.pool.get('account.invoice.line').write(cr, uid, [line.id], {'account_id': result_id[0]}) + inv_line_obj.write(cr, uid, [line.id], {'account_id': result_id[0]}) else: if invoice_line: for inv_line in invoice_line: @@ -580,7 +589,7 @@ class account_invoice(osv.osv): else: val['currency_id'] = company.currency_id.id - return {'value': val, 'domain': dom } + return {'value': val, 'domain': dom} # go from canceled state to draft state def action_cancel_draft(self, cr, uid, ids, *args): @@ -792,7 +801,6 @@ class account_invoice(osv.osv): line = [] for key, val in line2.items(): line.append((0,0,val)) - return line def action_move_create(self, cr, uid, ids, *args): @@ -967,7 +975,9 @@ class account_invoice(osv.osv): 'analytic_account_id':x.get('account_analytic_id',False), } - def action_number(self, cr, uid, ids, *args): + def action_number(self, cr, uid, ids, context=None): + if context is None: + context = {} #TODO: not correct fix but required a frech values before reading it. self.write(cr, uid, ids, {}) @@ -981,7 +991,10 @@ class account_invoice(osv.osv): self.write(cr, uid, ids, {'internal_number':number}) if invtype in ('in_invoice', 'in_refund'): - ref = reference + if not reference: + ref = self._convert_ref(cr, uid, number) + else: + ref = reference else: ref = self._convert_ref(cr, uid, number) @@ -998,9 +1011,11 @@ class account_invoice(osv.osv): (ref, move_id)) for inv_id, name in self.name_get(cr, uid, [id]): + ctx = context.copy() + if obj_inv.type in ('out_invoice', 'out_refund'): + ctx = self.get_log_context(cr, uid, context=ctx) message = _('Invoice ') + " '" + name + "' "+ _("is validated.") - self.log(cr, uid, inv_id, message) - + self.log(cr, uid, inv_id, message, context=ctx) return True def action_cancel(self, cr, uid, ids, *args): @@ -1489,8 +1504,8 @@ class account_invoice_line(osv.osv): taxes = self.pool.get('account.account').browse(cr, uid, account_id).tax_ids fpos = fposition_id and self.pool.get('account.fiscal.position').browse(cr, uid, fposition_id) or False res = self.pool.get('account.fiscal.position').map_tax(cr, uid, fpos, taxes) - r = {'value':{'invoice_line_tax_id': res}} - return r + return {'value':{'invoice_line_tax_id': res}} + account_invoice_line() class account_invoice_tax(osv.osv): @@ -1522,7 +1537,6 @@ class account_invoice_tax(osv.osv): 'amount': fields.float('Amount', digits_compute=dp.get_precision('Account')), 'manual': fields.boolean('Manual'), 'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of invoice tax."), - 'base_code_id': fields.many2one('account.tax.code', 'Base Code', help="The account basis of the tax declaration."), 'base_amount': fields.float('Base Code Amount', digits_compute=dp.get_precision('Account')), 'tax_code_id': fields.many2one('account.tax.code', 'Tax Code', help="The tax basis of the tax declaration."), @@ -1560,9 +1574,9 @@ class account_invoice_tax(osv.osv): _order = 'sequence' _defaults = { - 'manual': lambda *a: 1, - 'base_amount': lambda *a: 0.0, - 'tax_amount': lambda *a: 0.0, + 'manual': 1, + 'base_amount': 0.0, + 'tax_amount': 0.0, } def compute(self, cr, uid, invoice_id, context={}): tax_grouped = {} diff --git a/addons/account/project/project.py b/addons/account/project/project.py index ee142903c87..27836d72a1e 100644 --- a/addons/account/project/project.py +++ b/addons/account/project/project.py @@ -44,7 +44,7 @@ class account_journal(osv.osv): _inherit="account.journal" _columns = { - 'analytic_journal_id':fields.many2one('account.analytic.journal','Analytic Journal',help="Journal for analytic entries"), + 'analytic_journal_id':fields.many2one('account.analytic.journal','Analytic Journal', help="Journal for analytic entries"), } account_journal() diff --git a/addons/account/project/project_view.xml b/addons/account/project/project_view.xml index 02536fc184c..e2f0bdf5709 100644 --- a/addons/account/project/project_view.xml +++ b/addons/account/project/project_view.xml @@ -197,7 +197,7 @@ - + diff --git a/addons/account/report/account_balance_sheet.py b/addons/account/report/account_balance_sheet.py index 820ddfb473d..4d3e06dee05 100644 --- a/addons/account/report/account_balance_sheet.py +++ b/addons/account/report/account_balance_sheet.py @@ -26,6 +26,7 @@ import rml_parse from report import report_sxw from account.report import account_profit_loss from common_report_header import common_report_header +from tools.translate import _ class report_balancesheet_horizontal(rml_parse.rml_parse, common_report_header): def __init__(self, cr, uid, name, context=None): @@ -61,12 +62,12 @@ class report_balancesheet_horizontal(rml_parse.rml_parse, common_report_header): self.context = context def sum_dr(self): - if self.res_bl['type'] == 'Net Profit': + if self.res_bl['type'] == _('Net Profit'): self.result_sum_dr += self.res_bl['balance']*-1 return self.result_sum_dr def sum_cr(self): - if self.res_bl['type'] == 'Net Loss': + if self.res_bl['type'] == _('Net Loss'): self.result_sum_cr += self.res_bl['balance'] return self.result_sum_cr @@ -78,6 +79,7 @@ class report_balancesheet_horizontal(rml_parse.rml_parse, common_report_header): db_pool = pooler.get_pool(self.cr.dbname) #Getting Profit or Loss Balance from profit and Loss report + self.obj_pl.get_data(data) self.res_bl = self.obj_pl.final_result() account_pool = db_pool.get('account.account') @@ -103,10 +105,14 @@ class report_balancesheet_horizontal(rml_parse.rml_parse, common_report_header): account_ids = account_pool._get_children_and_consol(cr, uid, account_id, context=ctx) accounts = account_pool.browse(cr, uid, account_ids, context=ctx) - if self.res_bl['type'] == 'Net Profit C.F.B.L.': - self.res_bl['type'] = 'Net Profit' + if not self.res_bl: + self.res_bl['type'] = _('Net Profit') + self.res_bl['balance'] = 0.0 + + if self.res_bl['type'] == _('Net Profit'): + self.res_bl['type'] = _('Net Profit') else: - self.res_bl['type'] = 'Net Loss' + self.res_bl['type'] = _('Net Loss') pl_dict = { 'code': self.res_bl['type'], 'name': self.res_bl['type'], @@ -199,4 +205,4 @@ report_sxw.report_sxw('report.account.balancesheet', 'account.account', 'addons/account/report/account_balance_sheet.rml',parser=report_balancesheet_horizontal, header='internal') -# 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/report/account_invoice_report_view.xml b/addons/account/report/account_invoice_report_view.xml index 839bfb2ed26..8f9e582c321 100644 --- a/addons/account/report/account_invoice_report_view.xml +++ b/addons/account/report/account_invoice_report_view.xml @@ -98,17 +98,6 @@ - - - - - - - - - - - @@ -130,6 +119,17 @@ + + + + + + + + + + + diff --git a/addons/account/report/account_partner_balance.py b/addons/account/report/account_partner_balance.py index c17de597e1c..ab1c6f656f2 100644 --- a/addons/account/report/account_partner_balance.py +++ b/addons/account/report/account_partner_balance.py @@ -20,8 +20,6 @@ ############################################################################## import time -import re -import copy from tools.translate import _ from report import report_sxw diff --git a/addons/account/report/account_print_overdue.py b/addons/account/report/account_print_overdue.py index 3e1f0b54de1..0a03801d409 100644 --- a/addons/account/report/account_print_overdue.py +++ b/addons/account/report/account_print_overdue.py @@ -21,8 +21,6 @@ import time -import ir -from osv import osv from report import report_sxw import pooler diff --git a/addons/account/report/account_profit_horizontal.rml b/addons/account/report/account_profit_horizontal.rml index f92f9e07983..89cbc4f8502 100644 --- a/addons/account/report/account_profit_horizontal.rml +++ b/addons/account/report/account_profit_horizontal.rml @@ -199,7 +199,7 @@ Code - Perticular + Particular Balance @@ -208,7 +208,7 @@ Code - Perticular + Particular Balance @@ -250,19 +250,19 @@ - [[ final_result()['type'] == 'Net Profit C.F.B.L.' and final_result()['type'] or '' ]] + [[ final_result()['type'] == 'Net Profit' and final_result()['type'] or '' ]] - [[ final_result()['balance'] and final_result()['type'] == 'Net Profit C.F.B.L.' and formatLang(abs(final_result()['balance'])) ]] [[ company.currency_id.symbol ]] + [[ final_result()['balance'] and final_result()['type'] == 'Net Profit' and formatLang(abs(final_result()['balance'])) ]] [[ company.currency_id.symbol ]] - [[ final_result()['type'] == 'Net Loss C.F.B.L.' and final_result()['type'] or '' ]] + [[ final_result()['type'] == 'Net Loss' and final_result()['type'] or '' ]] - [[ final_result()['balance'] and final_result()['type'] == 'Net Loss C.F.B.L.' and formatLang(abs(final_result()['balance'])) ]] [[ final_result()['balance'] and final_result()['type'] == 'Net Loss C.F.B.L.' and company.currency_id.symbol ]] + [[ final_result()['balance'] and final_result()['type'] == 'Net Loss' and formatLang(abs(final_result()['balance'])) ]] [[ final_result()['balance'] and final_result()['type'] == 'Net Loss' and company.currency_id.symbol ]] diff --git a/addons/account/report/account_profit_loss.py b/addons/account/report/account_profit_loss.py index 792b88053a1..9469c3e0d7e 100644 --- a/addons/account/report/account_profit_loss.py +++ b/addons/account/report/account_profit_loss.py @@ -24,6 +24,7 @@ import pooler import rml_parse from report import report_sxw from common_report_header import common_report_header +from tools.translate import _ class report_pl_account_horizontal(rml_parse.rml_parse, common_report_header): @@ -62,12 +63,12 @@ class report_pl_account_horizontal(rml_parse.rml_parse, common_report_header): return self.res_pl def sum_dr(self): - if self.res_pl['type'] == 'Net Profit C.F.B.L.': + if self.res_pl['type'] == _('Net Profit'): self.result_sum_dr += self.res_pl['balance'] return self.result_sum_dr def sum_cr(self): - if self.res_pl['type'] == 'Net Loss C.F.B.L.': + if self.res_pl['type'] == _('Net Loss'): self.result_sum_cr += self.res_pl['balance'] return self.result_sum_cr @@ -114,10 +115,10 @@ class report_pl_account_horizontal(rml_parse.rml_parse, common_report_header): else: accounts_temp.append(account) if self.result_sum_dr > self.result_sum_cr: - self.res_pl['type'] = 'Net Loss C.F.B.L.' + self.res_pl['type'] = _('Net Loss') self.res_pl['balance'] = (self.result_sum_dr - self.result_sum_cr) else: - self.res_pl['type'] = 'Net Profit C.F.B.L.' + self.res_pl['type'] = _('Net Profit') self.res_pl['balance'] = (self.result_sum_cr - self.result_sum_dr) self.result[typ] = accounts_temp cal_list[typ] = self.result[typ] diff --git a/addons/account/report/account_profit_loss.rml b/addons/account/report/account_profit_loss.rml index 2d85dc590e6..c371ab4c638 100644 --- a/addons/account/report/account_profit_loss.rml +++ b/addons/account/report/account_profit_loss.rml @@ -228,10 +228,10 @@ - [[ final_result()['type'] == 'Net Profit C.F.B.L.' and final_result()['type'] or removeParentNode('blockTable') ]] + [[ final_result()['type'] == 'Net Profit' and final_result()['type'] or removeParentNode('blockTable') ]] - [[ final_result()['balance'] and final_result()['type'] == 'Net Loss C.F.B.L.' and formatLang(abs(final_result()['balance'])) ]] [[ final_result()['balance'] and final_result()['type'] == 'Net Loss C.F.B.L.' and company.currency_id.symbol ]] + [[ final_result()['balance'] and final_result()['type'] == 'Net Loss' and formatLang(abs(final_result()['balance'])) ]] [[ final_result()['balance'] and final_result()['type'] == 'Net Loss' and company.currency_id.symbol ]] @@ -283,10 +283,10 @@ - [[ final_result()['type'] == 'Net Loss C.F.B.L.' and final_result()['type'] or removeParentNode('blockTable') ]] + [[ final_result()['type'] == 'Net Loss' and final_result()['type'] or removeParentNode('blockTable') ]] - [[ final_result()['balance'] and final_result()['type'] == 'Net Loss C.F.B.L.' and formatLang(abs(final_result()['balance'])) ]] [[ final_result()['balance'] and final_result()['type'] == 'Net Loss C.F.B.L.' and company.currency_id.symbol ]] + [[ final_result()['balance'] and final_result()['type'] == 'Net Loss' and formatLang(abs(final_result()['balance'])) ]] [[ final_result()['balance'] and final_result()['type'] == 'Net Loss' and company.currency_id.symbol ]] diff --git a/addons/account/report/account_tax_code.py b/addons/account/report/account_tax_code.py index 2f123fd00be..e59839f8267 100644 --- a/addons/account/report/account_tax_code.py +++ b/addons/account/report/account_tax_code.py @@ -21,9 +21,7 @@ ############################################################################## import time -import pooler import rml_parse -import copy from report import report_sxw import re diff --git a/addons/account/report/account_tax_report.py b/addons/account/report/account_tax_report.py index c245e735d65..93e02eea92d 100644 --- a/addons/account/report/account_tax_report.py +++ b/addons/account/report/account_tax_report.py @@ -20,55 +20,54 @@ ############################################################################## import time -import copy -import rml_parse -from report import report_sxw + from common_report_header import common_report_header +from report import report_sxw + class tax_report(rml_parse.rml_parse, common_report_header): _name = 'report.account.vat.declaration' - def __init__(self, cr, uid, name, context={}): - super(tax_report, self).__init__(cr, uid, name, context=context) - self.localcontext.update({ - 'time': time, - 'get_account': self._get_account, - 'get_period': self._get_period, - 'get_codes': self._get_codes, - 'get_general': self._get_general, - 'get_company': self._get_company, - 'get_currency': self._get_currency, - 'get_lines': self._get_lines, - 'get_years': self.get_years, - }) + def set_context(self, objects, data, ids, report_type=None): + new_ids = ids + res = {} + self.period_ids = [] + period_obj = self.pool.get('account.period') + res['periods'] = '' + res['fiscalyear'] = data['form']['fiscalyear_id'] - -# def _get_account(self, form): -# if data['model']=='account.account': -# return self.pool.get('account.account').browse(self.cr, self.uid, data['form']['id']).company_id.name -# return super(tax_report ,self)._get_account(form) - - - def get_years(self,form): - res={} - fiscal_year_name = self.pool.get('account.fiscalyear').name_get(self.cr,self.uid,form['fiscalyear_id']) - - if fiscal_year_name: - res['fname'] = fiscal_year_name[0][1] - res['periods'] = '' - if form['periods']: - periods_l = self.pool.get('account.period').read(self.cr, self.uid, form['periods'], ['name']) + if data['form']['period_from'] and data['form']['period_to']: + self.period_ids = period_obj.build_ctx_periods(self.cr, self.uid, data['form']['period_from'], data['form']['period_to']) + periods_l = period_obj.read(self.cr, self.uid, self.period_ids, ['name']) for period in periods_l: - if res['periods']=='': + if res['periods'] == '': res['periods'] = period['name'] else: res['periods'] += ", "+ period['name'] - return res + return super(tax_report, self).set_context(objects, data, new_ids, report_type=report_type) - def _get_lines(self, based_on, period_list, company_id=False, parent=False, level=0, context={}): + def __init__(self, cr, uid, name, context=None): + super(tax_report, self).__init__(cr, uid, name, context=context) + self.localcontext.update({ + 'time': time, + 'get_codes': self._get_codes, + 'get_general': self._get_general, + 'get_currency': self._get_currency, + 'get_lines': self._get_lines, + 'get_fiscalyear': self._get_fiscalyear, + 'get_account': self._get_account, + 'get_start_period': self.get_start_period, + 'get_end_period': self.get_end_period, + 'get_basedon': self._get_basedon, + }) + + def _get_basedon(self, form): + return form['form']['based_on'] + + def _get_lines(self, based_on, company_id=False, parent=False, level=0, context=None): + period_list = self.period_ids res = self._get_codes(based_on, company_id, parent, level, period_list, context=context) - if period_list: res = self._add_codes(based_on, res, period_list, context=context) else: @@ -105,13 +104,9 @@ class tax_report(rml_parse.rml_parse, common_report_header): ind_general+=1 i+=1 return top_result - #return array_result - def _get_period(self, period_id, context={}): - return self.pool.get('account.period').browse(self.cr, self.uid, period_id, context=context).name - - def _get_general(self, tax_code_id, period_list,company_id, based_on, context={}): - res=[] + def _get_general(self, tax_code_id, period_list, company_id, based_on, context=None): + res = [] obj_account = self.pool.get('account.account') periods_ids = tuple(period_list) if based_on == 'payments': @@ -164,7 +159,7 @@ class tax_report(rml_parse.rml_parse, common_report_header): i+=1 return res - def _get_codes(self, based_on, company_id, parent=False, level=0, period_list=[], context={}): + def _get_codes(self, based_on, company_id, parent=False, level=0, period_list=[], context=None): obj_tc = self.pool.get('account.tax.code') ids = obj_tc.search(self.cr, self.uid, [('parent_id','=',parent),('company_id','=',company_id)], context=context) @@ -175,7 +170,7 @@ class tax_report(rml_parse.rml_parse, common_report_header): res += self._get_codes(based_on, company_id, code.id, level+1, context=context) return res - def _add_codes(self, based_on, account_list=[], period_list=[], context={}): + def _add_codes(self, based_on, account_list=[], period_list=[], context=None): res = [] obj_tc = self.pool.get('account.tax.code') for account in account_list: @@ -190,16 +185,10 @@ class tax_report(rml_parse.rml_parse, common_report_header): res.append((account[0], code)) return res + def _get_currency(self, form, context=None): + return self.pool.get('res.company').browse(self.cr, self.uid, form['company_id'], context=context).currency_id.name - def _get_company(self, form, context={}): - obj_company = self.pool.get('res.company') - return obj_company.browse(self.cr, self.uid, form['company_id'], context=context).name - - def _get_currency(self, form, context={}): - obj_company = self.pool.get('res.company') - return obj_company.browse(self.cr, self.uid, form['company_id'], context=context).currency_id.name - - def sort_result(self, accounts, context={}): + def sort_result(self, accounts, context=None): # On boucle sur notre rapport result_accounts = [] ind=0 @@ -242,4 +231,4 @@ class tax_report(rml_parse.rml_parse, common_report_header): report_sxw.report_sxw('report.account.vat.declaration', 'account.tax.code', 'addons/account/report/account_tax_report.rml', parser=tax_report, header="internal") -# 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/report/account_tax_report.rml b/addons/account/report/account_tax_report.rml index 52f19147ef2..4d29c90cc59 100644 --- a/addons/account/report/account_tax_report.rml +++ b/addons/account/report/account_tax_report.rml @@ -1,200 +1,187 @@ -