Merge lp:~camptocamp/banking-addons/bank-statement-reconcile-70-fix-logger into lp:banking-addons/bank-statement-reconcile-70

Proposed by Nicolas Bessi - Camptocamp
Status: Superseded
Proposed branch: lp:~camptocamp/banking-addons/bank-statement-reconcile-70-fix-logger
Merge into: lp:banking-addons/bank-statement-reconcile-70
Diff against target: 216 lines (+36/-41)
5 files modified
account_statement_base_completion/statement.py (+4/-2)
account_statement_base_import/statement.py (+7/-19)
account_statement_base_import/statement_view.xml (+6/-4)
account_statement_ext/statement.py (+2/-0)
account_statement_ext/statement_view.xml (+17/-16)
To merge this branch: bzr merge lp:~camptocamp/banking-addons/bank-statement-reconcile-70-fix-logger
Reviewer Review Type Date Requested Status
Joël Grand-Guillaume @ camptocamp Needs Fixing
Review via email: mp+145139@code.launchpad.net

This proposal has been superseded by a proposal from 2013-01-29.

Description of the change

Fix logger + use of mail thread system

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

Hi Nicolas,

Thanks for the merge and improvements. I would suggest not to delete the rec_log field for now as we may need it for one version more (to let the time to users to migrate their datas).

Could you please set it as deprecated instead of removing it ?

The rest looks good to me.

Thanks,

review: Needs Fixing
Revision history for this message
Nicolas Bessi - Camptocamp (nbessi-c2c-deactivatedaccount) wrote :

Hello,

I'll do it and will hide the rec_log field if empty.

But I think the log data here are not so valuable and it will means having duplicated place for same data. We do not log errors of importation wizard just the fact that a statement was imported with x line. Maybe we have a bug/design problem here...

The clean way would be an init function that create messages from existing logs but it is quite a work and potential bugs for a limited usage.

Any opinions?

Regards

Nicolas

78. By Nicolas Bessi - Camptocamp

[FIX] logger of account.bank.profile that was broken + use mail thread system

79. By Nicolas Bessi - Camptocamp

[IMP] historical logs

80. By Nicolas Bessi - Camptocamp

