Skip to content

Commit

Permalink
[MIG] account_invoice_merge: Migration to 12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Sylvain Van Hoof authored and sylvainvh committed May 15, 2019
1 parent 3326db6 commit 5764427
Show file tree
Hide file tree
Showing 10 changed files with 128 additions and 77 deletions.
1 change: 1 addition & 0 deletions account_invoice_merge/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Contributors
* Cédric Pigeon <[email protected]>
* Lois Rilo <[email protected]>
* Miquel Raïch <[email protected]>
* Sylvain Van Hoof <[email protected]>

Maintainer
----------
Expand Down
1 change: 0 additions & 1 deletion account_invoice_merge/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2004-2010 Tiny SPRL (http://tiny.be).
# Copyright 2010-2011 Elico Corp.
# Copyright 2016 Acsone (https://www.acsone.eu/)
Expand Down
4 changes: 2 additions & 2 deletions account_invoice_merge/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# -*- coding: utf-8 -*-
# Copyright 2004-2010 Tiny SPRL (http://tiny.be).
# Copyright 2010-2011 Elico Corp.
# Copyright 2016 Acsone (https://www.acsone.eu/)
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# (http://www.eficent.com)
# Copyright 2019 Okia SPRL
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

{
'name': 'Account Invoice Merge',
'version': '10.0.1.0.1',
'version': '12.0.1.0.1',
'category': 'Finance',
'summary': "Merge invoices in draft",
'author': "Elico Corp,Odoo Community Association (OCA)",
Expand Down
99 changes: 47 additions & 52 deletions account_invoice_merge/i18n/nl_BE.po
Original file line number Diff line number Diff line change
@@ -1,160 +1,155 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_invoice_merge
# * account_invoice_merge
#
# Translators:
# OCA Transbot <[email protected]>, 2016
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 9.0c\n"
"Project-Id-Version: Odoo Server 12.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-12-09 03:38+0000\n"
"PO-Revision-Date: 2016-12-09 03:38+0000\n"
"Last-Translator: OCA Transbot <[email protected]>, 2016\n"
"Language-Team: Dutch (Belgium) (https://www.transifex.com/oca/teams/23907/"
"nl_BE/)\n"
"Language: nl_BE\n"
"POT-Creation-Date: 2019-02-13 16:13+0000\n"
"PO-Revision-Date: 2019-02-13 16:13+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Plural-Forms: \n"

#. module: account_invoice_merge
#: model:ir.ui.view,arch_db:account_invoice_merge.view_invoice_merge
#: model_terms:ir.ui.view,arch_db:account_invoice_merge.view_invoice_merge
msgid "Are you sure you want to merge these invoices?"
msgstr ""

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

#. module: account_invoice_merge
#: model:ir.ui.view,arch_db:account_invoice_merge.view_invoice_merge
#: model_terms:ir.ui.view,arch_db:account_invoice_merge.view_invoice_merge
msgid "Cancel"
msgstr "Annuleren"

#. module: account_invoice_merge
#: model:ir.model.fields,field_description:account_invoice_merge.field_invoice_merge_create_uid
#: model:ir.model.fields,field_description:account_invoice_merge.field_invoice_merge__create_uid
msgid "Created by"
msgstr "Gemaakt door"
msgstr "Aangemaakt door"

#. module: account_invoice_merge
#: model:ir.model.fields,field_description:account_invoice_merge.field_invoice_merge_create_date
#: model:ir.model.fields,field_description:account_invoice_merge.field_invoice_merge__create_date
msgid "Created on"
msgstr "Gemaakt op"

#. module: account_invoice_merge
#: model:ir.model.fields,field_description:account_invoice_merge.field_invoice_merge_display_name
#: model:ir.model.fields,field_description:account_invoice_merge.field_invoice_merge__display_name
msgid "Display Name"
msgstr "Schermnaam"

#. module: account_invoice_merge
#: model:ir.model.fields,field_description:account_invoice_merge.field_invoice_merge_id
#: model:ir.model.fields,field_description:account_invoice_merge.field_invoice_merge__id
msgid "ID"
msgstr "ID"
msgstr ""

#. module: account_invoice_merge
#: model:ir.model,name:account_invoice_merge.model_account_invoice
msgid "Invoice"
msgstr "Factuur"

#. module: account_invoice_merge
#: model:ir.model.fields,field_description:account_invoice_merge.field_invoice_merge_date_invoice
#: model:ir.model.fields,field_description:account_invoice_merge.field_invoice_merge__date_invoice
msgid "Invoice Date"
msgstr ""
msgstr "Factuurdatum"

#. module: account_invoice_merge
#: model:ir.model.fields,field_description:account_invoice_merge.field_invoice_merge_keep_references
#: model:ir.model.fields,field_description:account_invoice_merge.field_invoice_merge__keep_references
msgid "Keep references from original invoices"
msgstr ""
msgstr "Referenties van samengevoegde facturen behouden"

#. module: account_invoice_merge
#: model:ir.model.fields,field_description:account_invoice_merge.field_invoice_merge___last_update
#: model:ir.model.fields,field_description:account_invoice_merge.field_invoice_merge____last_update
msgid "Last Modified on"
msgstr "Laatst Aangepast op"
msgstr "Laatst gewijzigd op"

#. module: account_invoice_merge
#: model:ir.model.fields,field_description:account_invoice_merge.field_invoice_merge_write_uid
#: model:ir.model.fields,field_description:account_invoice_merge.field_invoice_merge__write_uid
msgid "Last Updated by"
msgstr "Laatst bijgewerkt door"

#. module: account_invoice_merge
#: model:ir.model.fields,field_description:account_invoice_merge.field_invoice_merge_write_date
#: model:ir.model.fields,field_description:account_invoice_merge.field_invoice_merge__write_date
msgid "Last Updated on"
msgstr "Laatst bijgewerkt op"

#. module: account_invoice_merge
#: model:ir.ui.view,arch_db:account_invoice_merge.view_invoice_merge
#: model_terms:ir.ui.view,arch_db:account_invoice_merge.view_invoice_merge
msgid "Merge Invoices"
msgstr ""
msgstr "Facturen samenvoegen"

#. module: account_invoice_merge
#: model:ir.actions.act_window,name:account_invoice_merge.action_view_invoice_merge
#: model:ir.model,name:account_invoice_merge.model_invoice_merge
#: model:ir.ui.view,arch_db:account_invoice_merge.view_invoice_merge
#: model_terms:ir.ui.view,arch_db:account_invoice_merge.view_invoice_merge
msgid "Merge Partner Invoice"
msgstr ""
msgstr "Facturen samenvoegen per relatie"

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

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

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

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

#. module: account_invoice_merge
#: code:addons/account_invoice_merge/wizard/invoice_merge.py:47
#: code:addons/account_invoice_merge/wizard/invoice_merge.py:48
#, python-format
msgid "Not all invoices are of the same type!"
msgstr ""
msgstr "Niet alle facturen hebben hetzelfde type!"

#. module: account_invoice_merge
#: code:addons/account_invoice_merge/wizard/invoice_merge.py:38
#: code:addons/account_invoice_merge/wizard/invoice_merge.py:39
#, python-format
msgid "Not all invoices use the same account!"
msgstr ""
msgstr "Niet alle facturen staan op dezelfde grootboekrekening!"

#. module: account_invoice_merge
#: model:ir.ui.view,arch_db:account_invoice_merge.view_invoice_merge
msgid ""
"Please note that:<br/><br/>\n"
#: model_terms:ir.ui.view,arch_db:account_invoice_merge.view_invoice_merge
msgid "Please note that:<br/><br/>\n"
" Invoices will only be merged if:<br/>\n"
" * Invoices are in state 'draft'.<br/>\n"
" * Invoices belong to the same partner.<br/>\n"
" * Invoices have the same company, partner, address,\n"
" currency, journal, salesman, account and type.<br/"
"><br/>\n"
" currency, journal, salesman, account and type.<br/><br/>\n"
" Lines will only be merged if:<br/>\n"
" * Invoice lines are exactly the same except for the\n"
" product, quantity and unit.<br/>"
msgstr ""

#. module: account_invoice_merge
#: code:addons/account_invoice_merge/wizard/invoice_merge.py:27
#: code:addons/account_invoice_merge/wizard/invoice_merge.py:28
#, python-format
msgid "Please select multiple invoices to merge in the list view."
msgstr ""

#. module: account_invoice_merge
#: model:ir.ui.view,arch_db:account_invoice_merge.view_invoice_merge
#: model_terms:ir.ui.view,arch_db:account_invoice_merge.view_invoice_merge
msgid "or"
msgstr "of"

1 change: 0 additions & 1 deletion account_invoice_merge/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2004-2010 Tiny SPRL (http://tiny.be).
# Copyright 2010-2011 Elico Corp.
# Copyright 2016 Acsone (https://www.acsone.eu/)
Expand Down
11 changes: 6 additions & 5 deletions account_invoice_merge/models/account_invoice.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
# Copyright 2004-2010 Tiny SPRL (http://tiny.be).
# Copyright 2010-2011 Elico Corp.
# Copyright 2016 Acsone (https://www.acsone.eu/)
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# (http://www.eficent.com)
# Copyright 2019 Okia SPRL
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import api, models
Expand Down Expand Up @@ -152,27 +152,28 @@ def make_key(br, fields):
allinvoices = []
allnewinvoices = []
invoices_info = {}
old_invoices = self.env['account.invoice']
qty_prec = self.env['decimal.precision'].precision_get(
'Product Unit of Measure')
for invoice_key, (invoice_data, old_ids) in new_invoices.iteritems():
for invoice_key, (invoice_data, old_ids) in new_invoices.items():
# skip merges with only one invoice
if len(old_ids) < 2:
allinvoices += (old_ids or [])
continue
# cleanup invoice line data
for key, value in invoice_data['invoice_line_ids'].iteritems():
for key, value in invoice_data['invoice_line_ids'].items():
value.update(dict(key))

if remove_empty_invoice_lines:
invoice_data['invoice_line_ids'] = [
(0, 0, value) for value in
invoice_data['invoice_line_ids'].itervalues() if
invoice_data['invoice_line_ids'].values() if
not float_is_zero(
value['quantity'], precision_digits=qty_prec)]
else:
invoice_data['invoice_line_ids'] = [
(0, 0, value) for value in
invoice_data['invoice_line_ids'].itervalues()]
invoice_data['invoice_line_ids'].values()]

if date_invoice:
invoice_data['date_invoice'] = date_invoice
Expand Down
1 change: 0 additions & 1 deletion account_invoice_merge/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# (http://www.eficent.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
Expand Down
63 changes: 60 additions & 3 deletions account_invoice_merge/tests/test_account_invoice_merge.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# (http://www.eficent.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo.tests.common import TransactionCase
from odoo.exceptions import Warning
from odoo.exceptions import UserError


class TestAccountInvoiceMerge(TransactionCase):
Expand Down Expand Up @@ -101,5 +100,63 @@ def test_account_invoice_merge_2(self):
active_ids=[self.invoice1.id, self.invoice3.id],
active_model='account.invoice'
).create({})
with self.assertRaises(Warning):
with self.assertRaises(UserError):
wiz_id.fields_view_get()

def test_dirty_check(self):
""" Check """
wiz_id = self.wiz.with_context(
active_model='account.invoice'
)

# Check with only one invoice
with self.assertRaises(UserError):
wiz_id.with_context(
active_ids=[self.invoice1.id])\
.fields_view_get()

# Check with two different invoice type
# Create the invoice 4 with a different account
new_account = self.acc_model.create({
'code': 'TEST',
'name': 'Test Account',
'reconcile': True,
'user_type_id':
self.env.ref('account.data_account_type_receivable').id
})
invoice_line4 = self._create_inv_line(new_account.id)
invoice4 = self._create_invoice(self.partner1, 'D', invoice_line4)
invoice4.account_id = new_account.id
with self.assertRaises(UserError):
wiz_id.with_context(
active_ids=[self.invoice1.id, invoice4.id]) \
.fields_view_get()

# Check with a canceled invoice
# Create and cancel the invoice 5
invoice_line5 = self._create_inv_line(self.invoice_account.id)
invoice5 = self._create_invoice(self.partner1, 'E', invoice_line5)
invoice5.action_invoice_cancel()
with self.assertRaises(UserError):
wiz_id.with_context(
active_ids=[self.invoice1.id, invoice5.id]) \
.fields_view_get()

# Check with an another company
# Create the invoice 6 and change the company
invoice_line6 = self._create_inv_line(self.invoice_account.id)
invoice6 = self._create_invoice(self.partner1, 'E', invoice_line6)
new_company = self.env['res.company'].create({
'name': 'Hello World'
})
invoice6.company_id = new_company.id
with self.assertRaises(UserError):
wiz_id.with_context(
active_ids=[self.invoice1.id, invoice6.id]) \
.fields_view_get()

# Check with two different partners
with self.assertRaises(UserError):
wiz_id.with_context(
active_ids=[self.invoice1.id, self.invoice3.id]) \
.fields_view_get()
1 change: 0 additions & 1 deletion account_invoice_merge/wizard/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2004-2010 Tiny SPRL (http://tiny.be).
# Copyright 2010-2011 Elico Corp.
# Copyright 2016 Acsone (https://www.acsone.eu/)
Expand Down
Loading

0 comments on commit 5764427

Please sign in to comment.