[IMP] account: bank statement reconciliation widget (part 2)

This commit is contained in:
qdp-odoo 2014-05-30 18:47:50 +02:00
parent 7580b6510b
commit e3491ccb71
29 changed files with 2337 additions and 778 deletions

View File

@ -65,6 +65,7 @@ for a particular financial year and for preparation of vouchers there is a modul
'wizard/account_period_close_view.xml',
'wizard/account_reconcile_view.xml',
'wizard/account_unreconcile_view.xml',
'wizard/account_statement_from_invoice_view.xml',
'account_view.xml',
'account_report.xml',
'account_financial_report_data.xml',
@ -144,6 +145,7 @@ for a particular financial year and for preparation of vouchers there is a modul
'qweb' : [
"static/src/xml/account_move_reconciliation.xml",
"static/src/xml/account_move_line_quickadd.xml",
"static/src/xml/account_bank_statement_reconciliation.xml",
],
'demo': [
'demo/account_demo.xml',
@ -151,6 +153,7 @@ for a particular financial year and for preparation of vouchers there is a modul
'project/analytic_account_demo.xml',
'demo/account_minimal.xml',
'demo/account_invoice_demo.xml',
'demo/account_bank_statement.xml',
'account_unit_test.xml',
],
'test': [

View File

@ -2075,6 +2075,11 @@ class account_tax(osv.osv):
cur_price_unit+=amount2
return res
def compute_for_bank_reconciliation(self, cr, uid, tax_id, amount, context=None):
""" Called by RPC by the bank statement reconciliation widget """
tax = self.browse(cr, uid, tax_id, context=context)
return self.compute_all(cr, uid, [tax], amount, 1) # TOCHECK may use force_exclude parameter
def compute_all(self, cr, uid, taxes, price_unit, quantity, product=None, partner=None, force_excluded=False):
"""
:param force_excluded: boolean used to say that we don't want to consider the value of field price_include of

View File

@ -19,11 +19,10 @@
#
##############################################################################
import time
from openerp.osv import fields, osv
from openerp.tools.translate import _
import openerp.addons.decimal_precision as dp
from openerp.report import report_sxw
class account_bank_statement(osv.osv):
def create(self, cr, uid, vals, context=None):
@ -66,6 +65,18 @@ class account_bank_statement(osv.osv):
return periods[0]
return False
def _compute_default_statement_name(self, cr, uid, context=None):
if context is None:
context = {}
obj_seq = self.pool.get('ir.sequence')
default_journal_id = self._default_journal_id(cr, uid, context=context)
if default_journal_id != False:
period = self.pool.get('account.period').browse(cr, uid, self._get_period(cr, uid, context=context), context=context)
context['fiscalyear_id'] = period.fiscalyear_id.id
journal = self.pool.get('account.journal').browse(cr, uid, default_journal_id, None)
return obj_seq.next_by_id(cr, uid, journal.sequence_id.id, context=context)
return obj_seq.next_by_code(cr, uid, 'account.bank.statement', context=context)
def _currency(self, cursor, user, ids, name, args, context=None):
res = {}
res_currency_obj = self.pool.get('res.currency')
@ -92,12 +103,18 @@ class account_bank_statement(osv.osv):
result[line.statement_id.id] = True
return result.keys()
def _all_lines_reconciled(self, cr, uid, ids, name, args, context=None):
res = {}
for statement in self.browse(cr, uid, ids, context=context):
res[statement.id] = all([line.journal_entry_id.id for line in statement.line_ids])
return res
_order = "date desc, id desc"
_name = "account.bank.statement"
_description = "Bank Statement"
_inherit = ['mail.thread']
_columns = {
'name': fields.char('Reference', 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'), # readonly for account_cash_statement
'name': fields.char('Reference', size=64, 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'), # readonly for account_cash_statement
'date': fields.date('Date', required=True, states={'confirm': [('readonly', True)]}, select=True),
'journal_id': fields.many2one('account.journal', 'Journal', required=True,
readonly=True, states={'draft':[('readonly',False)]}),
@ -129,10 +146,11 @@ class account_bank_statement(osv.osv):
type='many2one', relation='res.currency'),
'account_id': fields.related('journal_id', 'default_debit_account_id', type='many2one', relation='account.account', string='Account used in this journal', readonly=True, help='used in statement reconciliation domain, but shouldn\'t be used elswhere.'),
'cash_control': fields.related('journal_id', 'cash_control' , type='boolean', relation='account.journal',string='Cash control'),
'all_lines_reconciled': fields.function(_all_lines_reconciled, string='All lines reconciled', type='boolean'),
}
_defaults = {
'name': "/",
'name': _compute_default_statement_name,
'date': fields.date.context_today,
'state': 'draft',
'journal_id': _default_journal_id,
@ -193,37 +211,6 @@ class account_bank_statement(osv.osv):
'ref': st_line.ref,
}
def _prepare_bank_move_line(self, cr, uid, st_line, move_id, amount, company_currency_id,
context=None):
"""Compute the args to build the dict of values to create the bank move line from a
statement line by calling the _prepare_move_line_vals. This method may be
overridden to implement custom move generation (making sure to call super() to
establish a clean extension chain).
:param browse_record st_line: account.bank.statement.line record to
create the move from.
:param int/long move_id: ID of the account.move to link the move line
:param float amount: amount of the move line
:param int/long company_currency_id: ID of currency of the concerned company
:return: dict of value to create() the bank account.move.line
"""
anl_id = st_line.analytic_account_id and st_line.analytic_account_id.id or False
debit = ((amount<0) and -amount) or 0.0
credit = ((amount>0) and amount) or 0.0
cur_id = False
amt_cur = False
if st_line.statement_id.currency.id <> company_currency_id:
cur_id = st_line.statement_id.currency.id
if st_line.account_id and st_line.account_id.currency_id and st_line.account_id.currency_id.id <> company_currency_id:
cur_id = st_line.account_id.currency_id.id
if cur_id:
res_currency_obj = self.pool.get('res.currency')
amt_cur = -res_currency_obj.compute(cr, uid, company_currency_id, cur_id, amount, context=context)
res = self._prepare_move_line_vals(cr, uid, st_line, move_id, debit, credit,
amount_currency=amt_cur, currency_id=cur_id, analytic_id=anl_id, context=context)
return res
def _get_counter_part_account(sefl, cr, uid, st_line, context=None):
"""Retrieve the account to use in the counterpart move.
This method may be overridden to implement custom move generation (making sure to
@ -248,8 +235,7 @@ class account_bank_statement(osv.osv):
"""
return st_line.partner_id and st_line.partner_id.id or False
def _prepare_counterpart_move_line(self, cr, uid, st_line, move_id, amount, company_currency_id,
context=None):
def _prepare_bank_move_line(self, cr, uid, st_line, move_id, amount, company_currency_id, context=None):
"""Compute the args to build the dict of values to create the counter part move line from a
statement line by calling the _prepare_move_line_vals. This method may be
overridden to implement custom move generation (making sure to call super() to
@ -269,16 +255,19 @@ class account_bank_statement(osv.osv):
credit = ((amount < 0) and -amount) or 0.0
cur_id = False
amt_cur = False
if st_line.statement_id.currency.id <> company_currency_id:
if st_line.statement_id.currency.id != company_currency_id:
amt_cur = st_line.amount
cur_id = st_line.statement_id.currency.id
cur_id = st_line.currency_id or st_line.statement_id.currency.id
# TODO : FIXME the amount should be in the journal currency
if st_line.currency_id and st_line.amount_currency:
amt_cur = st_line.amount_currency
cur_id = st_line.currency_id.id
return self._prepare_move_line_vals(cr, uid, st_line, move_id, debit, credit,
amount_currency = amt_cur, currency_id = cur_id, account_id = account_id,
partner_id = partner_id, context=context)
amount_currency=amt_cur, currency_id=cur_id, account_id=account_id,
partner_id=partner_id, context=context)
def _prepare_move_line_vals(self, cr, uid, st_line, move_id, debit, credit, currency_id = False,
amount_currency= False, account_id = False, analytic_id = False,
partner_id = False, context=None):
def _prepare_move_line_vals(self, cr, uid, st_line, move_id, debit, credit, currency_id=False,
amount_currency=False, account_id=False, partner_id=False, context=None):
"""Prepare the dict of values to create the move line from a
statement line. All non-mandatory args will replace the default computed one.
This method may be overridden to implement custom move generation (making sure to
@ -293,7 +282,6 @@ class account_bank_statement(osv.osv):
:param float amount_currency: amount of the debit/credit expressed in the currency_id
:param int/long account_id: ID of the account to use in the move line if different
from the statement line account ID
:param int/long analytic_id: ID of analytic account to put on the move line
:param int/long partner_id: ID of the partner to put on the move line
:return: dict of value to create() the account.move.line
"""
@ -314,67 +302,8 @@ class account_bank_statement(osv.osv):
'period_id': st_line.statement_id.period_id.id,
'currency_id': amount_currency and cur_id,
'amount_currency': amount_currency,
'analytic_account_id': analytic_id,
}
def create_move_from_st_line(self, cr, uid, st_line_id, company_currency_id, st_line_number, context=None):
"""Create the account move from the statement line.
:param int/long st_line_id: ID of the account.bank.statement.line to create the move from.
:param int/long company_currency_id: ID of the res.currency of the company
:param char st_line_number: will be used as the name of the generated account move
:return: ID of the account.move created
"""
if context is None:
context = {}
res_currency_obj = self.pool.get('res.currency')
account_move_obj = self.pool.get('account.move')
account_move_line_obj = self.pool.get('account.move.line')
account_bank_statement_line_obj = self.pool.get('account.bank.statement.line')
st_line = account_bank_statement_line_obj.browse(cr, uid, st_line_id, context=context)
st = st_line.statement_id
context.update({'date': st_line.date})
move_vals = self._prepare_move(cr, uid, st_line, st_line_number, context=context)
move_id = account_move_obj.create(cr, uid, move_vals, context=context)
account_bank_statement_line_obj.write(cr, uid, [st_line.id], {
'move_ids': [(4, move_id, False)]
})
torec = []
acc_cur = ((st_line.amount<=0) and st.journal_id.default_debit_account_id) or st_line.account_id
context.update({
'res.currency.compute.account': acc_cur,
})
amount = res_currency_obj.compute(cr, uid, st.currency.id,
company_currency_id, st_line.amount, context=context)
bank_move_vals = self._prepare_bank_move_line(cr, uid, st_line, move_id, amount,
company_currency_id, context=context)
move_line_id = account_move_line_obj.create(cr, uid, bank_move_vals, context=context)
torec.append(move_line_id)
counterpart_move_vals = self._prepare_counterpart_move_line(cr, uid, st_line, move_id,
amount, company_currency_id, context=context)
account_move_line_obj.create(cr, uid, counterpart_move_vals, context=context)
for line in account_move_line_obj.browse(cr, uid, [x.id for x in
account_move_obj.browse(cr, uid, move_id,
context=context).line_id],
context=context):
if line.state <> 'valid':
raise osv.except_osv(_('Error!'),
_('Journal item "%s" is not valid.') % line.name)
# Bank statements will not consider boolean on journal entry_posted
account_move_obj.post(cr, uid, [move_id], context=context)
return move_id
def get_next_st_line_number(self, cr, uid, st_number, st_line, context=None):
return st_number + '/' + str(st_line.sequence)
def balance_check(self, cr, uid, st_id, journal_type='bank', context=None):
st = self.browse(cr, uid, st_id, context=context)
if not ((abs((st.balance_end or 0.0) - st.balance_end_real) < 0.0001) or (abs((st.balance_end or 0.0) - st.balance_end_real) < 0.0001)):
@ -389,49 +318,30 @@ class account_bank_statement(osv.osv):
return state in ('draft','open')
def button_confirm_bank(self, cr, uid, ids, context=None):
obj_seq = self.pool.get('ir.sequence')
if context is None:
context = {}
for st in self.browse(cr, uid, ids, context=context):
j_type = st.journal_id.type
company_currency_id = st.journal_id.company_id.currency_id.id
if not self.check_status_condition(cr, uid, st.state, journal_type=j_type):
continue
self.balance_check(cr, uid, st.id, journal_type=j_type, context=context)
if (not st.journal_id.default_credit_account_id) \
or (not st.journal_id.default_debit_account_id):
raise osv.except_osv(_('Configuration Error!'),
_('Please verify that an account is defined in the journal.'))
if not st.name == '/':
st_number = st.name
else:
c = {'fiscalyear_id': st.period_id.fiscalyear_id.id}
if st.journal_id.sequence_id:
st_number = obj_seq.next_by_id(cr, uid, st.journal_id.sequence_id.id, context=c)
else:
st_number = obj_seq.next_by_code(cr, uid, 'account.bank.statement', context=c)
raise osv.except_osv(_('Configuration Error!'), _('Please verify that an account is defined in the journal.'))
for line in st.move_line_ids:
if line.state <> 'valid':
raise osv.except_osv(_('Error!'),
_('The account entries lines are not in valid state.'))
raise osv.except_osv(_('Error!'), _('The account entries lines are not in valid state.'))
move_ids = []
for st_line in st.line_ids:
if st_line.analytic_account_id:
if not st.journal_id.analytic_journal_id:
raise osv.except_osv(_('No Analytic Journal!'),_("You have to assign an analytic journal on the '%s' journal!") % (st.journal_id.name,))
if not st_line.amount:
continue
st_line_number = self.get_next_st_line_number(cr, uid, st_number, st_line, context)
self.create_move_from_st_line(cr, uid, st_line.id, company_currency_id, st_line_number, context)
self.write(cr, uid, [st.id], {
'name': st_number,
'balance_end_real': st.balance_end
}, context=context)
self.message_post(cr, uid, [st.id], body=_('Statement %s confirmed, journal items were created.') % (st_number,), context=context)
if not st_line.journal_entry_id.id:
raise osv.except_osv(_('Error!'), _('All the account entries lines must be processed in order to close the statement.'))
move_ids.append(st_line.journal_entry_id.id)
self.pool.get('account.move').post(cr, uid, move_ids, context=context)
self.message_post(cr, uid, [st.id], body=_('Statement %s confirmed, journal items were created.') % (st.name,), context=context)
return self.write(cr, uid, ids, {'state':'confirm'}, context=context)
def button_cancel(self, cr, uid, ids, context=None):
@ -505,80 +415,343 @@ class account_bank_statement(osv.osv):
'context':ctx,
}
def number_of_lines_reconciled(self, cr, uid, id, context=None):
bsl_obj = self.pool.get('account.bank.statement.line')
return bsl_obj.search_count(cr, uid, [('statement_id','=',id), ('journal_entry_id','!=',False)], context=context)
def get_format_currency_js_function(self, cr, uid, id, context=None):
""" Returns a string that can be used to instanciate a javascript function.
That function formats a number according to the statement's journal currency """
company_currency = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.currency_id
currency_obj = id and self.browse(cr, uid, id, context=context).journal_id.currency or company_currency
digits = 2 # TODO : from currency_obj
if currency_obj.position == 'after':
return "return amount.toFixed("+str(digits)+") + ' "+currency_obj.symbol+"';"
elif currency_obj.position == 'before':
return "return '"+currency_obj.symbol+" ' + amount.toFixed("+str(digits)+");"
class account_bank_statement_line(osv.osv):
def onchange_partner_id(self, cr, uid, ids, partner_id, context=None):
obj_partner = self.pool.get('res.partner')
if context is None:
context = {}
if not partner_id:
return {}
part = obj_partner.browse(cr, uid, partner_id, context=context)
if not part.supplier and not part.customer:
type = 'general'
elif part.supplier and part.customer:
type = 'general'
else:
if part.supplier == True:
type = 'supplier'
if part.customer == True:
type = 'customer'
res_type = self.onchange_type(cr, uid, ids, partner_id=partner_id, type=type, context=context)
if res_type['value'] and res_type['value'].get('account_id', False):
return {'value': {'type': type, 'account_id': res_type['value']['account_id']}}
return {'value': {'type': type}}
def get_data_for_reconciliations(self, cr, uid, ids, context=None):
""" Used to instanciate a batch of reconciliations in a single request """
# Build a list of reconciliations data
ret = []
mv_line_ids_selected = []
for st_line_id in ids:
reconciliation_data = {
'st_line': self.get_statement_line_for_reconciliation(cr, uid, st_line_id, context),
'reconciliation_proposition': self.get_reconciliation_proposition(cr, uid, st_line_id, mv_line_ids_selected, context)
}
for mv_line in reconciliation_data['reconciliation_proposition']:
mv_line_ids_selected.append(mv_line['id'])
ret.append(reconciliation_data);
def onchange_type(self, cr, uid, line_id, partner_id, type, context=None):
res = {'value': {}}
obj_partner = self.pool.get('res.partner')
# Check if, now that 'candidate' move lines were selected, there are moves left for statement lines
for reconciliation_data in ret:
if not reconciliation_data['st_line']['has_no_partner']:
if self.get_move_lines_counterparts(cr, uid, reconciliation_data['st_line']['id'], excluded_ids=mv_line_ids_selected, count=True, context=context) == 0:
reconciliation_data['st_line']['no_match'] = True
return ret
def get_statement_line_for_reconciliation(self, cr, uid, id, context=None):
""" Returns the data required by the bank statement reconciliation use case """
line = self.browse(cr, uid, id, context=context)
statement_currency = line.journal_id.currency or line.journal_id.company_id.currency_id
rml_parser = report_sxw.rml_parse(cr, uid, 'statement_line_widget', context=context)
amount_str = line.amount > 0 and line.amount or -line.amount
amount_str = rml_parser.formatLang(amount_str, currency_obj=statement_currency)
amount_currency_str = ""
if line.amount_currency and line.currency_id:
amount_currency_str = rml_parser.formatLang(line.amount_currency, currency_obj=line.currency_id)
dict = {
'id': line.id,
'ref': line.ref,
'note': line.note or "",
'name': line.name,
'date': line.date,
'amount': line.amount,
'amount_str': amount_str,
'no_match': self.get_move_lines_counterparts(cr, uid, id, count=True, context=context) == 0 and line.partner_id.id,
'partner_id': line.partner_id.id,
'statement_id': line.statement_id.id,
'account_code': line.journal_id.default_debit_account_id.code,
'account_name': line.journal_id.default_debit_account_id.name,
'partner_name': line.partner_id.name,
'amount_currency_str': amount_currency_str,
'has_no_partner': not line.partner_id.id,
}
if line.partner_id.id:
if line.amount > 0:
dict['open_balance_account_id'] = line.partner_id.property_account_receivable.id
else:
dict['open_balance_account_id'] = line.partner_id.property_account_payable.id
return dict
def get_reconciliation_proposition(self, cr, uid, id, excluded_ids=[], context=None):
""" Returns move lines that constitute the best guess to reconcile a statement line. """
st_line = self.browse(cr, uid, id, context=context)
company_currency = st_line.journal_id.company_id.currency_id.id
statement_currency = st_line.journal_id.currency.id or company_currency
# either use the unsigned debit/credit fields or the signed amount_currency field
sign = 1
if statement_currency == company_currency:
if st_line.amount > 0:
amount_field = 'debit'
else:
amount_field = 'credit'
else:
amount_field = 'amount_currency'
if st_line.amount < 0:
sign = -1
# look for exact match
exact_match_id = self.get_move_lines_counterparts(cr, uid, id, excluded_ids=excluded_ids, limit=1, additional_domain=[(amount_field,'=',(sign*st_line.amount))])
if exact_match_id:
return exact_match_id
# select oldest move lines
if sign == -1:
mv_lines = self.get_move_lines_counterparts(cr, uid, id, excluded_ids=excluded_ids, limit=50, additional_domain=[(amount_field,'<',0)])
else:
mv_lines = self.get_move_lines_counterparts(cr, uid, id, excluded_ids=excluded_ids, limit=50, additional_domain=[(amount_field,'>',0)])
ret = []
total = 0
# get_move_lines_counterparts inverts debit and credit
amount_field = 'debit' if amount_field == 'credit' else 'credit'
for line in mv_lines:
if total + line[amount_field] <= st_line.amount:
ret.append(line)
total += line[amount_field]
else:
break
return ret
def get_move_lines_counterparts(self, cr, uid, id, excluded_ids=[], str="", offset=0, limit=None, count=False, additional_domain=[], context=None):
""" Find the move lines that could be used to reconcile a statement line and returns the counterpart that could be created to reconcile them
If count is true, only returns the count.
:param integer id: the id of the statement line
:param integers list excluded_ids: ids of move lines that should not be fetched
:param string str: string to filter lines
:param integer offset: offset of the request
:param integer limit: number of lines to fetch
:param boolean count: just return the number of records
:param tuples list domain: additional domain restrictions
"""
if context is None:
context = {}
if not partner_id:
return res
account_id = False
line = self.browse(cr, uid, line_id, context=context)
if not line or (line and not line[0].account_id):
part = obj_partner.browse(cr, uid, partner_id, context=context)
if type == 'supplier':
account_id = part.property_account_payable.id
rml_parser = report_sxw.rml_parse(cr, uid, 'statement_line_counterpart_widget', context=context)
st_line = self.browse(cr, uid, id, context=context)
company_currency = st_line.journal_id.company_id.currency_id
statement_currency = st_line.journal_id.currency or company_currency
mv_line_pool = self.pool.get('account.move.line')
currency_obj = self.pool.get('res.currency')
domain = additional_domain + [
('partner_id', '=', st_line.partner_id.id),
('reconcile_id', '=', False),
('state','=','valid'),
'|',('account_id.type', '=', 'receivable'),
('account_id.type', '=', 'payable'), #Let the front-end warn the user if he tries to mix payable and receivable in the same reconciliation
]
if excluded_ids:
domain.append(('id', 'not in', excluded_ids))
if str:
domain += ['|', ('move_id.name', 'ilike', str), ('move_id.ref', 'ilike', str)]
#partially reconciled lines can be displayed only once
reconcile_partial_ids = []
ids = mv_line_pool.search(cr, uid, domain, offset=offset, limit=limit, order="date_maturity asc, id asc", context=context)
if count:
nb_lines = 0
for line in mv_line_pool.browse(cr, uid, ids, context=context):
if line.reconcile_partial_id and line.reconcile_partial_id.id in reconcile_partial_ids:
continue
nb_lines += 1
if line.reconcile_partial_id:
reconcile_partial_ids.append(line.reconcile_partial_id.id)
return nb_lines
else:
account_id = part.property_account_receivable.id
res['value']['account_id'] = account_id
return res
ret = []
for line in mv_line_pool.browse(cr, uid, ids, context=context):
if line.reconcile_partial_id and line.reconcile_partial_id.id in reconcile_partial_ids:
continue
amount_currency_str = ""
if line.currency_id and line.amount_currency:
amount_currency_str = rml_parser.formatLang(line.amount_currency, currency_obj=line.currency_id)
ret_line = {
'id': line.id,
'name': line.move_id.name,
'ref': line.move_id.ref,
'account_code': line.account_id.code,
'account_name': line.account_id.name,
'account_type': line.account_id.type,
'date_maturity': line.date_maturity,
'date': line.date,
'period_name': line.period_id.name,
'journal_name': line.journal_id.name,
'amount_currency_str': amount_currency_str,
}
if statement_currency.id != company_currency.id and line.currency_id and line.currency_id.id == statement_currency.id:
if line.amount_residual_currency < 0:
ret_line['debit'] = 0
ret_line['credit'] = -line.amount_residual_currency
else:
ret_line['debit'] = line.amount_residual_currency if line.credit != 0 else 0
ret_line['credit'] = line.amount_residual_currency if line.debit != 0 else 0
ret_line['amount_currency_str'] = rml_parser.formatLang(line.amount_residual, currency_obj=company_currency)
else:
if line.amount_residual < 0:
ret_line['debit'] = 0
ret_line['credit'] = -line.amount_residual
else:
ret_line['debit'] = line.amount_residual if line.credit != 0 else 0
ret_line['credit'] = line.amount_residual if line.debit != 0 else 0
ctx = context.copy()
ctx.update({'date': st_line.date})
ret_line['debit'] = currency_obj.compute(cr, uid, statement_currency.id, company_currency.id, ret_line['debit'], context=ctx)
ret_line['credit'] = currency_obj.compute(cr, uid, statement_currency.id, company_currency.id, ret_line['credit'], context=ctx)
ret_line['debit_str'] = rml_parser.formatLang(ret_line['debit'], currency_obj=statement_currency)
ret_line['credit_str'] = rml_parser.formatLang(ret_line['credit'], currency_obj=statement_currency)
ret.append(ret_line)
if line.reconcile_partial_id:
reconcile_partial_ids.append(line.reconcile_partial_id.id)
return ret
def process_reconciliation(self, cr, uid, id, mv_line_dicts, context=None):
""" Creates a move line for each item of mv_line_dicts and for the statement line. Reconcile a new move line with its counterpart_move_line_id if specified. Finally, mark the statement line as reconciled by putting the newly created move id in the column journal_entry_id.
:param int id: id of the bank statement line
:param list of dicts mv_line_dicts: move lines to create. If counterpart_move_line_id is specified, reconcile with it
"""
st_line = self.browse(cr, uid, id, context=context)
company_currency = st_line.journal_id.company_id.currency_id
statement_currency = st_line.journal_id.currency or company_currency
bs_obj = self.pool.get('account.bank.statement')
am_obj = self.pool.get('account.move')
aml_obj = self.pool.get('account.move.line')
currency_obj = self.pool.get('res.currency')
# Checks
if st_line.journal_entry_id.id != False:
raise osv.except_osv(_('Error!'), _('The bank statement line was already reconciled.'))
for mv_line_dict in mv_line_dicts:
for field in ['debit', 'credit', 'amount_currency']:
if field not in mv_line_dict:
mv_line_dict[field] = 0.0
if mv_line_dict.get('counterpart_move_line_id'):
mv_line = aml_obj.browse(cr, uid, mv_line_dict.get('counterpart_move_line_id'), context=context)
if mv_line.reconcile_id:
raise osv.except_osv(_('Error!'), _('A selected move line was already reconciled.'))
# Create the move
move_name = st_line.statement_id.name + "/" + str(st_line.sequence)
move_vals = bs_obj._prepare_move(cr, uid, st_line, move_name, context=context)
move_id = am_obj.create(cr, uid, move_vals, context=context)
# Create the move line for the statement line
amount = currency_obj.compute(cr, uid, st_line.statement_id.currency.id, company_currency.id, st_line.amount, context=context)
bank_st_move_vals = bs_obj._prepare_bank_move_line(cr, uid, st_line, move_id, amount, company_currency.id, context=context)
aml_obj.create(cr, uid, bank_st_move_vals, context=context)
st_line_currency_rate = bank_st_move_vals['amount_currency'] and statement_currency.id == company_currency.id and (bank_st_move_vals['amount_currency'] / st_line.amount) or False
st_line_currency = bank_st_move_vals['currency_id']
# Complete the dicts
st_line_statement_id = st_line.statement_id.id
st_line_journal_id = st_line.journal_id.id
st_line_partner_id = st_line.partner_id.id
st_line_company_id = st_line.company_id.id
st_line_period_id = st_line.statement_id.period_id.id
for mv_line_dict in mv_line_dicts:
mv_line_dict['ref'] = move_name
mv_line_dict['move_id'] = move_id
mv_line_dict['period_id'] = st_line_period_id
mv_line_dict['journal_id'] = st_line_journal_id
mv_line_dict['partner_id'] = st_line_partner_id
mv_line_dict['company_id'] = st_line_company_id
mv_line_dict['statement_id'] = st_line_statement_id
if mv_line_dict.get('counterpart_move_line_id'):
mv_line = aml_obj.browse(cr, uid, mv_line_dict['counterpart_move_line_id'], context=context)
mv_line_dict['account_id'] = mv_line.account_id.id
if statement_currency.id != company_currency.id:
mv_line_dict['amount_currency'] = mv_line_dict['debit'] - mv_line_dict['credit']
mv_line_dict['currency_id'] = statement_currency.id
mv_line_dict['debit'] = currency_obj.compute(cr, uid, statement_currency.id, company_currency.id, mv_line_dict['debit'])
mv_line_dict['credit'] = currency_obj.compute(cr, uid, statement_currency.id, company_currency.id, mv_line_dict['credit'])
elif st_line_currency and st_line_currency_rate:
mv_line_dict['amount_currency'] = self.pool.get('res.currency').round(cr, uid, st_line.currency_id, (mv_line_dict['debit'] - mv_line_dict['credit']) * st_line_currency_rate)
mv_line_dict['currency_id'] = st_line_currency
# Create move lines
move_line_pairs_to_reconcile = []
for mv_line_dict in mv_line_dicts:
counterpart_move_line_id = None # NB : this attribute is irrelevant for aml_obj.create() and needs to be removed from the dict
if mv_line_dict.get('counterpart_move_line_id'):
counterpart_move_line_id = mv_line_dict['counterpart_move_line_id']
del mv_line_dict['counterpart_move_line_id']
new_aml_id = aml_obj.create(cr, uid, mv_line_dict, context=context)
if counterpart_move_line_id != None:
move_line_pairs_to_reconcile.append([new_aml_id, counterpart_move_line_id])
# Reconcile
for pair in move_line_pairs_to_reconcile:
# TODO : too slow
aml_obj.reconcile_partial(cr, uid, pair, context=context)
# Mark the statement line as reconciled
self.write(cr, uid, id, {'journal_entry_id': move_id}, context=context)
# FIXME : if it wasn't for the multicompany security settings in account_security.xml, the method would just
# return [('journal_entry_id', '=', False)]
# Unfortunately, that spawns a "no access rights" error ; it shouldn't.
def _needaction_domain_get(self, cr, uid, context=None):
user = self.pool.get("res.users").browse(cr, uid, uid)
return ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id]),('journal_entry_id', '=', False)]
_order = "statement_id desc, sequence"
_name = "account.bank.statement.line"
_description = "Bank Statement Line"
_inherit = ['ir.needaction_mixin']
_columns = {
'name': fields.char('Description', required=True),
'date': fields.date('Date', required=True),
'amount': fields.float('Amount', digits_compute=dp.get_precision('Account')),
'type': fields.selection([
('supplier','Supplier'),
('customer','Customer'),
('general','General')
], 'Type', required=True),
'partner_id': fields.many2one('res.partner', 'Partner'),
'account_id': fields.many2one('account.account','Account',
required=True),
'statement_id': fields.many2one('account.bank.statement', 'Statement',
select=True, required=True, ondelete='cascade'),
'bank_account_id': fields.many2one('res.partner.bank','Bank Account'),
'statement_id': fields.many2one('account.bank.statement', 'Statement', select=True, required=True, ondelete='cascade'),
'journal_id': fields.related('statement_id', 'journal_id', type='many2one', relation='account.journal', string='Journal', store=True, readonly=True),
'analytic_account_id': fields.many2one('account.analytic.account', 'Analytic Account'),
'move_ids': fields.many2many('account.move',
'account_bank_statement_line_move_rel', 'statement_line_id','move_id',
'Moves'),
'ref': fields.char('Reference', size=32),
'note': fields.text('Notes'),
'sequence': fields.integer('Sequence', select=True, help="Gives the sequence order when displaying a list of bank statement lines."),
'company_id': fields.related('statement_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True),
'journal_entry_id': fields.many2one('account.move', 'Journal Entry'),
'amount_currency': fields.float('Amount Currency', help="The amount expressed in an optional other currency if it is a multi-currency entry.", digits_compute=dp.get_precision('Account')),
'currency_id': fields.many2one('res.currency', 'Currency', help="The optional other currency if it is a multi-currency entry."),
}
_defaults = {
'name': lambda self,cr,uid,context={}: self.pool.get('ir.sequence').get(cr, uid, 'account.bank.statement.line'),
'date': lambda self,cr,uid,context={}: context.get('date', fields.date.context_today(self,cr,uid,context=context)),
'type': 'general',
}
class account_statement_operation_template(osv.osv):
_name = "account.statement.operation.template"
_description = "Preset for the lines that can be created in a bank statement reconciliation"
_columns = {
'name': fields.char('Button Label', required=True),
'account_id': fields.many2one('account.account', 'Account', ondelete='cascade', domain=[('type','!=','view')]),
'label': fields.char('Label'),
'amount_type': fields.selection([('fixed', 'Fixed'),('percentage_of_total','Percentage of total amount'),('percentage_of_balance', 'Percentage of open balance')],
'Amount type', required=True),
'amount': fields.float('Amount', digits_compute=dp.get_precision('Account'), help="Leave to 0 to ignore."),
'tax_id': fields.many2one('account.tax', 'Tax', ondelete='cascade'),
'analytic_account_id': fields.many2one('account.analytic.account', 'Analytic Account', ondelete='cascade'),
}
_defaults = {
'amount_type': 'fixed',
'amount': 0.0
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -216,7 +216,7 @@ class account_invoice(osv.osv):
_name = "account.invoice"
_inherit = ['mail.thread']
_description = 'Invoice'
_order = "id desc"
_order = "number desc, id desc"
_track = {
'type': {
},

View File

@ -796,6 +796,8 @@ class account_move_line(osv.osv):
raise osv.except_osv(_('Warning'), _("Journal Item '%s' (id: %s), Move '%s' is already reconciled!") % (line.name, line.id, line.move_id.name))
if line.reconcile_partial_id:
for line2 in line.reconcile_partial_id.line_partial_ids:
if line2.state != 'valid':
raise osv.except_osv(_('Warning'), _("Journal Item '%s' (id: %s) cannot be used in a reconciliation as it is not balanced!") % (line2.name, line2.id))
if not line2.reconcile_id:
if line2.id not in merges:
merges.append(line2.id)

View File

@ -6,10 +6,10 @@
<field name="currency_id" ref="base.EUR"/>
<field name="company_id" ref="base.main_company"/>
<field name="partner_id" ref="base.res_partner_1"/>
<field name="journal_id" ref="account.sales_journal"/>
<field name="journal_id" ref="account.expenses_journal"/>
<field name="state">draft</field>
<field name="type">in_invoice</field>
<field name="account_id" ref="account.a_recv"/>
<field name="account_id" ref="account.a_pay"/>
<field name="name">Test invoice 1</field>
</record>
<record id="test_tax_line" model="account.invoice.tax">

View File

@ -489,6 +489,13 @@
src_model="account.journal"/>
<!-- Bank statement -->
<record id="action_bank_reconcile_bank_statements" model="ir.actions.client">
<field name="name">Reconciliation on Bank Statements</field>
<field name="tag">bank_statement_reconciliation_view</field>
<field name="context">{'statement_id': active_id}</field>
</record>
<record id="view_account_bank_statement_filter" model="ir.ui.view">
<field name="name">account.cash.statement.select</field>
<field name="model">account.bank.statement</field>
@ -525,6 +532,7 @@
</tree>
</field>
</record>
<record id="view_bank_statement_search" model="ir.ui.view">
<field name="name">account.bank.statement.search</field>
<field name="model">account.bank.statement</field>
@ -544,6 +552,7 @@
</search>
</field>
</record>
<record id="view_bank_statement_form" model="ir.ui.view">
<field name="name">account.bank.statement.form</field>
<field name="model">account.bank.statement</field>
@ -551,14 +560,21 @@
<field name="arch" type="xml">
<form string="Bank Statement" version="7.0">
<header>
<button name="button_confirm_bank" states="draft" string="Confirm" type="object" class="oe_highlight"/>
<button name="button_dummy" states="draft" string="Compute" type="object" class="oe_highlight"/>
<field name="all_lines_reconciled" invisible="1" />
<span attrs="{'invisible':['|',('all_lines_reconciled','=',True),('line_ids','=',[])]}">
<button name="%(action_bank_reconcile_bank_statements)d" states="draft" string="Reconcile" type="action" class="oe_highlight"/>
</span>
<span attrs="{'invisible':[('all_lines_reconciled','=',False)]}">
<button name="button_confirm_bank" states="draft" string="Close" type="object" class="oe_highlight"/>
</span>
<button name="button_cancel" states="confirm" string="Cancel Statement" type="object"/>
<field name="state" widget="statusbar" statusbar_visible="draft,confirm"/>
</header>
<sheet>
<div class="oe_right oe_button_box" name="import_buttons">
<!-- Put here related buttons -->
<button class="oe_inline oe_stat_button" name="%(action_view_account_statement_from_invoice_lines)d"
string="Import Invoice" type="action"
attrs="{'invisible':[('state','=','confirm')]}" widget="statinfo" icon="fa-pencil-square-o"/>
</div>
<label for="name" class="oe_edit_only"/>
<h1><field name="name"/></h1>
@ -581,41 +597,30 @@
<notebook>
<page string="Transactions" name="statement_line_ids">
<field name="line_ids" context="{'date':date}">
<tree editable="bottom" string="Statement lines">
<tree editable="bottom" string="Statement lines" colors="grey:journal_entry_id!=False">
<field name="sequence" readonly="1" invisible="1"/>
<field name="date"/>
<field name="name"/>
<field name="ref"/>
<field name="partner_id" on_change="onchange_partner_id(partner_id)" domain="[
<field name="journal_entry_id" invisible="1"/>
<field name="date" attrs="{'readonly' : [('journal_entry_id', '!=', False)] }"/>
<field name="name" attrs="{'readonly' : [('journal_entry_id', '!=', False)] }"/>
<field name="ref" attrs="{'readonly' : [('journal_entry_id', '!=', False)] }"/>
<field name="partner_id" domain="[
'&amp;',
'|',('parent_id','=',False),('is_company','=',True),
'|',('customer','=',True),('supplier','=',True)]" context="{'default_supplier': 1}"/>
<field name="type" on_change="onchange_type(partner_id, type)"/>
<field name="account_id" options='{"no_open":True}' domain="[('journal_id','=',parent.journal_id), ('company_id', '=', parent.company_id)]"/>
<field name="analytic_account_id" groups="analytic.group_analytic_accounting" domain="[('company_id', '=', parent.company_id), ('type', '&lt;&gt;', 'view')]"/>
<field name="amount"/>
'|',('customer','=',True),('supplier','=',True)]"
context="{'default_supplier': 1}"
attrs="{'readonly' : [('journal_entry_id', '!=', False)] }"/>
<field name="amount" attrs="{'readonly' : [('journal_entry_id', '!=', False)] }"/>
<field name="amount_currency" groups="base.group_multi_currency" attrs="{'readonly' : [('journal_entry_id', '!=', False)] }"/>
<field name="currency_id" groups="base.group_multi_currency" attrs="{'readonly' : [('journal_entry_id', '!=', False)] }"/>
<field name="bank_account_id" groups="base.group_no_one"/>
</tree>
<form string="Statement lines" version="7.0">
<group col="4">
<field name="date"/>
<field name="name"/>
<field name="ref"/>
<field name="partner_id" on_change="onchange_partner_id(partner_id)"/>
<field name="type" on_change="onchange_type(partner_id, type)"/>
<field name="account_id" domain="[('journal_id', '=', parent.journal_id), ('type', '&lt;&gt;', 'view'), ('company_id', '=', parent.company_id)]"/>
<field name="analytic_account_id" groups="analytic.group_analytic_accounting" domain="[('company_id', '=', parent.company_id), ('type', '&lt;&gt;', 'view')]"/>
<field name="amount"/>
<field name="sequence" readonly="0"/>
</group>
<separator string="Notes"/>
<field name="note"/>
</form>
</field>
</page>
</notebook>
<group class="oe_subtotal_footer oe_right" colspan="2" name="sale_total">
<div class="oe_subtotal_footer_separator oe_inline">
<label for="balance_end" />
<button name="button_dummy" states="draft" string="(update)" type="object" class="oe_edit_only oe_link"/>
</div>
<field name="balance_end" nolabel="1" class="oe_subtotal_footer_separator" widget='monetary' options="{'currency_field': 'currency_id'}"/>
</group>
@ -683,6 +688,85 @@
<field name="filter" eval="True"/>
</record>
<record id="action_bank_reconcile" model="ir.actions.client">
<field name="name">Reconciliation on Bank Statements</field>
<field name="res_model">account.bank.statement.line</field>
<field name="tag">bank_statement_reconciliation_view</field>
</record>
<!-- because of the needaction badge, groups needs to be specified -->
<menuitem id="menu_bank_reconcile_bank_statements" name="Reconciliation on Bank Statements" parent="account.periodical_processing_reconciliation" groups="group_account_user" action="action_bank_reconcile" sequence="20"/>
<record id="view_account_statement_operation_template_form" model="ir.ui.view">
<field name="name">account.statement.operation.template.form</field>
<field name="model">account.statement.operation.template</field>
<field name="arch" type="xml">
<form string="Statement Operation Templates" version="7.0">
<sheet>
<div class="oe_title">
<label for="name" class="oe_edit_only"/>
<h1>
<field name="name"/>
</h1>
</div>
<group>
<group>
<field name="account_id"/>
<field name="amount_type"/>
<field name="tax_id"/>
</group>
<group>
<field name="label"/>
<label for="amount"/>
<div>
<field name="amount" class="oe_inline" />
<label string="%" class="oe_inline" attrs="{'invisible':[('amount_type','not in',('percentage_of_total', 'percentage_of_balance'))]}" />
</div>
<field name="analytic_account_id" groups="analytic.group_analytic_accounting"/>
</group>
</group>
</sheet>
</form>
</field>
</record>
<record id="view_account_statement_operation_template_tree" model="ir.ui.view">
<field name="name">account.statement.operation.template.tree</field>
<field name="model">account.statement.operation.template</field>
<field name="arch" type="xml">
<tree string="Bank Reconciliation Move Presets">
<field name="name"/>
<field name="account_id"/>
<field name="amount_type"/>
</tree>
</field>
</record>
<record id="view_account_statement_operation_template_search" model="ir.ui.view">
<field name="name">account.statement.operation.template.search</field>
<field name="model">account.statement.operation.template</field>
<field name="arch" type="xml">
<search string="Bank Reconciliation Move preset">
<filter string="With tax" domain="[('tax_id','!=',False)]"/>
<field name="amount_type"/>
</search>
</field>
</record>
<record id="action_account_statement_operation_template" model="ir.actions.act_window">
<field name="name">Statement Operation Templates</field>
<field name="res_model">account.statement.operation.template</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="search_view_id" ref="view_account_statement_operation_template_search"/>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to create a statement operation template.
</p><p>
Those can be used to quickly create a move line when reconciling
your bank statements.
</p>
</field>
</record>
<menuitem action="action_account_statement_operation_template" id="menu_action_account_statement_operation_template" parent="menu_configuration_misc" name="Statement Operation Templates" sequence="22"/>
<!-- Account Types -->
<record id="view_account_type_search" model="ir.ui.view">
<field name="name">account.account.type.search</field>
@ -2258,7 +2342,13 @@
<field name="arch" type="xml">
<form string="Statement" version="7.0">
<header>
<field name="all_lines_reconciled" invisible="1" />
<span attrs="{'invisible':['|',('all_lines_reconciled','=',True),('line_ids','=',[])]}">
<button name="%(action_bank_reconcile_bank_statements)d" states="open" string="Reconcile" type="action" class="oe_highlight"/>
</span>
<span attrs="{'invisible':[('all_lines_reconciled','=',False)]}">
<button name="button_confirm_cash" states="open" string="Close CashBox" type="object" class="oe_highlight"/>
</span>
<button name="button_open" states="draft" string="Open CashBox" type="object" class="oe_highlight"/>
<button name="button_cancel" states="confirm,open" string="Cancel CashBox" type="object"/>
<field name="state" widget="statusbar" nolabel="1" statusbar_visible="draft,confirm"/>
@ -2288,10 +2378,7 @@
<field name="date"/>
<field name="name"/>
<field name="ref"/>
<field name="partner_id" on_change="onchange_partner_id(partner_id)"/>
<field name="type" on_change="onchange_type(partner_id, type)"/>
<field domain="[('journal_id','=',parent.journal_id), ('company_id', '=', parent.company_id)]" name="account_id"/>
<field name="analytic_account_id" domain="[('company_id', '=', parent.company_id), ('type', '&lt;&gt;', 'view')]" groups="analytic.group_analytic_accounting" />
<field name="partner_id"/>
<field name="amount"/>
</tree>
<form string="Statement lines" version="7.0">
@ -2299,10 +2386,7 @@
<field name="date"/>
<field name="name"/>
<field name="ref"/>
<field name="partner_id" on_change="onchange_partner_id(partner_id)"/>
<field name="type" on_change="onchange_type(partner_id, type)"/>
<field domain="[('journal_id', '=', parent.journal_id), ('type', '&lt;&gt;', 'view'), ('company_id', '=', parent.company_id)]" name="account_id"/>
<field name="analytic_account_id" domain="[('company_id', '=', parent.company_id), ('type', '&lt;&gt;', 'view')]" groups="analytic.group_analytic_accounting" />
<field name="partner_id"/>
<field name="amount"/>
<field name="sequence"/>
</group>

View File

@ -44,5 +44,135 @@
<field name="partner_id" ref="base.res_partner_17"/>
<field name="name">Zed+ Antivirus</field>
</record>
<!-- Some customer invoices used to show the reconciliation process on the bank statement -->
<record id="invoice_1" model="account.invoice">
<field name="currency_id" ref="base.EUR"/>
<field name="company_id" ref="base.main_company"/>
<field name="journal_id" ref="account.sales_journal"/>
<field name="state">draft</field>
<field name="type">out_invoice</field>
<field name="account_id" ref="a_recv"/>
<field name="partner_id" ref="base.res_partner_9"/>
</record>
<record id="invoice_1_line_1" model="account.invoice.line">
<field name="name">Otpez Laptop without OS</field>
<field name="invoice_id" ref="invoice_1"/>
<field name="price_unit">642</field>
<field name="quantity">5</field>
<field name="account_id" ref="a_sale"/>
</record>
<record id="invoice_1_line_2" model="account.invoice.line">
<field name="name">Linutop</field>
<field name="invoice_id" ref="invoice_1"/>
<field name="price_unit">280</field>
<field name="quantity">5</field>
<field name="account_id" ref="a_sale"/>
</record>
<workflow action="invoice_open" model="account.invoice" ref="invoice_1"/>
<record id="invoice_2" model="account.invoice">
<field name="currency_id" ref="base.EUR"/>
<field name="company_id" ref="base.main_company"/>
<field name="journal_id" ref="account.sales_journal"/>
<field name="state">draft</field>
<field name="type">out_invoice</field>
<field name="account_id" ref="a_recv"/>
<field name="partner_id" ref="base.res_partner_9"/>
<field eval="time.strftime('%Y-%m') + '-01'" name="date_invoice"/>
</record>
<record id="invoice_2_line_1" model="account.invoice.line">
<field name="name">8-port Switch</field>
<field name="invoice_id" ref="invoice_2"/>
<field name="price_unit">50</field>
<field name="quantity">3</field>
<field name="account_id" ref="a_sale"/>
</record>
<record id="invoice_2_line_2" model="account.invoice.line">
<field name="name">30m RJ45 wire</field>
<field name="invoice_id" ref="invoice_2"/>
<field name="price_unit">25</field>
<field name="quantity">20</field>
<field name="account_id" ref="a_sale"/>
</record>
<workflow action="invoice_open" model="account.invoice" ref="invoice_2"/>
<record id="invoice_3" model="account.invoice">
<field name="currency_id" ref="base.EUR"/>
<field name="company_id" ref="base.main_company"/>
<field name="journal_id" ref="account.sales_journal"/>
<field name="state">draft</field>
<field name="type">out_invoice</field>
<field name="account_id" ref="a_recv"/>
<field name="partner_id" ref="base.res_partner_2"/>
<field eval="time.strftime('%Y-%m') + '-08'" name="date_invoice"/>
</record>
<record id="invoice_3_line_1" model="account.invoice.line">
<field name="name">TypeMatrix Dvorak Keyboard</field>
<field name="invoice_id" ref="invoice_3"/>
<field name="price_unit">90</field>
<field name="quantity">5</field>
<field name="account_id" ref="a_sale"/>
</record>
<record id="invoice_3_line_2" model="account.invoice.line">
<field name="name">Ergonomic Mouse</field>
<field name="invoice_id" ref="invoice_3"/>
<field name="price_unit">15</field>
<field name="quantity">5</field>
<field name="account_id" ref="a_sale"/>
</record>
<workflow action="invoice_open" model="account.invoice" ref="invoice_3"/>
<record id="invoice_4" model="account.invoice">
<field name="currency_id" ref="base.EUR"/>
<field name="company_id" ref="base.main_company"/>
<field name="journal_id" ref="account.sales_journal"/>
<field name="state">draft</field>
<field name="type">out_invoice</field>
<field name="account_id" ref="a_recv"/>
<field name="partner_id" ref="base.res_partner_2"/>
<field eval="time.strftime('%Y-%m') + '-15'" name="date_invoice"/>
</record>
<record id="invoice_4_line_1" model="account.invoice.line">
<field name="name">Desktop Computer Table</field>
<field name="invoice_id" ref="invoice_4"/>
<field name="price_unit">80</field>
<field name="quantity">5</field>
<field name="account_id" ref="a_sale"/>
</record>
<record id="invoice_4_line_2" model="account.invoice.line">
<field name="name">Desktop Lamp</field>
<field name="invoice_id" ref="invoice_4"/>
<field name="price_unit">20</field>
<field name="quantity">5</field>
<field name="account_id" ref="a_sale"/>
</record>
<workflow action="invoice_open" model="account.invoice" ref="invoice_4"/>
<record id="invoice_5" model="account.invoice">
<field name="currency_id" ref="base.EUR"/>
<field name="company_id" ref="base.main_company"/>
<field name="journal_id" ref="account.sales_journal"/>
<field name="state">draft</field>
<field name="type">out_invoice</field>
<field name="account_id" ref="a_recv"/>
<field name="partner_id" ref="base.res_partner_9"/>
<field eval="time.strftime('%Y-%m') + '-08'" name="date_invoice"/>
</record>
<record id="invoice_5_line_1" model="account.invoice.line">
<field name="name">TypeMatrix Dvorak Keyboard</field>
<field name="invoice_id" ref="invoice_5"/>
<field name="price_unit">90</field>
<field name="quantity">5</field>
<field name="account_id" ref="a_sale"/>
</record>
<record id="invoice_5_line_2" model="account.invoice.line">
<field name="name">Ergonomic Mouse</field>
<field name="invoice_id" ref="invoice_5"/>
<field name="price_unit">15</field>
<field name="quantity">5</field>
<field name="account_id" ref="a_sale"/>
</record>
<workflow action="invoice_open" model="account.invoice" ref="invoice_5"/>
</data>
</openerp>

View File

@ -98,3 +98,4 @@ access_account_sequence_fiscal_year_sale_manager,account.sequence.fiscalyear.sal
access_account_treasury_report_manager,account.treasury.report.manager,model_account_treasury_report,account.group_account_manager,1,0,0,0
access_account_financial_report,account.financial.report,model_account_financial_report,account.group_account_user,1,1,1,1
access_account_financial_report_invoice,account.financial.report invoice,model_account_financial_report,account.group_account_invoice,1,0,0,0
access_account_statement_operation_template,account.statement.operation.template,model_account_statement_operation_template,account.group_account_user,1,1,1,1

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
98 access_account_treasury_report_manager account.treasury.report.manager model_account_treasury_report account.group_account_manager 1 0 0 0
99 access_account_financial_report account.financial.report model_account_financial_report account.group_account_user 1 1 1 1
100 access_account_financial_report_invoice account.financial.report invoice model_account_financial_report account.group_account_invoice 1 0 0 0
101 access_account_statement_operation_template account.statement.operation.template model_account_statement_operation_template account.group_account_user 1 1 1 1

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,8 @@
<link rel="stylesheet" href="/account/static/src/css/account_move_reconciliation.css"/>
<link rel="stylesheet" href="/account/static/src/css/account_move_line_quickadd.css"/>
<link rel="stylesheet" href="/account/static/src/css/account_bank_and_cash.css"/>
<script type="text/javascript" src="/account/static/src/js/account_move_reconciliation.js"></script>
<link rel="stylesheet" href="/account/static/src/css/account_bank_statement_reconciliation.css"/>
<script type="text/javascript" src="/account/static/src/js/account_widgets.js"></script>
<script type="text/javascript" src="/account/static/src/js/account_move_line_quickadd.js"></script>
</xpath>
</template>

View File

@ -63,8 +63,6 @@ import account_report_account_balance
import account_change_currency
import pos_box;
import pos_box
import account_statement_from_invoice
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -56,7 +56,6 @@ class CashBoxIn(CashBox):
return {
'statement_id' : record.id,
'journal_id' : record.journal_id.id,
'account_id' : record.journal_id.internal_account_id.id,
'amount' : box.amount or 0.0,
'ref' : '%s' % (box.ref or ''),
'name' : box.name,
@ -73,7 +72,6 @@ class CashBoxOut(CashBox):
return {
'statement_id' : record.id,
'journal_id' : record.journal_id.id,
'account_id' : record.journal_id.internal_account_id.id,
'amount' : -amount if amount > 0.0 else amount,
'name' : box.name,
}

View File

@ -74,6 +74,7 @@ The analytic plan validates the minimum and maximum percentage at the time of cr
'wizard/analytic_plan_create_model_view.xml',
'wizard/account_crossovered_analytic_view.xml',
'views/report_crossoveredanalyticplans.xml',
'views/account_analytic_plans.xml',
],
'demo': [],
'test': ['test/acount_analytic_plans_report.yml'],

View File

@ -248,42 +248,10 @@
<field name="model">account.analytic.default</field>
<field name="inherit_id" ref="account_analytic_default.view_account_analytic_default_tree"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='analytic_id']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='analytic_id']" position="after">
<xpath expr="//field[@name='analytic_id']" position="replace">
<field name="analytics_id" required="1"/>
</xpath>
</field>
</record>
<record id="view_bank_statement_inherit_form" model="ir.ui.view">
<field name="name">account.bank.statement.form.inherit</field>
<field name="model">account.bank.statement</field>
<field name="inherit_id" ref="account.view_bank_statement_form"/>
<field name="arch" type="xml">
<xpath expr="/form/sheet/notebook/page/field[@name='line_ids']/tree/field[@name='analytic_account_id']" position="replace">
<field name="analytics_id" groups="analytic.group_analytic_accounting"/>
</xpath>
<xpath expr="/form/sheet/notebook/page/field[@name='line_ids']/form/group/field[@name='analytic_account_id']" position="replace">
<field name="analytics_id" groups="analytic.group_analytic_accounting"/>
</xpath>
</field>
</record>
<record id="view_bank_statement_inherit_form2" model="ir.ui.view">
<field name="name">account.bank.statement.form.inherit</field>
<field name="model">account.bank.statement</field>
<field name="inherit_id" ref="account.view_bank_statement_form2"/>
<field name="arch" type="xml">
<xpath expr="/form/sheet/notebook/page/field[@name='line_ids']/tree/field[@name='analytic_account_id']" position="replace">
<field name="analytics_id" groups="analytic.group_analytic_accounting"/>
</xpath>
<xpath expr="/form/sheet/notebook/page/field[@name='line_ids']/form/group/field[@name='analytic_account_id']" position="replace">
<field name="analytics_id" groups="analytic.group_analytic_accounting"/>
</xpath>
</field>
</record>
</data>
</openerp>

