Merge lp:~camptocamp/openerp-swiss-localization/7.0-wip-invoice-ref-transaction-id into lp:~camptocamp/openerp-swiss-localization/7.0
- 7.0-wip-invoice-ref-transaction-id
- Merge into 7.0
Status: | Superseded |
---|---|
Proposed branch: | lp:~camptocamp/openerp-swiss-localization/7.0-wip-invoice-ref-transaction-id |
Merge into: | lp:~camptocamp/openerp-swiss-localization/7.0 |
Diff against target: |
832 lines (+579/-89) 17 files modified
l10n_ch_base_bank/bank.py (+2/-0) l10n_ch_dta/wizard/create_dta.py (+8/-2) l10n_ch_dta_base_transaction_id/__init__.py (+22/-0) l10n_ch_dta_base_transaction_id/__openerp__.py (+48/-0) l10n_ch_dta_base_transaction_id/wizard/__init__.py (+3/-0) l10n_ch_dta_base_transaction_id/wizard/create_dta.py (+34/-0) l10n_ch_payment_slip/invoice.py (+80/-45) l10n_ch_payment_slip/wizard/bvr_import.py (+46/-42) l10n_ch_payment_slip_account_statement_base_completion/__init__.py (+23/-0) l10n_ch_payment_slip_account_statement_base_completion/__openerp__.py (+52/-0) l10n_ch_payment_slip_account_statement_base_completion/data.xml (+12/-0) l10n_ch_payment_slip_account_statement_base_completion/statement.py (+103/-0) l10n_ch_payment_slip_account_statement_base_completion/wizard/__init__.py (+3/-0) l10n_ch_payment_slip_account_statement_base_completion/wizard/bvr_import.py (+34/-0) l10n_ch_payment_slip_base_transaction_id/__init__.py (+22/-0) l10n_ch_payment_slip_base_transaction_id/__openerp__.py (+48/-0) l10n_ch_payment_slip_base_transaction_id/invoice.py (+39/-0) |
To merge this branch: | bzr merge lp:~camptocamp/openerp-swiss-localization/7.0-wip-invoice-ref-transaction-id |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Frederic Clementi - Camptocamp | Needs Fixing | ||
Joël Grand-Guillaume @ camptocamp | code review, no tests | Approve | |
Review via email: mp+203006@code.launchpad.net |
This proposal has been superseded by a proposal from 2014-03-21.
Commit message
Description of the change
Compatibility with the base_transaction_id module. No BVR number for invoices with a transaction id.
- 195. By Guewen Baconnier @ Camptocamp
-
typo
- 196. By Vincent Renaville@camptocamp
-
[FIX] use moveline transaction_ref field for payment reference instead of ref field
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote : | # |
- 197. By Guewen Baconnier @ Camptocamp
-
rename l10n_ch_
base_transactio n_id to l10n_ch_ payment_ slip_base_ transaction_ id because we'll have several 'link' modules - 198. By Guewen Baconnier @ Camptocamp
-
add a todo
- 199. By Guewen Baconnier @ Camptocamp
-
add a link module between l10n_ch_
payment_ slip and account_ statement_ base_completion : write the bvr ref in the transaction id of the bank statement lines - 200. By Guewen Baconnier @ Camptocamp
-
refactoring
- 201. By Guewen Baconnier @ Camptocamp
-
copy the bvr reference in the transaction_id field so we can use it for bank statement completion
- 202. By Guewen Baconnier @ Camptocamp
-
refactor, allow better extension by subclassing. fix a bug preventing the bvr number to be displayed on the invoice with multiple payment terms. Do no longer copy the bvr ref in the transaction_id field
- 203. By Guewen Baconnier @ Camptocamp
-
add a completion rule by BVR/ESR reference
- 204. By Guewen Baconnier @ Camptocamp
-
fix a bug when an account number is empty
- 205. By Guewen Baconnier @ Camptocamp
-
add a link module between l10n_ch_dta and base_transaction_id to create the DTA with the BVR ref of the lines
- 206. By Guewen Baconnier @ Camptocamp
-
copy the bvr reference of supplier invoices in the transaction_ref field of the move lines
- 207. By Guewen Baconnier @ Camptocamp
-
bank statements completion from bvr reference searches also for supplier invoices
- 208. By Guewen Baconnier @ Camptocamp
-
_set_bank_data returns None and expects elec_context to be modified in-place
- 209. By Guewen Baconnier @ Camptocamp
-
branch missing leading to local variable 'ref' referenced before assignment
- 210. By Guewen Baconnier @ Camptocamp
-
fix conditions and indentation
Frederic Clementi - Camptocamp (frederic-clementi) wrote : | # |
Customer invoices creation :
* BVR number is populated on all account move lines. it is no relevant. We should only have this information on the account move line containing the same account_id than the one indicated on the related invoice.
* The field call reference on the SO (and the webkit pdf also) becomes a description on the invoice and the move line. I suggest to call it description everywhere.
note that on the webkit invoice this information appears twice under the name Subject & You reference... which is not ideal as well
* Bank statement with all swiss modules :
-> button 'import invoice' : no BVR no populated into the transaction ref
-> button 'import payment lines' : no BVR no populated into the transaction ref (but ok in payment lines)
- butoon 'import BVR' - transaction ref is correctely populated but I should have the invoice number into the field 'reference' and a / into 'communication' (currentely it is the other way around so it is not consistent with all the new logic in place)
Thanks
Frederic
- 211. By Guewen Baconnier @ Camptocamp
-
the reference is already copied in the ref (and eventually in the transaction_id), useless and cumbersome to have it in the name too
- 212. By Guewen Baconnier @ Camptocamp
-
the transaction id is copied only on account move lines having the same account than the invoice's one (the payable / receivable), simplify the code
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote : | # |
> Customer invoices creation :
>
> * BVR number is populated on all account move lines. it is no relevant. We
> should only have this information on the account move line containing the same
> account_id than the one indicated on the related invoice.
Done (as well as for the transaction ids branch [0])
>
> * The field call reference on the SO (and the webkit pdf also) becomes a
> description on the invoice and the move line. I suggest to call it description
> everywhere.
> note that on the webkit invoice this information appears twice under the name
> Subject & You reference... which is not ideal as well
I won't rename the fields. This is the field name used by OpenERP and we should keep it even if it is bad, changing it will break the translations. We have 2 possible courses of action here: 1) propose a new name for the next OpenERP release and 2) change the name in a custom translation.
The "Your Reference" field is now hidden when both fields have the same content.
This is done in the account-
>
> * Bank statement with all swiss modules :
> -> button 'import invoice' : no BVR no populated into the transaction ref
Done in a new compatibility module (autoinstallable) account_
This is done in the generic MP [0], not in the swiss localization.
> -> button 'import payment lines' : no BVR no populated into the transaction
> ref (but ok in payment lines)
Added in account_
> - butoon 'import BVR' - transaction ref is correctely populated but I should
> have the invoice number into the field 'reference' and a / into
> 'communication' (currentely it is the other way around so it is not consistent
> with all the new logic in place)
Done.
>
> Thanks
>
> Frederic
[0] https:/
[1] https:/
Unmerged revisions
Preview Diff
1 | === modified file 'l10n_ch_base_bank/bank.py' | |||
2 | --- l10n_ch_base_bank/bank.py 2013-05-24 07:33:46 +0000 | |||
3 | +++ l10n_ch_base_bank/bank.py 2014-03-05 10:48:25 +0000 | |||
4 | @@ -162,6 +162,8 @@ | |||
5 | 162 | for p_bank in p_banks: | 162 | for p_bank in p_banks: |
6 | 163 | if not p_bank.state in ('bv', 'bvr'): | 163 | if not p_bank.state in ('bv', 'bvr'): |
7 | 164 | continue | 164 | continue |
8 | 165 | if not p_bank.get_account_number(): | ||
9 | 166 | continue | ||
10 | 165 | if not (self._check_9_pos_postal_num(p_bank.get_account_number()) or | 167 | if not (self._check_9_pos_postal_num(p_bank.get_account_number()) or |
11 | 166 | self._check_5_pos_postal_num(p_bank.get_account_number())): | 168 | self._check_5_pos_postal_num(p_bank.get_account_number())): |
12 | 167 | return False | 169 | return False |
13 | 168 | 170 | ||
14 | === modified file 'l10n_ch_dta/wizard/create_dta.py' | |||
15 | --- l10n_ch_dta/wizard/create_dta.py 2014-01-15 08:13:14 +0000 | |||
16 | +++ l10n_ch_dta/wizard/create_dta.py 2014-03-05 10:48:25 +0000 | |||
17 | @@ -490,11 +490,17 @@ | |||
18 | 490 | bank = payment.mode.bank_id | 490 | bank = payment.mode.bank_id |
19 | 491 | if not bank: | 491 | if not bank: |
20 | 492 | raise except_osv(_('Error'), _('No bank account for the company.')) | 492 | raise except_osv(_('Error'), _('No bank account for the company.')) |
22 | 493 | elec_context['comp_bank_name'] = bank.bank and bank.bank.name or False | 493 | if not bank.bank: |
23 | 494 | raise except_osv(_('Error'), | ||
24 | 495 | _('You must set a bank ' | ||
25 | 496 | 'for the bank account with number %s' % | ||
26 | 497 | bank.acc_number or '')) | ||
27 | 498 | elec_context['comp_bank_name'] = bank.bank.name | ||
28 | 494 | elec_context['comp_bank_clearing'] = bank.bank.clearing | 499 | elec_context['comp_bank_clearing'] = bank.bank.clearing |
29 | 495 | if not elec_context['comp_bank_clearing']: | 500 | if not elec_context['comp_bank_clearing']: |
30 | 496 | raise except_osv(_('Error'), | 501 | raise except_osv(_('Error'), |
32 | 497 | _('You must provide a Clearing Number for your bank account.')) | 502 | _('You must provide a Clearing Number ' |
33 | 503 | 'for the bank %s.' % bank.bank.name)) | ||
34 | 498 | company = payment.company_id | 504 | company = payment.company_id |
35 | 499 | co_addr = company.partner_id | 505 | co_addr = company.partner_id |
36 | 500 | elec_context['comp_country'] = co_addr.country_id and co_addr.country_id.name or '' | 506 | elec_context['comp_country'] = co_addr.country_id and co_addr.country_id.name or '' |
37 | 501 | 507 | ||
38 | === added directory 'l10n_ch_dta_base_transaction_id' | |||
39 | === added file 'l10n_ch_dta_base_transaction_id/__init__.py' | |||
40 | --- l10n_ch_dta_base_transaction_id/__init__.py 1970-01-01 00:00:00 +0000 | |||
41 | +++ l10n_ch_dta_base_transaction_id/__init__.py 2014-03-05 10:48:25 +0000 | |||
42 | @@ -0,0 +1,22 @@ | |||
43 | 1 | # -*- coding: utf-8 -*- | ||
44 | 2 | ############################################################################## | ||
45 | 3 | # | ||
46 | 4 | # Author: Guewen Baconnier | ||
47 | 5 | # Copyright 2014 Camptocamp SA | ||
48 | 6 | # | ||
49 | 7 | # This program is free software: you can redistribute it and/or modify | ||
50 | 8 | # it under the terms of the GNU Affero General Public License as | ||
51 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
52 | 10 | # License, or (at your option) any later version. | ||
53 | 11 | # | ||
54 | 12 | # This program is distributed in the hope that it will be useful, | ||
55 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
56 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
57 | 15 | # GNU Affero General Public License for more details. | ||
58 | 16 | # | ||
59 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
60 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
61 | 19 | # | ||
62 | 20 | ############################################################################## | ||
63 | 21 | |||
64 | 22 | from . import wizard | ||
65 | 0 | 23 | ||
66 | === added file 'l10n_ch_dta_base_transaction_id/__openerp__.py' | |||
67 | --- l10n_ch_dta_base_transaction_id/__openerp__.py 1970-01-01 00:00:00 +0000 | |||
68 | +++ l10n_ch_dta_base_transaction_id/__openerp__.py 2014-03-05 10:48:25 +0000 | |||
69 | @@ -0,0 +1,48 @@ | |||
70 | 1 | # -*- coding: utf-8 -*- | ||
71 | 2 | ############################################################################## | ||
72 | 3 | # | ||
73 | 4 | # Author: Guewen Baconnier | ||
74 | 5 | # Copyright 2014 Camptocamp SA | ||
75 | 6 | # | ||
76 | 7 | # This program is free software: you can redistribute it and/or modify | ||
77 | 8 | # it under the terms of the GNU Affero General Public License as | ||
78 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
79 | 10 | # License, or (at your option) any later version. | ||
80 | 11 | # | ||
81 | 12 | # This program is distributed in the hope that it will be useful, | ||
82 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
83 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
84 | 15 | # GNU Affero General Public License for more details. | ||
85 | 16 | # | ||
86 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
87 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
88 | 19 | # | ||
89 | 20 | ############################################################################## | ||
90 | 21 | |||
91 | 22 | {'name' : 'Swiss Localization Bank Payment File (DTA) - Transaction ID Compatibility', | ||
92 | 23 | 'version' : '1.0', | ||
93 | 24 | 'author' : 'Camptocamp', | ||
94 | 25 | 'maintainer': 'Camptocamp', | ||
95 | 26 | 'license': 'AGPL-3', | ||
96 | 27 | 'category': 'Hidden', | ||
97 | 28 | 'depends' : ['l10n_ch_dta', | ||
98 | 29 | 'base_transaction_id', # lp:banking-addons/bank-statement-reconcile-7.0 | ||
99 | 30 | ], | ||
100 | 31 | 'description': """ | ||
101 | 32 | Swiss Localization Bank Payment File (DTA) - Transaction ID Compatibility | ||
102 | 33 | ========================================================================= | ||
103 | 34 | |||
104 | 35 | Link module between the Swiss localization Payment File (DTA) module | ||
105 | 36 | (l10n_ch_dta) and the module adding a transaction ID | ||
106 | 37 | field (base_transaction_id). | ||
107 | 38 | |||
108 | 39 | When an invoice has a transaction ID, the DTA is exported with this ID | ||
109 | 40 | as reference. | ||
110 | 41 | |||
111 | 42 | """, | ||
112 | 43 | 'website': 'http://www.camptocamp.com', | ||
113 | 44 | 'data': [], | ||
114 | 45 | 'tests': [], | ||
115 | 46 | 'installable': True, | ||
116 | 47 | 'auto_install': True, | ||
117 | 48 | } | ||
118 | 0 | 49 | ||
119 | === added directory 'l10n_ch_dta_base_transaction_id/wizard' | |||
120 | === added file 'l10n_ch_dta_base_transaction_id/wizard/__init__.py' | |||
121 | --- l10n_ch_dta_base_transaction_id/wizard/__init__.py 1970-01-01 00:00:00 +0000 | |||
122 | +++ l10n_ch_dta_base_transaction_id/wizard/__init__.py 2014-03-05 10:48:25 +0000 | |||
123 | @@ -0,0 +1,3 @@ | |||
124 | 1 | # -*- coding: utf-8 -*- | ||
125 | 2 | |||
126 | 3 | from . import create_dta | ||
127 | 0 | 4 | ||
128 | === added file 'l10n_ch_dta_base_transaction_id/wizard/create_dta.py' | |||
129 | --- l10n_ch_dta_base_transaction_id/wizard/create_dta.py 1970-01-01 00:00:00 +0000 | |||
130 | +++ l10n_ch_dta_base_transaction_id/wizard/create_dta.py 2014-03-05 10:48:25 +0000 | |||
131 | @@ -0,0 +1,34 @@ | |||
132 | 1 | # -*- coding: utf-8 -*- | ||
133 | 2 | ############################################################################## | ||
134 | 3 | # | ||
135 | 4 | # Author: Guewen Baconnier | ||
136 | 5 | # Copyright 2014 Camptocamp SA | ||
137 | 6 | # | ||
138 | 7 | # This program is free software: you can redistribute it and/or modify | ||
139 | 8 | # it under the terms of the GNU Affero General Public License as | ||
140 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
141 | 10 | # License, or (at your option) any later version. | ||
142 | 11 | # | ||
143 | 12 | # This program is distributed in the hope that it will be useful, | ||
144 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
145 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
146 | 15 | # GNU Affero General Public License for more details. | ||
147 | 16 | # | ||
148 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
149 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
150 | 19 | # | ||
151 | 20 | ############################################################################## | ||
152 | 21 | |||
153 | 22 | from openerp.osv import orm | ||
154 | 23 | |||
155 | 24 | |||
156 | 25 | class DTAFileGenerator(orm.TransientModel): | ||
157 | 26 | _inherit = "create.dta.wizard" | ||
158 | 27 | |||
159 | 28 | def _set_bank_data(self, cr, uid, data, pline, elec_context, | ||
160 | 29 | seq, context=None): | ||
161 | 30 | super(DTAFileGenerator, self).\ | ||
162 | 31 | _set_bank_data(cr, uid, data, pline, | ||
163 | 32 | elec_context, seq, context=context) | ||
164 | 33 | if pline.move_line_id.transaction_ref: | ||
165 | 34 | elec_context['reference'] = pline.move_line_id.transaction_ref | ||
166 | 0 | 35 | ||
167 | === modified file 'l10n_ch_payment_slip/invoice.py' | |||
168 | --- l10n_ch_payment_slip/invoice.py 2013-09-20 08:59:37 +0000 | |||
169 | +++ l10n_ch_payment_slip/invoice.py 2014-03-05 10:48:25 +0000 | |||
170 | @@ -33,14 +33,13 @@ | |||
171 | 33 | 'transaction_ref': fields.char('Transaction Ref.', size=128), | 33 | 'transaction_ref': fields.char('Transaction Ref.', size=128), |
172 | 34 | } | 34 | } |
173 | 35 | 35 | ||
174 | 36 | def init(self, cr): | ||
175 | 37 | cr.execute('UPDATE account_move_line SET transaction_ref = ref' | ||
176 | 38 | ' WHERE transaction_ref IS NULL' | ||
177 | 39 | ' AND ref IS NOT NULL') | ||
178 | 40 | return True | ||
179 | 41 | |||
180 | 42 | def get_bvr_ref(self, cursor, uid, move_line_id, context=None): | 36 | def get_bvr_ref(self, cursor, uid, move_line_id, context=None): |
182 | 43 | """Retrieve ESR/BVR reference from move line in order to print it""" | 37 | """Retrieve ESR/BVR reference from move line in order to print it |
183 | 38 | |||
184 | 39 | Returns False when no BVR reference should be generated. No | ||
185 | 40 | reference is generated when a transaction reference already | ||
186 | 41 | exists for the line (likely been generated by a payment service). | ||
187 | 42 | """ | ||
188 | 44 | res = '' | 43 | res = '' |
189 | 45 | if isinstance(move_line_id, (tuple, list)): | 44 | if isinstance(move_line_id, (tuple, list)): |
190 | 46 | assert len(move_line_id) == 1, "Only 1 ID expected" | 45 | assert len(move_line_id) == 1, "Only 1 ID expected" |
191 | @@ -55,7 +54,13 @@ | |||
192 | 55 | move_number = '' | 54 | move_number = '' |
193 | 56 | if move_line.invoice.number: | 55 | if move_line.invoice.number: |
194 | 57 | move_number = self._compile_get_ref.sub('', str(move_line.invoice.number) + str(move_line_id)) | 56 | move_number = self._compile_get_ref.sub('', str(move_line.invoice.number) + str(move_line_id)) |
196 | 58 | return mod10r(res + move_number.rjust(26 - len(res), '0')) | 57 | reference = mod10r(res + move_number.rjust(26 - len(res), '0')) |
197 | 58 | if (move_line.transaction_ref and | ||
198 | 59 | move_line.transaction_ref != reference): | ||
199 | 60 | # the line has already a transaction id and it is not | ||
200 | 61 | # a BVR reference | ||
201 | 62 | return '' | ||
202 | 63 | return reference | ||
203 | 59 | 64 | ||
204 | 60 | 65 | ||
205 | 61 | class AccountInvoice(Model): | 66 | class AccountInvoice(Model): |
206 | @@ -102,22 +107,35 @@ | |||
207 | 102 | store=True, readonly=True) | 107 | store=True, readonly=True) |
208 | 103 | } | 108 | } |
209 | 104 | 109 | ||
210 | 110 | def _get_bvr_ref(self, cr, uid, invoice, context=None): | ||
211 | 111 | """Retrieve ESR/BVR reference form invoice in order to print it | ||
212 | 112 | |||
213 | 113 | Receive a browse record so it can be overloaded without rebrowsing | ||
214 | 114 | the invoice. | ||
215 | 115 | """ | ||
216 | 116 | res = '' | ||
217 | 117 | ## We check if the type is bvr, if not we return false | ||
218 | 118 | if invoice.partner_bank_id.state != 'bvr': | ||
219 | 119 | return '' | ||
220 | 120 | ## | ||
221 | 121 | if invoice.partner_bank_id.bvr_adherent_num: | ||
222 | 122 | res = invoice.partner_bank_id.bvr_adherent_num | ||
223 | 123 | invoice_number = '' | ||
224 | 124 | if invoice.number: | ||
225 | 125 | invoice_number = self._compile_get_ref.sub('', invoice.number) | ||
226 | 126 | return mod10r(res + invoice_number.rjust(26 - len(res), '0')) | ||
227 | 127 | |||
228 | 105 | def get_bvr_ref(self, cursor, uid, inv_id, context=None): | 128 | def get_bvr_ref(self, cursor, uid, inv_id, context=None): |
232 | 106 | """Retrieve ESR/BVR reference form invoice in order to print it""" | 129 | """Retrieve ESR/BVR reference form invoice in order to print it |
233 | 107 | res = '' | 130 | |
234 | 108 | if isinstance(inv_id, list): | 131 | Returns False when no BVR reference should be generated. No |
235 | 132 | reference is generated when the invoice is not a BVR invoice. | ||
236 | 133 | """ | ||
237 | 134 | if isinstance(inv_id, (list, tuple)): | ||
238 | 135 | assert len(inv_id) == 1, "1 ID expected, got %s" % inv_id | ||
239 | 109 | inv_id = inv_id[0] | 136 | inv_id = inv_id[0] |
240 | 110 | inv = self.browse(cursor, uid, inv_id, context=context) | 137 | inv = self.browse(cursor, uid, inv_id, context=context) |
251 | 111 | ## We check if the type is bvr, if not we return false | 138 | return self._get_bvr_ref(cursor, uid, inv, context=context) |
242 | 112 | if inv.partner_bank_id.state != 'bvr': | ||
243 | 113 | return '' | ||
244 | 114 | ## | ||
245 | 115 | if inv.partner_bank_id.bvr_adherent_num: | ||
246 | 116 | res = inv.partner_bank_id.bvr_adherent_num | ||
247 | 117 | invoice_number = '' | ||
248 | 118 | if inv.number: | ||
249 | 119 | invoice_number = self._compile_get_ref.sub('', inv.number) | ||
250 | 120 | return mod10r(res + invoice_number.rjust(26 - len(res), '0')) | ||
252 | 121 | 139 | ||
253 | 122 | def _space(self, nbr, nbrspc=5): | 140 | def _space(self, nbr, nbrspc=5): |
254 | 123 | """Spaces * 5. | 141 | """Spaces * 5. |
255 | @@ -136,37 +154,54 @@ | |||
256 | 136 | (ref, move_id)) | 154 | (ref, move_id)) |
257 | 137 | return True | 155 | return True |
258 | 138 | 156 | ||
259 | 157 | def _action_bvr_number_move_line(self, cr, uid, invoice, move_line, | ||
260 | 158 | ref, context=None): | ||
261 | 159 | if not ref: | ||
262 | 160 | return | ||
263 | 161 | cr.execute('UPDATE account_move_line SET transaction_ref=%s' | ||
264 | 162 | ' WHERE id=%s', (ref, move_line.id)) | ||
265 | 163 | self._update_ref_on_account_analytic_line(cr, uid, ref, | ||
266 | 164 | move_line.move_id.id) | ||
267 | 165 | |||
268 | 139 | def action_number(self, cr, uid, ids, context=None): | 166 | def action_number(self, cr, uid, ids, context=None): |
269 | 167 | """ Copy the BVR/ESR reference in the transaction_ref of move lines. | ||
270 | 168 | |||
271 | 169 | For customers invoices: the BVR reference is computed using | ||
272 | 170 | ``get_bvr_ref()`` on the invoice or move lines. | ||
273 | 171 | |||
274 | 172 | For suppliers invoices: the BVR reference is stored in the reference | ||
275 | 173 | field of the invoice. | ||
276 | 174 | |||
277 | 175 | """ | ||
278 | 140 | res = super(AccountInvoice, self).action_number(cr, uid, ids, context=context) | 176 | res = super(AccountInvoice, self).action_number(cr, uid, ids, context=context) |
279 | 141 | move_line_obj = self.pool.get('account.move.line') | 177 | move_line_obj = self.pool.get('account.move.line') |
280 | 142 | account_obj = self.pool.get('account.account') | ||
281 | 143 | tier_account_id = account_obj.search(cr, uid, [('type', 'in', ['receivable', 'payable'])]) | ||
282 | 144 | 178 | ||
283 | 145 | for inv in self.browse(cr, uid, ids, context=context): | 179 | for inv in self.browse(cr, uid, ids, context=context): |
285 | 146 | if inv.type != 'out_invoice' and inv.partner_bank_id.state != 'bvr': | 180 | move_line_ids = move_line_obj.search( |
286 | 181 | cr, uid, | ||
287 | 182 | [('move_id', '=', inv.move_id.id), | ||
288 | 183 | ('account_id', '=', inv.account_id.id)], | ||
289 | 184 | context=context) | ||
290 | 185 | if not move_line_ids: | ||
291 | 147 | continue | 186 | continue |
307 | 148 | move_lines = move_line_obj.search(cr, uid, [('move_id', '=', inv.move_id.id), | 187 | move_lines = move_line_obj.browse(cr, uid, move_line_ids, |
308 | 149 | ('account_id', 'in', tier_account_id)]) | 188 | context=context) |
309 | 150 | # We keep this branch for compatibility with single BVR report. | 189 | for move_line in move_lines: |
310 | 151 | # This should be cleaned when porting to V8 | 190 | if inv.type in ('out_invoice', 'out_refund'): |
311 | 152 | if move_lines: | 191 | if len(move_lines) == 1: |
312 | 153 | if len(move_lines) == 1: | 192 | # We keep this branch for compatibility with single |
313 | 154 | ref = inv.get_bvr_ref() | 193 | # BVR report. |
314 | 155 | move_id = inv.move_id | 194 | # This should be cleaned when porting to V8 |
315 | 156 | if move_id: | 195 | ref = inv.get_bvr_ref() |
316 | 157 | cr.execute('UPDATE account_move_line SET transaction_ref=%s' | 196 | else: |
302 | 158 | ' WHERE move_id=%s', | ||
303 | 159 | (ref, move_id.id)) | ||
304 | 160 | self._update_ref_on_account_analytic_line(cr, uid, ref, move_id.id) | ||
305 | 161 | else: | ||
306 | 162 | for move_line in move_line_obj.browse(cr, uid, move_lines, context=context): | ||
317 | 163 | ref = move_line.get_bvr_ref() | 197 | ref = move_line.get_bvr_ref() |
324 | 164 | if ref: | 198 | elif inv.reference_type == 'bvr' and inv.reference: |
325 | 165 | cr.execute('UPDATE account_move_line SET transaction_ref=%s' | 199 | ref = inv.reference |
326 | 166 | ' WHERE id=%s', | 200 | else: |
327 | 167 | (ref, move_line.id)) | 201 | ref = False |
328 | 168 | self._update_ref_on_account_analytic_line(cr, uid, ref, | 202 | self._action_bvr_number_move_line(cr, uid, inv, |
329 | 169 | move_line.move_id.id) | 203 | move_line, ref, |
330 | 204 | context=context) | ||
331 | 170 | return res | 205 | return res |
332 | 171 | 206 | ||
333 | 172 | def copy(self, cursor, uid, inv_id, default=None, context=None): | 207 | def copy(self, cursor, uid, inv_id, default=None, context=None): |
334 | 173 | 208 | ||
335 | === modified file 'l10n_ch_payment_slip/wizard/bvr_import.py' | |||
336 | --- l10n_ch_payment_slip/wizard/bvr_import.py 2013-08-14 14:32:54 +0000 | |||
337 | +++ l10n_ch_payment_slip/wizard/bvr_import.py 2014-03-05 10:48:25 +0000 | |||
338 | @@ -181,6 +181,49 @@ | |||
339 | 181 | _('The properties account payable account receivable are not set')) | 181 | _('The properties account payable account receivable are not set')) |
340 | 182 | return account_id | 182 | return account_id |
341 | 183 | 183 | ||
342 | 184 | def _prepare_line_vals(self, cursor, uid, statement, record, | ||
343 | 185 | voucher_enabled, context=None): | ||
344 | 186 | # Remove the 11 first char because it can be adherent number | ||
345 | 187 | # TODO check if 11 is the right number | ||
346 | 188 | move_line_obj = self.pool.get('account.move.line') | ||
347 | 189 | reference = record['reference'] | ||
348 | 190 | values = {'name': '/', | ||
349 | 191 | 'date': record['date'], | ||
350 | 192 | 'amount': record['amount'], | ||
351 | 193 | 'ref': reference, | ||
352 | 194 | 'type': (record['amount'] >= 0 and 'customer') or 'supplier', | ||
353 | 195 | 'statement_id': statement.id, | ||
354 | 196 | } | ||
355 | 197 | line_ids = move_line_obj.search(cursor, uid, | ||
356 | 198 | [('ref', '=', reference), | ||
357 | 199 | ('reconcile_id', '=', False), | ||
358 | 200 | ('account_id.type', 'in', ['receivable', 'payable']), | ||
359 | 201 | ('journal_id.type', '=', 'sale')], | ||
360 | 202 | order='date desc', context=context) | ||
361 | 203 | #for multiple payments | ||
362 | 204 | if not line_ids: | ||
363 | 205 | line_ids = move_line_obj.search(cursor, uid, | ||
364 | 206 | [('transaction_ref', '=', reference), | ||
365 | 207 | ('reconcile_id', '=', False), | ||
366 | 208 | ('account_id.type', 'in', ['receivable', 'payable']), | ||
367 | 209 | ('journal_id.type', '=', 'sale')], | ||
368 | 210 | order='date desc', context=context) | ||
369 | 211 | if not line_ids: | ||
370 | 212 | line_ids = self._reconstruct_invoice_ref(cursor, uid, reference, None) | ||
371 | 213 | if line_ids and voucher_enabled: | ||
372 | 214 | values['voucher_id'] = self._create_voucher_from_record(cursor, uid, record, | ||
373 | 215 | statement, line_ids, | ||
374 | 216 | context=context) | ||
375 | 217 | account_id = self._get_account(cursor, uid, line_ids, | ||
376 | 218 | record, context=context) | ||
377 | 219 | values['account_id'] = account_id | ||
378 | 220 | if line_ids: | ||
379 | 221 | line = move_line_obj.browse(cursor, uid, line_ids[0]) | ||
380 | 222 | partner_id = line.partner_id.id | ||
381 | 223 | values['name'] = line.invoice and (_('Inv. no ') + line.invoice.number) or values['name'] | ||
382 | 224 | values['partner_id'] = partner_id | ||
383 | 225 | return values | ||
384 | 226 | |||
385 | 184 | def import_v11(self, cursor, uid, ids, data, context=None): | 227 | def import_v11(self, cursor, uid, ids, data, context=None): |
386 | 185 | """Import v11 file and transfor it into statement lines""" | 228 | """Import v11 file and transfor it into statement lines""" |
387 | 186 | if context is None: context = {} | 229 | if context is None: context = {} |
388 | @@ -196,7 +239,6 @@ | |||
389 | 196 | if para.lower() not in ['0', 'false']: # if voucher is disabled | 239 | if para.lower() not in ['0', 'false']: # if voucher is disabled |
390 | 197 | voucher_enabled = False | 240 | voucher_enabled = False |
391 | 198 | statement_line_obj = self.pool.get('account.bank.statement.line') | 241 | statement_line_obj = self.pool.get('account.bank.statement.line') |
392 | 199 | move_line_obj = self.pool.get('account.move.line') | ||
393 | 200 | attachment_obj = self.pool.get('ir.attachment') | 242 | attachment_obj = self.pool.get('ir.attachment') |
394 | 201 | statement_obj = self.pool.get('account.bank.statement') | 243 | statement_obj = self.pool.get('account.bank.statement') |
395 | 202 | file = data['form']['file'] | 244 | file = data['form']['file'] |
396 | @@ -207,49 +249,11 @@ | |||
397 | 207 | lines = base64.decodestring(file).split("\n") | 249 | lines = base64.decodestring(file).split("\n") |
398 | 208 | records = self._parse_lines(cursor, uid, lines, context=context) | 250 | records = self._parse_lines(cursor, uid, lines, context=context) |
399 | 209 | 251 | ||
400 | 210 | if context is None: | ||
401 | 211 | context = {} | ||
402 | 212 | |||
403 | 213 | statement = statement_obj.browse(cursor, uid, statement_id, context=context) | 252 | statement = statement_obj.browse(cursor, uid, statement_id, context=context) |
404 | 214 | for record in records: | 253 | for record in records: |
443 | 215 | # Remove the 11 first char because it can be adherent number | 254 | values = self._prepare_line_vals(cursor, uid, statement, |
444 | 216 | # TODO check if 11 is the right number | 255 | record, voucher_enabled, |
445 | 217 | reference = record['reference'] | 256 | context=context) |
408 | 218 | values = {'name': reference, | ||
409 | 219 | 'date': record['date'], | ||
410 | 220 | 'amount': record['amount'], | ||
411 | 221 | 'ref': reference, | ||
412 | 222 | 'type': (record['amount'] >= 0 and 'customer') or 'supplier', | ||
413 | 223 | 'statement_id': statement_id, | ||
414 | 224 | } | ||
415 | 225 | line_ids = move_line_obj.search(cursor, uid, | ||
416 | 226 | [('ref', '=', reference), | ||
417 | 227 | ('reconcile_id', '=', False), | ||
418 | 228 | ('account_id.type', 'in', ['receivable', 'payable']), | ||
419 | 229 | ('journal_id.type', '=', 'sale')], | ||
420 | 230 | order='date desc', context=context) | ||
421 | 231 | #for multiple payments | ||
422 | 232 | if not line_ids: | ||
423 | 233 | line_ids = move_line_obj.search(cursor, uid, | ||
424 | 234 | [('transaction_ref', '=', reference), | ||
425 | 235 | ('reconcile_id', '=', False), | ||
426 | 236 | ('account_id.type', 'in', ['receivable', 'payable']), | ||
427 | 237 | ('journal_id.type', '=', 'sale')], | ||
428 | 238 | order='date desc', context=context) | ||
429 | 239 | if not line_ids: | ||
430 | 240 | line_ids = self._reconstruct_invoice_ref(cursor, uid, reference, None) | ||
431 | 241 | if line_ids and voucher_enabled: | ||
432 | 242 | values['voucher_id'] = self._create_voucher_from_record(cursor, uid, record, | ||
433 | 243 | statement, line_ids, | ||
434 | 244 | context=context) | ||
435 | 245 | account_id = self._get_account(cursor, uid, line_ids, | ||
436 | 246 | record, context=context) | ||
437 | 247 | values['account_id'] = account_id | ||
438 | 248 | if line_ids: | ||
439 | 249 | line = move_line_obj.browse(cursor, uid, line_ids[0]) | ||
440 | 250 | partner_id = line.partner_id.id | ||
441 | 251 | values['name'] = line.invoice and (_('Inv. no ') + line.invoice.number) or values['name'] | ||
442 | 252 | values['partner_id'] = partner_id | ||
446 | 253 | statement_line_obj.create(cursor, uid, values, context=context) | 257 | statement_line_obj.create(cursor, uid, values, context=context) |
447 | 254 | attachment_obj.create(cursor, uid, | 258 | attachment_obj.create(cursor, uid, |
448 | 255 | {'name': 'BVR %s' % time.strftime("%Y-%m-%d_%H:%M:%S", time.gmtime()), | 259 | {'name': 'BVR %s' % time.strftime("%Y-%m-%d_%H:%M:%S", time.gmtime()), |
449 | 256 | 260 | ||
450 | === added directory 'l10n_ch_payment_slip_account_statement_base_completion' | |||
451 | === added file 'l10n_ch_payment_slip_account_statement_base_completion/__init__.py' | |||
452 | --- l10n_ch_payment_slip_account_statement_base_completion/__init__.py 1970-01-01 00:00:00 +0000 | |||
453 | +++ l10n_ch_payment_slip_account_statement_base_completion/__init__.py 2014-03-05 10:48:25 +0000 | |||
454 | @@ -0,0 +1,23 @@ | |||
455 | 1 | # -*- coding: utf-8 -*- | ||
456 | 2 | ############################################################################## | ||
457 | 3 | # | ||
458 | 4 | # Author: Guewen Baconnier | ||
459 | 5 | # Copyright 2014 Camptocamp SA | ||
460 | 6 | # | ||
461 | 7 | # This program is free software: you can redistribute it and/or modify | ||
462 | 8 | # it under the terms of the GNU Affero General Public License as | ||
463 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
464 | 10 | # License, or (at your option) any later version. | ||
465 | 11 | # | ||
466 | 12 | # This program is distributed in the hope that it will be useful, | ||
467 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
468 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
469 | 15 | # GNU Affero General Public License for more details. | ||
470 | 16 | # | ||
471 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
472 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
473 | 19 | # | ||
474 | 20 | ############################################################################## | ||
475 | 21 | |||
476 | 22 | from . import wizard | ||
477 | 23 | from . import statement | ||
478 | 0 | 24 | ||
479 | === added file 'l10n_ch_payment_slip_account_statement_base_completion/__openerp__.py' | |||
480 | --- l10n_ch_payment_slip_account_statement_base_completion/__openerp__.py 1970-01-01 00:00:00 +0000 | |||
481 | +++ l10n_ch_payment_slip_account_statement_base_completion/__openerp__.py 2014-03-05 10:48:25 +0000 | |||
482 | @@ -0,0 +1,52 @@ | |||
483 | 1 | # -*- coding: utf-8 -*- | ||
484 | 2 | ############################################################################## | ||
485 | 3 | # | ||
486 | 4 | # Author: Guewen Baconnier | ||
487 | 5 | # Copyright 2014 Camptocamp SA | ||
488 | 6 | # | ||
489 | 7 | # This program is free software: you can redistribute it and/or modify | ||
490 | 8 | # it under the terms of the GNU Affero General Public License as | ||
491 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
492 | 10 | # License, or (at your option) any later version. | ||
493 | 11 | # | ||
494 | 12 | # This program is distributed in the hope that it will be useful, | ||
495 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
496 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
497 | 15 | # GNU Affero General Public License for more details. | ||
498 | 16 | # | ||
499 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
500 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
501 | 19 | # | ||
502 | 20 | ############################################################################## | ||
503 | 21 | |||
504 | 22 | {'name' : 'Swiss Localization BVR/ESR - Bank statement Completion', | ||
505 | 23 | 'version' : '1.0', | ||
506 | 24 | 'author' : 'Camptocamp', | ||
507 | 25 | 'maintainer': 'Camptocamp', | ||
508 | 26 | 'license': 'AGPL-3', | ||
509 | 27 | 'category': 'Hidden', | ||
510 | 28 | 'depends' : ['l10n_ch_payment_slip', | ||
511 | 29 | 'account_statement_base_completion', # lp:banking-addons/bank-statement-reconcile-7.0 | ||
512 | 30 | ], | ||
513 | 31 | 'description': """ | ||
514 | 32 | Swiss Localization BVR/ESR - Bank statement Completion | ||
515 | 33 | ====================================================== | ||
516 | 34 | |||
517 | 35 | Link module between the Swiss localization BVR/ESR module | ||
518 | 36 | (l10n_ch_payment_slip) and the module adding a transaction ID | ||
519 | 37 | field in the bank statement (account_statement_base_completion). | ||
520 | 38 | |||
521 | 39 | It adds a completion rule to search the partner from the invoice | ||
522 | 40 | using the BVR/ESR reference. | ||
523 | 41 | |||
524 | 42 | When importing a BVR/ESR, the transaction ID is also copied to the | ||
525 | 43 | transaction id field of the bank statement. | ||
526 | 44 | |||
527 | 45 | """, | ||
528 | 46 | 'website': 'http://www.camptocamp.com', | ||
529 | 47 | 'data': ['data.xml', | ||
530 | 48 | ], | ||
531 | 49 | 'tests': [], | ||
532 | 50 | 'installable': True, | ||
533 | 51 | 'auto_install': True, | ||
534 | 52 | } | ||
535 | 0 | 53 | ||
536 | === added file 'l10n_ch_payment_slip_account_statement_base_completion/data.xml' | |||
537 | --- l10n_ch_payment_slip_account_statement_base_completion/data.xml 1970-01-01 00:00:00 +0000 | |||
538 | +++ l10n_ch_payment_slip_account_statement_base_completion/data.xml 2014-03-05 10:48:25 +0000 | |||
539 | @@ -0,0 +1,12 @@ | |||
540 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
541 | 2 | <openerp> | ||
542 | 3 | <data noupdate="1"> | ||
543 | 4 | |||
544 | 5 | <record id="bank_statement_completion_rule_bvr_invoice" model="account.statement.completion.rule"> | ||
545 | 6 | <field name="name">Match from Invoice using BVR/ESR Reference</field> | ||
546 | 7 | <field name="sequence">40</field> | ||
547 | 8 | <field name="function_to_call">get_from_bvr_reference_and_invoice</field> | ||
548 | 9 | </record> | ||
549 | 10 | |||
550 | 11 | </data> | ||
551 | 12 | </openerp> | ||
552 | 0 | 13 | ||
553 | === added file 'l10n_ch_payment_slip_account_statement_base_completion/statement.py' | |||
554 | --- l10n_ch_payment_slip_account_statement_base_completion/statement.py 1970-01-01 00:00:00 +0000 | |||
555 | +++ l10n_ch_payment_slip_account_statement_base_completion/statement.py 2014-03-05 10:48:25 +0000 | |||
556 | @@ -0,0 +1,103 @@ | |||
557 | 1 | # -*- coding: utf-8 -*- | ||
558 | 2 | ############################################################################## | ||
559 | 3 | # | ||
560 | 4 | # Author: Guewen Baconnier | ||
561 | 5 | # Copyright 2014 Camptocamp SA | ||
562 | 6 | # | ||
563 | 7 | # This program is free software: you can redistribute it and/or modify | ||
564 | 8 | # it under the terms of the GNU Affero General Public License as | ||
565 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
566 | 10 | # License, or (at your option) any later version. | ||
567 | 11 | # | ||
568 | 12 | # This program is distributed in the hope that it will be useful, | ||
569 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
570 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
571 | 15 | # GNU Affero General Public License for more details. | ||
572 | 16 | # | ||
573 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
574 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
575 | 19 | # | ||
576 | 20 | ############################################################################## | ||
577 | 21 | |||
578 | 22 | from openerp.tools.translate import _ | ||
579 | 23 | from openerp.osv import orm, fields | ||
580 | 24 | from openerp.addons.account_statement_base_completion.statement import ( | ||
581 | 25 | ErrorTooManyPartner | ||
582 | 26 | ) | ||
583 | 27 | |||
584 | 28 | |||
585 | 29 | class account_statement_completion_rule(orm.Model): | ||
586 | 30 | """ Add a rule based on BVR Reference """ | ||
587 | 31 | _inherit = "account.statement.completion.rule" | ||
588 | 32 | |||
589 | 33 | def _get_functions(self, cr, uid, context=None): | ||
590 | 34 | res = super(account_statement_completion_rule, self).\ | ||
591 | 35 | _get_functions(cr, uid, context=context) | ||
592 | 36 | res.append(('get_from_bvr_reference_and_invoice', | ||
593 | 37 | 'Match Invoice using BVR/ESR Reference')) | ||
594 | 38 | return res | ||
595 | 39 | |||
596 | 40 | _columns = { | ||
597 | 41 | 'function_to_call': fields.selection(_get_functions, 'Method'), | ||
598 | 42 | } | ||
599 | 43 | |||
600 | 44 | def get_from_bvr_reference_and_invoice(self, cr, uid, st_line, context=None): | ||
601 | 45 | """ | ||
602 | 46 | Match the partner based on the BVR reference field of the invoice. | ||
603 | 47 | Then, call the generic st_line method to complete other values. | ||
604 | 48 | |||
605 | 49 | In that case, we always fulfill the reference of the line with | ||
606 | 50 | the invoice name. | ||
607 | 51 | |||
608 | 52 | :param dict st_line: read of the concerned account.bank.statement.line | ||
609 | 53 | :return: | ||
610 | 54 | A dict of value that can be passed directly to the write method of | ||
611 | 55 | the statement line or {} | ||
612 | 56 | {'partner_id': value, | ||
613 | 57 | 'account_id' : value, | ||
614 | 58 | ...} | ||
615 | 59 | """ | ||
616 | 60 | st_obj = self.pool.get('account.bank.statement.line') | ||
617 | 61 | res = {} | ||
618 | 62 | invoice_obj = self.pool.get('account.invoice') | ||
619 | 63 | # For customer invoices, search in bvr_reference that is as list | ||
620 | 64 | # of references separated by semicolons and formatted with | ||
621 | 65 | # spaces inside them. | ||
622 | 66 | # For supplier invoices, search in 'reference' | ||
623 | 67 | query = ("SELECT id FROM account_invoice " | ||
624 | 68 | "WHERE company_id = %s " | ||
625 | 69 | "AND (%s = ANY (string_to_array( " | ||
626 | 70 | " replace(bvr_reference, ' ', ''), " | ||
627 | 71 | " ';')) " | ||
628 | 72 | " AND type IN ('out_invoice', 'out_refund') " | ||
629 | 73 | " OR type IN ('in_invoice', 'in_refund') " | ||
630 | 74 | " AND reference_type = 'bvr' AND reference = %s " | ||
631 | 75 | ")") | ||
632 | 76 | cr.execute(query, (st_line['company_id'][0], | ||
633 | 77 | st_line['transaction_id'], | ||
634 | 78 | st_line['transaction_id'])) | ||
635 | 79 | rows = cr.fetchall() | ||
636 | 80 | invoice_ids = [row[0] for row in rows] | ||
637 | 81 | if len(invoice_ids) > 1: | ||
638 | 82 | raise ErrorTooManyPartner( | ||
639 | 83 | _('Line named "%s" (Ref:%s) was matched by more than ' | ||
640 | 84 | 'one partner.') % (st_line['name'], st_line['ref'])) | ||
641 | 85 | elif len(invoice_ids) == 1: | ||
642 | 86 | invoice = invoice_obj.browse(cr, uid, invoice_ids[0], | ||
643 | 87 | context=context) | ||
644 | 88 | res['partner_id'] = invoice.partner_id.id | ||
645 | 89 | # we want the move to have the same ref than the found | ||
646 | 90 | # invoice's move, thus it will be easier to link them for the | ||
647 | 91 | # accountants | ||
648 | 92 | if invoice.move_id: | ||
649 | 93 | res['ref'] = invoice.move_id.ref | ||
650 | 94 | st_vals = st_obj.get_values_for_line( | ||
651 | 95 | cr, uid, | ||
652 | 96 | profile_id=st_line['profile_id'], | ||
653 | 97 | master_account_id=st_line['master_account_id'], | ||
654 | 98 | partner_id=res.get('partner_id', False), | ||
655 | 99 | line_type=st_line['type'], | ||
656 | 100 | amount=st_line['amount'] if st_line['amount'] else 0.0, | ||
657 | 101 | context=context) | ||
658 | 102 | res.update(st_vals) | ||
659 | 103 | return res | ||
660 | 0 | 104 | ||
661 | === added directory 'l10n_ch_payment_slip_account_statement_base_completion/wizard' | |||
662 | === added file 'l10n_ch_payment_slip_account_statement_base_completion/wizard/__init__.py' | |||
663 | --- l10n_ch_payment_slip_account_statement_base_completion/wizard/__init__.py 1970-01-01 00:00:00 +0000 | |||
664 | +++ l10n_ch_payment_slip_account_statement_base_completion/wizard/__init__.py 2014-03-05 10:48:25 +0000 | |||
665 | @@ -0,0 +1,3 @@ | |||
666 | 1 | # -*- coding: utf-8 -*- | ||
667 | 2 | |||
668 | 3 | from . import bvr_import | ||
669 | 0 | 4 | ||
670 | === added file 'l10n_ch_payment_slip_account_statement_base_completion/wizard/bvr_import.py' | |||
671 | --- l10n_ch_payment_slip_account_statement_base_completion/wizard/bvr_import.py 1970-01-01 00:00:00 +0000 | |||
672 | +++ l10n_ch_payment_slip_account_statement_base_completion/wizard/bvr_import.py 2014-03-05 10:48:25 +0000 | |||
673 | @@ -0,0 +1,34 @@ | |||
674 | 1 | # -*- coding: utf-8 -*- | ||
675 | 2 | ############################################################################## | ||
676 | 3 | # | ||
677 | 4 | # Author: Guewen Baconnier | ||
678 | 5 | # Copyright 2014 Camptocamp SA | ||
679 | 6 | # | ||
680 | 7 | # This program is free software: you can redistribute it and/or modify | ||
681 | 8 | # it under the terms of the GNU Affero General Public License as | ||
682 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
683 | 10 | # License, or (at your option) any later version. | ||
684 | 11 | # | ||
685 | 12 | # This program is distributed in the hope that it will be useful, | ||
686 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
687 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
688 | 15 | # GNU Affero General Public License for more details. | ||
689 | 16 | # | ||
690 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
691 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
692 | 19 | # | ||
693 | 20 | ############################################################################## | ||
694 | 21 | |||
695 | 22 | from openerp.osv import orm | ||
696 | 23 | |||
697 | 24 | |||
698 | 25 | class BvrImporterWizard(orm.TransientModel): | ||
699 | 26 | _inherit = 'bvr.import.wizard' | ||
700 | 27 | |||
701 | 28 | def _prepare_line_vals(self, cursor, uid, statement, record, | ||
702 | 29 | voucher_enabled, context=None): | ||
703 | 30 | record = super(BvrImporterWizard, self).\ | ||
704 | 31 | _prepare_line_vals(cursor, uid, statement, record, | ||
705 | 32 | voucher_enabled, context=context) | ||
706 | 33 | record['transaction_id'] = record['ref'] | ||
707 | 34 | return record | ||
708 | 0 | 35 | ||
709 | === added directory 'l10n_ch_payment_slip_base_transaction_id' | |||
710 | === added file 'l10n_ch_payment_slip_base_transaction_id/__init__.py' | |||
711 | --- l10n_ch_payment_slip_base_transaction_id/__init__.py 1970-01-01 00:00:00 +0000 | |||
712 | +++ l10n_ch_payment_slip_base_transaction_id/__init__.py 2014-03-05 10:48:25 +0000 | |||
713 | @@ -0,0 +1,22 @@ | |||
714 | 1 | # -*- coding: utf-8 -*- | ||
715 | 2 | ############################################################################## | ||
716 | 3 | # | ||
717 | 4 | # Author: Guewen Baconnier | ||
718 | 5 | # Copyright 2014 Camptocamp SA | ||
719 | 6 | # | ||
720 | 7 | # This program is free software: you can redistribute it and/or modify | ||
721 | 8 | # it under the terms of the GNU Affero General Public License as | ||
722 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
723 | 10 | # License, or (at your option) any later version. | ||
724 | 11 | # | ||
725 | 12 | # This program is distributed in the hope that it will be useful, | ||
726 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
727 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
728 | 15 | # GNU Affero General Public License for more details. | ||
729 | 16 | # | ||
730 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
731 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
732 | 19 | # | ||
733 | 20 | ############################################################################## | ||
734 | 21 | |||
735 | 22 | from . import invoice | ||
736 | 0 | 23 | ||
737 | === added file 'l10n_ch_payment_slip_base_transaction_id/__openerp__.py' | |||
738 | --- l10n_ch_payment_slip_base_transaction_id/__openerp__.py 1970-01-01 00:00:00 +0000 | |||
739 | +++ l10n_ch_payment_slip_base_transaction_id/__openerp__.py 2014-03-05 10:48:25 +0000 | |||
740 | @@ -0,0 +1,48 @@ | |||
741 | 1 | # -*- coding: utf-8 -*- | ||
742 | 2 | ############################################################################## | ||
743 | 3 | # | ||
744 | 4 | # Author: Guewen Baconnier | ||
745 | 5 | # Copyright 2014 Camptocamp SA | ||
746 | 6 | # | ||
747 | 7 | # This program is free software: you can redistribute it and/or modify | ||
748 | 8 | # it under the terms of the GNU Affero General Public License as | ||
749 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
750 | 10 | # License, or (at your option) any later version. | ||
751 | 11 | # | ||
752 | 12 | # This program is distributed in the hope that it will be useful, | ||
753 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
754 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
755 | 15 | # GNU Affero General Public License for more details. | ||
756 | 16 | # | ||
757 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
758 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
759 | 19 | # | ||
760 | 20 | ############################################################################## | ||
761 | 21 | |||
762 | 22 | {'name' : 'Swiss Localization BVR/ESR - Transaction ID Compatibility', | ||
763 | 23 | 'version' : '1.0', | ||
764 | 24 | 'author' : 'Camptocamp', | ||
765 | 25 | 'maintainer': 'Camptocamp', | ||
766 | 26 | 'license': 'AGPL-3', | ||
767 | 27 | 'category': 'Hidden', | ||
768 | 28 | 'depends' : ['l10n_ch_payment_slip', | ||
769 | 29 | 'base_transaction_id', # lp:banking-addons/bank-statement-reconcile-7.0 | ||
770 | 30 | ], | ||
771 | 31 | 'description': """ | ||
772 | 32 | Swiss Localization BVR/ESR - Transaction ID Compatibility | ||
773 | 33 | ========================================================== | ||
774 | 34 | |||
775 | 35 | Link module between the Swiss localization BVR/ESR module | ||
776 | 36 | (l10n_ch_payment_slip) and the module adding a transaction ID | ||
777 | 37 | field (base_transaction_id). | ||
778 | 38 | |||
779 | 39 | When an invoice has a transaction ID, no BVR reference should be generated | ||
780 | 40 | because the reconciliation should be done with the transaction ID, not | ||
781 | 41 | a new reference. | ||
782 | 42 | """, | ||
783 | 43 | 'website': 'http://www.camptocamp.com', | ||
784 | 44 | 'data': [], | ||
785 | 45 | 'tests': [], | ||
786 | 46 | 'installable': True, | ||
787 | 47 | 'auto_install': True, | ||
788 | 48 | } | ||
789 | 0 | 49 | ||
790 | === added file 'l10n_ch_payment_slip_base_transaction_id/invoice.py' | |||
791 | --- l10n_ch_payment_slip_base_transaction_id/invoice.py 1970-01-01 00:00:00 +0000 | |||
792 | +++ l10n_ch_payment_slip_base_transaction_id/invoice.py 2014-03-05 10:48:25 +0000 | |||
793 | @@ -0,0 +1,39 @@ | |||
794 | 1 | # -*- coding: utf-8 -*- | ||
795 | 2 | ############################################################################## | ||
796 | 3 | # | ||
797 | 4 | # Author: Guewen Baconnier | ||
798 | 5 | # Copyright 2014 Camptocamp SA | ||
799 | 6 | # | ||
800 | 7 | # This program is free software: you can redistribute it and/or modify | ||
801 | 8 | # it under the terms of the GNU Affero General Public License as | ||
802 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
803 | 10 | # License, or (at your option) any later version. | ||
804 | 11 | # | ||
805 | 12 | # This program is distributed in the hope that it will be useful, | ||
806 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
807 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
808 | 15 | # GNU Affero General Public License for more details. | ||
809 | 16 | # | ||
810 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
811 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
812 | 19 | # | ||
813 | 20 | ############################################################################## | ||
814 | 21 | |||
815 | 22 | from openerp.osv import orm | ||
816 | 23 | |||
817 | 24 | |||
818 | 25 | class account_invoice(orm.Model): | ||
819 | 26 | _inherit = 'account.invoice' | ||
820 | 27 | |||
821 | 28 | def _get_bvr_ref(self, cr, uid, invoice, context=None): | ||
822 | 29 | """Retrieve ESR/BVR reference form invoice in order to print it | ||
823 | 30 | |||
824 | 31 | Returns False when no BVR reference should be generated. No | ||
825 | 32 | reference is generated when a transaction ID already exists on | ||
826 | 33 | the invoice (likely generated by a payment service so BVR ref not | ||
827 | 34 | used). | ||
828 | 35 | """ | ||
829 | 36 | if invoice.transaction_id: | ||
830 | 37 | return '' | ||
831 | 38 | return super(account_invoice, self)._get_bvr_ref(cr, uid, invoice, | ||
832 | 39 | context=context) |
Hi,
Thanks for the good work. I will love to have Fred's comment in there. But for what I see, that' LGTM.
Regards,
Joël