openerp-community-reviewer team mailing list archive
-
openerp-community-reviewer team
-
Mailing list archive
-
Message #04614
[Merge] lp:~camptocamp/account-invoicing/7.0-account_invoice_zero into lp:account-invoicing
Guewen Baconnier @ Camptocamp has proposed merging lp:~camptocamp/account-invoicing/7.0-account_invoice_zero into lp:account-invoicing.
Commit message:
add account_invoice_zero: automatically set invoices with a zero amount to 'paid'
Requested reviews:
Account Core Editors (account-core-editors)
For more details, see:
https://code.launchpad.net/~camptocamp/account-invoicing/7.0-account_invoice_zero/+merge/210215
Invoices with a amount of 0 are automatically set as paid.
When an invoice has an amount of 0, OpenERP still generates a
receivable/payable move line with a 0 balance. The invoice stays as
open even if there is nothing to pay. The user has 2 ways to set the
invoice as paid: create a payment of 0 and reconcile the line with the
payment or reconcile the receivable/payable move line with itself.
This module takes the latter approach and will directly set the invoice
as paid once it is opened.
--
https://code.launchpad.net/~camptocamp/account-invoicing/7.0-account_invoice_zero/+merge/210215
Your team Account Core Editors is requested to review the proposed merge of lp:~camptocamp/account-invoicing/7.0-account_invoice_zero into lp:account-invoicing.
=== added directory 'account_invoice_zero'
=== added file 'account_invoice_zero/__init__.py'
--- account_invoice_zero/__init__.py 1970-01-01 00:00:00 +0000
+++ account_invoice_zero/__init__.py 2014-03-10 14:26:50 +0000
@@ -0,0 +1,3 @@
+# -*- coding: utf-8 -*-
+
+from . import account_invoice
=== added file 'account_invoice_zero/__openerp__.py'
--- account_invoice_zero/__openerp__.py 1970-01-01 00:00:00 +0000
+++ account_invoice_zero/__openerp__.py 2014-03-10 14:26:50 +0000
@@ -0,0 +1,52 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Author: Guewen Baconnier
+# Copyright 2014 Camptocamp SA
+#
+# 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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+{'name': 'Account Invoice Zero',
+ 'version': '1.0',
+ 'author': 'Camptocamp',
+ 'maintainer': 'Camptocamp',
+ 'license': 'AGPL-3',
+ 'category': 'Accounting & Finance',
+ 'depends': ['account',
+ ],
+ 'description': """
+Account Invoice Zero
+====================
+
+Invoices with a amount of 0 are automatically set as paid.
+
+When an invoice has an amount of 0, OpenERP still generates a
+receivable/payable move line with a 0 balance. The invoice stays as
+open even if there is nothing to pay. The user has 2 ways to set the
+invoice as paid: create a payment of 0 and reconcile the line with the
+payment or reconcile the receivable/payable move line with itself.
+This module takes the latter approach and will directly set the invoice
+as paid once it is opened.
+
+ """,
+ 'website': 'http://www.camptocamp.com',
+ 'data': [],
+ 'test': ['test/account_invoice_zero_paid.yml',
+ 'test/account_invoice_no_zero_open.yml',
+ ],
+ 'installable': True,
+ 'auto_install': False,
+}
=== added file 'account_invoice_zero/account_invoice.py'
--- account_invoice_zero/account_invoice.py 1970-01-01 00:00:00 +0000
+++ account_invoice_zero/account_invoice.py 2014-03-10 14:26:50 +0000
@@ -0,0 +1,44 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Author: Guewen Baconnier
+# Copyright 2014 Camptocamp SA
+#
+# 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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openerp.osv import orm
+
+
+class account_invoice(orm.Model):
+ _inherit = 'account.invoice'
+
+ def invoice_validate(self, cr, uid, ids, context=None):
+ result = super(account_invoice, self).invoice_validate(
+ cr, uid, ids, context=context)
+ for invoice in self.browse(cr, uid, ids, context=context):
+ if not invoice.amount_total:
+ account = invoice.account_id.id
+ # search the payable / receivable lines
+ lines = [line for line in invoice.move_id.line_id
+ if line.account_id.id == account]
+ # reconcile the lines with a zero balance
+ if not sum(line.debit - line.credit for line in lines):
+ move_line_obj = self.pool['account.move.line']
+ move_line_obj.reconcile(cr, uid,
+ [line.id for line in lines],
+ context=context)
+ return result
+
=== added directory 'account_invoice_zero/test'
=== added file 'account_invoice_zero/test/account_invoice_no_zero_open.yml'
--- account_invoice_zero/test/account_invoice_no_zero_open.yml 1970-01-01 00:00:00 +0000
+++ account_invoice_zero/test/account_invoice_no_zero_open.yml 2014-03-10 14:26:50 +0000
@@ -0,0 +1,40 @@
+-
+ In order to test that the invoices with an amount still behave normally, I create on invoice
+-
+ !record {model: account.invoice, id: account_invoice_state}:
+ account_id: account.a_recv
+ company_id: base.main_company
+ currency_id: base.EUR
+ invoice_line:
+ - account_id: account.a_sale
+ name: '[PCSC234] PC Assemble SC234'
+ price_unit: 450.0
+ quantity: 1.0
+ product_id: product.product_product_3
+ uos_id: product.product_uom_unit
+ journal_id: account.bank_journal
+ partner_id: base.res_partner_12
+ reference_type: none
+-
+ I check that Initially customer invoice state is "Draft"
+-
+ !assert {model: account.invoice, id: account_invoice_state}:
+ - state == 'draft'
+-
+ I called the "Confirm Draft Invoices" wizard
+-
+ !record {model: account.invoice.confirm, id: account_invoice_confirm_0}:
+ {}
+-
+ I clicked on Confirm Invoices Button
+-
+ !python {model: account.invoice.confirm}: |
+ self.invoice_confirm(cr, uid, [ref("account_invoice_confirm_0")], {"lang": 'en_US',
+ "tz": False, "active_model": "account.invoice", "active_ids": [ref("account_invoice_state")],
+ "type": "out_invoice", "active_id": ref("account_invoice_state"), })
+-
+ I check that customer invoice state is "Open"
+-
+ !assert {model: account.invoice, id: account_invoice_state}:
+ - state == 'open'
+
=== added file 'account_invoice_zero/test/account_invoice_zero_paid.yml'
--- account_invoice_zero/test/account_invoice_zero_paid.yml 1970-01-01 00:00:00 +0000
+++ account_invoice_zero/test/account_invoice_zero_paid.yml 2014-03-10 14:26:50 +0000
@@ -0,0 +1,44 @@
+-
+ In order to test that an invoice with a zero amount is directly paid, I create an invoice
+-
+ !record {model: account.invoice, id: account_invoice_zero_paid}:
+ account_id: account.a_recv
+ company_id: base.main_company
+ currency_id: base.EUR
+ invoice_line:
+ - account_id: account.a_sale
+ name: '[PCSC234] PC Assemble SC234'
+ price_unit: 120.0
+ quantity: 1.0
+ product_id: product.product_product_3
+ uos_id: product.product_uom_unit
+ - account_id: account.a_sale
+ name: discount
+ price_unit: -120.0
+ quantity: 1.0
+ uos_id: product.product_uom_unit
+ journal_id: account.bank_journal
+ partner_id: base.res_partner_12
+ reference_type: none
+-
+ I check that Initially customer invoice state is "Draft"
+-
+ !assert {model: account.invoice, id: account_invoice_zero_paid}:
+ - state == 'draft'
+-
+ I called the "Confirm Draft Invoices" wizard
+-
+ !record {model: account.invoice.confirm, id: account_invoice_confirm_0}:
+ {}
+-
+ I clicked on Confirm Invoices Button
+-
+ !python {model: account.invoice.confirm}: |
+ self.invoice_confirm(cr, uid, [ref("account_invoice_confirm_0")], {"lang": 'en_US',
+ "tz": False, "active_model": "account.invoice", "active_ids": [ref("account_invoice_zero_paid")],
+ "type": "out_invoice", "active_id": ref("account_invoice_zero_paid"), })
+-
+ I check that customer invoice state is "Paid"
+-
+ !assert {model: account.invoice, id: account_invoice_zero_paid}:
+ - state == 'paid'
Follow ups
-
Re: [Merge] lp:~camptocamp/account-invoicing/7.0-account_invoice_zero into lp:account-invoicing
From: Pedro Manuel Baeza, 2014-03-14
-
[Merge] lp:~camptocamp/account-invoicing/7.0-account_invoice_zero into lp:account-invoicing
From: noreply, 2014-03-14
-
[Merge] lp:~camptocamp/account-invoicing/7.0-account_invoice_zero into lp:account-invoicing
From: Yannick Vaucher @ Camptocamp, 2014-03-14
-
Re: [Merge] lp:~camptocamp/account-invoicing/7.0-account_invoice_zero into lp:account-invoicing
From: Guewen Baconnier @ Camptocamp, 2014-03-13
-
Re: [Merge] lp:~camptocamp/account-invoicing/7.0-account_invoice_zero into lp:account-invoicing
From: Pedro Manuel Baeza, 2014-03-13
-
Re: [Merge] lp:~camptocamp/account-invoicing/7.0-account_invoice_zero into lp:account-invoicing
From: Vincent Renaville@camptocamp, 2014-03-13
-
Re: [Merge] lp:~camptocamp/account-invoicing/7.0-account_invoice_zero into lp:account-invoicing
From: Yannick Vaucher @ Camptocamp, 2014-03-13
-
Re: [Merge] lp:~camptocamp/account-invoicing/7.0-account_invoice_zero into lp:account-invoicing
From: Yannick Vaucher @ Camptocamp, 2014-03-13
-
Re: [Merge] lp:~camptocamp/account-invoicing/7.0-account_invoice_zero into lp:account-invoicing
From: Pedro Manuel Baeza, 2014-03-10
-
Re: [Merge] lp:~camptocamp/account-invoicing/7.0-account_invoice_zero into lp:account-invoicing
From: Vincent Renaville@camptocamp, 2014-03-10