Merge lp:~pexego/sepa-tools/several_fixes-6.0 into lp:sepa-tools/6.0

Proposed by Omar (Pexego) on 2014-05-30
Status: Needs review
Proposed branch: lp:~pexego/sepa-tools/several_fixes-6.0
Merge into: lp:sepa-tools/6.0
Diff against target: 326 lines (+52/-41)
6 files modified
account_payment_direct_debit/model/account_invoice.py (+24/-24)
account_payment_direct_debit/view/account_invoice.xml (+4/-1)
account_payment_direct_debit/workflow/account_invoice.xml (+7/-6)
account_payment_pain_base/banking_export_pain.py (+4/-5)
account_payment_sepa_credit_transfer/wizard/export_sepa.py (+6/-2)
account_payment_sepa_direct_debit/wizard/export_sdd.py (+7/-3)
To merge this branch: bzr merge lp:~pexego/sepa-tools/several_fixes-6.0
Reviewer Review Type Date Requested Status
OpenERP SEPA Team 2014-05-30 Pending
Review via email: mp+221546@code.launchpad.net

Description of the change

Several fixes:

- The new debit_denied state in account_invoice object, was being created in init function but, it didn't check if state already had been created. Result: several debit_denied states registered in selection column of ir_model_fields, one for each server startup.
- I add reopen button in invoices with debit_denied state like paid state.
- Was impossible go out debit_denied state, because nowhere in code its signal was called, I changed its definition like open to paid behaviour, now, when test_paid is called, the workflow checks if can be moved from debit_denied to paid, newly.
- It was accessing to company, from payment type associated to payment mode, but, company field in payment type is not required because you can want share it between companies, I change it, to check the company in payment mode.
- I change the type of nb_transaction field from integer to char type, because in 6.0 there is a bug with integer function fields and you have to click twice in button to create xml file.

Other small fixes are required to work with these modules, but these are fixed in other merge proposal that we have to merge.

regards

To post a comment you must log in.
11. By Omar (Pexego) on 2014-07-04

[FIX] account_payment_pain_base: Changed one except_orm not supported in 6.0 to osv.osv_except

Unmerged revisions

11. By Omar (Pexego) on 2014-07-04

[FIX] account_payment_pain_base: Changed one except_orm not supported in 6.0 to osv.osv_except

10. By Omar (Pexego) on 2014-05-30

