Merge lp:~akretion-team/banking-addons/bank-statement-reconcile-70-api-improvement into lp:banking-addons/bank-statement-reconcile-70

Proposed by Sébastien BEAU - http://www.akretion.com
Status: Needs review
Proposed branch: lp:~akretion-team/banking-addons/bank-statement-reconcile-70-api-improvement
Merge into: lp:banking-addons/bank-statement-reconcile-70
Diff against target: 156 lines (+18/-28)
8 files modified
account_statement_bankaccount_completion/statement.py (+0/-3)
account_statement_base_completion/statement.py (+7/-1)
account_statement_base_import/statement.py (+7/-4)
account_statement_ofx_import/statement.py (+2/-2)
account_statement_regex_account_completion/statement.py (+0/-1)
account_statement_so_completion/statement.py (+0/-3)
account_statement_transactionid_completion/statement.py (+0/-3)
account_statement_transactionid_import/statement.py (+2/-11)
To merge this branch: bzr merge lp:~akretion-team/banking-addons/bank-statement-reconcile-70-api-improvement
Reviewer Review Type Date Requested Status
Yannick Vaucher @ Camptocamp code review, no test Approve
Stéphane Bidoul (Acsone) (community) code review Needs Information
Pedro Manuel Baeza code review Approve
Joël Grand-Guillaume @ camptocamp code review, no tests Approve
Guewen Baconnier @ Camptocamp Pending
Review via email: mp+197774@code.launchpad.net

Description of the change

Hi
I just made some change so it's easier to inherit the actual method.

To post a comment you must log in.
Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote :

Hi,

Thanks for the contrib, LGTM

Regards

review: Approve (code review, no tests)
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

LGTM

review: Approve (code review)
Revision history for this message
Stéphane Bidoul (Acsone) (sbi) wrote :

LGTM.

Perhaps this MP should update the code everywhere _get_function is used (bank_statement_account_completion, account_statement_regex_account_completion, account_statement_so_completion, account_statement_transactionid_completion)?

review: Needs Information (code review)
Revision history for this message
Sébastien BEAU - http://www.akretion.com (sebastien.beau) wrote :

Hi Stéphane, I agree it will be great to always use this everywhere in banking addons and better in all OCA module! we can update the MP in this direction.

After thinking twice, and before we change it everywhere. I am not sure that using get_... and _get... is a good idea because the "get_..." method didn't have as signature the "cr, uid, ids...."

Maybe it will be better to use _get and __get ?

def _get_functions(self, cr, uid, context=None):
    """
    List of available methods for rules. Override this to add you own.
    """
    #Add you code here ....

def __get_functions(self, cr, uid, context=None):
        """
        This method can not be inherited call get_functions instead
        """
        return self._get_functions(cr, uid, context=context)

We can use this convention everywhere in OCA double underscore : "__" mean that you can not inherit the method because OpenERP call it directly.

What you you think?

Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

Agreed with Sébastien on "__", selection fields and function field should be inheritable and that mean modules with this one as dependency should be changed as well.

review: Needs Fixing (code review)
104. By Florian da Costa

[MERGE]

105. By Florian da Costa

[FIX] Change convention for selection fields and function : __function(...)

Revision history for this message
Florian da Costa (florian-dacosta) wrote :

I made these changes in all the modules of the branch for the functions get_import_type_selection (account_statement_base_import) and get_functions (account_statement_base_completion)

Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

LGTM thanks for the changes

review: Approve (code review, no test)
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

This project is now hosted on https://github.com/OCA/bank-statement-reconcile. Please move your proposal there. This guide may help you https://github.com/OCA/maintainers-tools/wiki/How-to-move-a-Merge-Proposal-to-GitHub

Unmerged revisions

105. By Florian da Costa

[FIX] Change convention for selection fields and function : __function(...)

104. By Florian da Costa

[MERGE]

103. By Sébastien BEAU - http://www.akretion.com

