mirror of
https://github.com/OCA/account-reconcile.git
synced 2025-01-20 12:27:39 +02:00
[FIX] standardize the naming of the argument 'cr' instead of 'cursor'
This commit is contained in:
@@ -122,7 +122,7 @@ class AccountStatementCompletionRule(Model):
|
||||
'function_to_call': fields.selection(_get_functions, 'Method'),
|
||||
}
|
||||
|
||||
def get_from_ref_and_invoice(self, cursor, uid, line_id, context=None):
|
||||
def get_from_ref_and_invoice(self, cr, uid, line_id, context=None):
|
||||
"""
|
||||
Match the partner based on the invoice number and the reference of the statement
|
||||
line. Then, call the generic get_values_for_line method to complete other values.
|
||||
@@ -138,25 +138,25 @@ class AccountStatementCompletionRule(Model):
|
||||
...}
|
||||
"""
|
||||
st_obj = self.pool.get('account.bank.statement.line')
|
||||
st_line = st_obj.browse(cursor, uid, line_id, context=context)
|
||||
st_line = st_obj.browse(cr, uid, line_id, context=context)
|
||||
res = {}
|
||||
if st_line:
|
||||
inv_obj = self.pool.get('account.invoice')
|
||||
inv_id = inv_obj.search(
|
||||
cursor,
|
||||
cr,
|
||||
uid,
|
||||
[('number', '=', st_line.ref)],
|
||||
context=context)
|
||||
if inv_id:
|
||||
if inv_id and len(inv_id) == 1:
|
||||
inv = inv_obj.browse(cursor, uid, inv_id[0], context=context)
|
||||
inv = inv_obj.browse(cr, uid, inv_id[0], context=context)
|
||||
res['partner_id'] = inv.partner_id.id
|
||||
elif inv_id and len(inv_id) > 1:
|
||||
raise ErrorTooManyPartner(
|
||||
_('Line named "%s" (Ref:%s) was matched by more '
|
||||
'than one partner.') % (st_line.name, st_line.ref))
|
||||
st_vals = st_obj.get_values_for_line(
|
||||
cursor,
|
||||
cr,
|
||||
uid,
|
||||
profile_id=st_line.statement_id.profile_id.id,
|
||||
partner_id=res.get('partner_id', False),
|
||||
@@ -166,7 +166,7 @@ class AccountStatementCompletionRule(Model):
|
||||
res.update(st_vals)
|
||||
return res
|
||||
|
||||
def get_from_ref_and_so(self, cursor, uid, line_id, context=None):
|
||||
def get_from_ref_and_so(self, cr, uid, line_id, context=None):
|
||||
"""
|
||||
Match the partner based on the SO number and the reference of the statement
|
||||
line. Then, call the generic get_values_for_line method to complete other values.
|
||||
@@ -182,18 +182,18 @@ class AccountStatementCompletionRule(Model):
|
||||
...}
|
||||
"""
|
||||
st_obj = self.pool.get('account.bank.statement.line')
|
||||
st_line = st_obj.browse(cursor, uid, line_id, context=context)
|
||||
st_line = st_obj.browse(cr, uid, line_id, context=context)
|
||||
res = {}
|
||||
if st_line:
|
||||
so_obj = self.pool.get('sale.order')
|
||||
so_id = so_obj.search(
|
||||
cursor,
|
||||
cr,
|
||||
uid,
|
||||
[('name', '=', st_line.ref)],
|
||||
context=context)
|
||||
if so_id:
|
||||
if so_id and len(so_id) == 1:
|
||||
so = so_obj.browse(cursor, uid, so_id[0], context=context)
|
||||
so = so_obj.browse(cr, uid, so_id[0], context=context)
|
||||
res['partner_id'] = so.partner_id.id
|
||||
elif so_id and len(so_id) > 1:
|
||||
raise ErrorTooManyPartner(
|
||||
@@ -201,7 +201,7 @@ class AccountStatementCompletionRule(Model):
|
||||
'than one partner.') %
|
||||
(st_line.name, st_line.ref))
|
||||
st_vals = st_obj.get_values_for_line(
|
||||
cursor,
|
||||
cr,
|
||||
uid,
|
||||
profile_id=st_line.statement_id.profile_id.id,
|
||||
partner_id=res.get('partner_id', False),
|
||||
@@ -211,7 +211,7 @@ class AccountStatementCompletionRule(Model):
|
||||
res.update(st_vals)
|
||||
return res
|
||||
|
||||
def get_from_label_and_partner_field(self, cursor, uid, line_id, context=None):
|
||||
def get_from_label_and_partner_field(self, cr, uid, line_id, context=None):
|
||||
"""
|
||||
Match the partner based on the label field of the statement line
|
||||
and the text defined in the 'bank_statement_label' field of the partner.
|
||||
@@ -230,16 +230,16 @@ class AccountStatementCompletionRule(Model):
|
||||
"""
|
||||
partner_obj = self.pool.get('res.partner')
|
||||
st_obj = self.pool.get('account.bank.statement.line')
|
||||
st_line = st_obj.browse(cursor, uid, line_id, context=context)
|
||||
st_line = st_obj.browse(cr, uid, line_id, context=context)
|
||||
res = {}
|
||||
compt = 0
|
||||
if st_line:
|
||||
ids = partner_obj.search(
|
||||
cursor,
|
||||
cr,
|
||||
uid,
|
||||
[('bank_statement_label', '!=', False)],
|
||||
context=context)
|
||||
for partner in partner_obj.browse(cursor, uid, ids, context=context):
|
||||
for partner in partner_obj.browse(cr, uid, ids, context=context):
|
||||
for partner_label in partner.bank_statement_label.split(';'):
|
||||
if partner_label in st_line.label:
|
||||
compt += 1
|
||||
@@ -251,7 +251,7 @@ class AccountStatementCompletionRule(Model):
|
||||
(st_line.name, st_line.ref))
|
||||
if res:
|
||||
st_vals = st_obj.get_values_for_line(
|
||||
cursor,
|
||||
cr,
|
||||
uid,
|
||||
profile_id=st_line.statement_id.profile_id.id,
|
||||
partner_id=res.get('partner_id', False),
|
||||
@@ -261,7 +261,7 @@ class AccountStatementCompletionRule(Model):
|
||||
res.update(st_vals)
|
||||
return res
|
||||
|
||||
def get_from_label_and_partner_name(self, cursor, uid, line_id, context=None):
|
||||
def get_from_label_and_partner_name(self, cr, uid, line_id, context=None):
|
||||
"""
|
||||
Match the partner based on the label field of the statement line
|
||||
and the name of the partner.
|
||||
@@ -280,12 +280,12 @@ class AccountStatementCompletionRule(Model):
|
||||
# This Method has not been tested yet !
|
||||
res = {}
|
||||
st_obj = self.pool.get('account.bank.statement.line')
|
||||
st_line = st_obj.browse(cursor, uid, line_id, context=context)
|
||||
st_line = st_obj.browse(cr, uid, line_id, context=context)
|
||||
if st_line:
|
||||
sql = "SELECT id FROM res_partner WHERE name ~* %s"
|
||||
pattern = ".*%s.*" % st_line.label
|
||||
cursor.execute(sql, (pattern,))
|
||||
result = cursor.fetchall()
|
||||
cr.execute(sql, (pattern,))
|
||||
result = cr.fetchall()
|
||||
if len(result) > 1:
|
||||
raise ErrorTooManyPartner(
|
||||
_('Line named "%s" (Ref:%s) was matched by more '
|
||||
@@ -295,7 +295,7 @@ class AccountStatementCompletionRule(Model):
|
||||
res['partner_id'] = id
|
||||
if res:
|
||||
st_vals = st_obj.get_values_for_line(
|
||||
cursor,
|
||||
cr,
|
||||
uid,
|
||||
profile_id=st_line.statement_id.profile_id.id,
|
||||
partner_id=res.get('partner_id', False),
|
||||
|
||||
@@ -116,7 +116,7 @@ class AccountStatementProfil(Model):
|
||||
return comm_values
|
||||
|
||||
def prepare_statetement_lines_vals(
|
||||
self, cursor, uid, parser_vals, account_payable, account_receivable,
|
||||
self, cr, uid, parser_vals, account_payable, account_receivable,
|
||||
statement_id, context):
|
||||
"""
|
||||
Hook to build the values of a line from the parser returned values. At
|
||||
@@ -134,7 +134,7 @@ class AccountStatementProfil(Model):
|
||||
values = parser_vals
|
||||
values['statement_id'] = statement_id
|
||||
values['account_id'] = statement_obj.get_account_for_counterpart(
|
||||
cursor,
|
||||
cr,
|
||||
uid,
|
||||
parser_vals['amount'],
|
||||
account_receivable,
|
||||
@@ -142,7 +142,7 @@ class AccountStatementProfil(Model):
|
||||
)
|
||||
return values
|
||||
|
||||
def statement_import(self, cursor, uid, ids, profile_id, file_stream, ftype="csv", context=None):
|
||||
def statement_import(self, cr, uid, ids, profile_id, file_stream, ftype="csv", context=None):
|
||||
"""
|
||||
Create a bank statement with the given profile and parser. It will fullfill the bank statement
|
||||
with the values of the file providen, but will not complete data (like finding the partner, or
|
||||
@@ -163,7 +163,7 @@ class AccountStatementProfil(Model):
|
||||
raise osv.except_osv(
|
||||
_("No Profile !"),
|
||||
_("You must provide a valid profile to import a bank statement !"))
|
||||
prof = prof_obj.browse(cursor, uid, profile_id, context=context)
|
||||
prof = prof_obj.browse(cr, uid, profile_id, context=context)
|
||||
|
||||
parser = new_bank_statement_parser(prof.import_type, ftype=ftype)
|
||||
result_row_list = parser.parse(file_stream)
|
||||
@@ -177,27 +177,27 @@ class AccountStatementProfil(Model):
|
||||
"present in the bank statement line !") % col)
|
||||
|
||||
statement_id = statement_obj.create(
|
||||
cursor, uid, {'profile_id': prof.id}, context=context)
|
||||
cr, uid, {'profile_id': prof.id}, context=context)
|
||||
account_receivable, account_payable = statement_obj.get_default_pay_receiv_accounts(
|
||||
cursor, uid, context)
|
||||
cr, uid, context)
|
||||
try:
|
||||
# Record every line in the bank statement and compute the global commission
|
||||
# based on the commission_amount column
|
||||
for line in result_row_list:
|
||||
parser_vals = parser.get_st_line_vals(line)
|
||||
values = self.prepare_statetement_lines_vals(
|
||||
cursor, uid, parser_vals, account_payable,
|
||||
cr, uid, parser_vals, account_payable,
|
||||
account_receivable, statement_id, context)
|
||||
# we finally create the line in system
|
||||
statement_line_obj.create(cursor, uid, values, context=context)
|
||||
statement_line_obj.create(cr, uid, values, context=context)
|
||||
# Build and create the global commission line for the whole statement
|
||||
comm_vals = self.prepare_global_commission_line_vals(
|
||||
cursor, uid, parser, result_row_list, prof, statement_id, context)
|
||||
cr, uid, parser, result_row_list, prof, statement_id, context)
|
||||
if comm_vals:
|
||||
statement_line_obj.create(cursor, uid, comm_vals, context=context)
|
||||
statement_line_obj.create(cr, uid, comm_vals, context=context)
|
||||
|
||||
attachment_obj.create(
|
||||
cursor,
|
||||
cr,
|
||||
uid,
|
||||
{
|
||||
'name': 'statement file',
|
||||
@@ -212,14 +212,14 @@ class AccountStatementProfil(Model):
|
||||
)
|
||||
# If user ask to launch completion at end of import, do it !
|
||||
if prof.launch_import_completion:
|
||||
statement_obj.button_auto_completion(cursor, uid, [statement_id], context)
|
||||
statement_obj.button_auto_completion(cr, uid, [statement_id], context)
|
||||
|
||||
# Write the needed log infos on profile
|
||||
self.write_logs_after_import(
|
||||
cursor, uid, prof.id, statement_id, len(result_row_list), context)
|
||||
cr, uid, prof.id, statement_id, len(result_row_list), context)
|
||||
|
||||
except Exception:
|
||||
statement_obj.unlink(cursor, uid, [statement_id], context=context)
|
||||
statement_obj.unlink(cr, uid, [statement_id], context=context)
|
||||
error_type, error_value, trbk = sys.exc_info()
|
||||
st = "Error: %s\nDescription: %s\nTraceback:" % (error_type.__name__, error_value)
|
||||
st += ''.join(traceback.format_tb(trbk, 30))
|
||||
|
||||
@@ -97,16 +97,16 @@ class CreditPartnerStatementImporter(orm.TransientModel):
|
||||
raise Exception(_('Please use a file with an extention'))
|
||||
return ftype
|
||||
|
||||
def import_statement(self, cursor, uid, req_id, context=None):
|
||||
def import_statement(self, cr, uid, req_id, context=None):
|
||||
"""This Function import credit card agency statement"""
|
||||
context = context or {}
|
||||
if isinstance(req_id, list):
|
||||
req_id = req_id[0]
|
||||
importer = self.browse(cursor, uid, req_id, context)
|
||||
importer = self.browse(cr, uid, req_id, context)
|
||||
ftype = self._check_extension(importer.file_name)
|
||||
sid = self.pool.get(
|
||||
'account.statement.profile').statement_import(
|
||||
cursor,
|
||||
cr,
|
||||
uid,
|
||||
False,
|
||||
importer.profile_id.id,
|
||||
@@ -116,7 +116,7 @@ class CreditPartnerStatementImporter(orm.TransientModel):
|
||||
)
|
||||
model_obj = self.pool.get('ir.model.data')
|
||||
action_obj = self.pool.get('ir.actions.act_window')
|
||||
action_id = model_obj.get_object_reference(cursor, uid, 'account', 'action_bank_statement_tree')[1]
|
||||
res = action_obj.read(cursor, uid, action_id)
|
||||
action_id = model_obj.get_object_reference(cr, uid, 'account', 'action_bank_statement_tree')[1]
|
||||
res = action_obj.read(cr, uid, action_id)
|
||||
res['domain'] = res['domain'][:-1] + ",('id', '=', %d)]" % sid
|
||||
return res
|
||||
|
||||
@@ -27,8 +27,8 @@ from report_webkit import webkit_report
|
||||
|
||||
class BankStatementWebkit(report_sxw.rml_parse):
|
||||
|
||||
def __init__(self, cursor, uid, name, context):
|
||||
super(BankStatementWebkit, self).__init__(cursor, uid, name, context=context)
|
||||
def __init__(self, cr, uid, name, context):
|
||||
super(BankStatementWebkit, self).__init__(cr, uid, name, context=context)
|
||||
self.pool = pooler.get_pool(self.cr.dbname)
|
||||
self.cursor = self.cr
|
||||
|
||||
@@ -38,7 +38,7 @@ class BankStatementWebkit(report_sxw.rml_parse):
|
||||
company.name, company.currency_id.name))
|
||||
footer_date_time = self.formatLang(str(datetime.today())[:19], date_time=True)
|
||||
self.localcontext.update({
|
||||
'cr': cursor,
|
||||
'cr': cr,
|
||||
'uid': uid,
|
||||
'get_bank_statement': self._get_bank_statement_data,
|
||||
'report_name': _('BORDEREAU DE REMISE DE CHEQUES'),
|
||||
|
||||
@@ -148,12 +148,12 @@ class AccountBankSatement(Model):
|
||||
vals['journal_id'] = profile.journal_id.id
|
||||
return super(AccountBankSatement, self).create(cr, uid, vals, context=context)
|
||||
|
||||
def _get_period(self, cursor, uid, date, context=None):
|
||||
def _get_period(self, cr, uid, date, context=None):
|
||||
"""
|
||||
Find matching period for date, used in the statement line creation.
|
||||
"""
|
||||
period_obj = self.pool.get('account.period')
|
||||
periods = period_obj.find(cursor, uid, dt=date, context=context)
|
||||
periods = period_obj.find(cr, uid, dt=date, context=context)
|
||||
return periods and periods[0] or False
|
||||
|
||||
def _check_company_id(self, cr, uid, ids, context=None):
|
||||
@@ -354,7 +354,7 @@ class AccountBankSatement(Model):
|
||||
return self.write(cr, uid, ids, {'state': 'confirm'}, context=context)
|
||||
|
||||
def get_account_for_counterpart(
|
||||
self, cursor, uid, amount, account_receivable, account_payable):
|
||||
self, cr, uid, amount, account_receivable, account_payable):
|
||||
"""
|
||||
Give the amount, payable and receivable account (that can be found using
|
||||
get_default_pay_receiv_accounts method) and receive the one to use. This method
|
||||
@@ -378,7 +378,7 @@ class AccountBankSatement(Model):
|
||||
)
|
||||
return account_id
|
||||
|
||||
def get_default_pay_receiv_accounts(self, cursor, uid, context=None):
|
||||
def get_default_pay_receiv_accounts(self, cr, uid, context=None):
|
||||
"""
|
||||
We try to determine default payable/receivable accounts to be used as counterpart
|
||||
from the company default propoerty. This is to be used if there is no otherway to
|
||||
@@ -393,7 +393,7 @@ class AccountBankSatement(Model):
|
||||
property_obj = self.pool.get('ir.property')
|
||||
model_fields_obj = self.pool.get('ir.model.fields')
|
||||
model_fields_ids = model_fields_obj.search(
|
||||
cursor,
|
||||
cr,
|
||||
uid,
|
||||
[('name', 'in', ['property_account_receivable',
|
||||
'property_account_payable']),
|
||||
@@ -401,7 +401,7 @@ class AccountBankSatement(Model):
|
||||
context=context
|
||||
)
|
||||
property_ids = property_obj.search(
|
||||
cursor,
|
||||
cr,
|
||||
uid,
|
||||
[('fields_id', 'in', model_fields_ids),
|
||||
('res_id', '=', False),
|
||||
@@ -410,7 +410,7 @@ class AccountBankSatement(Model):
|
||||
)
|
||||
|
||||
for erp_property in property_obj.browse(
|
||||
cursor, uid, property_ids, context=context):
|
||||
cr, uid, property_ids, context=context):
|
||||
if erp_property.fields_id.name == 'property_account_receivable':
|
||||
account_receivable = erp_property.value_reference.id
|
||||
elif erp_property.fields_id.name == 'property_account_payable':
|
||||
@@ -465,16 +465,16 @@ class AccountBankSatementLine(Model):
|
||||
"""
|
||||
_inherit = "account.bank.statement.line"
|
||||
|
||||
def _get_period(self, cursor, user, context=None):
|
||||
def _get_period(self, cr, user, context=None):
|
||||
"""
|
||||
Return a period from a given date in the context.
|
||||
"""
|
||||
date = context.get('date', None)
|
||||
periods = self.pool.get('account.period').find(cursor, user, dt=date)
|
||||
periods = self.pool.get('account.period').find(cr, user, dt=date)
|
||||
return periods and periods[0] or False
|
||||
|
||||
def _get_default_account(self, cursor, user, context=None):
|
||||
return self.get_values_for_line(cursor, user, context=context)['account_id']
|
||||
def _get_default_account(self, cr, user, context=None):
|
||||
return self.get_values_for_line(cr, user, context=context)['account_id']
|
||||
|
||||
_columns = {
|
||||
# Set them as required + 64 char instead of 32
|
||||
|
||||
@@ -34,10 +34,10 @@ class SaleOrder(Model):
|
||||
help="Transaction id from the financial institute"),
|
||||
}
|
||||
|
||||
def _prepare_invoice(self, cursor, uid, order, lines, context=None):
|
||||
def _prepare_invoice(self, cr, uid, order, lines, context=None):
|
||||
#we put the transaction id in the generated invoices
|
||||
invoice_vals = super(SaleOrder, self)._prepare_invoice(
|
||||
cursor, uid, order, lines, context=context)
|
||||
cr, uid, order, lines, context=context)
|
||||
invoice_vals.update({
|
||||
'transaction_id': order.transaction_id})
|
||||
return invoice_vals
|
||||
|
||||
@@ -26,15 +26,15 @@ class StockPicking(Model):
|
||||
_inherit = "stock.picking"
|
||||
|
||||
def action_invoice_create(
|
||||
self, cursor, uid, ids, journal_id=False, group=False,
|
||||
self, cr, uid, ids, journal_id=False, group=False,
|
||||
type='out_invoice', context=None):
|
||||
res = super(StockPicking, self).action_invoice_create(
|
||||
cursor, uid, ids, journal_id, group, type, context)
|
||||
cr, uid, ids, journal_id, group, type, context)
|
||||
for pick_id in res:
|
||||
pick = self.browse(cursor, uid, pick_id, context=context)
|
||||
pick = self.browse(cr, uid, pick_id, context=context)
|
||||
if pick.sale_id and pick.sale_id.transaction_id:
|
||||
self.pool.get('account.invoice').write(
|
||||
cursor,
|
||||
cr,
|
||||
uid,
|
||||
res[pick_id],
|
||||
{'transaction_id': pick.sale_id.transaction_id},
|
||||
|
||||
Reference in New Issue
Block a user