[FIX] Several fixes

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account_payment_direct_debit/model/account_invoice.py'
2--- account_payment_direct_debit/model/account_invoice.py 2014-02-11 18:29:05 +0000
3+++ account_payment_direct_debit/model/account_invoice.py 2014-07-04 14:29:28 +0000
4@@ -2,7 +2,7 @@
5 ##############################################################################
6 #
7 # Copyright (C) 2011 - 2013 Therp BV (<http://therp.nl>).
8-#
9+#
10 # All other contributions are (C) by their respective contributors
11 #
12 # All Rights Reserved
13@@ -33,12 +33,12 @@
14
15 Invoice workflow:
16
17-1 the sale leads to
18+1 the sale leads to
19 1300 Debtors 100
20 8000 Sales 100
21
22-Balance:
23- Debtors 2000 |
24+Balance:
25+ Debtors 2000 |
26 Sales | 2000
27
28 2 an external booking takes place
29@@ -59,11 +59,11 @@
30
31 2000 Transfer account 100 |
32 1300 Debtors | 100
33- Reconciliation takes place between 1 and 2a.
34+ Reconciliation takes place between 1 and 2a.
35 The invoice gets set to state 'paid', and 'reconciled' = True
36
37 Balance:
38- Debtors 0 |
39+ Debtors 0 |
40 Transfer account 2000 |
41 Bank 0 |
42 Sales | 2000
43@@ -76,7 +76,7 @@
44 Reconciliation takes place between 3a and 2a
45
46 Balance:
47- Debtors 0 |
48+ Debtors 0 |
49 Transfer account 0 |
50 Bank 2000 |
51 Sales | 2000
52@@ -84,59 +84,59 @@
53 4 a storno from invoice [1] triggers a new booking on the bank account
54 1300 Debtors 100 |
55 1100 Bank | 100
56-
57+
58 Balance:
59- Debtors 100 |
60+ Debtors 100 |
61 Transfer account 0 |
62 Bank 1900 |
63 Sales | 2000
64
65- The reconciliation of 2a is undone. The booking of 2a is reconciled
66+ The reconciliation of 2a is undone. The booking of 2a is reconciled
67 with the booking of 4 instead.
68 The payment line attribute 'storno' is set to True and the invoice
69 state is no longer 'paid'.
70
71 Two cases need to be distinguisted:
72 1) If the storno is a manual storno from the partner, the invoice is set to
73- state 'debit_denied', with 'reconciled' = False
74+ state 'debit_denied', with 'reconciled' = False
75 This module implements this option by allowing the bank module to call
76-
77+
78 netsvc.LocalService("workflow").trg_validate(
79 uid, 'account.invoice', ids, 'debit_denied', cr)
80
81 2) If the storno is an error generated by the bank (assumingly non-fatal),
82 the invoice is reopened for the next debit run. This is a call to existing
83-
84+
85 netsvc.LocalService("workflow").trg_validate(
86 uid, 'account.invoice', ids, 'open_test', cr)
87
88 Should also be adding a log entry on the invoice for tracing purposes
89
90- self._log_event(cr, uid, ids, -1.0, 'Debit denied')
91+ self._log_event(cr, uid, ids, -1.0, 'Debit denied')
92
93 If not for that funny comment
94 "#TODO: implement messages system" in account/invoice.py
95
96 Repeating non-fatal fatal errors need to be dealt with manually by checking
97 open invoices with a matured invoice- or due date.
98-"""
99+"""
100
101 class account_invoice(osv.osv):
102 _inherit = "account.invoice"
103
104 def __init__(self, pool, cr):
105- """
106+ """
107 Adding a state to the hardcoded state list of the inherited
108- model. The alternative is duplicating the field definition
109+ model. The alternative is duplicating the field definition
110 in columns but only one module can do that!
111
112 Maybe apply a similar trick when overriding the buttons' 'states' attributes
113 in the form view, manipulating the xml in fields_view_get().
114- """
115+ """
116 super(account_invoice, self).__init__(pool, cr)
117 invoice_obj = pool.get('account.invoice')
118- invoice_obj._columns['state'].selection.append(
119- ('debit_denied', 'Debit denied'))
120+ if ('debit_denied', 'Debit denied') not in invoice_obj._columns['state'].selection:
121+ invoice_obj._columns['state'].selection.append(('debit_denied', 'Debit denied'))
122
123 def action_debit_denied(self, cr, uid, ids, context=None):
124 for invoice_id in ids:
125@@ -144,7 +144,7 @@
126 number = self.read(
127 cr, uid, invoice_id, ['number'], context=context)['number']
128 raise osv.except_osv(
129- _('Error !'),
130+ _('Error !'),
131 _('You cannot set invoice \'%s\' to state \'debit denied\', ' +
132 'as it is still reconciled.') % number)
133 self.write(cr, uid, ids, {'state': 'debit_denied'}, context=context)
134@@ -154,13 +154,13 @@
135 return True
136
137 def test_undo_debit_denied(self, cr, uid, ids, context=None):
138- """
139+ """
140 Called from the workflow. Used to unset paid state on
141- invoices that were paid with bank transfers which are being cancelled
142+ invoices that were paid with bank transfers which are being cancelled
143 """
144 for invoice in self.read(cr, uid, ids, ['reconciled'], context):
145 if not invoice['reconciled']:
146 return False
147 return True
148
149-account_invoice()
150\ No newline at end of file
151+account_invoice()
152
153=== modified file 'account_payment_direct_debit/view/account_invoice.xml'
154--- account_payment_direct_debit/view/account_invoice.xml 2014-02-11 18:29:05 +0000
155+++ account_payment_direct_debit/view/account_invoice.xml 2014-07-04 14:29:28 +0000
156@@ -7,7 +7,7 @@
157 <field name="inherit_id" ref="account.invoice_form"/>
158 <field name="arch" type="xml">
159 <data>
160- <!--
161+ <!--
162 Add new state 'debit_denied' to applicable buttons.
163 Maybe apply trick in fields_view_get instead, for
164 better compatibility with other modules?
165@@ -19,6 +19,9 @@
166 <button name="invoice_debit_denied" states="paid"
167 string="Debit Denied" icon="gtk-cancel"/>
168 </button>
169+ <button name="%(account.action_account_state_open)d" position="replace">
170+ <button name="%(account.action_account_state_open)d" type='action' string='Re-Open' states='paid,debit_denied' icon="gtk-convert" groups="base.group_no_one"/>
171+ </button>
172 </data>
173 </field>
174 </record>
175
176=== modified file 'account_payment_direct_debit/workflow/account_invoice.xml'
177--- account_payment_direct_debit/workflow/account_invoice.xml 2014-02-11 18:29:05 +0000
178+++ account_payment_direct_debit/workflow/account_invoice.xml 2014-07-04 14:29:28 +0000
179@@ -8,7 +8,7 @@
180 <field name="kind">function</field>
181 </record>
182 <record id="paid_to_debit_denied" model="workflow.transition">
183- <!--
184+ <!--
185 Set an invoice to state debit denied, either manually
186 or by confirming a bank statement line that constitutes
187 a fatal storno
188@@ -18,7 +18,7 @@
189 <field name="signal">invoice_debit_denied</field>
190 </record>
191 <record id="open_test_to_debit_denied" model="workflow.transition">
192- <!--
193+ <!--
194 A storno leads to unreconciling the move line, which
195 reopens the invoice. We need to allow a transition from
196 this state to the debit denied state if the storno is fatal.
197@@ -28,17 +28,18 @@
198 <field name="signal">invoice_debit_denied</field>
199 </record>
200 <record id="debit_denied_to_paid" model="workflow.transition">
201- <!--
202+ <!--
203 Cancel a bank statement line that constitutes a fatal
204 storno
205 -->
206 <field name="act_from" ref="act_debit_denied"/>
207 <field name="act_to" ref="account.act_paid"/>
208- <field name="condition">test_undo_debit_denied()</field>
209- <field name="signal">undo_debit_denied</field>
210+ <field name="trigger_model">account.move.line</field>
211+ <field name="trigger_expr_id">move_line_id_payment_get()</field>
212+ <field name="condition">test_paid()</field>
213 </record>
214 <record id="debit_denied_to_open" model="workflow.transition">
215- <!--
216+ <!--
217 Allow the user to manually reset a debit denied status
218 on a paid invoice (but only after manually unreconciling
219 the invoice)
220
221=== modified file 'account_payment_pain_base/banking_export_pain.py'
222--- account_payment_pain_base/banking_export_pain.py 2014-02-11 18:29:05 +0000
223+++ account_payment_pain_base/banking_export_pain.py 2014-07-04 14:29:28 +0000
224@@ -154,7 +154,6 @@
225 'file_id': file_id,
226 'state': 'finish',
227 }, context=context)
228-
229 action = {
230 'name': 'SEPA File',
231 'type': 'ir.actions.act_window',
232@@ -264,10 +263,10 @@
233 initiating_party_identifier = self.pool.get('res.company').\
234 _get_initiating_party_identifier(
235 cr, uid,
236- gen_args['sepa_export'].payment_order_ids[0].mode.type.company_id.id,
237+ gen_args['sepa_export'].payment_order_ids[0].mode.company_id.id,
238 context=context)
239 initiating_party_issuer = gen_args['sepa_export'].\
240- payment_order_ids[0].mode.type.company_id.initiating_party_issuer
241+ payment_order_ids[0].mode.company_id.initiating_party_issuer
242 if initiating_party_identifier and initiating_party_issuer:
243 iniparty_id = etree.SubElement(initiating_party_1_8, 'Id')
244 iniparty_org_id = etree.SubElement(iniparty_id, 'OrgId')
245@@ -295,7 +294,7 @@
246 party_agent_bic = etree.SubElement(
247 party_agent_institution, gen_args.get('bic_xml_tag'))
248 party_agent_bic.text = bic
249- except except_orm:
250+ except osv.except_osv:
251 if order == 'C':
252 if iban[0:2] != gen_args['initiating_party_country_code']:
253 raise osv.except_osv(
254@@ -437,5 +436,5 @@
255 csi_scheme_name, 'Prtry')
256 csi_scheme_name_proprietary.text = scheme_name_proprietary
257 return True
258-
259+
260 banking_export_pain()
261
262=== modified file 'account_payment_sepa_credit_transfer/wizard/export_sepa.py'
263--- account_payment_sepa_credit_transfer/wizard/export_sepa.py 2014-02-11 18:29:05 +0000
264+++ account_payment_sepa_credit_transfer/wizard/export_sepa.py 2014-07-04 14:29:28 +0000
265@@ -58,7 +58,7 @@
266 "to be borne by the creditor. Borne by debtor : all transaction "
267 "charges are to be borne by the debtor."),
268 'nb_transactions': fields.related(
269- 'file_id', 'nb_transactions', type='integer',
270+ 'file_id', 'nb_transactions', type='char',
271 string='Number of Transactions', readonly=True),
272 'total_amount': fields.related(
273 'file_id', 'total_amount', type='float', string='Total Amount',
274@@ -251,7 +251,7 @@
275 self.generate_party_block(
276 cr, uid, credit_transfer_transaction_info_2_27, 'Cdtr',
277 'C', 'line.partner_id.name', 'line.bank_id.iban',
278- 'line.bank_id.bank.bic', line.bank_id.id,
279+ 'line.bank_id.bank.bic', line.bank_id.id,
280 {'line': line}, gen_args, context=context)
281
282 self.generate_remittance_info_block(
283@@ -268,6 +268,10 @@
284 else:
285 nb_of_transactions_1_6.text = str(transactions_count_1_6)
286 control_sum_1_7.text = '%.2f' % amount_control_sum_1_7
287+ # LLamada a set_done en payment.order para hacer movimientos contables del pago
288+ # cuando create_account_moves = 'direct-payment'
289+ payment_order_ids = context.get('active_ids', [])
290+ self.pool.get('payment.order').set_done(cr, uid, payment_order_ids, context)
291 return self.finalize_sepa_file_creation(
292 cr, uid, ids, xml_root, total_amount, transactions_count_1_6,
293 gen_args, context=context)
294
295=== modified file 'account_payment_sepa_direct_debit/wizard/export_sdd.py'
296--- account_payment_sepa_direct_debit/wizard/export_sdd.py 2014-02-11 18:29:05 +0000
297+++ account_payment_sepa_direct_debit/wizard/export_sdd.py 2014-07-04 14:29:28 +0000
298@@ -58,7 +58,7 @@
299 "borne by the creditor. Borne by debtor : all transaction "
300 "charges are to be borne by the debtor."),
301 'nb_transactions': fields.related(
302- 'file_id', 'nb_transactions', type='integer',
303+ 'file_id', 'nb_transactions', type='char',
304 string='Number of Transactions', readonly=True),
305 'total_amount': fields.related(
306 'file_id', 'total_amount', type='float', string='Total Amount',
307@@ -400,7 +400,11 @@
308 control_sum_2_5.text = '%.2f' % amount_control_sum_2_5
309 nb_of_transactions_1_6.text = str(transactions_count_1_6)
310 control_sum_1_7.text = '%.2f' % amount_control_sum_1_7
311-
312+
313+ # LLamada a set_done en payment.order para hacer movimientos contables del adeudo
314+ # cuando create_account_moves = 'direct-payment'
315+ payment_order_ids = context.get('active_ids', [])
316+ self.pool.get('payment.order').set_done(cr, uid, payment_order_ids, context)
317 return self.finalize_sepa_file_creation(
318 cr, uid, ids, xml_root, total_amount, transactions_count_1_6,
319 gen_args, context=context)
320@@ -451,4 +455,4 @@
321 'sepa_migrated': True,
322 }, context=context)
323 return {'type': 'ir.actions.act_window_close'}
324-banking_export_sdd_wizard()
325\ No newline at end of file
326+banking_export_sdd_wizard()

Subscribers

People subscribed via source and target branches

to all changes: