Skip to content

Commit 5764427

Browse files
Sylvain Van Hoofsylvainvh
authored andcommitted
[MIG] account_invoice_merge: Migration to 12.0
1 parent 3326db6 commit 5764427

File tree

10 files changed

+128
-77
lines changed

10 files changed

+128
-77
lines changed

account_invoice_merge/README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Contributors
4343
* Cédric Pigeon <[email protected]>
4444
* Lois Rilo <[email protected]>
4545
* Miquel Raïch <[email protected]>
46+
* Sylvain Van Hoof <[email protected]>
4647

4748
Maintainer
4849
----------

account_invoice_merge/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
# Copyright 2004-2010 Tiny SPRL (http://tiny.be).
32
# Copyright 2010-2011 Elico Corp.
43
# Copyright 2016 Acsone (https://www.acsone.eu/)

account_invoice_merge/__manifest__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
# -*- coding: utf-8 -*-
21
# Copyright 2004-2010 Tiny SPRL (http://tiny.be).
32
# Copyright 2010-2011 Elico Corp.
43
# Copyright 2016 Acsone (https://www.acsone.eu/)
54
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
65
# (http://www.eficent.com)
6+
# Copyright 2019 Okia SPRL
77
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
88

99
{
1010
'name': 'Account Invoice Merge',
11-
'version': '10.0.1.0.1',
11+
'version': '12.0.1.0.1',
1212
'category': 'Finance',
1313
'summary': "Merge invoices in draft",
1414
'author': "Elico Corp,Odoo Community Association (OCA)",
Lines changed: 47 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,160 +1,155 @@
11
# Translation of Odoo Server.
22
# This file contains the translation of the following modules:
3-
# * account_invoice_merge
3+
# * account_invoice_merge
44
#
5-
# Translators:
6-
# OCA Transbot <[email protected]>, 2016
75
msgid ""
86
msgstr ""
9-
"Project-Id-Version: Odoo Server 9.0c\n"
7+
"Project-Id-Version: Odoo Server 12.0+e\n"
108
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2016-12-09 03:38+0000\n"
12-
"PO-Revision-Date: 2016-12-09 03:38+0000\n"
13-
"Last-Translator: OCA Transbot <[email protected]>, 2016\n"
14-
"Language-Team: Dutch (Belgium) (https://www.transifex.com/oca/teams/23907/"
15-
"nl_BE/)\n"
16-
"Language: nl_BE\n"
9+
"POT-Creation-Date: 2019-02-13 16:13+0000\n"
10+
"PO-Revision-Date: 2019-02-13 16:13+0000\n"
11+
"Last-Translator: <>\n"
12+
"Language-Team: \n"
1713
"MIME-Version: 1.0\n"
1814
"Content-Type: text/plain; charset=UTF-8\n"
1915
"Content-Transfer-Encoding: \n"
20-
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
16+
"Plural-Forms: \n"
2117

2218
#. module: account_invoice_merge
23-
#: model:ir.ui.view,arch_db:account_invoice_merge.view_invoice_merge
19+
#: model_terms:ir.ui.view,arch_db:account_invoice_merge.view_invoice_merge
2420
msgid "Are you sure you want to merge these invoices?"
2521
msgstr ""
2622

2723
#. module: account_invoice_merge
28-
#: code:addons/account_invoice_merge/wizard/invoice_merge.py:34
24+
#: code:addons/account_invoice_merge/wizard/invoice_merge.py:35
2925
#, python-format
3026
msgid "At least one of the selected invoices is %s!"
31-
msgstr ""
27+
msgstr "Er is in ieder geval één factuur in status %s. Deze kan niet samengevoegd worden."
3228

3329
#. module: account_invoice_merge
34-
#: model:ir.ui.view,arch_db:account_invoice_merge.view_invoice_merge
30+
#: model_terms:ir.ui.view,arch_db:account_invoice_merge.view_invoice_merge
3531
msgid "Cancel"
3632
msgstr "Annuleren"
3733

3834
#. module: account_invoice_merge
39-
#: model:ir.model.fields,field_description:account_invoice_merge.field_invoice_merge_create_uid
35+
#: model:ir.model.fields,field_description:account_invoice_merge.field_invoice_merge__create_uid
4036
msgid "Created by"
41-
msgstr "Gemaakt door"
37+
msgstr "Aangemaakt door"
4238

4339
#. module: account_invoice_merge
44-
#: model:ir.model.fields,field_description:account_invoice_merge.field_invoice_merge_create_date
40+
#: model:ir.model.fields,field_description:account_invoice_merge.field_invoice_merge__create_date
4541
msgid "Created on"
4642
msgstr "Gemaakt op"
4743

4844
#. module: account_invoice_merge
49-
#: model:ir.model.fields,field_description:account_invoice_merge.field_invoice_merge_display_name
45+
#: model:ir.model.fields,field_description:account_invoice_merge.field_invoice_merge__display_name
5046
msgid "Display Name"
5147
msgstr "Schermnaam"
5248

5349
#. module: account_invoice_merge
54-
#: model:ir.model.fields,field_description:account_invoice_merge.field_invoice_merge_id
50+
#: model:ir.model.fields,field_description:account_invoice_merge.field_invoice_merge__id
5551
msgid "ID"
56-
msgstr "ID"
52+
msgstr ""
5753

5854
#. module: account_invoice_merge
5955
#: model:ir.model,name:account_invoice_merge.model_account_invoice
6056
msgid "Invoice"
6157
msgstr "Factuur"
6258

6359
#. module: account_invoice_merge
64-
#: model:ir.model.fields,field_description:account_invoice_merge.field_invoice_merge_date_invoice
60+
#: model:ir.model.fields,field_description:account_invoice_merge.field_invoice_merge__date_invoice
6561
msgid "Invoice Date"
66-
msgstr ""
62+
msgstr "Factuurdatum"
6763

6864
#. module: account_invoice_merge
69-
#: model:ir.model.fields,field_description:account_invoice_merge.field_invoice_merge_keep_references
65+
#: model:ir.model.fields,field_description:account_invoice_merge.field_invoice_merge__keep_references
7066
msgid "Keep references from original invoices"
71-
msgstr ""
67+
msgstr "Referenties van samengevoegde facturen behouden"
7268

7369
#. module: account_invoice_merge
74-
#: model:ir.model.fields,field_description:account_invoice_merge.field_invoice_merge___last_update
70+
#: model:ir.model.fields,field_description:account_invoice_merge.field_invoice_merge____last_update
7571
msgid "Last Modified on"
76-
msgstr "Laatst Aangepast op"
72+
msgstr "Laatst gewijzigd op"
7773

7874
#. module: account_invoice_merge
79-
#: model:ir.model.fields,field_description:account_invoice_merge.field_invoice_merge_write_uid
75+
#: model:ir.model.fields,field_description:account_invoice_merge.field_invoice_merge__write_uid
8076
msgid "Last Updated by"
8177
msgstr "Laatst bijgewerkt door"
8278

8379
#. module: account_invoice_merge
84-
#: model:ir.model.fields,field_description:account_invoice_merge.field_invoice_merge_write_date
80+
#: model:ir.model.fields,field_description:account_invoice_merge.field_invoice_merge__write_date
8581
msgid "Last Updated on"
8682
msgstr "Laatst bijgewerkt op"
8783

8884
#. module: account_invoice_merge
89-
#: model:ir.ui.view,arch_db:account_invoice_merge.view_invoice_merge
85+
#: model_terms:ir.ui.view,arch_db:account_invoice_merge.view_invoice_merge
9086
msgid "Merge Invoices"
91-
msgstr ""
87+
msgstr "Facturen samenvoegen"
9288

9389
#. module: account_invoice_merge
9490
#: model:ir.actions.act_window,name:account_invoice_merge.action_view_invoice_merge
9591
#: model:ir.model,name:account_invoice_merge.model_invoice_merge
96-
#: model:ir.ui.view,arch_db:account_invoice_merge.view_invoice_merge
92+
#: model_terms:ir.ui.view,arch_db:account_invoice_merge.view_invoice_merge
9793
msgid "Merge Partner Invoice"
98-
msgstr ""
94+
msgstr "Facturen samenvoegen per relatie"
9995

10096
#. module: account_invoice_merge
101-
#: code:addons/account_invoice_merge/wizard/invoice_merge.py:41
97+
#: code:addons/account_invoice_merge/wizard/invoice_merge.py:42
10298
#, python-format
10399
msgid "Not all invoices are at the same company!"
104-
msgstr ""
100+
msgstr "Niet alle facturen behoren tot hetzelfde bedrijf!"
105101

106102
#. module: account_invoice_merge
107-
#: code:addons/account_invoice_merge/wizard/invoice_merge.py:50
103+
#: code:addons/account_invoice_merge/wizard/invoice_merge.py:51
108104
#, python-format
109105
msgid "Not all invoices are at the same currency!"
110-
msgstr ""
106+
msgstr "Niet alle facturen staan in dezelfde valuta!"
111107

112108
#. module: account_invoice_merge
113-
#: code:addons/account_invoice_merge/wizard/invoice_merge.py:53
109+
#: code:addons/account_invoice_merge/wizard/invoice_merge.py:54
114110
#, python-format
115111
msgid "Not all invoices are at the same journal!"
116-
msgstr ""
112+
msgstr "Niet alle facturen staan in hetzelfde dagboek!"
117113

118114
#. module: account_invoice_merge
119-
#: code:addons/account_invoice_merge/wizard/invoice_merge.py:44
115+
#: code:addons/account_invoice_merge/wizard/invoice_merge.py:45
120116
#, python-format
121117
msgid "Not all invoices are for the same partner!"
122-
msgstr ""
118+
msgstr "Niet alle facturen zijn voor dezelfde relatie!"
123119

124120
#. module: account_invoice_merge
125-
#: code:addons/account_invoice_merge/wizard/invoice_merge.py:47
121+
#: code:addons/account_invoice_merge/wizard/invoice_merge.py:48
126122
#, python-format
127123
msgid "Not all invoices are of the same type!"
128-
msgstr ""
124+
msgstr "Niet alle facturen hebben hetzelfde type!"
129125

130126
#. module: account_invoice_merge
131-
#: code:addons/account_invoice_merge/wizard/invoice_merge.py:38
127+
#: code:addons/account_invoice_merge/wizard/invoice_merge.py:39
132128
#, python-format
133129
msgid "Not all invoices use the same account!"
134-
msgstr ""
130+
msgstr "Niet alle facturen staan op dezelfde grootboekrekening!"
135131

136132
#. module: account_invoice_merge
137-
#: model:ir.ui.view,arch_db:account_invoice_merge.view_invoice_merge
138-
msgid ""
139-
"Please note that:<br/><br/>\n"
133+
#: model_terms:ir.ui.view,arch_db:account_invoice_merge.view_invoice_merge
134+
msgid "Please note that:<br/><br/>\n"
140135
" Invoices will only be merged if:<br/>\n"
141136
" * Invoices are in state 'draft'.<br/>\n"
142137
" * Invoices belong to the same partner.<br/>\n"
143138
" * Invoices have the same company, partner, address,\n"
144-
" currency, journal, salesman, account and type.<br/"
145-
"><br/>\n"
139+
" currency, journal, salesman, account and type.<br/><br/>\n"
146140
" Lines will only be merged if:<br/>\n"
147141
" * Invoice lines are exactly the same except for the\n"
148142
" product, quantity and unit.<br/>"
149143
msgstr ""
150144

151145
#. module: account_invoice_merge
152-
#: code:addons/account_invoice_merge/wizard/invoice_merge.py:27
146+
#: code:addons/account_invoice_merge/wizard/invoice_merge.py:28
153147
#, python-format
154148
msgid "Please select multiple invoices to merge in the list view."
155149
msgstr ""
156150

157151
#. module: account_invoice_merge
158-
#: model:ir.ui.view,arch_db:account_invoice_merge.view_invoice_merge
152+
#: model_terms:ir.ui.view,arch_db:account_invoice_merge.view_invoice_merge
159153
msgid "or"
160154
msgstr "of"
155+

account_invoice_merge/models/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
# Copyright 2004-2010 Tiny SPRL (http://tiny.be).
32
# Copyright 2010-2011 Elico Corp.
43
# Copyright 2016 Acsone (https://www.acsone.eu/)

account_invoice_merge/models/account_invoice.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# -*- coding: utf-8 -*-
21
# Copyright 2004-2010 Tiny SPRL (http://tiny.be).
32
# Copyright 2010-2011 Elico Corp.
43
# Copyright 2016 Acsone (https://www.acsone.eu/)
54
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
65
# (http://www.eficent.com)
6+
# Copyright 2019 Okia SPRL
77
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
88

99
from odoo import api, models
@@ -152,27 +152,28 @@ def make_key(br, fields):
152152
allinvoices = []
153153
allnewinvoices = []
154154
invoices_info = {}
155+
old_invoices = self.env['account.invoice']
155156
qty_prec = self.env['decimal.precision'].precision_get(
156157
'Product Unit of Measure')
157-
for invoice_key, (invoice_data, old_ids) in new_invoices.iteritems():
158+
for invoice_key, (invoice_data, old_ids) in new_invoices.items():
158159
# skip merges with only one invoice
159160
if len(old_ids) < 2:
160161
allinvoices += (old_ids or [])
161162
continue
162163
# cleanup invoice line data
163-
for key, value in invoice_data['invoice_line_ids'].iteritems():
164+
for key, value in invoice_data['invoice_line_ids'].items():
164165
value.update(dict(key))
165166

166167
if remove_empty_invoice_lines:
167168
invoice_data['invoice_line_ids'] = [
168169
(0, 0, value) for value in
169-
invoice_data['invoice_line_ids'].itervalues() if
170+
invoice_data['invoice_line_ids'].values() if
170171
not float_is_zero(
171172
value['quantity'], precision_digits=qty_prec)]
172173
else:
173174
invoice_data['invoice_line_ids'] = [
174175
(0, 0, value) for value in
175-
invoice_data['invoice_line_ids'].itervalues()]
176+
invoice_data['invoice_line_ids'].values()]
176177

