[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)'))
return res
_columns = {
'function_to_call': fields.selection(_get_functions, 'Method'),
}
def get_from_bank_account(self, cr, uid, st_line, context=None):
"""
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_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 = {
'sequence': fields.integer('Sequence', help="Lower means parsed first."),
'name': fields.char('Name', size=128),
@@ -146,7 +152,7 @@ class AccountStatementCompletionRule(orm.Model):
'account.statement.profile',
rel='as_rul_st_prof_rel',
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):

View File

@@ -32,12 +32,15 @@ from openerp.tools.config import config
class AccountStatementProfil(Model):
_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"""
return [('generic_csvxls_so', 'Generic .csv/.xls based on SO Name')]
def _get_import_type_selection(self, cr, uid, context=None):
return self.get_import_type_selection(cr, uid, context=context)
def __get_import_type_selection(self, cr, uid, context=None):
"""
Call method which can be inherited
"""
return self._get_import_type_selection(cr, uid, context=context)
_columns = {
'launch_import_completion': fields.boolean(
@@ -48,7 +51,7 @@ class AccountStatementProfil(Model):
# we remove deprecated as it floods logs in standard/warning level sob...
'rec_log': fields.text('log', readonly=True), # Deprecated
'import_type': fields.selection(
_get_import_type_selection,
__get_import_type_selection,
'Type of import',
required=True,
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):
_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.
"""
selection = super(AccountStatementProfil, self
).get_import_type_selection(cr, uid,
)._get_import_type_selection(cr, uid,
context=context)
selection.append(('ofx_so', _('OFX - Open Financial Exchange')))
return selection

View File

@@ -47,7 +47,6 @@ class AccountStatementCompletionRule(Model):
return res
_columns = {
'function_to_call': fields.selection(_get_functions, 'Method'),
'regex': fields.char('Regular Expression', size=128),
'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)
res.update(st_vals)
return res
_columns = {
'function_to_call': fields.selection(_get_functions, 'Method'),
}

View File

@@ -41,10 +41,6 @@ class AccountStatementCompletionRule(Model):
]
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):
"""
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):
_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
"""
res = super(AccountStatementProfil, self).get_import_type_selection(
res = super(AccountStatementProfil, self)._get_import_type_selection(
cr, uid, context=context)
res.append(('generic_csvxls_transaction',
'Generic .csv/.xls based on SO transaction ID'))
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."),
}