[IMP] use of deprecated keyword in signature

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account_statement_base_completion/statement.py'
2--- account_statement_base_completion/statement.py 2012-12-20 13:40:22 +0000
3+++ account_statement_base_completion/statement.py 2013-01-29 08:08:21 +0000
4@@ -286,6 +286,8 @@
5 pattern = ".*%s.*" % st_line.label
6 cr.execute(sql, (pattern,))
7 result = cr.fetchall()
8+ if not result:
9+ return res
10 if len(result) > 1:
11 raise ErrorTooManyPartner(
12 _('Line named "%s" (Ref:%s) was matched by more '
13@@ -442,9 +444,9 @@
14 if res:
15 compl_lines += 1
16 except ErrorTooManyPartner, exc:
17- msg += exc.value + "\n"
18+ msg += exc.__repr__() + "\n"
19 except Exception, exc:
20- msg += exc.value + "\n"
21+ msg += exc.__repr__() + "\n"
22 # vals = res and res.keys() or False
23 if res:
24 vals = res[line.id]
25
26=== modified file 'account_statement_base_import/statement.py'
27--- account_statement_base_import/statement.py 2012-12-20 13:40:22 +0000
28+++ account_statement_base_import/statement.py 2013-01-29 08:08:21 +0000
29@@ -43,7 +43,7 @@
30 help="Tic that box to automatically launch the completion "
31 "on each imported file using this profile."),
32 'last_import_date': fields.datetime("Last Import Date"),
33- 'rec_log': fields.text('log', readonly=True),
34+ 'rec_log': fields.text('log', readonly=True), # deprecated
35 'import_type': fields.selection(
36 get_import_type_selection,
37 'Type of import',
38@@ -55,29 +55,17 @@
39
40 def write_logs_after_import(self, cr, uid, ids, statement_id, num_lines, context):
41 """
42- Write the log in the logger + in the log field of the profile to report the user about
43- what has been done.
44+ Write the log in the logger
45
46 :param int/long statement_id: ID of the concerned account.bank.statement
47 :param int/long num_lines: Number of line that have been parsed
48 :return: True
49 """
50- if isinstance(ids, (int, long)):
51- ids = [ids]
52- for id in ids:
53- log = self.read(cr, uid, id, ['rec_log'], context=context)['rec_log']
54- log_line = log and log.split("\n") or []
55- import_date = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
56- log_line[0:0] = [import_date + ' : '
57- + _("Bank Statement ID %s have been imported with %s lines ") % (statement_id, num_lines)]
58- log = "\n".join(log_line)
59- self.write(cr, uid, id, {'rec_log': log, 'last_import_date': import_date}, context=context)
60- self.message_post(
61- cr,
62- uid,
63- [statement_id],
64- body=_('Statement ID %s have been imported with %s lines.') % (statement_id, num_lines),
65- context=context)
66+ self.message_post(cr,
67+ uid,
68+ ids,
69+ body=_('Statement ID %s have been imported with %s lines.') % (statement_id, num_lines),
70+ context=context)
71 return True
72
73 def prepare_global_commission_line_vals(
74
75=== modified file 'account_statement_base_import/statement_view.xml'
76--- account_statement_base_import/statement_view.xml 2012-12-18 20:38:21 +0000
77+++ account_statement_base_import/statement_view.xml 2013-01-29 08:08:21 +0000
78@@ -16,10 +16,12 @@
79 <field name="import_type"/>
80 <button name="%(account_statement_base_import.statement_importer_action)d"
81 string="Import Bank Statement"
82- type="action" icon="gtk-ok"
83+ type="action" icon="gtk-ok"
84 colspan = "2"/>
85- <separator colspan="4" string="Import Logs"/>
86- <field name="rec_log" colspan="4" nolabel="1"/>
87+ <group attrs="{'invisible': [('rec_log', '=', False)]}">
88+ <separator colspan="4" string="Historical Import Logs"/>
89+ <field name="rec_log" colspan="4" nolabel="1" />
90+ </group>
91 </field>
92 </field>
93 </record>
94@@ -39,6 +41,6 @@
95 </field>
96 </record>
97
98-
99+
100 </data>
101 </openerp>
102
103=== modified file 'account_statement_ext/statement.py'
104--- account_statement_ext/statement.py 2012-12-20 13:41:45 +0000
105+++ account_statement_ext/statement.py 2013-01-29 08:08:21 +0000
106@@ -31,6 +31,8 @@
107 journal to use, the partner and commision account and so on.
108 """
109 _name = "account.statement.profile"
110+ _inherit = ['mail.thread']
111+
112 _description = "Statement Profil"
113
114 _columns = {
115
116=== modified file 'account_statement_ext/statement_view.xml'
117--- account_statement_ext/statement_view.xml 2013-01-10 14:51:19 +0000
118+++ account_statement_ext/statement_view.xml 2013-01-29 08:08:21 +0000
119@@ -18,6 +18,7 @@
120 <field name="force_partner_on_bank"/>
121 <field name="balance_check"/>
122 <field name="bank_statement_prefix"/>
123+ <field name="message_ids" widget="mail_thread" placeholder="Share a note..." colspan="4"/>
124 </form>
125 </field>
126 </record>
127@@ -46,10 +47,10 @@
128 <field name="view_mode">tree,form</field>
129 </record>
130
131- <menuitem string="Bank Statements Profile" action="action_treasury_statement_profile_tree" id="menu_treasury_statement_profile_tree" parent="account.menu_configuration_misc" sequence="30"/>
132-
133-
134-
135+ <menuitem string="Bank Statements Profile" action="action_treasury_statement_profile_tree" id="menu_treasury_statement_profile_tree" parent="account.menu_configuration_misc" sequence="30"/>
136+
137+
138+
139 <record id="view_treasury_statement_search" model="ir.ui.view">
140 <field name="name">account.bank.statement.search</field>
141 <field name="model">account.bank.statement</field>
142@@ -87,7 +88,7 @@
143 </field>
144 </record>
145
146-
147+
148 <record id="view_treasury_statement_form" model="ir.ui.view">
149 <field name="name">account.bank.statement.form</field>
150 <field name="model">account.bank.statement</field>
151@@ -98,7 +99,7 @@
152 <!-- Add before the group : profile and related infos -->
153 <xpath expr="/form/sheet/group/group/field[@name='journal_id']" position="replace">
154 </xpath>
155-
156+
157 <xpath expr="/form/sheet/group" position="after">
158 <group>
159 <field name="profile_id" select="1" required="1" on_change="onchange_imp_config_id(profile_id)" widget="selection"/>
160@@ -109,7 +110,7 @@
161 <field name="balance_check" invisible="1"/>
162 </group>
163 </xpath>
164-
165+
166 # Make balance visible or not depending on profile
167 <xpath expr="/form/sheet/group/group/field[@name='balance_start']" position="attributes">
168 <attribute name="attrs">{'invisible':[('balance_check','=',False)]}</attribute>
169@@ -120,11 +121,11 @@
170 <xpath expr="/form/sheet/group/group/field[@name='balance_end_real']" position="after">
171 <field name="balance_end" widget="monetary" options='{"currency_field" : "currency"}' attrs="{'invisible':[('balance_check','=',False)]}"/>
172 </xpath>
173-
174+
175 <xpath expr="/form/sheet/notebook/page/field/tree/field[@name='sequence']" position="after">
176 <field name="id" readonly="1" />
177 </xpath>
178-
179+
180 <xpath expr="/form/sheet/notebook/page/field/form/group/field[@name='date']" position="before">
181 <field name="id" readonly="1" />
182 </xpath>
183@@ -132,7 +133,7 @@
184 <xpath expr="/form/sheet/notebook/page/field/tree/field[@name='partner_id']" position="replace">
185 <field name="partner_id" on_change="onchange_partner_id(partner_id,parent.profile_id)" domain="['|',('parent_id','=',False),('is_company','=',True)]"/>
186 </xpath>
187-
188+
189 <xpath expr="/form/sheet/notebook/page/field/form/group/field[@name='partner_id']" position="replace">
190 <field name="partner_id" on_change="onchange_partner_id(partner_id,parent.profile_id)" domain="['|',('parent_id','=',False),('is_company','=',True)]"/>
191 </xpath>
192@@ -142,18 +143,18 @@
193 <xpath expr="/form/sheet/notebook/page/field/tree/field[@name='type']" position="replace">
194 <field name="type" on_change="onchange_type(partner_id, type, parent.profile_id)"/>
195 </xpath>
196-
197+
198 </field>
199 </record>
200
201-
202+
203 <act_window id="act_bank_statement_from_profile"
204- name="Open Statements"
205- res_model="account.bank.statement"
206- src_model="account.statement.profile"
207+ name="Open Statements"
208+ res_model="account.bank.statement"
209+ src_model="account.statement.profile"
210 domain="[('profile_id','=',active_id),]"
211 view_type="form"/>
212-
213+
214
215 </data>
216 </openerp>

Subscribers

People subscribed via source and target branches