177178
if date_invoice:
178179
invoice_data['date_invoice'] = date_invoice

account_invoice_merge/tests/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
32
# (http://www.eficent.com)
43
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

account_invoice_merge/tests/test_account_invoice_merge.py

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
# -*- coding: utf-8 -*-
21
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
32
# (http://www.eficent.com)
43
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
54
from odoo.tests.common import TransactionCase
6-
from odoo.exceptions import Warning
5+
from odoo.exceptions import UserError
76

87

98
class TestAccountInvoiceMerge(TransactionCase):
@@ -101,5 +100,63 @@ def test_account_invoice_merge_2(self):
101100
active_ids=[self.invoice1.id, self.invoice3.id],
102101
active_model='account.invoice'
103102
).create({})
104-
with self.assertRaises(Warning):
103+
with self.assertRaises(UserError):
105104
wiz_id.fields_view_get()
105+
106+
def test_dirty_check(self):
107+
""" Check """
108+
wiz_id = self.wiz.with_context(
109+
active_model='account.invoice'
110+
)
111+
112+
# Check with only one invoice
113+
with self.assertRaises(UserError):
114+
wiz_id.with_context(
115+
active_ids=[self.invoice1.id])\
116+
.fields_view_get()
117+
118+
# Check with two different invoice type
119+
# Create the invoice 4 with a different account
120+
new_account = self.acc_model.create({
121+
'code': 'TEST',
122+
'name': 'Test Account',
123+
'reconcile': True,
124+
'user_type_id':
125+
self.env.ref('account.data_account_type_receivable').id
126+
})
127+
invoice_line4 = self._create_inv_line(new_account.id)
128+
invoice4 = self._create_invoice(self.partner1, 'D', invoice_line4)
129+
invoice4.account_id = new_account.id
130+
with self.assertRaises(UserError):
131+
wiz_id.with_context(
132+
active_ids=[self.invoice1.id, invoice4.id]) \
133+
.fields_view_get()
134+
135+
# Check with a canceled invoice
136+
# Create and cancel the invoice 5
137+
invoice_line5 = self._create_inv_line(self.invoice_account.id)
138+
invoice5 = self._create_invoice(self.partner1, 'E', invoice_line5)
139+
invoice5.action_invoice_cancel()
140+
with self.assertRaises(UserError):
141+
wiz_id.with_context(
142+
active_ids=[self.invoice1.id, invoice5.id]) \
143+
.fields_view_get()
144+
145+
# Check with an another company
146+
# Create the invoice 6 and change the company
147+
invoice_line6 = self._create_inv_line(self.invoice_account.id)
148+
invoice6 = self._create_invoice(self.partner1, 'E', invoice_line6)
149+
new_company = self.env['res.company'].create({
150+
'name': 'Hello World'
151+
})
152+
invoice6.company_id = new_company.id
153+
with self.assertRaises(UserError):
154+
wiz_id.with_context(
155+
active_ids=[self.invoice1.id, invoice6.id]) \
156+
.fields_view_get()
157+
158+
# Check with two different partners
159+
with self.assertRaises(UserError):
160+
wiz_id.with_context(
161+
active_ids=[self.invoice1.id, self.invoice3.id]) \
162+
.fields_view_get()

account_invoice_merge/wizard/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
# Copyright 2004-2010 Tiny SPRL (http://tiny.be).
32
# Copyright 2010-2011 Elico Corp.
43
# Copyright 2016 Acsone (https://www.acsone.eu/)

0 commit comments

Comments
 (0)