Merge lp:~therp-nl/banking-addons/6.1-match_multiple_invoices_split into lp:banking-addons/6.1
- 6.1-match_multiple_invoices_split
- Merge into 6.1
Proposed by
Stefan Rijnhart (Opener)
Status: | Merged |
---|---|
Merged at revision: | 172 |
Proposed branch: | lp:~therp-nl/banking-addons/6.1-match_multiple_invoices_split |
Merge into: | lp:banking-addons/6.1 |
Diff against target: |
558 lines (+265/-90) 7 files modified
account_banking/__openerp__.py (+3/-0) account_banking/account_banking_view.xml (+8/-2) account_banking/banking_import_transaction.py (+73/-3) account_banking/i18n/nl.po (+6/-6) account_banking/static/src/js/account_banking.js (+51/-0) account_banking/wizard/banking_transaction_wizard.py (+113/-57) account_banking/wizard/banking_transaction_wizard.xml (+11/-22) |
To merge this branch: | bzr merge lp:~therp-nl/banking-addons/6.1-match_multiple_invoices_split |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Holger Brunn (Therp) | Approve | ||
Stefan Rijnhart (Opener) | testing, code review | Approve | |
Review via email:
|
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message

Holger Brunn (Therp) (hbrunn) wrote : | # |
Revision history for this message

Stefan Rijnhart (Opener) (stefan-opener) : | # |
review:
Approve
(testing, code review)
Revision history for this message

