diff --git a/account_banking/account_banking.py b/account_banking/account_banking.py index 51c5c370c..357ed9723 100644 --- a/account_banking/account_banking.py +++ b/account_banking/account_banking.py @@ -351,8 +351,10 @@ class account_bank_statement(osv.osv): st = st_line.statement_id context.update({'date': st_line.date}) + ctxt = context.copy() # AB + ctxt['company_id'] = st_line.company_id.id # AB period_id = self._get_period( - cr, uid, st_line.date, context=context) # AB + cr, uid, st_line.date, context=ctxt) # AB move_id = account_move_obj.create(cr, uid, { 'journal_id': st.journal_id.id, @@ -364,6 +366,7 @@ class account_bank_statement(osv.osv): 'move_ids': [(4, move_id, False)] }) + torec = [] if st_line.amount >= 0: account_id = st.journal_id.default_credit_account_id.id else: @@ -411,7 +414,7 @@ class account_bank_statement(osv.osv): move_line_id = account_move_line_obj.create( cr, uid, val, context=context) - torec = move_line_id + torec.append(move_line_id) # Fill the secondary amount/currency # if currency is not the same than the company @@ -454,7 +457,7 @@ class account_bank_statement(osv.osv): - Pay invoices through workflow """ if st_line.reconcile_id: - account_move_line_obj.write(cr, uid, [torec], { + account_move_line_obj.write(cr, uid, torec, { (st_line.reconcile_id.line_partial_ids and 'reconcile_partial_id' or 'reconcile_id'): st_line.reconcile_id.id }, context=context) diff --git a/account_banking/banking_import_transaction.py b/account_banking/banking_import_transaction.py index 19a3e38f6..c52627617 100644 --- a/account_banking/banking_import_transaction.py +++ b/account_banking/banking_import_transaction.py @@ -810,15 +810,19 @@ class banking_import_transaction(osv.osv): move_line_obj = self.pool.get('account.move.line') move_obj = self.pool.get('account.move') for trans in self.browse(cr, uid, ids, context=context): + # Get the period for the company and date + ctxt = context.copy() + ctxt['company_id'] = trans.company_id.id periods = self.pool.get('account.period').find( - cr, uid, trans.statement_line_id.date) + cr, uid, trans.statement_line_id.date, context=ctxt) period_id = periods and periods[0] or False + move_id = move_obj.create(cr, uid, { 'journal_id': trans.writeoff_journal_id.id, 'period_id': period_id, 'date': trans.statement_line_id.date, 'name': '(write-off) %s' % ( - trans.move_line_id.move_id.name or '') + trans.move_line_id.move_id.name or ''), }, context=context) if trans.residual > 0: writeoff_debit = trans.residual @@ -839,6 +843,7 @@ class banking_import_transaction(osv.osv): 'journal_id': trans.writeoff_journal_id.id, 'period_id': period_id, 'currency_id': trans.statement_line_id.statement_id.currency.id, + 'analytic_account_id': trans.writeoff_analytic_id.id, } move_line_id = move_line_obj.create( cr, uid, vals, context=context) @@ -1143,7 +1148,7 @@ class banking_import_transaction(osv.osv): if not injected: i += 1 continue - if 'journal_id' not in account_info: + if 'journal_id' not in account_info.keys(): results['log'].append( _('Transaction found for account %(bank_account)s, ' 'but no default journal was defined.' @@ -1603,6 +1608,8 @@ class banking_import_transaction(osv.osv): 'account.journal', 'Write-off journal'), 'writeoff_move_line_id': fields.many2one( 'account.move.line', 'Write off move line'), + 'writeoff_analytic_id': fields.many2one( + 'account.analytic.account', 'Write off analytic account'), } _defaults = { 'company_id': lambda s,cr,uid,c: @@ -1707,7 +1714,7 @@ class account_bank_statement_line(osv.osv): statement_obj.write( cr, uid, [st_line.statement_id.id], {'name': st_number}, context=context) - + st_line_number = statement_obj.get_next_st_line_number( cr, uid, st_number, st_line, context) company_currency_id = st_line.statement_id.journal_id.company_id.currency_id.id diff --git a/account_banking/wizard/bank_import.py b/account_banking/wizard/bank_import.py index 6838de8e0..37423aa46 100644 --- a/account_banking/wizard/bank_import.py +++ b/account_banking/wizard/bank_import.py @@ -202,7 +202,7 @@ class banking_import(osv.osv_memory): error_accounts[statement.local_account] = True results.error_cnt += 1 continue - if 'journal_id' not in account_info: + if 'journal_id' not in account_info.keys(): results.log.append( _('Statements found for account %(bank_account)s, ' 'but no default journal was defined.' @@ -292,6 +292,7 @@ class banking_import(osv.osv_memory): values['statement_id'] = statement_id values['bank_country_code'] = bank_country_code values['local_account'] = statement.local_account + values['local_currency'] = statement.local_currency transaction_id = import_transaction_obj.create(cursor, uid, values, context=context) if transaction_id: diff --git a/account_banking/wizard/banking_transaction_wizard.py b/account_banking/wizard/banking_transaction_wizard.py index 94d762a38..5a09232d8 100644 --- a/account_banking/wizard/banking_transaction_wizard.py +++ b/account_banking/wizard/banking_transaction_wizard.py @@ -329,9 +329,17 @@ class banking_transaction_wizard(osv.osv_memory): 'account.move.line', 'Or match this entry', domain=[('account_id.reconcile', '=', True), ('reconcile_id', '=', False)], + ), + 'writeoff_analytic_id': fields.related( + 'import_transaction_id', 'writeoff_analytic_id', + type='many2one', relation='account.analytic.account', + string='Write-off analytic account'), + 'analytic_account_id': fields.related( + 'statement_line_id', 'analytic_account_id', + type='many2one', relation='account.analytic.account', + string="Analytic Account"), #'manual_payment_order_id': fields.many2one( # 'payment.order', "Payment order to reconcile"), - ), } banking_transaction_wizard() diff --git a/account_banking/wizard/banking_transaction_wizard.xml b/account_banking/wizard/banking_transaction_wizard.xml index b3950919d..f71b2e109 100644 --- a/account_banking/wizard/banking_transaction_wizard.xml +++ b/account_banking/wizard/banking_transaction_wizard.xml @@ -36,7 +36,7 @@ - + @@ -54,6 +54,7 @@ attrs="{'readonly': [('match_multi', '=', False)], 'invisible': [('match_type', '!=', 'payment_order')]}" domain="[('id', 'in', payment_order_ids[0][2])]" /> +