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
1=== modified file 'account_statement_bankaccount_completion/statement.py'
2--- account_statement_bankaccount_completion/statement.py 2013-09-12 08:36:23 +0000
3+++ account_statement_bankaccount_completion/statement.py 2014-05-14 11:50:22 +0000
4@@ -38,9 +38,6 @@
5 'From bank account number (Normal or IBAN)'))
6 return res
7
8- _columns = {
9- 'function_to_call': fields.selection(_get_functions, 'Method'),
10- }
11
12 def get_from_bank_account(self, cr, uid, st_line, context=None):
13 """
14
15=== modified file 'account_statement_base_completion/statement.py'
16--- account_statement_base_completion/statement.py 2014-05-06 12:22:55 +0000
17+++ account_statement_base_completion/statement.py 2014-05-14 11:50:22 +0000
18@@ -138,6 +138,12 @@
19 ('get_from_label_and_partner_field', 'From line label (based on partner field)'),
20 ('get_from_label_and_partner_name', 'From line label (based on partner name)')]
21
22+ def __get_functions(self, cr, uid, context=None):
23+ """
24+ Call method which can be inherited
25+ """
26+ return self._get_functions(cr, uid, context=context)
27+
28 _columns = {
29 'sequence': fields.integer('Sequence', help="Lower means parsed first."),
30 'name': fields.char('Name', size=128),
31@@ -145,7 +151,7 @@
32 'account.statement.profile',
33 rel='as_rul_st_prof_rel',
34 string='Related statement profiles'),
35- 'function_to_call': fields.selection(_get_functions, 'Method'),
36+ 'function_to_call': fields.selection(__get_functions, 'Method'),
37 }
38
39 def _find_invoice(self, cr, uid, st_line, inv_type, context=None):
40
41=== modified file 'account_statement_base_import/statement.py'
42--- account_statement_base_import/statement.py 2014-05-07 08:50:38 +0000
43+++ account_statement_base_import/statement.py 2014-05-14 11:50:22 +0000
44@@ -32,12 +32,15 @@
45 class AccountStatementProfil(Model):
46 _inherit = "account.statement.profile"
47
48- def get_import_type_selection(self, cr, uid, context=None):
49+ def _get_import_type_selection(self, cr, uid, context=None):
50 """This is the method to be inherited for adding the parser"""
51 return [('generic_csvxls_so', 'Generic .csv/.xls based on SO Name')]
52
53- def _get_import_type_selection(self, cr, uid, context=None):
54- return self.get_import_type_selection(cr, uid, context=context)
55+ def __get_import_type_selection(self, cr, uid, context=None):
56+ """
57+ Call method which can be inherited
58+ """
59+ return self._get_import_type_selection(cr, uid, context=context)
60
61 _columns = {
62 'launch_import_completion': fields.boolean(
63@@ -48,7 +51,7 @@
64 # we remove deprecated as it floods logs in standard/warning level sob...
65 'rec_log': fields.text('log', readonly=True), # Deprecated
66 'import_type': fields.selection(
67- _get_import_type_selection,
68+ __get_import_type_selection,
69 'Type of import',
70 required=True,
71 help="Choose here the method by which you want to import bank"
72
73=== modified file 'account_statement_ofx_import/statement.py'
74--- account_statement_ofx_import/statement.py 2014-01-21 01:04:59 +0000
75+++ account_statement_ofx_import/statement.py 2014-05-14 11:50:22 +0000
76@@ -24,12 +24,12 @@
77 class AccountStatementProfil(orm.Model):
78 _inherit = "account.statement.profile"
79
80- def get_import_type_selection(self, cr, uid, context=None):
81+ def _get_import_type_selection(self, cr, uid, context=None):
82 """
83 Inherited from parent to add parser.
84 """
85 selection = super(AccountStatementProfil, self
86- ).get_import_type_selection(cr, uid,
87+ )._get_import_type_selection(cr, uid,
88 context=context)
89 selection.append(('ofx_so', _('OFX - Open Financial Exchange')))
90 return selection
91
92=== modified file 'account_statement_regex_account_completion/statement.py'
93--- account_statement_regex_account_completion/statement.py 2014-01-20 09:06:39 +0000
94+++ account_statement_regex_account_completion/statement.py 2014-05-14 11:50:22 +0000
95@@ -47,7 +47,6 @@
96 return res
97
98 _columns = {
99- 'function_to_call': fields.selection(_get_functions, 'Method'),
100 'regex': fields.char('Regular Expression', size=128),
101 'account_id': fields.many2one('account.account', string="Account to set"),
102 }
103
104=== modified file 'account_statement_so_completion/statement.py'
105--- account_statement_so_completion/statement.py 2013-12-20 15:45:19 +0000
106+++ account_statement_so_completion/statement.py 2014-05-14 11:50:22 +0000
107@@ -89,6 +89,3 @@
108 res.update(st_vals)
109 return res
110
111- _columns = {
112- 'function_to_call': fields.selection(_get_functions, 'Method'),
113- }
114
115=== modified file 'account_statement_transactionid_completion/statement.py'
116--- account_statement_transactionid_completion/statement.py 2014-01-17 15:07:46 +0000
117+++ account_statement_transactionid_completion/statement.py 2014-05-14 11:50:22 +0000
118@@ -41,9 +41,6 @@
119 ]
120 return res
121
122- _columns = {
123- 'function_to_call': fields.selection(_get_functions, 'Method'),
124- }
125
126 def get_from_transaction_id_and_so(self, cr, uid, st_line, context=None):
127 """
128
129=== modified file 'account_statement_transactionid_import/statement.py'
130--- account_statement_transactionid_import/statement.py 2012-12-20 13:37:01 +0000
131+++ account_statement_transactionid_import/statement.py 2014-05-14 11:50:22 +0000
132@@ -26,22 +26,13 @@
133 class AccountStatementProfil(Model):
134 _inherit = "account.statement.profile"
135
136- def get_import_type_selection(self, cr, uid, context=None):
137+ def _get_import_type_selection(self, cr, uid, context=None):
138 """
139 Has to be inherited to add parser
140 """
141- res = super(AccountStatementProfil, self).get_import_type_selection(
142+ res = super(AccountStatementProfil, self)._get_import_type_selection(
143 cr, uid, context=context)
144 res.append(('generic_csvxls_transaction',
145 'Generic .csv/.xls based on SO transaction ID'))
146 return res
147
148- _columns = {
149- 'import_type': fields.selection(
150- get_import_type_selection,
151- 'Type of import',
152- required=True,
153- help="Choose here the method by which you want to import "
154- "bank statement for this profile."),
155-
156- }

Subscribers

People subscribed via source and target branches