Holger Brunn (Therp) (hbrunn) : | # |
review:
Approve
- 170. By Stefan Rijnhart (Opener)
-
[FIX] Calculation of residual in the case of split transactions
[FIX] Transaction amount when credit amounts are split
[FIX] Restore bank account's partner when disabling match
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'account_banking/__openerp__.py' | |||
2 | --- account_banking/__openerp__.py 2012-05-07 11:49:08 +0000 | |||
3 | +++ account_banking/__openerp__.py 2013-06-03 09:55:43 +0000 | |||
4 | @@ -47,6 +47,9 @@ | |||
5 | 47 | 'wizard/banking_transaction_wizard.xml', | 47 | 'wizard/banking_transaction_wizard.xml', |
6 | 48 | 'workflow/account_invoice.xml', | 48 | 'workflow/account_invoice.xml', |
7 | 49 | ], | 49 | ], |
8 | 50 | 'js': [ | ||
9 | 51 | 'static/src/js/account_banking.js', | ||
10 | 52 | ], | ||
11 | 50 | 'demo_xml': [], | 53 | 'demo_xml': [], |
12 | 51 | 'external_dependencies': { | 54 | 'external_dependencies': { |
13 | 52 | 'python' : ['BeautifulSoup'], | 55 | 'python' : ['BeautifulSoup'], |
14 | 53 | 56 | ||
15 | === modified file 'account_banking/account_banking_view.xml' | |||
16 | --- account_banking/account_banking_view.xml 2013-04-25 08:15:21 +0000 | |||
17 | +++ account_banking/account_banking_view.xml 2013-06-03 09:55:43 +0000 | |||
18 | @@ -292,9 +292,12 @@ | |||
19 | 292 | <xpath expr="/form/notebook/page/field[@name='line_ids']/tree/field[@name='amount']" position="after"> | 292 | <xpath expr="/form/notebook/page/field[@name='line_ids']/tree/field[@name='amount']" position="after"> |
20 | 293 | <field name="match_type"/> | 293 | <field name="match_type"/> |
21 | 294 | <field name="residual"/> | 294 | <field name="residual"/> |
23 | 295 | <button name="match_wizard" states="draft" | 295 | <field name="parent_id" invisible="1" /> |
24 | 296 | <button name="match_wizard" | ||
25 | 296 | string="Match" | 297 | string="Match" |
26 | 297 | icon="terp-gtk-jump-to-ltr" | 298 | icon="terp-gtk-jump-to-ltr" |
27 | 299 | attrs="{'invisible': ['|', ('parent_id', '!=', False), | ||
28 | 300 | ('state', '!=', 'draft')]}" | ||
29 | 298 | type="object"/> | 301 | type="object"/> |
30 | 299 | <field name="match_multi" invisible="1"/> | 302 | <field name="match_multi" invisible="1"/> |
31 | 300 | <field name="duplicate" invisible="1"/> | 303 | <field name="duplicate" invisible="1"/> |
32 | @@ -523,9 +526,12 @@ | |||
33 | 523 | <field name="amount"/> | 526 | <field name="amount"/> |
34 | 524 | <field name="match_type"/> | 527 | <field name="match_type"/> |
35 | 525 | <field name="residual"/> | 528 | <field name="residual"/> |
37 | 526 | <button name="match_wizard" states="draft" | 529 | <field name="parent_id" invisible="1" /> |
38 | 530 | <button name="match_wizard" | ||
39 | 527 | string="Match" | 531 | string="Match" |
40 | 528 | icon="terp-gtk-jump-to-ltr" | 532 | icon="terp-gtk-jump-to-ltr" |
41 | 533 | attrs="{'invisible': ['|', ('parent_id', '!=', False), | ||
42 | 534 | ('state', '!=', 'draft')]}" | ||
43 | 529 | type="object"/> | 535 | type="object"/> |
44 | 530 | <field name="match_multi" invisible="1"/> | 536 | <field name="match_multi" invisible="1"/> |
45 | 531 | <field name="duplicate" invisible="1"/> | 537 | <field name="duplicate" invisible="1"/> |
46 | 532 | 538 | ||
47 | === modified file 'account_banking/banking_import_transaction.py' | |||
48 | --- account_banking/banking_import_transaction.py 2013-05-20 08:07:48 +0000 | |||
49 | +++ account_banking/banking_import_transaction.py 2013-06-03 09:55:43 +0000 | |||
50 | @@ -1485,7 +1485,7 @@ | |||
51 | 1485 | not(transaction.move_currency_amount is False)): | 1485 | not(transaction.move_currency_amount is False)): |
52 | 1486 | res[transaction.id] = ( | 1486 | res[transaction.id] = ( |
53 | 1487 | transaction.move_currency_amount - | 1487 | transaction.move_currency_amount - |
55 | 1488 | transaction.transferred_amount | 1488 | transaction.statement_line_id.amount |
56 | 1489 | ) | 1489 | ) |
57 | 1490 | return res | 1490 | return res |
58 | 1491 | 1491 | ||
59 | @@ -1572,6 +1572,22 @@ | |||
60 | 1572 | 1572 | ||
61 | 1573 | return res | 1573 | return res |
62 | 1574 | 1574 | ||
63 | 1575 | def unlink(self, cr, uid, ids, context=None): | ||
64 | 1576 | """ | ||
65 | 1577 | Unsplit if this if a split transaction | ||
66 | 1578 | """ | ||
67 | 1579 | for this in self.browse(cr, uid, ids, context): | ||
68 | 1580 | if this.parent_id: | ||
69 | 1581 | this.parent_id.write( | ||
70 | 1582 | {'transferred_amount': | ||
71 | 1583 | this.parent_id.transferred_amount + \ | ||
72 | 1584 | this.transferred_amount, | ||
73 | 1585 | }) | ||
74 | 1586 | this.parent_id.refresh() | ||
75 | 1587 | return super(banking_import_transaction, self).unlink( | ||
76 | 1588 | cr, uid, ids, context=context) | ||
77 | 1589 | |||
78 | 1590 | |||
79 | 1575 | column_map = { | 1591 | column_map = { |
80 | 1576 | # used in bank_import.py, converting non-osv transactions | 1592 | # used in bank_import.py, converting non-osv transactions |
81 | 1577 | 'statement_id': 'statement', | 1593 | 'statement_id': 'statement', |
82 | @@ -1623,7 +1639,7 @@ | |||
83 | 1623 | 'duplicate': fields.boolean('duplicate'), | 1639 | 'duplicate': fields.boolean('duplicate'), |
84 | 1624 | 'statement_line_id': fields.many2one( | 1640 | 'statement_line_id': fields.many2one( |
85 | 1625 | 'account.bank.statement.line', 'Statement line', | 1641 | 'account.bank.statement.line', 'Statement line', |
87 | 1626 | ondelete='CASCADE'), | 1642 | ondelete='cascade'), |
88 | 1627 | 'statement_id': fields.many2one( | 1643 | 'statement_id': fields.many2one( |
89 | 1628 | 'account.bank.statement', 'Statement'), | 1644 | 'account.bank.statement', 'Statement'), |
90 | 1629 | 'parent_id': fields.many2one( | 1645 | 'parent_id': fields.many2one( |
91 | @@ -1694,7 +1710,7 @@ | |||
92 | 1694 | _columns = { | 1710 | _columns = { |
93 | 1695 | 'import_transaction_id': fields.many2one( | 1711 | 'import_transaction_id': fields.many2one( |
94 | 1696 | 'banking.import.transaction', | 1712 | 'banking.import.transaction', |
96 | 1697 | 'Import transaction', readonly=True, delete='cascade'), | 1713 | 'Import transaction', readonly=True, ondelete='cascade'), |
97 | 1698 | 'match_multi': fields.related( | 1714 | 'match_multi': fields.related( |
98 | 1699 | 'import_transaction_id', 'match_multi', type='boolean', | 1715 | 'import_transaction_id', 'match_multi', type='boolean', |
99 | 1700 | string='Multi match', readonly=True), | 1716 | string='Multi match', readonly=True), |
100 | @@ -1715,6 +1731,8 @@ | |||
101 | 1715 | 'state': fields.selection( | 1731 | 'state': fields.selection( |
102 | 1716 | [('draft', 'Draft'), ('confirmed', 'Confirmed')], 'State', | 1732 | [('draft', 'Draft'), ('confirmed', 'Confirmed')], 'State', |
103 | 1717 | readonly=True, required=True), | 1733 | readonly=True, required=True), |
104 | 1734 | 'parent_id': fields.many2one('account.bank.statement.line', | ||
105 | 1735 | 'Parent'), | ||
106 | 1718 | } | 1736 | } |
107 | 1719 | 1737 | ||
108 | 1720 | _defaults = { | 1738 | _defaults = { |
109 | @@ -1857,6 +1875,8 @@ | |||
110 | 1857 | def unlink(self, cr, uid, ids, context=None): | 1875 | def unlink(self, cr, uid, ids, context=None): |
111 | 1858 | """ | 1876 | """ |
112 | 1859 | Don't allow deletion of a confirmed statement line | 1877 | Don't allow deletion of a confirmed statement line |
113 | 1878 | If this statement line comes from a split transaction, give the | ||
114 | 1879 | amount back | ||
115 | 1860 | """ | 1880 | """ |
116 | 1861 | if type(ids) is int: | 1881 | if type(ids) is int: |
117 | 1862 | ids = [ids] | 1882 | ids = [ids] |
118 | @@ -1866,6 +1886,12 @@ | |||
119 | 1866 | _('Confirmed Statement Line'), | 1886 | _('Confirmed Statement Line'), |
120 | 1867 | _("You cannot delete a confirmed Statement Line" | 1887 | _("You cannot delete a confirmed Statement Line" |
121 | 1868 | ": '%s'" % line.name)) | 1888 | ": '%s'" % line.name)) |
122 | 1889 | if line.parent_id: | ||
123 | 1890 | line.parent_id.write( | ||
124 | 1891 | { | ||
125 | 1892 | 'amount': line.parent_id.amount + line.amount, | ||
126 | 1893 | }) | ||
127 | 1894 | line.parent_id.refresh() | ||
128 | 1869 | return super(account_bank_statement_line, self).unlink( | 1895 | return super(account_bank_statement_line, self).unlink( |
129 | 1870 | cr, uid, ids, context=context) | 1896 | cr, uid, ids, context=context) |
130 | 1871 | 1897 | ||
131 | @@ -1905,6 +1931,50 @@ | |||
132 | 1905 | 'import_transaction_id': res}, | 1931 | 'import_transaction_id': res}, |
133 | 1906 | context=context) | 1932 | context=context) |
134 | 1907 | 1933 | ||
135 | 1934 | def split_off(self, cr, uid, ids, amount, context=None): | ||
136 | 1935 | """ | ||
137 | 1936 | Create a child statement line with amount, deduce that from this line, | ||
138 | 1937 | change transactions accordingly | ||
139 | 1938 | """ | ||
140 | 1939 | if context is None: | ||
141 | 1940 | context = {} | ||
142 | 1941 | |||
143 | 1942 | transaction_pool = self.pool.get('banking.import.transaction') | ||
144 | 1943 | |||
145 | 1944 | child_statement_ids = [] | ||
146 | 1945 | for this in self.browse(cr, uid, ids, context): | ||
147 | 1946 | transaction_data = transaction_pool.copy_data( | ||
148 | 1947 | cr, uid, this.import_transaction_id.id) | ||
149 | 1948 | transaction_data['transferred_amount'] = amount | ||
150 | 1949 | transaction_data['message'] = ( | ||
151 | 1950 | (transaction_data['message'] or '') + _(' (split)')) | ||
152 | 1951 | transaction_data['parent_id'] = this.import_transaction_id.id | ||
153 | 1952 | transaction_id = transaction_pool.create( | ||
154 | 1953 | cr, | ||
155 | 1954 | uid, | ||
156 | 1955 | transaction_data, | ||
157 | 1956 | context=dict( | ||
158 | 1957 | context, transaction_no_duplicate_search=True)) | ||
159 | 1958 | |||
160 | 1959 | statement_line_data = self.copy_data( | ||
161 | 1960 | cr, uid, this.id) | ||
162 | 1961 | statement_line_data['amount'] = amount | ||
163 | 1962 | statement_line_data['name'] = ( | ||
164 | 1963 | (statement_line_data['name'] or '') + _(' (split)')) | ||
165 | 1964 | statement_line_data['import_transaction_id'] = transaction_id | ||
166 | 1965 | statement_line_data['parent_id'] = this.id | ||
167 | 1966 | statement_line_id = self.create( | ||
168 | 1967 | cr, uid, statement_line_data, context=context) | ||
169 | 1968 | |||
170 | 1969 | child_statement_ids.append(statement_line_id) | ||
171 | 1970 | transaction_pool.write( | ||
172 | 1971 | cr, uid, transaction_id, { | ||
173 | 1972 | 'statement_line_id': statement_line_id, | ||
174 | 1973 | }, context=context) | ||
175 | 1974 | this.write({'amount': this.amount - amount}) | ||
176 | 1975 | |||
177 | 1976 | return child_statement_ids | ||
178 | 1977 | |||
179 | 1908 | account_bank_statement_line() | 1978 | account_bank_statement_line() |
180 | 1909 | 1979 | ||
181 | 1910 | class account_bank_statement(osv.osv): | 1980 | class account_bank_statement(osv.osv): |
182 | 1911 | 1981 | ||
183 | === modified file 'account_banking/i18n/nl.po' | |||
184 | --- account_banking/i18n/nl.po 2012-05-02 15:09:49 +0000 | |||
185 | +++ account_banking/i18n/nl.po 2013-06-03 09:55:43 +0000 | |||
186 | @@ -139,9 +139,9 @@ | |||
187 | 139 | msgstr "remote_bank_bic" | 139 | msgstr "remote_bank_bic" |
188 | 140 | 140 | ||
189 | 141 | #. module: account_banking | 141 | #. module: account_banking |
193 | 142 | #: field:banking.transaction.wizard,manual_invoice_id:0 | 142 | #: field:banking.transaction.wizard,manual_invoice_ids:0 |
194 | 143 | msgid "Match this invoice" | 143 | msgid "Match one or more invoices" |
195 | 144 | msgstr "Match deze factuur" | 144 | msgstr "Match een of meerdere facturen" |
196 | 145 | 145 | ||
197 | 146 | #. module: account_banking | 146 | #. module: account_banking |
198 | 147 | #: field:banking.import.transaction,remote_bank_ibei:0 | 147 | #: field:banking.import.transaction,remote_bank_ibei:0 |
199 | @@ -1022,9 +1022,9 @@ | |||
200 | 1022 | msgstr "Herzien" | 1022 | msgstr "Herzien" |
201 | 1023 | 1023 | ||
202 | 1024 | #. module: account_banking | 1024 | #. module: account_banking |
206 | 1025 | #: field:banking.transaction.wizard,manual_move_line_id:0 | 1025 | #: field:banking.transaction.wizard,manual_move_line_ids:0 |
207 | 1026 | msgid "Or match this entry" | 1026 | msgid "Or match one or more entries" |
208 | 1027 | msgstr "Of koppel deze boekingsregel" | 1027 | msgstr "Of koppel deze boekingsregel(s)" |
209 | 1028 | 1028 | ||
210 | 1029 | #. module: account_banking | 1029 | #. module: account_banking |
211 | 1030 | #: help:payment.mode.type,name:0 | 1030 | #: help:payment.mode.type,name:0 |
212 | 1031 | 1031 | ||
213 | === added directory 'account_banking/static' | |||
214 | === added directory 'account_banking/static/src' | |||
215 | === added directory 'account_banking/static/src/js' | |||
216 | === added file 'account_banking/static/src/js/account_banking.js' | |||
217 | --- account_banking/static/src/js/account_banking.js 1970-01-01 00:00:00 +0000 | |||
218 | +++ account_banking/static/src/js/account_banking.js 2013-06-03 09:55:43 +0000 | |||
219 | @@ -0,0 +1,51 @@ | |||
220 | 1 | /*############################################################################ | ||
221 | 2 | # | ||
222 | 3 | # Copyright (C) 2013 Therp BV (<http://therp.nl>). | ||
223 | 4 | # | ||
224 | 5 | # All other contributions are (C) by their respective contributors | ||
225 | 6 | # | ||
226 | 7 | # All Rights Reserved | ||
227 | 8 | # | ||
228 | 9 | # WARNING: This program as such is intended to be used by professional | ||
229 | 10 | # programmers who take the whole responsability of assessing all potential | ||
230 | 11 | # consequences resulting from its eventual inadequacies and bugs | ||
231 | 12 | # End users who are looking for a ready-to-use solution with commercial | ||
232 | 13 | # garantees and support are strongly adviced to contract EduSense BV | ||
233 | 14 | # | ||
234 | 15 | # This program is free software: you can redistribute it and/or modify | ||
235 | 16 | # it under the terms of the GNU General Public License as published by | ||
236 | 17 | # the Free Software Foundation, either version 3 of the License, or | ||
237 | 18 | # (at your option) any later version. | ||
238 | 19 | # | ||
239 | 20 | # This program is distributed in the hope that it will be useful, | ||
240 | 21 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
241 | 22 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
242 | 23 | # GNU General Public License for more details. | ||
243 | 24 | # | ||
244 | 25 | # You should have received a copy of the GNU General Public License | ||
245 | 26 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
246 | 27 | # | ||
247 | 28 | ############################################################################*/ | ||
248 | 29 | |||
249 | 30 | openerp.account_banking = function(openerp) | ||
250 | 31 | { | ||
251 | 32 | var _t = openerp.web._t; | ||
252 | 33 | openerp.web.Dialog.include( | ||
253 | 34 | { | ||
254 | 35 | on_close: function() | ||
255 | 36 | { | ||
256 | 37 | this._super.apply(this, arguments); | ||
257 | 38 | if(this.dialog_title == _t("Match transaction")) | ||
258 | 39 | { | ||
259 | 40 | if(this.widget_parent.widget_children[0].views.form.controller) | ||
260 | 41 | { | ||
261 | 42 | this.widget_parent.widget_children[0].views.form.controller.reload(); | ||
262 | 43 | } | ||
263 | 44 | if(this.widget_parent.widget_children[0].views.page.controller) | ||
264 | 45 | { | ||
265 | 46 | this.widget_parent.widget_children[0].views.page.controller.reload(); | ||
266 | 47 | } | ||
267 | 48 | } | ||
268 | 49 | }, | ||
269 | 50 | }); | ||
270 | 51 | } | ||
271 | 0 | 52 | ||
272 | === modified file 'account_banking/wizard/banking_transaction_wizard.py' | |||
273 | --- account_banking/wizard/banking_transaction_wizard.py 2012-12-01 18:31:34 +0000 | |||
274 | +++ account_banking/wizard/banking_transaction_wizard.py 2013-06-03 09:55:43 +0000 | |||
275 | @@ -94,8 +94,8 @@ | |||
276 | 94 | # The following fields get never written | 94 | # The following fields get never written |
277 | 95 | # they are just triggers for manual matching | 95 | # they are just triggers for manual matching |
278 | 96 | # which populates regular fields on the transaction | 96 | # which populates regular fields on the transaction |
281 | 97 | manual_invoice_id = vals.pop('manual_invoice_id', False) | 97 | manual_invoice_ids = vals.pop('manual_invoice_ids', []) |
282 | 98 | manual_move_line_id = vals.pop('manual_move_line_id', False) | 98 | manual_move_line_ids = vals.pop('manual_move_line_ids', []) |
283 | 99 | 99 | ||
284 | 100 | # Support for writing fields.related is still flakey: | 100 | # Support for writing fields.related is still flakey: |
285 | 101 | # https://bugs.launchpad.net/openobject-server/+bug/915975 | 101 | # https://bugs.launchpad.net/openobject-server/+bug/915975 |
286 | @@ -167,55 +167,93 @@ | |||
287 | 167 | _("No entry found for the selected invoice. " + | 167 | _("No entry found for the selected invoice. " + |
288 | 168 | "Try manual reconciliation.")) | 168 | "Try manual reconciliation.")) |
289 | 169 | 169 | ||
291 | 170 | if manual_move_line_id or manual_invoice_id: | 170 | if manual_move_line_ids or manual_invoice_ids: |
292 | 171 | move_line_obj = self.pool.get('account.move.line') | 171 | move_line_obj = self.pool.get('account.move.line') |
293 | 172 | invoice_obj = self.pool.get('account.invoice') | 172 | invoice_obj = self.pool.get('account.invoice') |
294 | 173 | statement_line_obj = self.pool.get('account.bank.statement.line') | 173 | statement_line_obj = self.pool.get('account.bank.statement.line') |
302 | 174 | for wiz in self.browse( | 174 | manual_invoice_ids = ( |
303 | 175 | cr, uid, ids, context=context): | 175 | [i[1] for i in manual_invoice_ids if i[0]==4] + |
304 | 176 | move_line_id = False | 176 | [j for i in manual_invoice_ids if i[0]==6 for j in i[2]]) |
305 | 177 | invoice_id = manual_invoice_id | 177 | manual_move_line_ids = ( |
306 | 178 | if invoice_id: | 178 | [i[1] for i in manual_move_line_ids if i[0]==4] + |
307 | 179 | invoice = invoice_obj.browse( | 179 | [j for i in manual_move_line_ids if i[0]==6 for j in i[2]]) |
308 | 180 | cr, uid, manual_invoice_id, context=context) | 180 | for wiz in self.browse(cr, uid, ids, context=context): |
309 | 181 | #write can be called multiple times for the same values | ||
310 | 182 | #that doesn't hurt above, but it does here | ||
311 | 183 | if wiz.match_type and ( | ||
312 | 184 | len(manual_move_line_ids) > 1 or | ||
313 | 185 | len(manual_invoice_ids) > 1): | ||
314 | 186 | continue | ||
315 | 187 | |||
316 | 188 | todo = [] | ||
317 | 189 | |||
318 | 190 | for invoice in invoice_obj.browse( | ||
319 | 191 | cr, uid, manual_invoice_ids, context=context): | ||
320 | 192 | found_move_line = False | ||
321 | 181 | if invoice.move_id: | 193 | if invoice.move_id: |
322 | 182 | for line in invoice.move_id.line_id: | 194 | for line in invoice.move_id.line_id: |
323 | 183 | if line.account_id.type in ('receivable', 'payable'): | 195 | if line.account_id.type in ('receivable', 'payable'): |
325 | 184 | move_line_id = line.id | 196 | todo.append((invoice.id, line.id)) |
326 | 197 | found_move_line = True | ||
327 | 185 | break | 198 | break |
330 | 186 | if not move_line_id: | 199 | if not found_move_line: |
331 | 187 | osv.except_osv( | 200 | raise osv.except_osv( |
332 | 188 | _("Cannot select for reconcilion"), | 201 | _("Cannot select for reconcilion"), |
333 | 189 | _("No entry found for the selected invoice. ")) | 202 | _("No entry found for the selected invoice. ")) |
363 | 190 | else: | 203 | for move_line_id in manual_move_line_ids: |
364 | 191 | move_line_id = manual_move_line_id | 204 | todo_entry = [False, move_line_id] |
365 | 192 | move_line = move_line_obj.read( | 205 | move_line=move_line_obj.read( |
366 | 193 | cr, uid, move_line_id, ['invoice'], context=context) | 206 | cr, |
367 | 194 | invoice_id = (move_line['invoice'] and | 207 | uid, |
368 | 195 | move_line['invoice'][0]) | 208 | move_line_id, |
369 | 196 | vals = { | 209 | ['invoice'], |
370 | 197 | 'move_line_id': move_line_id, | 210 | context=context) |
371 | 198 | 'move_line_ids': [(6, 0, [move_line_id])], | 211 | if move_line['invoice']: |
372 | 199 | 'invoice_id': invoice_id, | 212 | todo_entry[0] = move_line['invoice'][0] |
373 | 200 | 'invoice_ids': [(6, 0, invoice_id and | 213 | todo.append(todo_entry) |
374 | 201 | [invoice_id] or [])], | 214 | |
375 | 202 | 'match_type': 'manual', | 215 | while todo: |
376 | 203 | } | 216 | todo_entry = todo.pop() |
377 | 204 | transaction_obj.clear_and_write( | 217 | move_line = move_line_obj.browse( |
378 | 205 | cr, uid, wiz.import_transaction_id.id, | 218 | cr, uid, todo_entry[1], context) |
379 | 206 | vals, context=context) | 219 | transaction_id = wiz.import_transaction_id.id |
380 | 207 | st_line_vals = { | 220 | statement_line_id = wiz.statement_line_id.id |
381 | 208 | 'account_id': move_line_obj.read( | 221 | |
382 | 209 | cr, uid, move_line_id, | 222 | if len(todo) > 0: |
383 | 210 | ['account_id'], context=context)['account_id'][0], | 223 | statement_line_id = wiz.statement_line_id.split_off( |
384 | 211 | } | 224 | move_line.debit or -move_line.credit)[0] |
385 | 212 | if invoice_id: | 225 | transaction_id = statement_line_obj.browse( |
386 | 213 | st_line_vals['partner_id'] = invoice_obj.read( | 226 | cr, |
387 | 214 | cr, uid, invoice_id, | 227 | uid, |
388 | 215 | ['partner_id'], context=context)['partner_id'][0] | 228 | statement_line_id, |
389 | 216 | statement_line_obj.write( | 229 | context=context).import_transaction_id.id |
390 | 217 | cr, uid, wiz.import_transaction_id.statement_line_id.id, | 230 | |
391 | 218 | st_line_vals, context=context) | 231 | vals = { |
392 | 232 | 'move_line_id': todo_entry[1], | ||
393 | 233 | 'move_line_ids': [(6, 0, [todo_entry[1]])], | ||
394 | 234 | 'invoice_id': todo_entry[0], | ||
395 | 235 | 'invoice_ids': [(6, 0, | ||
396 | 236 | [todo_entry[0]] if todo_entry[0] else [])], | ||
397 | 237 | 'match_type': 'manual', | ||
398 | 238 | } | ||
399 | 239 | |||
400 | 240 | transaction_obj.clear_and_write( | ||
401 | 241 | cr, uid, transaction_id, vals, context=context) | ||
402 | 242 | |||
403 | 243 | st_line_vals = { | ||
404 | 244 | 'account_id': move_line_obj.read( | ||
405 | 245 | cr, uid, todo_entry[1], | ||
406 | 246 | ['account_id'], context=context)['account_id'][0], | ||
407 | 247 | } | ||
408 | 248 | |||
409 | 249 | if todo_entry[0]: | ||
410 | 250 | st_line_vals['partner_id'] = invoice_obj.read( | ||
411 | 251 | cr, uid, todo_entry[0], | ||
412 | 252 | ['partner_id'], context=context)['partner_id'][0] | ||
413 | 253 | |||
414 | 254 | statement_line_obj.write( | ||
415 | 255 | cr, uid, statement_line_id, | ||
416 | 256 | st_line_vals, context=context) | ||
417 | 219 | return res | 257 | return res |
418 | 220 | 258 | ||
419 | 221 | def trigger_write(self, cr, uid, ids, context=None): | 259 | def trigger_write(self, cr, uid, ids, context=None): |
420 | @@ -247,14 +285,26 @@ | |||
421 | 247 | account_id = setting.default_debit_account_id and setting.default_debit_account_id.id | 285 | account_id = setting.default_debit_account_id and setting.default_debit_account_id.id |
422 | 248 | statement_pool.write(cr, uid, wiz.statement_line_id.id, {'account_id':account_id}) | 286 | statement_pool.write(cr, uid, wiz.statement_line_id.id, {'account_id':account_id}) |
423 | 249 | 287 | ||
432 | 250 | self.write(cr, uid, wiz.id, {'partner_id': False}, context=context) | 288 | # Restore partner id from the bank account or else reset |
433 | 251 | 289 | partner_id = False | |
434 | 252 | wizs = self.read( | 290 | if (wiz.statement_line_id.partner_bank_id and |
435 | 253 | cr, uid, ids, ['import_transaction_id'], context=context) | 291 | wiz.statement_line_id.partner_bank_id.partner_id): |
436 | 254 | trans_ids = [x['import_transaction_id'][0] for x in wizs | 292 | partner_id = wiz.statement_line_id.partner_bank_id.partner_id.id |
437 | 255 | if x['import_transaction_id']] | 293 | wiz.write({'partner_id': partner_id}) |
438 | 256 | self.pool.get('banking.import.transaction').clear_and_write( | 294 | |
439 | 257 | cr, uid, trans_ids, context=context) | 295 | if wiz.statement_line_id: |
440 | 296 | #delete splits causing an unsplit if this is a split | ||
441 | 297 | #transaction | ||
442 | 298 | statement_pool.unlink(cr, uid, | ||
443 | 299 | statement_pool.search(cr, uid, | ||
444 | 300 | [('parent_id', '=', wiz.statement_line_id.id)], | ||
445 | 301 | context=context), | ||
446 | 302 | context=context) | ||
447 | 303 | |||
448 | 304 | if wiz.import_transaction_id: | ||
449 | 305 | wiz.import_transaction_id.clear_and_write() | ||
450 | 306 | |||
451 | 307 | |||
452 | 258 | return True | 308 | return True |
453 | 259 | 309 | ||
454 | 260 | def reverse_duplicate(self, cr, uid, ids, context=None): | 310 | def reverse_duplicate(self, cr, uid, ids, context=None): |
455 | @@ -281,7 +331,7 @@ | |||
456 | 281 | return res | 331 | return res |
457 | 282 | 332 | ||
458 | 283 | def button_done(self, cr, uid, ids, context=None): | 333 | def button_done(self, cr, uid, ids, context=None): |
460 | 284 | return {'nodestroy': False, 'type': 'ir.actions.act_window_close'} | 334 | return {'type': 'ir.actions.act_window_close'} |
461 | 285 | 335 | ||
462 | 286 | _defaults = { | 336 | _defaults = { |
463 | 287 | # 'match_type': _get_default_match_type, | 337 | # 'match_type': _get_default_match_type, |
464 | @@ -305,6 +355,9 @@ | |||
465 | 305 | 'statement_line_id', 'partner_id', | 355 | 'statement_line_id', 'partner_id', |
466 | 306 | type='many2one', relation='res.partner', | 356 | type='many2one', relation='res.partner', |
467 | 307 | string="Partner", readonly=True), | 357 | string="Partner", readonly=True), |
468 | 358 | 'statement_line_parent_id': fields.related( | ||
469 | 359 | 'statement_line_id', 'parent_id', type='many2one', | ||
470 | 360 | relation='account.bank.statement.line', readonly=True), | ||
471 | 308 | 'import_transaction_id': fields.related( | 361 | 'import_transaction_id': fields.related( |
472 | 309 | 'statement_line_id', 'import_transaction_id', | 362 | 'statement_line_id', 'import_transaction_id', |
473 | 310 | string="Import transaction", | 363 | string="Import transaction", |
474 | @@ -350,14 +403,17 @@ | |||
475 | 350 | 'match_type': fields.related( | 403 | 'match_type': fields.related( |
476 | 351 | 'import_transaction_id', 'match_type', | 404 | 'import_transaction_id', 'match_type', |
477 | 352 | type="char", size=16, string='Match type', readonly=True), | 405 | type="char", size=16, string='Match type', readonly=True), |
480 | 353 | 'manual_invoice_id': fields.many2one( | 406 | 'manual_invoice_ids': fields.many2many( |
481 | 354 | 'account.invoice', 'Match this invoice', | 407 | 'account.invoice', |
482 | 408 | 'banking_transaction_wizard_account_invoice_rel', | ||
483 | 409 | 'wizard_id', 'invoice_id', string='Match one or more invoices', | ||
484 | 355 | domain=[('reconciled', '=', False)]), | 410 | domain=[('reconciled', '=', False)]), |
487 | 356 | 'manual_move_line_id': fields.many2one( | 411 | 'manual_move_line_ids': fields.many2many( |
488 | 357 | 'account.move.line', 'Or match this entry', | 412 | 'account.move.line', |
489 | 413 | 'banking_transaction_wizard_account_move_line_rel', | ||
490 | 414 | 'wizard_id', 'move_line_id', string='Or match one or more entries', | ||
491 | 358 | domain=[('account_id.reconcile', '=', True), | 415 | domain=[('account_id.reconcile', '=', True), |
494 | 359 | ('reconcile_id', '=', False)], | 416 | ('reconcile_id', '=', False)]), |
493 | 360 | ), | ||
495 | 361 | 'payment_option': fields.related('import_transaction_id','payment_option', string='Payment Difference', type='selection', required=True, | 417 | 'payment_option': fields.related('import_transaction_id','payment_option', string='Payment Difference', type='selection', required=True, |
496 | 362 | selection=[('without_writeoff', 'Keep Open'),('with_writeoff', 'Reconcile Payment Balance')]), | 418 | selection=[('without_writeoff', 'Keep Open'),('with_writeoff', 'Reconcile Payment Balance')]), |
497 | 363 | 'writeoff_analytic_id': fields.related( | 419 | 'writeoff_analytic_id': fields.related( |
498 | 364 | 420 | ||
499 | === modified file 'account_banking/wizard/banking_transaction_wizard.xml' | |||
500 | --- account_banking/wizard/banking_transaction_wizard.xml 2013-01-13 14:11:44 +0000 | |||
501 | +++ account_banking/wizard/banking_transaction_wizard.xml 2013-06-03 09:55:43 +0000 | |||
502 | @@ -9,6 +9,7 @@ | |||
503 | 9 | <form string="Match transaction"> | 9 | <form string="Match transaction"> |
504 | 10 | <!-- fields used for form logic --> | 10 | <!-- fields used for form logic --> |
505 | 11 | <field name="payment_order_ids" invisible="True"/> | 11 | <field name="payment_order_ids" invisible="True"/> |
506 | 12 | <field name="statement_line_parent_id" invisible="True"/> | ||
507 | 12 | <field name="invoice_ids" invisible="True"/> | 13 | <field name="invoice_ids" invisible="True"/> |
508 | 13 | <field name="move_line_ids" invisible="True"/> | 14 | <field name="move_line_ids" invisible="True"/> |
509 | 14 | <field name="match_multi" invisible="True"/> | 15 | <field name="match_multi" invisible="True"/> |
510 | @@ -89,30 +90,18 @@ | |||
511 | 89 | name="trigger_match" | 90 | name="trigger_match" |
512 | 90 | type="object" | 91 | type="object" |
513 | 91 | string="Match again"/> | 92 | string="Match again"/> |
514 | 92 | <!-- Manual selection --> | ||
515 | 93 | </page> | 93 | </page> |
516 | 94 | <!-- Manual selection --> | ||
517 | 94 | <page string="Manual match"> | 95 | <page string="Manual match"> |
537 | 95 | <field name="manual_invoice_id"/> | 96 | <field name="manual_invoice_ids" colspan="4" |
538 | 96 | <!-- | 97 | context="{'search_default_partner_id': partner_id}" |
539 | 97 | Specify alternative tree_view_ref as a | 98 | /> |
540 | 98 | workaround for lp:1073521 in OpenERP 6.1 | 99 | <field name="manual_move_line_ids" colspan="4" |
541 | 99 | Need to also define 'view_mode' to prevent | 100 | context="{'search_default_partner_id': partner_id}" |
542 | 100 | an instant editable tree view | 101 | /> |
543 | 101 | reconstruction by account.move.line's | 102 | <button name="trigger_write" |
525 | 102 | fields_view_get(). | ||
526 | 103 | Both are not needed in OpenERP 6.0 or 7.0. | ||
527 | 104 | --> | ||
528 | 105 | <field name="manual_move_line_id" | ||
529 | 106 | context="{ | ||
530 | 107 | 'tree_view_ref': 'account.view_move_line_tax_tree', | ||
531 | 108 | 'view_mode': 'yes' | ||
532 | 109 | }" | ||
533 | 110 | /> | ||
534 | 111 | <newline/> | ||
535 | 112 | <button colspan="1" | ||
536 | 113 | name="trigger_write" | ||
544 | 114 | type="object" | 103 | type="object" |
546 | 115 | string="Match"/> | 104 | string="Match" /> |
547 | 116 | </page> | 105 | </page> |
548 | 117 | <page string="Write-Off" attrs="{'invisible': [('match_type', '=', False)]}"> | 106 | <page string="Write-Off" attrs="{'invisible': [('match_type', '=', False)]}"> |
549 | 118 | <group colspan="2" col="2"> | 107 | <group colspan="2" col="2"> |
550 | @@ -139,7 +128,7 @@ | |||
551 | 139 | </notebook> | 128 | </notebook> |
552 | 140 | <group colspan="2"> | 129 | <group colspan="2"> |
553 | 141 | <separator/> | 130 | <separator/> |
555 | 142 | <button icon="gtk-ok" string="Done" special="cancel"/> | 131 | <button icon="gtk-ok" string="Close" special="cancel"/> |
556 | 143 | </group> | 132 | </group> |
557 | 144 | </group> | 133 | </group> |
558 | 145 | </form> | 134 | </form> |
Unholding because what was claimed to be a problem is a works as designed: Invoices obviously only get paid after you confirm a match, that also applies to split matches.