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

Proposed by Omar (Pexego)
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 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)

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

Unmerged revisions

11. By Omar (Pexego)

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

10. By Omar (Pexego)

[FIX] Several fixes

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'account_payment_direct_debit/model/account_invoice.py'
--- account_payment_direct_debit/model/account_invoice.py 2014-02-11 18:29:05 +0000
+++ account_payment_direct_debit/model/account_invoice.py 2014-07-04 14:29:28 +0000
@@ -2,7 +2,7 @@
2##############################################################################2##############################################################################
3#3#
4# Copyright (C) 2011 - 2013 Therp BV (<http://therp.nl>).4# Copyright (C) 2011 - 2013 Therp BV (<http://therp.nl>).
5# 5#
6# All other contributions are (C) by their respective contributors6# All other contributions are (C) by their respective contributors
7#7#
8# All Rights Reserved8# All Rights Reserved
@@ -33,12 +33,12 @@
3333
34Invoice workflow:34Invoice workflow:
3535
361 the sale leads to 361 the sale leads to
37 1300 Debtors 10037 1300 Debtors 100
38 8000 Sales 10038 8000 Sales 100
3939
40Balance: 40Balance:
41 Debtors 2000 | 41 Debtors 2000 |
42 Sales | 200042 Sales | 2000
4343
442 an external booking takes place442 an external booking takes place
@@ -59,11 +59,11 @@
5959
60 2000 Transfer account 100 |60 2000 Transfer account 100 |
61 1300 Debtors | 10061 1300 Debtors | 100
62 Reconciliation takes place between 1 and 2a. 62 Reconciliation takes place between 1 and 2a.
63 The invoice gets set to state 'paid', and 'reconciled' = True63 The invoice gets set to state 'paid', and 'reconciled' = True
6464
65Balance:65Balance:
66 Debtors 0 | 66 Debtors 0 |
67 Transfer account 2000 |67 Transfer account 2000 |
68 Bank 0 |68 Bank 0 |
69 Sales | 200069 Sales | 2000
@@ -76,7 +76,7 @@
76 Reconciliation takes place between 3a and 2a76 Reconciliation takes place between 3a and 2a
7777
78Balance:78Balance:
79 Debtors 0 | 79 Debtors 0 |
80 Transfer account 0 |80 Transfer account 0 |
81 Bank 2000 |81 Bank 2000 |
82 Sales | 200082 Sales | 2000
@@ -84,59 +84,59 @@
844 a storno from invoice [1] triggers a new booking on the bank account844 a storno from invoice [1] triggers a new booking on the bank account
85 1300 Debtors 100 |85 1300 Debtors 100 |
86 1100 Bank | 10086 1100 Bank | 100
87 87
88Balance:88Balance:
89 Debtors 100 | 89 Debtors 100 |
90 Transfer account 0 |90 Transfer account 0 |
91 Bank 1900 |91 Bank 1900 |
92 Sales | 200092 Sales | 2000
9393
94 The reconciliation of 2a is undone. The booking of 2a is reconciled 94 The reconciliation of 2a is undone. The booking of 2a is reconciled
95 with the booking of 4 instead.95 with the booking of 4 instead.
96 The payment line attribute 'storno' is set to True and the invoice96 The payment line attribute 'storno' is set to True and the invoice
97 state is no longer 'paid'.97 state is no longer 'paid'.
9898
99Two cases need to be distinguisted:99Two cases need to be distinguisted:
100 1) If the storno is a manual storno from the partner, the invoice is set to100 1) If the storno is a manual storno from the partner, the invoice is set to
101 state 'debit_denied', with 'reconciled' = False 101 state 'debit_denied', with 'reconciled' = False
102 This module implements this option by allowing the bank module to call102 This module implements this option by allowing the bank module to call
103 103
104 netsvc.LocalService("workflow").trg_validate(104 netsvc.LocalService("workflow").trg_validate(
105 uid, 'account.invoice', ids, 'debit_denied', cr)105 uid, 'account.invoice', ids, 'debit_denied', cr)
106106
107 2) If the storno is an error generated by the bank (assumingly non-fatal),107 2) If the storno is an error generated by the bank (assumingly non-fatal),
108 the invoice is reopened for the next debit run. This is a call to existing108 the invoice is reopened for the next debit run. This is a call to existing
109 109
110 netsvc.LocalService("workflow").trg_validate(110 netsvc.LocalService("workflow").trg_validate(
111 uid, 'account.invoice', ids, 'open_test', cr)111 uid, 'account.invoice', ids, 'open_test', cr)
112112
113 Should also be adding a log entry on the invoice for tracing purposes113 Should also be adding a log entry on the invoice for tracing purposes
114114
115 self._log_event(cr, uid, ids, -1.0, 'Debit denied') 115 self._log_event(cr, uid, ids, -1.0, 'Debit denied')
116116
117 If not for that funny comment117 If not for that funny comment
118 "#TODO: implement messages system" in account/invoice.py118 "#TODO: implement messages system" in account/invoice.py
119119
120 Repeating non-fatal fatal errors need to be dealt with manually by checking120 Repeating non-fatal fatal errors need to be dealt with manually by checking
121 open invoices with a matured invoice- or due date.121 open invoices with a matured invoice- or due date.
122""" 122"""
123123
124class account_invoice(osv.osv):124class account_invoice(osv.osv):
125 _inherit = "account.invoice"125 _inherit = "account.invoice"
126126
127 def __init__(self, pool, cr):127 def __init__(self, pool, cr):
128 """ 128 """
129 Adding a state to the hardcoded state list of the inherited129 Adding a state to the hardcoded state list of the inherited
130 model. The alternative is duplicating the field definition 130 model. The alternative is duplicating the field definition
131 in columns but only one module can do that!131 in columns but only one module can do that!
132132
133 Maybe apply a similar trick when overriding the buttons' 'states' attributes133 Maybe apply a similar trick when overriding the buttons' 'states' attributes
134 in the form view, manipulating the xml in fields_view_get().134 in the form view, manipulating the xml in fields_view_get().
135 """ 135 """
136 super(account_invoice, self).__init__(pool, cr)136 super(account_invoice, self).__init__(pool, cr)
137 invoice_obj = pool.get('account.invoice')137 invoice_obj = pool.get('account.invoice')
138 invoice_obj._columns['state'].selection.append(138 if ('debit_denied', 'Debit denied') not in invoice_obj._columns['state'].selection:
139 ('debit_denied', 'Debit denied'))139 invoice_obj._columns['state'].selection.append(('debit_denied', 'Debit denied'))
140140
141 def action_debit_denied(self, cr, uid, ids, context=None):141 def action_debit_denied(self, cr, uid, ids, context=None):
142 for invoice_id in ids:142 for invoice_id in ids:
@@ -144,7 +144,7 @@
144 number = self.read(144 number = self.read(
145 cr, uid, invoice_id, ['number'], context=context)['number']145 cr, uid, invoice_id, ['number'], context=context)['number']
146 raise osv.except_osv(146 raise osv.except_osv(
147 _('Error !'), 147 _('Error !'),
148 _('You cannot set invoice \'%s\' to state \'debit denied\', ' +148 _('You cannot set invoice \'%s\' to state \'debit denied\', ' +
149 'as it is still reconciled.') % number)149 'as it is still reconciled.') % number)
150 self.write(cr, uid, ids, {'state': 'debit_denied'}, context=context)150 self.write(cr, uid, ids, {'state': 'debit_denied'}, context=context)
@@ -154,13 +154,13 @@
154 return True154 return True
155155
156 def test_undo_debit_denied(self, cr, uid, ids, context=None):156 def test_undo_debit_denied(self, cr, uid, ids, context=None):
157 """ 157 """
158 Called from the workflow. Used to unset paid state on158 Called from the workflow. Used to unset paid state on
159 invoices that were paid with bank transfers which are being cancelled 159 invoices that were paid with bank transfers which are being cancelled
160 """160 """
161 for invoice in self.read(cr, uid, ids, ['reconciled'], context):161 for invoice in self.read(cr, uid, ids, ['reconciled'], context):
162 if not invoice['reconciled']:162 if not invoice['reconciled']:
163 return False163 return False
164 return True164 return True
165165
166account_invoice()
167\ No newline at end of file166\ No newline at end of file
167account_invoice()
168168
=== modified file 'account_payment_direct_debit/view/account_invoice.xml'
--- account_payment_direct_debit/view/account_invoice.xml 2014-02-11 18:29:05 +0000
+++ account_payment_direct_debit/view/account_invoice.xml 2014-07-04 14:29:28 +0000
@@ -7,7 +7,7 @@
7 <field name="inherit_id" ref="account.invoice_form"/>7 <field name="inherit_id" ref="account.invoice_form"/>
8 <field name="arch" type="xml">8 <field name="arch" type="xml">
9 <data>9 <data>
10 <!-- 10 <!--
11 Add new state 'debit_denied' to applicable buttons.11 Add new state 'debit_denied' to applicable buttons.
12 Maybe apply trick in fields_view_get instead, for12 Maybe apply trick in fields_view_get instead, for
13 better compatibility with other modules?13 better compatibility with other modules?
@@ -19,6 +19,9 @@
19 <button name="invoice_debit_denied" states="paid"19 <button name="invoice_debit_denied" states="paid"
20 string="Debit Denied" icon="gtk-cancel"/>20 string="Debit Denied" icon="gtk-cancel"/>
21 </button>21 </button>
22 <button name="%(account.action_account_state_open)d" position="replace">
23 <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"/>
24 </button>
22 </data>25 </data>
23 </field>26 </field>
24 </record>27 </record>
2528
=== modified file 'account_payment_direct_debit/workflow/account_invoice.xml'
--- account_payment_direct_debit/workflow/account_invoice.xml 2014-02-11 18:29:05 +0000
+++ account_payment_direct_debit/workflow/account_invoice.xml 2014-07-04 14:29:28 +0000
@@ -8,7 +8,7 @@
8 <field name="kind">function</field>8 <field name="kind">function</field>
9 </record>9 </record>
10 <record id="paid_to_debit_denied" model="workflow.transition">10 <record id="paid_to_debit_denied" model="workflow.transition">
11 <!-- 11 <!--
12 Set an invoice to state debit denied, either manually12 Set an invoice to state debit denied, either manually
13 or by confirming a bank statement line that constitutes13 or by confirming a bank statement line that constitutes
14 a fatal storno14 a fatal storno
@@ -18,7 +18,7 @@
18 <field name="signal">invoice_debit_denied</field>18 <field name="signal">invoice_debit_denied</field>
19 </record>19 </record>
20 <record id="open_test_to_debit_denied" model="workflow.transition">20 <record id="open_test_to_debit_denied" model="workflow.transition">
21 <!-- 21 <!--
22 A storno leads to unreconciling the move line, which22 A storno leads to unreconciling the move line, which
23 reopens the invoice. We need to allow a transition from23 reopens the invoice. We need to allow a transition from
24 this state to the debit denied state if the storno is fatal.24 this state to the debit denied state if the storno is fatal.
@@ -28,17 +28,18 @@
28 <field name="signal">invoice_debit_denied</field>28 <field name="signal">invoice_debit_denied</field>
29 </record>29 </record>
30 <record id="debit_denied_to_paid" model="workflow.transition">30 <record id="debit_denied_to_paid" model="workflow.transition">
31 <!-- 31 <!--
32 Cancel a bank statement line that constitutes a fatal32 Cancel a bank statement line that constitutes a fatal
33 storno33 storno
34 -->34 -->
35 <field name="act_from" ref="act_debit_denied"/>35 <field name="act_from" ref="act_debit_denied"/>
36 <field name="act_to" ref="account.act_paid"/>36 <field name="act_to" ref="account.act_paid"/>
37 <field name="condition">test_undo_debit_denied()</field>37 <field name="trigger_model">account.move.line</field>
38 <field name="signal">undo_debit_denied</field>38 <field name="trigger_expr_id">move_line_id_payment_get()</field>
39 <field name="condition">test_paid()</field>
39 </record>40 </record>
40 <record id="debit_denied_to_open" model="workflow.transition">41 <record id="debit_denied_to_open" model="workflow.transition">
41 <!-- 42 <!--
42 Allow the user to manually reset a debit denied status43 Allow the user to manually reset a debit denied status
43 on a paid invoice (but only after manually unreconciling44 on a paid invoice (but only after manually unreconciling
44 the invoice)45 the invoice)
4546
=== modified file 'account_payment_pain_base/banking_export_pain.py'
--- account_payment_pain_base/banking_export_pain.py 2014-02-11 18:29:05 +0000
+++ account_payment_pain_base/banking_export_pain.py 2014-07-04 14:29:28 +0000
@@ -154,7 +154,6 @@
154 'file_id': file_id,154 'file_id': file_id,
155 'state': 'finish',155 'state': 'finish',
156 }, context=context)156 }, context=context)
157
158 action = {157 action = {
159 'name': 'SEPA File',158 'name': 'SEPA File',
160 'type': 'ir.actions.act_window',159 'type': 'ir.actions.act_window',
@@ -264,10 +263,10 @@
264 initiating_party_identifier = self.pool.get('res.company').\263 initiating_party_identifier = self.pool.get('res.company').\
265 _get_initiating_party_identifier(264 _get_initiating_party_identifier(
266 cr, uid,265 cr, uid,
267 gen_args['sepa_export'].payment_order_ids[0].mode.type.company_id.id,266 gen_args['sepa_export'].payment_order_ids[0].mode.company_id.id,
268 context=context)267 context=context)
269 initiating_party_issuer = gen_args['sepa_export'].\268 initiating_party_issuer = gen_args['sepa_export'].\
270 payment_order_ids[0].mode.type.company_id.initiating_party_issuer269 payment_order_ids[0].mode.company_id.initiating_party_issuer
271 if initiating_party_identifier and initiating_party_issuer:270 if initiating_party_identifier and initiating_party_issuer:
272 iniparty_id = etree.SubElement(initiating_party_1_8, 'Id')271 iniparty_id = etree.SubElement(initiating_party_1_8, 'Id')
273 iniparty_org_id = etree.SubElement(iniparty_id, 'OrgId')272 iniparty_org_id = etree.SubElement(iniparty_id, 'OrgId')
@@ -295,7 +294,7 @@
295 party_agent_bic = etree.SubElement(294 party_agent_bic = etree.SubElement(
296 party_agent_institution, gen_args.get('bic_xml_tag'))295 party_agent_institution, gen_args.get('bic_xml_tag'))
297 party_agent_bic.text = bic296 party_agent_bic.text = bic
298 except except_orm:297 except osv.except_osv:
299 if order == 'C':298 if order == 'C':
300 if iban[0:2] != gen_args['initiating_party_country_code']:299 if iban[0:2] != gen_args['initiating_party_country_code']:
301 raise osv.except_osv(300 raise osv.except_osv(
@@ -437,5 +436,5 @@
437 csi_scheme_name, 'Prtry')436 csi_scheme_name, 'Prtry')
438 csi_scheme_name_proprietary.text = scheme_name_proprietary437 csi_scheme_name_proprietary.text = scheme_name_proprietary
439 return True438 return True
440 439
441banking_export_pain()440banking_export_pain()
442441
=== modified file 'account_payment_sepa_credit_transfer/wizard/export_sepa.py'
--- account_payment_sepa_credit_transfer/wizard/export_sepa.py 2014-02-11 18:29:05 +0000
+++ account_payment_sepa_credit_transfer/wizard/export_sepa.py 2014-07-04 14:29:28 +0000
@@ -58,7 +58,7 @@
58 "to be borne by the creditor. Borne by debtor : all transaction "58 "to be borne by the creditor. Borne by debtor : all transaction "
59 "charges are to be borne by the debtor."),59 "charges are to be borne by the debtor."),
60 'nb_transactions': fields.related(60 'nb_transactions': fields.related(
61 'file_id', 'nb_transactions', type='integer',61 'file_id', 'nb_transactions', type='char',
62 string='Number of Transactions', readonly=True),62 string='Number of Transactions', readonly=True),
63 'total_amount': fields.related(63 'total_amount': fields.related(
64 'file_id', 'total_amount', type='float', string='Total Amount',64 'file_id', 'total_amount', type='float', string='Total Amount',
@@ -251,7 +251,7 @@
251 self.generate_party_block(251 self.generate_party_block(
252 cr, uid, credit_transfer_transaction_info_2_27, 'Cdtr',252 cr, uid, credit_transfer_transaction_info_2_27, 'Cdtr',
253 'C', 'line.partner_id.name', 'line.bank_id.iban',253 'C', 'line.partner_id.name', 'line.bank_id.iban',
254 'line.bank_id.bank.bic', line.bank_id.id, 254 'line.bank_id.bank.bic', line.bank_id.id,
255 {'line': line}, gen_args, context=context)255 {'line': line}, gen_args, context=context)
256256
257 self.generate_remittance_info_block(257 self.generate_remittance_info_block(
@@ -268,6 +268,10 @@
268 else:268 else:
269 nb_of_transactions_1_6.text = str(transactions_count_1_6)269 nb_of_transactions_1_6.text = str(transactions_count_1_6)
270 control_sum_1_7.text = '%.2f' % amount_control_sum_1_7270 control_sum_1_7.text = '%.2f' % amount_control_sum_1_7
271 # LLamada a set_done en payment.order para hacer movimientos contables del pago
272 # cuando create_account_moves = 'direct-payment'
273 payment_order_ids = context.get('active_ids', [])
274 self.pool.get('payment.order').set_done(cr, uid, payment_order_ids, context)
271 return self.finalize_sepa_file_creation(275 return self.finalize_sepa_file_creation(
272 cr, uid, ids, xml_root, total_amount, transactions_count_1_6,276 cr, uid, ids, xml_root, total_amount, transactions_count_1_6,
273 gen_args, context=context)277 gen_args, context=context)
274278
=== modified file 'account_payment_sepa_direct_debit/wizard/export_sdd.py'
--- account_payment_sepa_direct_debit/wizard/export_sdd.py 2014-02-11 18:29:05 +0000
+++ account_payment_sepa_direct_debit/wizard/export_sdd.py 2014-07-04 14:29:28 +0000
@@ -58,7 +58,7 @@
58 "borne by the creditor. Borne by debtor : all transaction "58 "borne by the creditor. Borne by debtor : all transaction "
59 "charges are to be borne by the debtor."),59 "charges are to be borne by the debtor."),
60 'nb_transactions': fields.related(60 'nb_transactions': fields.related(
61 'file_id', 'nb_transactions', type='integer',61 'file_id', 'nb_transactions', type='char',
62 string='Number of Transactions', readonly=True),62 string='Number of Transactions', readonly=True),
63 'total_amount': fields.related(63 'total_amount': fields.related(
64 'file_id', 'total_amount', type='float', string='Total Amount',64 'file_id', 'total_amount', type='float', string='Total Amount',
@@ -400,7 +400,11 @@
400 control_sum_2_5.text = '%.2f' % amount_control_sum_2_5400 control_sum_2_5.text = '%.2f' % amount_control_sum_2_5
401 nb_of_transactions_1_6.text = str(transactions_count_1_6)401 nb_of_transactions_1_6.text = str(transactions_count_1_6)
402 control_sum_1_7.text = '%.2f' % amount_control_sum_1_7402 control_sum_1_7.text = '%.2f' % amount_control_sum_1_7
403 403
404 # LLamada a set_done en payment.order para hacer movimientos contables del adeudo
405 # cuando create_account_moves = 'direct-payment'
406 payment_order_ids = context.get('active_ids', [])
407 self.pool.get('payment.order').set_done(cr, uid, payment_order_ids, context)
404 return self.finalize_sepa_file_creation(408 return self.finalize_sepa_file_creation(
405 cr, uid, ids, xml_root, total_amount, transactions_count_1_6,409 cr, uid, ids, xml_root, total_amount, transactions_count_1_6,
406 gen_args, context=context)410 gen_args, context=context)
@@ -451,4 +455,4 @@
451 'sepa_migrated': True,455 'sepa_migrated': True,
452 }, context=context)456 }, context=context)
453 return {'type': 'ir.actions.act_window_close'}457 return {'type': 'ir.actions.act_window_close'}
454banking_export_sdd_wizard()
455\ No newline at end of file458\ No newline at end of file
459banking_export_sdd_wizard()

Subscribers

People subscribed via source and target branches

to all changes: