diff --git a/.travis.yml b/.travis.yml
index c0317014848..fbc975ea952 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -11,14 +11,17 @@ addons:
env:
- VERSION="8.0" LINT_CHECK="1"
- - VERSION="8.0" ODOO_REPO="odoo/odoo" LINT_CHECK="0"
- - VERSION="8.0" ODOO_REPO="OCA/OCB" LINT_CHECK="0"
+ - VERSION="8.0" ODOO_REPO="odoo/odoo" EXCLUDE="account_default_draft_move,account_payment_include_draft_move" LINT_CHECK="0"
+ - VERSION="8.0" ODOO_REPO="OCA/OCB" EXCLUDE="account_default_draft_move,account_payment_include_draft_move" LINT_CHECK="0"
+ - VERSION="8.0" ODOO_REPO="odoo/odoo" INCLUDE="account_payment_include_draft_move" LINT_CHECK="0"
+ - VERSION="8.0" ODOO_REPO="OCA/OCB" INCLUDE="account_payment_include_draft_move" LINT_CHECK="0"
virtualenv:
system_site_packages: true
install:
- git clone https://github.com/OCA/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools
+ - git clone https://github.com/OCA/account-financial-tools.git ${HOME}/account-financial-tools
- export PATH=${HOME}/maintainer-quality-tools/travis:${PATH}
- pip install unidecode
- travis_install_nightly
diff --git a/account_payment_include_draft_move/__init__.py b/account_payment_include_draft_move/__init__.py
index 62da7f088ec..624a12d2799 100644
--- a/account_payment_include_draft_move/__init__.py
+++ b/account_payment_include_draft_move/__init__.py
@@ -21,3 +21,4 @@
##############################################################################
from . import wizard
+from . import models
diff --git a/account_payment_include_draft_move/__openerp__.py b/account_payment_include_draft_move/__openerp__.py
index e180d9ad3ab..103d63d33b8 100644
--- a/account_payment_include_draft_move/__openerp__.py
+++ b/account_payment_include_draft_move/__openerp__.py
@@ -27,8 +27,13 @@
"website": "http://www.acsone.eu",
"images": [],
"category": "Accounting",
- "depends": ["account_banking_payment_export"],
- "data": [],
+ "depends": ["account_banking_payment_export",
+ "account_default_draft_move",
+ ],
+ "data": [
+ 'views/account_invoice_view.xml',
+ 'wizard/validate_invoice_cancel_view.xml',
+ ],
"demo": [],
"test": [],
"licence": "AGPL-3",
diff --git a/account_payment_include_draft_move/i18n/fr.po b/account_payment_include_draft_move/i18n/fr.po
new file mode 100644
index 00000000000..42ece910a25
--- /dev/null
+++ b/account_payment_include_draft_move/i18n/fr.po
@@ -0,0 +1,54 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * account_payment_include_draft_move
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: Odoo Server 8.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2015-05-20 12:25+0000\n"
+"PO-Revision-Date: 2015-05-20 12:25+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: \n"
+
+#. module: account_payment_include_draft_move
+#: view:validate.invoice.cancel:account_payment_include_draft_move.validate_invoice_cancel
+msgid "Cancel"
+msgstr "Annuler"
+
+#. module: account_payment_include_draft_move
+#: view:validate.invoice.cancel:account_payment_include_draft_move.validate_invoice_cancel
+msgid "I accept and force invoice's cancellation"
+msgstr "J'accepte et force l'annulation de la facture"
+
+#. module: account_payment_include_draft_move
+#: model:ir.model,name:account_payment_include_draft_move.model_account_invoice
+msgid "Invoice"
+msgstr "Facture"
+
+#. module: account_payment_include_draft_move
+#: view:validate.invoice.cancel:account_payment_include_draft_move.validate_invoice_cancel
+msgid "This process can be dangerous. You assume the possible consequences of this action."
+msgstr "Cette procédure peut être dangereuse. Vous assumez les consquénces possible de cette action."
+
+#. module: account_payment_include_draft_move
+#: code:addons/account_payment_include_draft_move/models/account_invoice.py:53
+#: view:validate.invoice.cancel:account_payment_include_draft_move.validate_invoice_cancel
+#, python-format
+msgid "Validate Invoice Cancel"
+msgstr "Validation de l'annulation de la facture"
+
+#. module: account_payment_include_draft_move
+#: view:validate.invoice.cancel:account_payment_include_draft_move.validate_invoice_cancel
+msgid "WARNING ! You try to cancel an invoice related to a payment order."
+msgstr "ATTENTION ! Vous tentez d'annuler une facture liée à une ligne de paiement."
+
+#. module: account_payment_include_draft_move
+#: view:validate.invoice.cancel:account_payment_include_draft_move.validate_invoice_cancel
+msgid "or"
+msgstr "ou"
+
diff --git a/account_payment_include_draft_move/i18n/fr_BE.po b/account_payment_include_draft_move/i18n/fr_BE.po
new file mode 100644
index 00000000000..42ece910a25
--- /dev/null
+++ b/account_payment_include_draft_move/i18n/fr_BE.po
@@ -0,0 +1,54 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * account_payment_include_draft_move
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: Odoo Server 8.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2015-05-20 12:25+0000\n"
+"PO-Revision-Date: 2015-05-20 12:25+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: \n"
+
+#. module: account_payment_include_draft_move
+#: view:validate.invoice.cancel:account_payment_include_draft_move.validate_invoice_cancel
+msgid "Cancel"
+msgstr "Annuler"
+
+#. module: account_payment_include_draft_move
+#: view:validate.invoice.cancel:account_payment_include_draft_move.validate_invoice_cancel
+msgid "I accept and force invoice's cancellation"
+msgstr "J'accepte et force l'annulation de la facture"
+
+#. module: account_payment_include_draft_move
+#: model:ir.model,name:account_payment_include_draft_move.model_account_invoice
+msgid "Invoice"
+msgstr "Facture"
+
+#. module: account_payment_include_draft_move
+#: view:validate.invoice.cancel:account_payment_include_draft_move.validate_invoice_cancel
+msgid "This process can be dangerous. You assume the possible consequences of this action."
+msgstr "Cette procédure peut être dangereuse. Vous assumez les consquénces possible de cette action."
+
+#. module: account_payment_include_draft_move
+#: code:addons/account_payment_include_draft_move/models/account_invoice.py:53
+#: view:validate.invoice.cancel:account_payment_include_draft_move.validate_invoice_cancel
+#, python-format
+msgid "Validate Invoice Cancel"
+msgstr "Validation de l'annulation de la facture"
+
+#. module: account_payment_include_draft_move
+#: view:validate.invoice.cancel:account_payment_include_draft_move.validate_invoice_cancel
+msgid "WARNING ! You try to cancel an invoice related to a payment order."
+msgstr "ATTENTION ! Vous tentez d'annuler une facture liée à une ligne de paiement."
+
+#. module: account_payment_include_draft_move
+#: view:validate.invoice.cancel:account_payment_include_draft_move.validate_invoice_cancel
+msgid "or"
+msgstr "ou"
+
diff --git a/account_payment_include_draft_move/models/__init__.py b/account_payment_include_draft_move/models/__init__.py
new file mode 100644
index 00000000000..da41872cd26
--- /dev/null
+++ b/account_payment_include_draft_move/models/__init__.py
@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+#
+##############################################################################
+#
+# Authors: Adrien Peiffer
+# Copyright (c) 2015 Acsone SA/NV (http://www.acsone.eu)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+from . import account_invoice
diff --git a/account_payment_include_draft_move/models/account_invoice.py b/account_payment_include_draft_move/models/account_invoice.py
new file mode 100644
index 00000000000..b9b59cf9bd7
--- /dev/null
+++ b/account_payment_include_draft_move/models/account_invoice.py
@@ -0,0 +1,71 @@
+# -*- coding: utf-8 -*-
+#
+##############################################################################
+#
+# Authors: Adrien Peiffer
+# Copyright (c) 2015 Acsone SA/NV (http://www.acsone.eu)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+from openerp import models, api, workflow, _
+
+
+class account_invoice(models.Model):
+ _inherit = 'account.invoice'
+
+ @api.model
+ def get_payment_line_linked(self, invoice):
+ payment_line_obj = self.env['payment.line']
+ payment_lines = []
+ if invoice.move_id.id and invoice.move_id.line_id:
+ inv_mv_lines = [x.id for x in invoice.move_id.line_id]
+ payment_lines = payment_line_obj\
+ .search([('move_line_id', 'in', inv_mv_lines)])
+ return payment_lines
+
+ @api.model
+ def check_payment_line_linked(self, invoice):
+ payment_lines = self.get_payment_line_linked(invoice)
+ if len(payment_lines) > 0:
+ return True
+ else:
+ return False
+
+ @api.model
+ def open_validate_invoice_cancel(self, invoice):
+ wizard = self.env['validate.invoice.cancel'].create({})
+ ctx = self.env.context.copy()
+ ctx['invoice_id'] = invoice.id
+ return {
+ 'name': _("Validate Invoice Cancel"),
+ 'view_mode': 'form',
+ 'view_type': 'form',
+ 'res_model': 'validate.invoice.cancel',
+ 'res_id': wizard.id,
+ 'type': 'ir.actions.act_window',
+ 'target': 'new',
+ 'context': ctx
+ }
+
+ @api.multi
+ def invoice_cancel(self):
+ for invoice in self:
+ if self.check_payment_line_linked(invoice):
+ return self.open_validate_invoice_cancel(invoice)
+ else:
+ return workflow.trg_validate(self._uid, str(self._model),
+ invoice.id, 'invoice_cancel',
+ self._cr)
diff --git a/account_payment_include_draft_move/tests/__init__.py b/account_payment_include_draft_move/tests/__init__.py
new file mode 100644
index 00000000000..ba8186e4e18
--- /dev/null
+++ b/account_payment_include_draft_move/tests/__init__.py
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+#
+##############################################################################
+#
+# Authors: Adrien Peiffer
+# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+#
+
+from . import test_cancel_invoice
diff --git a/account_payment_include_draft_move/tests/test_cancel_invoice.py b/account_payment_include_draft_move/tests/test_cancel_invoice.py
new file mode 100644
index 00000000000..eb345eabeba
--- /dev/null
+++ b/account_payment_include_draft_move/tests/test_cancel_invoice.py
@@ -0,0 +1,107 @@
+# -*- coding: utf-8 -*-
+#
+##############################################################################
+#
+# Authors: Adrien Peiffer
+# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+import openerp.tests.common as common
+from openerp import workflow, fields
+
+
+def create_simple_invoice(self, date):
+ journal_id = self.ref('account.sales_journal')
+ partner_id = self.ref('base.res_partner_4')
+ product_id = self.ref('product.product_product_4')
+ return self.env['account.invoice']\
+ .create({'partner_id': partner_id,
+ 'account_id':
+ self.ref('account.a_pay'),
+ 'journal_id':
+ journal_id,
+ 'date_invoice': date,
+ 'date_due': date,
+ 'type': 'in_invoice',
+ 'invoice_line': [(0, 0, {'name': 'test',
+ 'account_id':
+ self.ref('account.a_expense'),
+ 'price_unit': 2000.00,
+ 'quantity': 1,
+ 'product_id': product_id,
+ }
+ )
+ ],
+ })
+
+
+class TestCancelInvoice(common.TransactionCase):
+
+ def setUp(self):
+ super(TestCancelInvoice, self).setUp()
+ self.context = self.registry("res.users").context_get(self.cr,
+ self.uid)
+
+ def test_cancel_invoice(self):
+ date = fields.Date.today()
+ invoice = create_simple_invoice(self, date)
+ workflow.trg_validate(self.uid, 'account.invoice', invoice.id,
+ 'invoice_open', self.cr)
+ # I check if created invoice isn't linked with a payment line
+ invoice_obj = self.env['account.invoice']
+ payment_lines = invoice_obj.get_payment_line_linked(invoice)
+ self.assertTrue(len(payment_lines) == 0,
+ "Invoice is linked with a payment line")
+ # I click on cancel invoice button
+ res = invoice.invoice_cancel()
+ # I check if the wizard is correctly instantiated
+ self.assertFalse(isinstance(res, dict), "wizard action is returned")
+ # I check if invoice is cancelled
+ self.assertEqual(invoice.state, 'cancel', 'Invoice isn\'t cancelled')
+
+ def test_payment_cancel_invoice(self):
+ date = fields.Date.today()
+ invoice = create_simple_invoice(self, date)
+ workflow.trg_validate(self.uid, 'account.invoice', invoice.id,
+ 'invoice_open', self.cr)
+ payment_order_create_obj = self.env['payment.order.create']
+ account_payment_id = self.ref('account_payment.payment_order_1')
+ payment_order_create = payment_order_create_obj.create(
+ {'duedate': date,
+ 'populate_results': True})
+ ctx = self.context.copy()
+ ctx.update({'active_id': account_payment_id})
+ res = payment_order_create.with_context(ctx).search_entries()
+ payment_order_create.entries = res['context']['line_ids']
+ payment_order_create.with_context(ctx).create_payment()
+ # I check if created invoice is linked with a payment line
+ invoice_obj = self.env['account.invoice']
+ payment_lines = invoice_obj.get_payment_line_linked(invoice)
+ self.assertTrue(len(payment_lines) > 0,
+ "Invoice isn't on a payment line")
+ # I click on cancel invoice button
+ res = invoice.invoice_cancel()
+ # I check if the wizard is correctly instantiated
+ self.assertTrue(isinstance(res, dict), "Not return wizard action")
+ ctx = res.get('context')
+ wizard_id = res.get('res_id')
+ wizard_obj = self.env['validate.invoice.cancel']
+ wizard = wizard_obj.browse([wizard_id])[0]
+ # click on force cancel button
+ wizard.with_context(ctx).validate_cancel()
+ # I check if invoice is cancelled
+ self.assertEqual(invoice.state, 'cancel', 'Invoice isn\'t cancelled')
diff --git a/account_payment_include_draft_move/views/account_invoice_view.xml b/account_payment_include_draft_move/views/account_invoice_view.xml
new file mode 100644
index 00000000000..f890c160683
--- /dev/null
+++ b/account_payment_include_draft_move/views/account_invoice_view.xml
@@ -0,0 +1,15 @@
+
+
+
+
+ account.invoice.supplier.form (account_payment_include_draft_move)
+ account.invoice
+
+
+
+ object
+
+
+
+
+
\ No newline at end of file
diff --git a/account_payment_include_draft_move/wizard/__init__.py b/account_payment_include_draft_move/wizard/__init__.py
index e087871c301..34b900002fb 100644
--- a/account_payment_include_draft_move/wizard/__init__.py
+++ b/account_payment_include_draft_move/wizard/__init__.py
@@ -21,3 +21,4 @@
##############################################################################
from . import payment_order_create
+from . import validate_invoice_cancel
diff --git a/account_payment_include_draft_move/wizard/validate_invoice_cancel.py b/account_payment_include_draft_move/wizard/validate_invoice_cancel.py
new file mode 100644
index 00000000000..4bfb3c56613
--- /dev/null
+++ b/account_payment_include_draft_move/wizard/validate_invoice_cancel.py
@@ -0,0 +1,38 @@
+# -*- coding: utf-8 -*-
+#
+##############################################################################
+#
+# Authors: Adrien Peiffer
+# Copyright (c) 2015 Acsone SA/NV (http://www.acsone.eu)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+from openerp import models, api, workflow
+
+
+class validate_invoice_cancel(models.TransientModel):
+ _name = 'validate.invoice.cancel'
+
+ @api.multi
+ def validate_cancel(self):
+ context = self.env.context
+ invoice_obj = self.env['account.invoice']
+ invoice_id = context.get('invoice_id')
+ invoice = invoice_obj.browse([invoice_id])[0]
+ payment_lines = invoice_obj.get_payment_line_linked(invoice)
+ payment_lines.write({'move_line_id': False})
+ workflow.trg_validate(self._uid, 'account.invoice', invoice.id,
+ 'invoice_cancel', self._cr)
diff --git a/account_payment_include_draft_move/wizard/validate_invoice_cancel_view.xml b/account_payment_include_draft_move/wizard/validate_invoice_cancel_view.xml
new file mode 100644
index 00000000000..e376ffe4747
--- /dev/null
+++ b/account_payment_include_draft_move/wizard/validate_invoice_cancel_view.xml
@@ -0,0 +1,26 @@
+
+
+
+
+ validate.invoice.cancel.form
+ validate.invoice.cancel
+
+
+
+
+
+
\ No newline at end of file