[FIX] API Improvement

This commit is contained in:
florian-dacosta
2014-07-23 17:30:02 +02:00
parent 1d1ae5741c
commit c6e8ea5500
8 changed files with 18 additions and 32 deletions

View File

@@ -38,10 +38,6 @@ class AccountStatementCompletionRule(Model):
'From bank account number (Normal or IBAN)')) 'From bank account number (Normal or IBAN)'))
return res return res
_columns = {
'function_to_call': fields.selection(_get_functions, 'Method'),
}
def get_from_bank_account(self, cr, uid, st_line, context=None): def get_from_bank_account(self, cr, uid, st_line, context=None):
""" """
Match the partner based on the partner account number field Match the partner based on the partner account number field

View File

@@ -139,6 +139,12 @@ class AccountStatementCompletionRule(orm.Model):
('get_from_label_and_partner_field', 'From line label (based on partner field)'), ('get_from_label_and_partner_field', 'From line label (based on partner field)'),
('get_from_label_and_partner_name', 'From line label (based on partner name)')] ('get_from_label_and_partner_name', 'From line label (based on partner name)')]
def __get_functions(self, cr, uid, context=None):
"""
Call method which can be inherited
"""
return self._get_functions(cr, uid, context=context)
_columns = { _columns = {
'sequence': fields.integer('Sequence', help="Lower means parsed first."), 'sequence': fields.integer('Sequence', help="Lower means parsed first."),
'name': fields.char('Name', size=128), 'name': fields.char('Name', size=128),
@@ -146,7 +152,7 @@ class AccountStatementCompletionRule(orm.Model):
'account.statement.profile', 'account.statement.profile',
rel='as_rul_st_prof_rel', rel='as_rul_st_prof_rel',
string='Related statement profiles'), string='Related statement profiles'),
'function_to_call': fields.selection(_get_functions, 'Method'), 'function_to_call': fields.selection(__get_functions, 'Method'),
} }
def _find_invoice(self, cr, uid, st_line, inv_type, context=None): def _find_invoice(self, cr, uid, st_line, inv_type, context=None):

View File

@@ -32,12 +32,15 @@ from openerp.tools.config import config
class AccountStatementProfil(Model): class AccountStatementProfil(Model):
_inherit = "account.statement.profile" _inherit = "account.statement.profile"
def get_import_type_selection(self, cr, uid, context=None): def _get_import_type_selection(self, cr, uid, context=None):
"""This is the method to be inherited for adding the parser""" """This is the method to be inherited for adding the parser"""
return [('generic_csvxls_so', 'Generic .csv/.xls based on SO Name')] return [('generic_csvxls_so', 'Generic .csv/.xls based on SO Name')]
def _get_import_type_selection(self, cr, uid, context=None): def __get_import_type_selection(self, cr, uid, context=None):
return self.get_import_type_selection(cr, uid, context=context) """
Call method which can be inherited
"""
return self._get_import_type_selection(cr, uid, context=context)
_columns = { _columns = {
'launch_import_completion': fields.boolean( 'launch_import_completion': fields.boolean(
@@ -48,7 +51,7 @@ class AccountStatementProfil(Model):
# we remove deprecated as it floods logs in standard/warning level sob... # we remove deprecated as it floods logs in standard/warning level sob...
'rec_log': fields.text('log', readonly=True), # Deprecated 'rec_log': fields.text('log', readonly=True), # Deprecated
'import_type': fields.selection( 'import_type': fields.selection(
_get_import_type_selection, __get_import_type_selection,
'Type of import', 'Type of import',
required=True, required=True,
help="Choose here the method by which you want to import bank" help="Choose here the method by which you want to import bank"

View File

@@ -24,12 +24,12 @@ from openerp.osv import fields, orm
class AccountStatementProfil(orm.Model): class AccountStatementProfil(orm.Model):
_inherit = "account.statement.profile" _inherit = "account.statement.profile"
def get_import_type_selection(self, cr, uid, context=None): def _get_import_type_selection(self, cr, uid, context=None):
""" """
Inherited from parent to add parser. Inherited from parent to add parser.
""" """
selection = super(AccountStatementProfil, self selection = super(AccountStatementProfil, self
).get_import_type_selection(cr, uid, )._get_import_type_selection(cr, uid,
context=context) context=context)
selection.append(('ofx_so', _('OFX - Open Financial Exchange'))) selection.append(('ofx_so', _('OFX - Open Financial Exchange')))
return selection return selection

View File

@@ -47,7 +47,6 @@ class AccountStatementCompletionRule(Model):
return res return res
_columns = { _columns = {
'function_to_call': fields.selection(_get_functions, 'Method'),
'regex': fields.char('Regular Expression', size=128), 'regex': fields.char('Regular Expression', size=128),
'account_id': fields.many2one('account.account', string="Account to set"), 'account_id': fields.many2one('account.account', string="Account to set"),
} }

View File

@@ -88,7 +88,3 @@ class account_statement_completion_rule(orm.Model):
context=context) context=context)
res.update(st_vals) res.update(st_vals)
return res return res
_columns = {
'function_to_call': fields.selection(_get_functions, 'Method'),
}

View File

@@ -41,10 +41,6 @@ class AccountStatementCompletionRule(Model):
] ]
return res return res
_columns = {
'function_to_call': fields.selection(_get_functions, 'Method'),
}
def get_from_transaction_id_and_so(self, cr, uid, st_line, context=None): def get_from_transaction_id_and_so(self, cr, uid, st_line, context=None):
""" """
Match the partner based on the transaction ID field of the SO. Match the partner based on the transaction ID field of the SO.

View File

@@ -26,22 +26,12 @@ from openerp.osv import fields
class AccountStatementProfil(Model): class AccountStatementProfil(Model):
_inherit = "account.statement.profile" _inherit = "account.statement.profile"
def get_import_type_selection(self, cr, uid, context=None): def _get_import_type_selection(self, cr, uid, context=None):
""" """
Has to be inherited to add parser Has to be inherited to add parser
""" """
res = super(AccountStatementProfil, self).get_import_type_selection( res = super(AccountStatementProfil, self)._get_import_type_selection(
cr, uid, context=context) cr, uid, context=context)
res.append(('generic_csvxls_transaction', res.append(('generic_csvxls_transaction',
'Generic .csv/.xls based on SO transaction ID')) 'Generic .csv/.xls based on SO transaction ID'))
return res return res
_columns = {
'import_type': fields.selection(
get_import_type_selection,
'Type of import',
required=True,
help="Choose here the method by which you want to import "
"bank statement for this profile."),
}