[REF] add abstract function in order to inherit easily the function in other module.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'account_statement_bankaccount_completion/statement.py'
--- account_statement_bankaccount_completion/statement.py 2013-09-12 08:36:23 +0000
+++ account_statement_bankaccount_completion/statement.py 2014-05-14 11:50:22 +0000
@@ -38,9 +38,6 @@
38 'From bank account number (Normal or IBAN)'))38 'From bank account number (Normal or IBAN)'))
39 return res39 return res
4040
41 _columns = {
42 'function_to_call': fields.selection(_get_functions, 'Method'),
43 }
4441
45 def get_from_bank_account(self, cr, uid, st_line, context=None):42 def get_from_bank_account(self, cr, uid, st_line, context=None):
46 """43 """
4744
=== modified file 'account_statement_base_completion/statement.py'
--- account_statement_base_completion/statement.py 2014-05-06 12:22:55 +0000
+++ account_statement_base_completion/statement.py 2014-05-14 11:50:22 +0000
@@ -138,6 +138,12 @@
138 ('get_from_label_and_partner_field', 'From line label (based on partner field)'),138 ('get_from_label_and_partner_field', 'From line label (based on partner field)'),
139 ('get_from_label_and_partner_name', 'From line label (based on partner name)')]139 ('get_from_label_and_partner_name', 'From line label (based on partner name)')]
140140
141 def __get_functions(self, cr, uid, context=None):
142 """
143 Call method which can be inherited
144 """
145 return self._get_functions(cr, uid, context=context)
146
141 _columns = {147 _columns = {
142 'sequence': fields.integer('Sequence', help="Lower means parsed first."),148 'sequence': fields.integer('Sequence', help="Lower means parsed first."),
143 'name': fields.char('Name', size=128),149 'name': fields.char('Name', size=128),
@@ -145,7 +151,7 @@
145 'account.statement.profile',151 'account.statement.profile',
146 rel='as_rul_st_prof_rel',152 rel='as_rul_st_prof_rel',
147 string='Related statement profiles'),153 string='Related statement profiles'),
148 'function_to_call': fields.selection(_get_functions, 'Method'),154 'function_to_call': fields.selection(__get_functions, 'Method'),
149 }155 }
150156
151 def _find_invoice(self, cr, uid, st_line, inv_type, context=None):157 def _find_invoice(self, cr, uid, st_line, inv_type, context=None):
152158
=== modified file 'account_statement_base_import/statement.py'
--- account_statement_base_import/statement.py 2014-05-07 08:50:38 +0000
+++ account_statement_base_import/statement.py 2014-05-14 11:50:22 +0000
@@ -32,12 +32,15 @@
32class AccountStatementProfil(Model):32class AccountStatementProfil(Model):
33 _inherit = "account.statement.profile"33 _inherit = "account.statement.profile"
3434
35 def get_import_type_selection(self, cr, uid, context=None):35 def _get_import_type_selection(self, cr, uid, context=None):
36 """This is the method to be inherited for adding the parser"""36 """This is the method to be inherited for adding the parser"""
37 return [('generic_csvxls_so', 'Generic .csv/.xls based on SO Name')]37 return [('generic_csvxls_so', 'Generic .csv/.xls based on SO Name')]
3838
39 def _get_import_type_selection(self, cr, uid, context=None):39 def __get_import_type_selection(self, cr, uid, context=None):
40 return self.get_import_type_selection(cr, uid, context=context)40 """
41 Call method which can be inherited
42 """
43 return self._get_import_type_selection(cr, uid, context=context)
4144
42 _columns = {45 _columns = {
43 'launch_import_completion': fields.boolean(46 'launch_import_completion': fields.boolean(
@@ -48,7 +51,7 @@
48 # we remove deprecated as it floods logs in standard/warning level sob...51 # we remove deprecated as it floods logs in standard/warning level sob...
49 'rec_log': fields.text('log', readonly=True), # Deprecated52 'rec_log': fields.text('log', readonly=True), # Deprecated
50 'import_type': fields.selection(53 'import_type': fields.selection(
51 _get_import_type_selection,54 __get_import_type_selection,
52 'Type of import',55 'Type of import',
53 required=True,56 required=True,
54 help="Choose here the method by which you want to import bank"57 help="Choose here the method by which you want to import bank"
5558
=== modified file 'account_statement_ofx_import/statement.py'
--- account_statement_ofx_import/statement.py 2014-01-21 01:04:59 +0000
+++ account_statement_ofx_import/statement.py 2014-05-14 11:50:22 +0000
@@ -24,12 +24,12 @@
24class AccountStatementProfil(orm.Model):24class AccountStatementProfil(orm.Model):
25 _inherit = "account.statement.profile"25 _inherit = "account.statement.profile"
2626
27 def get_import_type_selection(self, cr, uid, context=None):27 def _get_import_type_selection(self, cr, uid, context=None):
28 """28 """
29 Inherited from parent to add parser.29 Inherited from parent to add parser.
30 """30 """
31 selection = super(AccountStatementProfil, self31 selection = super(AccountStatementProfil, self
32 ).get_import_type_selection(cr, uid,32 )._get_import_type_selection(cr, uid,
33 context=context)33 context=context)
34 selection.append(('ofx_so', _('OFX - Open Financial Exchange')))34 selection.append(('ofx_so', _('OFX - Open Financial Exchange')))
35 return selection35 return selection
3636
=== modified file 'account_statement_regex_account_completion/statement.py'
--- account_statement_regex_account_completion/statement.py 2014-01-20 09:06:39 +0000
+++ account_statement_regex_account_completion/statement.py 2014-05-14 11:50:22 +0000
@@ -47,7 +47,6 @@
47 return res47 return res
4848
49 _columns = {49 _columns = {
50 'function_to_call': fields.selection(_get_functions, 'Method'),
51 'regex': fields.char('Regular Expression', size=128),50 'regex': fields.char('Regular Expression', size=128),
52 'account_id': fields.many2one('account.account', string="Account to set"),51 'account_id': fields.many2one('account.account', string="Account to set"),
53 }52 }
5453
=== modified file 'account_statement_so_completion/statement.py'
--- account_statement_so_completion/statement.py 2013-12-20 15:45:19 +0000
+++ account_statement_so_completion/statement.py 2014-05-14 11:50:22 +0000
@@ -89,6 +89,3 @@
89 res.update(st_vals)89 res.update(st_vals)
90 return res90 return res
9191
92 _columns = {
93 'function_to_call': fields.selection(_get_functions, 'Method'),
94 }
9592
=== modified file 'account_statement_transactionid_completion/statement.py'
--- account_statement_transactionid_completion/statement.py 2014-01-17 15:07:46 +0000
+++ account_statement_transactionid_completion/statement.py 2014-05-14 11:50:22 +0000
@@ -41,9 +41,6 @@
41 ]41 ]
42 return res42 return res
4343
44 _columns = {
45 'function_to_call': fields.selection(_get_functions, 'Method'),
46 }
4744
48 def get_from_transaction_id_and_so(self, cr, uid, st_line, context=None):45 def get_from_transaction_id_and_so(self, cr, uid, st_line, context=None):
49 """46 """
5047
=== modified file 'account_statement_transactionid_import/statement.py'
--- account_statement_transactionid_import/statement.py 2012-12-20 13:37:01 +0000
+++ account_statement_transactionid_import/statement.py 2014-05-14 11:50:22 +0000
@@ -26,22 +26,13 @@
26class AccountStatementProfil(Model):26class AccountStatementProfil(Model):
27 _inherit = "account.statement.profile"27 _inherit = "account.statement.profile"
2828
29 def get_import_type_selection(self, cr, uid, context=None):29 def _get_import_type_selection(self, cr, uid, context=None):
30 """30 """
31 Has to be inherited to add parser31 Has to be inherited to add parser
32 """32 """
33 res = super(AccountStatementProfil, self).get_import_type_selection(33 res = super(AccountStatementProfil, self)._get_import_type_selection(
34 cr, uid, context=context)34 cr, uid, context=context)
35 res.append(('generic_csvxls_transaction',35 res.append(('generic_csvxls_transaction',
36 'Generic .csv/.xls based on SO transaction ID'))36 'Generic .csv/.xls based on SO transaction ID'))
37 return res37 return res
3838
39 _columns = {
40 'import_type': fields.selection(
41 get_import_type_selection,
42 'Type of import',
43 required=True,
44 help="Choose here the method by which you want to import "
45 "bank statement for this profile."),
46
47 }

Subscribers

People subscribed via source and target branches