View File

@ -74,10 +74,7 @@
<field name="name"/>
<field name="statement_id"/>
<field name="ref" readonly="1"/>
<field name="partner_id" on_change="onchange_partner_id(partner_id)"/>
<field name="type" on_change="onchange_type(partner_id, type)"/>
<field name="account_id"/>
<field name="analytic_account_id" groups="analytic.group_analytic_accounting" domain="[('type', '&lt;&gt;', 'view')]"/>
<field name="partner_id"/>
<field name="amount" readonly="1" sum="Total Amount"/>
<field name="globalisation_id" string="Glob. Id"/>
<field name="globalisation_amount" string="Glob. Am."/>
@ -98,10 +95,7 @@
<field name="val_date"/>
<field name="name"/>
<field name="ref" readonly="0"/>
<field name="partner_id" on_change="onchange_partner_id(partner_id)"/>
<field name="type" on_change="onchange_type(partner_id, type)"/>
<field domain="[('type', '&lt;&gt;', 'view')]" name="account_id"/>
<field name="analytic_account_id" groups="analytic.group_analytic_accounting" domain="[('type', '&lt;&gt;', 'view')]"/>
<field name="partner_id"/>
<field name="amount"/>
<field name="globalisation_id"/>
<field name="sequence" readonly="0"/>
@ -129,7 +123,6 @@
<field name="statement_id"/>
<field name="globalisation_id" string="Glob. Id"/>
<group string="Extended Filters..." expand="0">
<field name="account_id"/>
<field name="partner_id"/>
<field name="amount"/>
<field name="globalisation_amount" string="Glob. Amount"/>
@ -138,7 +131,6 @@
<group string="Group By..." expand="1">
<filter string="Journal" context="{'group_by':'journal_id'}" icon="terp-folder-green"/>
<filter string="Statement" context="{'group_by':'statement_id'}" icon="terp-folder-orange"/>
<filter string="Fin.Account" context="{'group_by':'account_id'}" icon="terp-folder-yellow"/>
</group>
</search>
</field>

View File

@ -107,12 +107,9 @@ class account_payment_populate_statement(osv.osv_memory):
st_line_id = statement_line_obj.create(cr, uid, {
'name': line.order_id.reference or '?',
'amount': - amount,
'type': 'supplier',
'partner_id': line.partner_id.id,
'account_id': line.move_line_id.account_id.id,
'statement_id': statement.id,
'ref': line.communication,
'voucher_id': voucher_id,
}, context=context)
line_obj.write(cr, uid, [line.id], {'bank_statement_line_id': st_line_id})

View File

@ -22,6 +22,5 @@
import account_voucher
import invoice
import report
import wizard
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -49,7 +49,6 @@ This module manages:
'security/ir.model.access.csv',
'account_voucher_sequence.xml',
'account_voucher_workflow.xml',
'wizard/account_statement_from_invoice_view.xml',
'account_voucher_view.xml',
'voucher_payment_receipt_view.xml',
'voucher_sales_purchase_view.xml',

View File

@ -327,7 +327,6 @@ class account_voucher(osv.osv):
}
_columns = {
'active': fields.boolean('Active', help="By default, reconciliation vouchers made on draft bank statements are set as inactive, which allow to hide the customer/supplier payment while the bank statement isn't confirmed."),
'type':fields.selection([
('sale','Sale'),
('purchase','Purchase'),
@ -389,7 +388,6 @@ class account_voucher(osv.osv):
'currency_help_label': fields.function(_fnct_currency_help_label, type='text', string="Helping Sentence", help="This sentence helps you to know how to specify the payment rate by giving you the direct effect it has"),
}
_defaults = {
'active': True,
'period_id': _get_period,
'partner_id': _get_partner,
'journal_id':_get_journal,
@ -1583,114 +1581,6 @@ class account_voucher_line(osv.osv):
})
return values
class account_bank_statement(osv.osv):
_inherit = 'account.bank.statement'
def button_confirm_bank(self, cr, uid, ids, context=None):
voucher_obj = self.pool.get('account.voucher')
voucher_ids = []
for statement in self.browse(cr, uid, ids, context=context):
voucher_ids += [line.voucher_id.id for line in statement.line_ids if line.voucher_id]
if voucher_ids:
voucher_obj.write(cr, uid, voucher_ids, {'active': True}, context=context)
return super(account_bank_statement, self).button_confirm_bank(cr, uid, ids, context=context)
def button_cancel(self, cr, uid, ids, context=None):
voucher_obj = self.pool.get('account.voucher')
for st in self.browse(cr, uid, ids, context=context):
voucher_ids = []
for line in st.line_ids:
if line.voucher_id:
voucher_ids.append(line.voucher_id.id)
voucher_obj.cancel_voucher(cr, uid, voucher_ids, context)
return super(account_bank_statement, self).button_cancel(cr, uid, ids, context=context)
def create_move_from_st_line(self, cr, uid, st_line_id, company_currency_id, next_number, context=None):
voucher_obj = self.pool.get('account.voucher')
move_line_obj = self.pool.get('account.move.line')
bank_st_line_obj = self.pool.get('account.bank.statement.line')
st_line = bank_st_line_obj.browse(cr, uid, st_line_id, context=context)
if st_line.voucher_id:
voucher_obj.write(cr, uid, [st_line.voucher_id.id],
{'number': next_number,
'date': st_line.date,
'period_id': st_line.statement_id.period_id.id},
context=context)
if st_line.voucher_id.state == 'cancel':
voucher_obj.action_cancel_draft(cr, uid, [st_line.voucher_id.id], context=context)
voucher_obj.signal_proforma_voucher(cr, uid, [st_line.voucher_id.id])
v = voucher_obj.browse(cr, uid, st_line.voucher_id.id, context=context)
bank_st_line_obj.write(cr, uid, [st_line_id], {
'move_ids': [(4, v.move_id.id, False)]
})
return move_line_obj.write(cr, uid, [x.id for x in v.move_ids], {'statement_id': st_line.statement_id.id}, context=context)
return super(account_bank_statement, self).create_move_from_st_line(cr, uid, st_line.id, company_currency_id, next_number, context=context)
def write(self, cr, uid, ids, vals, context=None):
# Restrict to modify the journal if we already have some voucher of reconciliation created/generated.
# Because the voucher keeps in memory the journal it was created with.
for bk_st in self.browse(cr, uid, ids, context=context):
if vals.get('journal_id') and bk_st.line_ids:
if any([x.voucher_id and True or False for x in bk_st.line_ids]):
raise osv.except_osv(_('Unable to Change Journal!'), _('You can not change the journal as you already reconciled some statement lines!'))
return super(account_bank_statement, self).write(cr, uid, ids, vals, context=context)
class account_bank_statement_line(osv.osv):
_inherit = 'account.bank.statement.line'
def onchange_partner_id(self, cr, uid, ids, partner_id, context=None):
res = super(account_bank_statement_line, self).onchange_partner_id(cr, uid, ids, partner_id, context=context)
if 'value' not in res:
res['value'] = {}
res['value'].update({'voucher_id' : False})
return res
def onchange_amount(self, cr, uid, ids, amount, context=None):
return {'value' : {'voucher_id' : False}}
def _amount_reconciled(self, cursor, user, ids, name, args, context=None):
if not ids:
return {}
res = {}
for line in self.browse(cursor, user, ids, context=context):
if line.voucher_id:
res[line.id] = line.voucher_id.amount#
else:
res[line.id] = 0.0
return res
def _check_amount(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context):
if obj.voucher_id:
diff = abs(obj.amount) - abs(obj.voucher_id.amount)
if not self.pool.get('res.currency').is_zero(cr, uid, obj.statement_id.currency, diff):
return False
return True
_constraints = [
(_check_amount, 'The amount of the voucher must be the same amount as the one on the statement line.', ['amount']),
]
_columns = {
'amount_reconciled': fields.function(_amount_reconciled,
string='Amount reconciled', type='float'),
'voucher_id': fields.many2one('account.voucher', 'Reconciliation'),
}
def unlink(self, cr, uid, ids, context=None):
voucher_obj = self.pool.get('account.voucher')
statement_line = self.browse(cr, uid, ids, context=context)
unlink_ids = []
for st_line in statement_line:
if st_line.voucher_id:
unlink_ids.append(st_line.voucher_id.id)
voucher_obj.unlink(cr, uid, unlink_ids, context=context)
return super(account_bank_statement_line, self).unlink(cr, uid, ids, context=context)
def resolve_o2m_operations(cr, uid, target_osv, operations, fields, context):
results = []
for operation in operations:

View File

@ -194,58 +194,6 @@
<field name="search_view_id" ref="view_voucher_filter"/>
</record>
<record id="view_bank_statement_form_invoice" model="ir.ui.view">
<field name="name">account.bank.statement.invoice.form.inherit</field>
<field name="model">account.bank.statement</field>
<field name="inherit_id" ref="account.view_bank_statement_form"/>
<field name="arch" type="xml">
<xpath expr="//div[@name='import_buttons']" position="inside">
<button class="oe_inline oe_stat_button" name="%(action_view_account_statement_from_invoice_lines)d"
string="Import Invoice" type="action"
attrs="{'invisible':[('state','=','confirm')]}" widget="statinfo" icon="fa-pencil-square-o"/>
</xpath>
</field>
</record>
<record id="view_bank_statement_form_voucher" model="ir.ui.view">
<field name="name">account.bank.statement.voucher.tree.inherit</field>
<field name="model">account.bank.statement</field>
<field name="inherit_id" ref="account.view_bank_statement_form"/>
<field name="arch" type="xml">
<xpath expr="//page[@name='statement_line_ids']/field[@name='line_ids']/tree/field[@name='amount']" position="after">
<field name="voucher_id" string="" widget="many2onebutton" options="{'label':{'create':'Reconcile','edit':'Edit Reconciliation'}}" context="{'line_type': type, 'default_type': amount &lt; 0 and 'payment' or 'receipt', 'type': amount &lt; 0 and 'payment' or 'receipt', 'default_partner_id': partner_id, 'default_journal_id': parent.journal_id, 'default_amount': abs(amount), 'default_reference': ref, 'default_date': date, 'default_name': name, 'default_active': False, 'account_id': account_id}"/>
</xpath>
<xpath expr="//page[@name='statement_line_ids']/field[@name='line_ids']/form/group/field[@name='sequence']" position="before">
<field name="voucher_id" widget="many2onebutton" options="{'label':{'create':'Reconcile','edit':'Edit Reconciliation'}}" context="{'line_type': type, 'default_type': amount &lt; 0 and 'payment' or 'receipt', 'type': amount &lt; 0 and 'payment' or 'receipt', 'default_partner_id': partner_id, 'default_journal_id': parent.journal_id, 'default_amount': abs(amount), 'default_reference': ref, 'default_date': date, 'default_name': name, 'default_active': False, 'account_id': account_id}"/>
</xpath>
<field name="amount" position="attributes">
<attribute name="on_change">onchange_amount(amount)</attribute>
</field>
</field>
</record>
<record id="view_cash_statement_tree_voucher" model="ir.ui.view">
<field name="name">account.cash.statement.voucher.tree.inherit</field>
<field name="model">account.bank.statement</field>
<field name="inherit_id" ref="account.view_bank_statement_form2"/>
<field name="arch" type="xml">
<xpath expr="//page/field[@name='line_ids']/tree/field[@name='amount']" position="after">
<field name="voucher_id" context="{'line_type': type, 'default_type': amount &lt; 0 and 'payment' or 'receipt', 'type': amount &lt; 0 and 'payment' or 'receipt', 'default_partner_id': partner_id, 'default_journal_id': parent.journal_id, 'default_amount': abs(amount), 'default_reference': ref, 'default_date': date, 'default_name': name, 'account_id': account_id}"/>
</xpath>
</field>
</record>
<record id="view_cash_statement_form_voucher" model="ir.ui.view">
<field name="name">account.cash.statement.voucher.form.inherit</field>
<field name="model">account.bank.statement</field>
<field name="inherit_id" ref="account.view_bank_statement_form2"/>
<field name="arch" type="xml">
<xpath expr="//page/field[@name='line_ids']/form/group/field[@name='amount']" position="after">
<field name="voucher_id" context="{'line_type': type, 'default_type': amount &lt; 0 and 'payment' or 'receipt', 'type': amount &lt; 0 and 'payment' or 'receipt', 'default_partner_id': partner_id, 'default_journal_id': parent.journal_id, 'default_amount': abs(amount), 'default_reference': ref, 'default_date': date, 'default_name': name, 'account_id': account_id}"/>
</xpath>
</field>
</record>
<!-- res.config form view -->
<record model="ir.ui.view" id="view_account_settings_currency_xchange_form">
<field name="name">account.config.settings.inherit</field>

View File

@ -22,7 +22,6 @@
import time
from openerp.osv import fields, osv
from openerp.tools.translate import _
class account_statement_from_invoice_lines(osv.osv_memory):
"""
@ -35,6 +34,7 @@ class account_statement_from_invoice_lines(osv.osv_memory):
}
def populate_statement(self, cr, uid, ids, context=None):
#TODO: can be moved in account module
if context is None:
context = {}
statement_id = context.get('statement_id', False)
@ -49,14 +49,11 @@ class account_statement_from_invoice_lines(osv.osv_memory):
statement_obj = self.pool.get('account.bank.statement')
statement_line_obj = self.pool.get('account.bank.statement.line')
currency_obj = self.pool.get('res.currency')
voucher_obj = self.pool.get('account.voucher')
voucher_line_obj = self.pool.get('account.voucher.line')
line_date = time.strftime('%Y-%m-%d')
statement = statement_obj.browse(cr, uid, statement_id, context=context)
# for each selected move lines
for line in line_obj.browse(cr, uid, line_ids, context=context):
voucher_res = {}
ctx = context.copy()
# take the date for computation of currency => use payment date
ctx['date'] = line_date
@ -70,55 +67,19 @@ class account_statement_from_invoice_lines(osv.osv_memory):
if line.amount_currency:
amount = currency_obj.compute(cr, uid, line.currency_id.id,
statement.currency.id, line.amount_currency, context=ctx)
elif (line.invoice and line.invoice.currency_id.id <> statement.currency.id):
elif (line.invoice and line.invoice.currency_id.id != statement.currency.id):
amount = currency_obj.compute(cr, uid, line.invoice.currency_id.id,
statement.currency.id, amount, context=ctx)
context.update({'move_line_ids': [line.id],
'invoice_id': line.invoice.id})
type = 'general'
ttype = amount < 0 and 'payment' or 'receipt'
sign = 1
if line.journal_id.type in ('sale', 'sale_refund'):
type = 'customer'
ttype = 'receipt'
elif line.journal_id.type in ('purchase', 'purhcase_refund'):
type = 'supplier'
ttype = 'payment'
sign = -1
result = voucher_obj.onchange_partner_id(cr, uid, [], partner_id=line.partner_id.id, journal_id=statement.journal_id.id, amount=sign*amount, currency_id= statement.currency.id, ttype=ttype, date=line_date, context=context)
voucher_res = { 'type': ttype,
'name': line.name,
'partner_id': line.partner_id.id,
'journal_id': statement.journal_id.id,
'account_id': result['value'].get('account_id', statement.journal_id.default_credit_account_id.id),
'company_id': statement.company_id.id,
'currency_id': statement.currency.id,
'date': statement.date,
'amount': sign*amount,
'payment_rate': result['value']['payment_rate'],
'payment_rate_currency_id': result['value']['payment_rate_currency_id'],
'period_id':statement.period_id.id}
voucher_id = voucher_obj.create(cr, uid, voucher_res, context=context)
voucher_line_dict = {}
for line_dict in result['value']['line_cr_ids'] + result['value']['line_dr_ids']:
move_line = line_obj.browse(cr, uid, line_dict['move_line_id'], context)
if line.move_id.id == move_line.move_id.id:
voucher_line_dict = line_dict
if voucher_line_dict:
voucher_line_dict.update({'voucher_id': voucher_id})
voucher_line_obj.create(cr, uid, voucher_line_dict, context=context)
statement_line_obj.create(cr, uid, {
'name': line.name or '?',
'amount': amount,
'type': type,
'partner_id': line.partner_id.id,
'account_id': line.account_id.id,
'statement_id': statement_id,
'ref': line.ref,
'voucher_id': voucher_id,
'date': statement.date,
}, context=context)
return {'type': 'ir.actions.act_window_close'}

View File

@ -89,9 +89,9 @@ description provided by the CODA configuration tables is based upon the CODA
V2.2 specifications.
If required, you can manually adjust the descriptions via the CODA configuration menu.
''',
'images' : ['images/coda_logs.jpeg','images/import_coda_logs.jpeg'],
'depends': ['account_voucher','base_iban', 'l10n_be_invoice_bba',],
'demo': [],
'images': ['images/coda_logs.jpeg', 'images/import_coda_logs.jpeg'],
'depends': ['account_voucher', 'base_iban', 'l10n_be_invoice_bba'],
'demo': ['l10n_be_coda_demo.xml'],
'data': [
'l10n_be_coda_wizard.xml',
'l10n_be_coda_view.xml',

View File

@ -25,8 +25,6 @@
<field name="name"/>
<field name="ref" readonly="0"/>
<field name="partner_id"/>
<field name="type" />
<field domain="[('type', '&lt;&gt;', 'view')]" name="account_id"/>
<field name="amount"/>
<field name="sequence" readonly="0"/>
</group>
@ -46,10 +44,7 @@
<field name="date"/>
<field name="name"/>
<field name="ref"/>
<field name="partner_id" on_change="onchange_partner_id(partner_id)"/>
<field name="type" on_change="onchange_type(partner_id, type)"/>
<field name="account_id" options='{"no_open":True}' domain="[('type', '&lt;&gt;', 'view')]"/>
<field name="analytic_account_id" groups="analytic.group_analytic_accounting" domain="[('type', '&lt;&gt;', 'view')]"/>
<field name="partner_id"/>
<field name="amount"/>
<field name="note"/>
</tree>
@ -66,17 +61,14 @@
<filter name="credit" string="Credit" domain="[('amount','&lt;',0)]" icon="terp-folder-orange" help="Credit Transactions."/>
<field name="statement_id"/>
<group expand="0" string="Extended Filters...">
<field name="account_id"/>
<field name="partner_id"/>
<field name="amount"/>
<field name="type"/>
<field name="note"/>
</group>
<newline/>
<group string="Group By..." expand="0">
<filter string="Partner" context="{'group_by':'partner_id'}" icon="terp-folder-green"/>
<filter string="Statement" context="{'group_by':'statement_id'}" icon="terp-folder-orange"/>
<filter string="Fin.Account" context="{'group_by':'account_id'}" icon="terp-folder-yellow"/>
</group>
</search>
</field>

View File

@ -10,7 +10,6 @@
<form string="Import CODA File" version="7.0">
<group col="2">
<field name="coda_data" filename="coda_fname"/>
<field name="temporary_account_id" />
</group>
<footer>
<button name="coda_parsing" string="_Import" type="object" class="oe_highlight"/>

View File

@ -37,20 +37,10 @@ class account_coda_import(osv.osv_memory):
'coda_data': fields.binary('CODA File', required=True),
'coda_fname': fields.char('CODA Filename', size=128, required=True),
'note': fields.text('Log'),
'temporary_account_id': fields.many2one('account.account', 'Temporary Account', domain="[('type','!=','view')]", help="It acts as a temporary account for general amount", required=True),
}
def _get_default_tmp_account(self, cr, uid, context):
tmp_accounts = self.pool.get('account.account').search(cr, uid, [('code', '=', '490000')])
if tmp_accounts and len(tmp_accounts) > 0:
tmp_account_id = tmp_accounts[0]
else:
tmp_account_id = False
return tmp_account_id
_defaults = {
'coda_fname': lambda *a: '',
'temporary_account_id': _get_default_tmp_account,
}
def coda_parsing(self, cr, uid, ids, context=None, batch=False, codafile=None, codafilename=None):
@ -64,7 +54,6 @@ class account_coda_import(osv.osv_memory):
try:
codafile = data.coda_data
codafilename = data.coda_fname
temporaryaccount = data.temporary_account_id.id
except:
raise osv.except_osv(_('Error'), _('Wizard in incorrect state. Please hit the Cancel button'))
return {}
@ -149,7 +138,6 @@ class account_coda_import(osv.osv_memory):
statementLine['amount'] = float(rmspaces(line[32:47])) / 1000
if statementLine['debit'] == '1':
statementLine['amount'] = - statementLine['amount']
statementLine['transaction_type'] = line[53]
statementLine['transactionDate'] = time.strftime(tools.DEFAULT_SERVER_DATE_FORMAT, time.strptime(rmspaces(line[47:53]), '%d%m%y'))
statementLine['transaction_family'] = rmspaces(line[54:56])
statementLine['transaction_code'] = rmspaces(line[56:58])
@ -211,7 +199,6 @@ class account_coda_import(osv.osv_memory):
infoLine['sequence'] = len(statement['lines']) + 1
infoLine['ref'] = rmspaces(line[2:10])
infoLine['transactionRef'] = rmspaces(line[10:31])
infoLine['transaction_type'] = line[31]
infoLine['transaction_family'] = rmspaces(line[32:34])
infoLine['transaction_code'] = rmspaces(line[34:36])
infoLine['transaction_category'] = rmspaces(line[36:39])
@ -304,91 +291,78 @@ class account_coda_import(osv.osv_memory):
if 'counterpartyAddress' in line and line['counterpartyAddress'] != '':
note.append(_('Counter Party Address') + ': ' + line['counterpartyAddress'])
line['name'] = "\n".join(filter(None, [line['counterpartyName'], line['communication']]))
line['transaction_type'] = 'general'
partner = None
partner_id = None
invoice = False
if line['communication_struct'] and 'communication_type' in line and line['communication_type'] == '101':
ids = self.pool.get('account.invoice').search(cr, uid, [('reference', '=', line['communication']), ('reference_type', '=', 'bba')])
if ids:
invoice = self.pool.get('account.invoice').browse(cr, uid, ids[0])
partner = invoice.partner_id
partner_id = partner.id
if invoice.type in ['in_invoice', 'in_refund'] and line['debit'] == '1':
line['transaction_type'] = 'supplier'
elif invoice.type in ['out_invoice', 'out_refund'] and line['debit'] == '0':
line['transaction_type'] = 'customer'
line['account'] = invoice.account_id.id
line['reconcile'] = False
if invoice.type in ['in_invoice', 'out_invoice']:
iml_ids = self.pool.get('account.move.line').search(cr, uid, [('move_id', '=', invoice.move_id.id), ('reconcile_id', '=', False), ('account_id.reconcile', '=', True)])
if iml_ids:
line['reconcile'] = iml_ids[0]
if line['reconcile']:
voucher_vals = {
'type': line['transaction_type'] == 'supplier' and 'payment' or 'receipt',
'name': line['name'],
'partner_id': partner_id,
'journal_id': statement['journal_id'].id,
'account_id': statement['journal_id'].default_credit_account_id.id,
'company_id': statement['journal_id'].company_id.id,
'currency_id': statement['journal_id'].company_id.currency_id.id,
'date': line['entryDate'],
'amount': abs(line['amount']),
'period_id': statement['period_id'],
'invoice_id': invoice.id,
}
context['invoice_id'] = invoice.id
voucher_vals.update(self.pool.get('account.voucher').onchange_partner_id(cr, uid, [],
partner_id=partner_id,
journal_id=statement['journal_id'].id,
amount=abs(line['amount']),
currency_id=statement['journal_id'].company_id.currency_id.id,
ttype=line['transaction_type'] == 'supplier' and 'payment' or 'receipt',
date=line['transactionDate'],
context=context
)['value'])
line_drs = []
for line_dr in voucher_vals['line_dr_ids']:
line_drs.append((0, 0, line_dr))
voucher_vals['line_dr_ids'] = line_drs
line_crs = []
for line_cr in voucher_vals['line_cr_ids']:
line_crs.append((0, 0, line_cr))
voucher_vals['line_cr_ids'] = line_crs
line['voucher_id'] = self.pool.get('account.voucher').create(cr, uid, voucher_vals, context=context)
# Gère les communications structurées
# TODO : à faire primer sur resolution_proposition : si la communication indique une facture, on la sélectionne
# if ids:
# invoice = self.pool.get('account.invoice').browse(cr, uid, ids[0])
# partner = invoice.partner_id
# partner_id = partner.id
# if invoice.type in ['in_invoice', 'in_refund'] and line['debit'] == '1':
# line['transaction_type'] = 'supplier'
# elif invoice.type in ['out_invoice', 'out_refund'] and line['debit'] == '0':
# line['transaction_type'] = 'customer'
# line['account'] = invoice.account_id.id
# line['reconcile'] = False
# if invoice.type in ['in_invoice', 'out_invoice']:
# iml_ids = self.pool.get('account.move.line').search(cr, uid, [('move_id', '=', invoice.move_id.id), ('reconcile_id', '=', False), ('account_id.reconcile', '=', True)])
# if iml_ids:
# line['reconcile'] = iml_ids[0]
# if line['reconcile']:
# voucher_vals = {
# 'type': line['transaction_type'] == 'supplier' and 'payment' or 'receipt',
# 'name': line['name'],
# 'partner_id': partner_id,
# 'journal_id': statement['journal_id'].id,
# 'account_id': statement['journal_id'].default_credit_account_id.id,
# 'company_id': statement['journal_id'].company_id.id,
# 'currency_id': statement['journal_id'].company_id.currency_id.id,
# 'date': line['entryDate'],
# 'amount': abs(line['amount']),
# 'period_id': statement['period_id'],
# 'invoice_id': invoice.id,
# }
# context['invoice_id'] = invoice.id
# voucher_vals.update(self.pool.get('account.voucher').onchange_partner_id(cr, uid, [],
# partner_id=partner_id,
# journal_id=statement['journal_id'].id,
# amount=abs(line['amount']),
# currency_id=statement['journal_id'].company_id.currency_id.id,
# ttype=line['transaction_type'] == 'supplier' and 'payment' or 'receipt',
# date=line['transactionDate'],
# context=context
# )['value'])
# line_drs = []
# for line_dr in voucher_vals['line_dr_ids']:
# line_drs.append((0, 0, line_dr))
# voucher_vals['line_dr_ids'] = line_drs
# line_crs = []
# for line_cr in voucher_vals['line_cr_ids']:
# line_crs.append((0, 0, line_cr))
# voucher_vals['line_cr_ids'] = line_crs
# line['voucher_id'] = self.pool.get('account.voucher').create(cr, uid, voucher_vals, context=context)
if 'counterpartyNumber' in line and line['counterpartyNumber']:
ids = self.pool.get('res.partner.bank').search(cr, uid, [('acc_number', '=', str(line['counterpartyNumber']))])
if ids and len(ids) > 0:
partner = self.pool.get('res.partner.bank').browse(cr, uid, ids[0], context=context).partner_id
partner_id = partner.id
if not invoice:
if line['debit'] == '0':
line['account'] = partner.property_account_receivable.id
if partner.customer:
line['transaction_type'] = 'customer'
elif line['debit'] == '1':
line['account'] = partner.property_account_payable.id
if partner.supplier:
line['transaction_type'] = 'supplier'
if not partner and not invoice:
line['account'] = temporaryaccount
if 'communication' in line and line['communication'] != '':
note.append(_('Communication') + ': ' + line['communication'])
if 'voucher_id' not in line:
line['voucher_id'] = None
data = {
'name': line['name'],
'note': "\n".join(note),
'date': line['entryDate'],
'amount': line['amount'],
'type': line['transaction_type'],
'partner_id': partner_id,
'account_id': line['account'],
'statement_id': statement['id'],
'ref': line['ref'],
'sequence': line['sequence'],
'voucher_id': line['voucher_id'],
'coda_account_number': line['counterpartyNumber'],
}
self.pool.get('account.bank.statement.line').create(cr, uid, data, context=context)

View File

@ -457,19 +457,13 @@ class pos_session(osv.osv):
if st.difference and st.journal_id.cash_control == True:
if st.difference > 0.0:
name= _('Point of Sale Profit')
account_id = st.journal_id.profit_account_id.id
else:
account_id = st.journal_id.loss_account_id.id
name= _('Point of Sale Loss')
if not account_id:
raise osv.except_osv( _('Error!'),
_("Please set your profit and loss accounts on your payment method '%s'. This will allow OpenERP to post the difference of %.2f in your ending balance. To close this session, you can update the 'Closing Cash Control' to avoid any difference.") % (st.journal_id.name,st.difference))
bsl.create(cr, uid, {
'statement_id': st.id,
'amount': st.difference,
'ref': record.name,
'name': name,
'account_id': account_id
}, context=context)
if st.journal_id.type == 'bank':
@ -820,20 +814,9 @@ class pos_order(osv.osv):
'amount': data['amount'],
'date': data.get('payment_date', time.strftime('%Y-%m-%d')),
'name': order.name + ': ' + (data.get('payment_name', '') or ''),
'partner_id': order.partner_id and order.partner_id.id or None,
}
account_def = property_obj.get(cr, uid, 'property_account_receivable', 'res.partner', context=context)
args['account_id'] = (order.partner_id and order.partner_id.property_account_receivable \
and order.partner_id.property_account_receivable.id) or (account_def and account_def.id) or False
args['partner_id'] = order.partner_id and order.partner_id.id or None
if not args['account_id']:
if not args['partner_id']:
msg = _('There is no receivable account defined to make payment.')
else:
msg = _('There is no receivable account defined to make payment for the partner: "%s" (id:%d).') % (order.partner_id.name, order.partner_id.id,)
raise osv.except_osv(_('Configuration Error!'), msg)
context.pop('pos_session_id', False)
journal_id = data.get('journal', False)
@ -855,7 +838,6 @@ class pos_order(osv.osv):
'statement_id' : statement_id,
'pos_statement_id' : order_id,
'journal_id' : journal_id,
'type' : 'customer',
'ref' : order.session_id.name,
})

View File

@ -68,13 +68,6 @@
<field name="statement_id"/>
<field name="amount"/>
</tree>
<form string="Statement lines" version="7.0">
<group col="4">
<field name="account_id"/>
<field name="amount"/>
<field name="statement_id" domain="[('company_id','=',parent.company_id),('state','=','open')]"/>
</group>
</form>
</field>
</page>
<page string="Extra Info">

View File

@ -1,5 +1,5 @@
-
In order to test Bank Statement feature of account I create a bank statement line and confirm it and check it's move created
In order to test the reports on Bank Statement defined in point_of_sale module, I create a bank statement line, confirm it and print the reports
-
I select the period and journal for the bank statement
-
@ -19,30 +19,31 @@
-
I create bank statement line
-
!python {model: account.bank.statement.line}: |
partner = self.onchange_partner_id(cr, uid, [], ref('base.res_partner_4'), context=None)
vals = {
'account_id': partner['value']['account_id'],
'amount': 1000.0,
'partner_id': ref('base.res_partner_4'),
'statement_id': ref('account_bank_statement_0'),
'name': 'EXT001'
}
vals.update(partner.get('value',{}))
line_id = self.create(cr, uid, vals)
assert line_id, "Account bank statement line has not been created"
!record {model: account.bank.statement.line, id: account_bank_statement_line_0}:
amount: 1000.0
partner_id: base.res_partner_4
statement_id: account_bank_statement_0
name: 'EXT001'
-
I compute bank statement using Compute button
-
!python {model: account.bank.statement}: |
self.button_dummy(cr, uid, [ref("account_bank_statement_0")])
-
I modify the bank statement and set the Closing Balance.
-
!record {model: account.bank.statement, id: account_bank_statement_0}:
balance_end_real: 1000.0
-
I reconcile the bank statement.
-
!python {model: account.bank.statement.line}: |
counterpart_line_dict = {
'account_id': self.pool.get('res.partner').browse(cr, uid, ref('base.res_partner_4')).property_account_receivable.id,
'name': "EXT001",
'credit': 1000.0
}
self.process_reconciliation(cr, uid, ref("account_bank_statement_line_0"), [counterpart_line_dict])
-
I confirm the bank statement using Confirm button
-