diff --git a/account_invoice_currency/README.rst b/account_invoice_currency/README.rst index 4dcf91b7a..86d88fc2a 100644 --- a/account_invoice_currency/README.rst +++ b/account_invoice_currency/README.rst @@ -1,3 +1,8 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +==================================== Account invoices in company currency ==================================== @@ -7,13 +12,39 @@ amount untaxed, amount taxed and amount total. These fields are shown in "Other information" tab in invoice form. +Usage +===== + +**NOTE #1**: Amount untaxed and amount total are official account fields in v9. +This addon adds amount taxes and shows all of them in invoice form. + +**NOTE #2**: Please note that these fields are negative (as done in v9 account addon) +for credit notes (for example a refund invoice) + + +Known issues / Roadmap +====================== + +These fields name change from v8: + +* cc_amount_untaxed -> amount_untaxed_signed (already in account v9) +* cc_amount_tax -> amount_tax_signed (added by this addon) +* cc_amount_total -> amount_total_company_signed (already in account v9) + + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/92/9.0 + + Bug Tracker =========== -Bugs are tracked on `GitHub Issues `_. -In case of trouble, please check there if your issue has already been reported. -If you spotted it first, help us smashing it by providing a detailed and welcomed feedback -`here `_. + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smashing it by providing a detailed and welcomed feedback. Credits @@ -25,16 +56,19 @@ Contributors * Jordi Esteve * Joaquín Gutierrez * Pedro M. Baeza +* Antonio Espinosa Maintainer ---------- -.. image:: http://odoo-community.org/logo.png +.. image:: https://odoo-community.org/logo.png :alt: Odoo Community Association - :target: http://odoo-community.org + :target: https://odoo-community.org This module is maintained by the OCA. -OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. -To contribute to this module, please visit http://odoo-community.org. \ No newline at end of file +To contribute to this module, please visit https://odoo-community.org. diff --git a/account_invoice_currency/__init__.py b/account_invoice_currency/__init__.py index ad1603250..794fe5bc2 100644 --- a/account_invoice_currency/__init__.py +++ b/account_invoice_currency/__init__.py @@ -1,20 +1,9 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# Copyright (C) 2004-2011 Zikzakmedia S.L. (http://zikzakmedia.com) -# -# 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 . -# -############################################################################## +# © 2004-2011 Pexego Sistemas Informáticos. (http://pexego.es) +# © 2004-2011 Zikzakmedia S.L. (http://zikzakmedia.com) +# Jordi Esteve +# © 2014-2015 Serv. Tecnol. Avanzados - Pedro M. Baeza +# © 2016 Antiun Ingenieria S.L. - Antonio Espinosa +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + from . import models diff --git a/account_invoice_currency/__manifest__.py b/account_invoice_currency/__manifest__.py index 99c703524..9d7cea0b2 100644 --- a/account_invoice_currency/__manifest__.py +++ b/account_invoice_currency/__manifest__.py @@ -1,41 +1,25 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP - Account invoice currency -# Copyright (C) 2004-2011 Zikzakmedia S.L. (http://zikzakmedia.com) -# Jordi Esteve -# Copyright (c) 2013 Joaquin Gutierrez (http://www.gutierrezweb.es) -# Copyright (c) 2014-2015 Serv. Tecnol. Avanzados - Pedro M. Baeza -# -# 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 . -# -############################################################################## +# © 2004-2011 Pexego Sistemas Informáticos. (http://pexego.es) +# © 2004-2011 Zikzakmedia S.L. (http://zikzakmedia.com) +# Jordi Esteve +# © 2014-2015 Serv. Tecnol. Avanzados - Pedro M. Baeza +# © 2016 Antonio Espinosa - +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { 'name': "Company currency in invoices", - 'version': "8.0.1.0.0", - 'author': "Zikzakmedia SL, ,Odoo Community Association (OCA)" + 'version': "9.0.1.0.0", + 'author': "Zikzakmedia SL, " "Joaquín Gutierrez, " - "Serv. Tecnol. Avanzados - Pedro M. Baeza", - 'website': "http://www.zikzakmedia.com, " - "http://www.gutierrezweb.es, " - "http://www.serviciosbaeza.com", + "Serv. Tecnol. Avanzados - Pedro M. Baeza, " + "Tecnativa, " + "Odoo Community Association (OCA) ", + 'website': "https://odoo-community.org/", 'category': "Localisation / Accounting", 'license': "AGPL-3", 'depends': ["account"], 'data': [ "views/account_invoice_view.xml" ], - 'installable': False, + 'installable': True, } diff --git a/account_invoice_currency/i18n/es.po b/account_invoice_currency/i18n/es.po index 2bf9f2c7d..9b5990bf1 100644 --- a/account_invoice_currency/i18n/es.po +++ b/account_invoice_currency/i18n/es.po @@ -1,14 +1,14 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: # * account_invoice_currency -# +# # Translators: msgid "" msgstr "" "Project-Id-Version: account-financial-tools (8.0)\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-07-01 13:25+0000\n" -"PO-Revision-Date: 2015-06-03 16:14+0000\n" +"POT-Creation-Date: 2016-03-03 01:39+0000\n" +"PO-Revision-Date: 2016-03-02 17:10+0000\n" "Last-Translator: OCA Transbot \n" "Language-Team: Spanish (http://www.transifex.com/oca/OCA-account-financial-tools-8-0/language/es/)\n" "MIME-Version: 1.0\n" @@ -23,7 +23,43 @@ msgstr "" msgid "Amounts in company currency" msgstr "Importes moneda compañía" +#. module: account_invoice_currency +#: field:account.invoice,cc_amount_tax:0 +msgid "Company Cur. Tax" +msgstr "Impuestos moneda compañía" + +#. module: account_invoice_currency +#: field:account.invoice,cc_amount_total:0 +msgid "Company Cur. Total" +msgstr "Total moneda compañía" + +#. module: account_invoice_currency +#: field:account.invoice,cc_amount_untaxed:0 +msgid "Company Cur. Untaxed" +msgstr "Base imponible moneda compañía" + #. module: account_invoice_currency #: model:ir.model,name:account_invoice_currency.model_account_invoice msgid "Invoice" msgstr "Factura" + +#. module: account_invoice_currency +#: help:account.invoice,cc_amount_tax:0 +msgid "" +"Invoice tax amount in the company currency (useful when invoice currency is " +"different from company currency)." +msgstr "Impuestos en la moneda de la compañía (útil cuando la moneda de la factura es diferente a la de la compañía)." + +#. module: account_invoice_currency +#: help:account.invoice,cc_amount_total:0 +msgid "" +"Invoice total amount in the company currency (useful when invoice currency " +"is different from company currency)." +msgstr "Total factura en la moneda de la compañía (útil cuando la moneda de la factura es diferente a la de la compañía)." + +#. module: account_invoice_currency +#: help:account.invoice,cc_amount_untaxed:0 +msgid "" +"Invoice untaxed amount in the company currency (useful when invoice currency" +" is different from company currency)." +msgstr "Base imponible en la moneda de la compañía (útil cuando la moneda de la factura es diferente a la de la compañía)." diff --git a/account_invoice_currency/i18n/sl.po b/account_invoice_currency/i18n/sl.po index 33c3fefd2..76e8c628b 100644 --- a/account_invoice_currency/i18n/sl.po +++ b/account_invoice_currency/i18n/sl.po @@ -3,13 +3,13 @@ # * account_invoice_currency # # Translators: -# Matjaž Mozetič , 2015 +# Matjaž Mozetič , 2015-2016 msgid "" msgstr "" "Project-Id-Version: account-financial-tools (8.0)\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-07-01 13:25+0000\n" -"PO-Revision-Date: 2015-07-04 11:49+0000\n" +"POT-Creation-Date: 2016-03-03 01:39+0000\n" +"PO-Revision-Date: 2016-03-03 05:29+0000\n" "Last-Translator: Matjaž Mozetič \n" "Language-Team: Slovenian (http://www.transifex.com/oca/OCA-account-financial-tools-8-0/language/sl/)\n" "MIME-Version: 1.0\n" @@ -24,7 +24,43 @@ msgstr "" msgid "Amounts in company currency" msgstr "Zneski v valuti družbe" +#. module: account_invoice_currency +#: field:account.invoice,cc_amount_tax:0 +msgid "Company Cur. Tax" +msgstr "Valuta davka družbe" + +#. module: account_invoice_currency +#: field:account.invoice,cc_amount_total:0 +msgid "Company Cur. Total" +msgstr "Valuta skupnega zneska družbe" + +#. module: account_invoice_currency +#: field:account.invoice,cc_amount_untaxed:0 +msgid "Company Cur. Untaxed" +msgstr "Valuta neobdavčenega družbe" + #. module: account_invoice_currency #: model:ir.model,name:account_invoice_currency.model_account_invoice msgid "Invoice" msgstr "Račun" + +#. module: account_invoice_currency +#: help:account.invoice,cc_amount_tax:0 +msgid "" +"Invoice tax amount in the company currency (useful when invoice currency is " +"different from company currency)." +msgstr "Obračun davčnega zneska v valuti družbe (koristno kadar je valuta računa drugačna od valute družbe)." + +#. module: account_invoice_currency +#: help:account.invoice,cc_amount_total:0 +msgid "" +"Invoice total amount in the company currency (useful when invoice currency " +"is different from company currency)." +msgstr "Skupni znesek računa v valuti družbe (koristno kadar je valuta računa drugačna od valute družbe)." + +#. module: account_invoice_currency +#: help:account.invoice,cc_amount_untaxed:0 +msgid "" +"Invoice untaxed amount in the company currency (useful when invoice currency" +" is different from company currency)." +msgstr "Neobdavčeni znesek računa v valuti družbe (koristno kadar je valuta računa drugačna od valute družbe)." diff --git a/account_invoice_currency/migrations/9.0.1.0.0/pre-migrate.py b/account_invoice_currency/migrations/9.0.1.0.0/pre-migrate.py new file mode 100644 index 000000000..fe73a927d --- /dev/null +++ b/account_invoice_currency/migrations/9.0.1.0.0/pre-migrate.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +# Copyright 2016 Antonio Espinosa +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from openupgradelib import openupgrade + +column_renames = { + 'account_invoice': [ + ('cc_amount_tax', 'amount_tax_signed'), + ], +} + +column_copies = { + 'account_invoice': [ + ('cc_amount_untaxed', 'amount_untaxed_signed', None), + ('cc_amount_total', 'amount_total_company_signed', None), + ], +} + + +def migrate(cr, version): + openupgrade.rename_columns(cr, column_renames) + openupgrade.copy_columns(cr, column_copies) diff --git a/account_invoice_currency/models/__init__.py b/account_invoice_currency/models/__init__.py index 9b006a320..99f5a6541 100644 --- a/account_invoice_currency/models/__init__.py +++ b/account_invoice_currency/models/__init__.py @@ -1,20 +1,4 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# Copyright (C) 2004-2011 Zikzakmedia S.L. (http://zikzakmedia.com) -# -# 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 . -# -############################################################################## +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + from . import account_invoice diff --git a/account_invoice_currency/models/account_invoice.py b/account_invoice_currency/models/account_invoice.py index 08d51a94a..a080aff48 100644 --- a/account_invoice_currency/models/account_invoice.py +++ b/account_invoice_currency/models/account_invoice.py @@ -1,77 +1,27 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# Copyright (C) 2004-2011 -# Pexego Sistemas Informáticos. (http://pexego.es) -# Zikzakmedia S.L. (http://zikzakmedia.com) -# -# 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 . -# -############################################################################## +# © 2004-2011 Pexego Sistemas Informáticos. (http://pexego.es) +# © 2004-2011 Zikzakmedia S.L. (http://zikzakmedia.com) +# Jordi Esteve +# © 2014-2015 Serv. Tecnol. Avanzados - Pedro M. Baeza +# © 2016 Antonio Espinosa +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + from openerp import models, fields, api -import openerp.addons.decimal_precision as dp class AccountInvoice(models.Model): _inherit = "account.invoice" - @api.one - @api.depends('amount_total', 'amount_untaxed', 'amount_tax', - 'currency_id', 'move_id') - def _cc_amount_all(self): - if self.company_id.currency_id == self.currency_id: - self.cc_amount_untaxed = self.amount_untaxed - self.cc_amount_tax = self.amount_tax - self.cc_amount_total = self.amount_total - else: - self.cc_amount_untaxed = 0.0 - self.cc_amount_tax = 0.0 - self.cc_amount_total = 0.0 - # It could be computed only in open or paid invoices with a - # generated account move - if self.move_id: - # Accounts to compute amount_untaxed - line_accounts = set([x.account_id.id for x in - self.invoice_line]) - # Accounts to compute amount_tax - tax_accounts = set([x.account_id.id for x in - self.tax_line if x.amount != 0]) - # The company currency amounts are the debit-credit - # amounts in the account moves - for line in self.move_id.line_id: - if line.account_id.id in line_accounts: - self.cc_amount_untaxed += line.debit - line.credit - if line.account_id.id in tax_accounts: - self.cc_amount_tax += line.debit - line.credit - if self.type in ('out_invoice', 'in_refund'): - self.cc_amount_untaxed = -self.cc_amount_untaxed - self.cc_amount_tax = -self.cc_amount_tax - self.cc_amount_total = (self.cc_amount_tax + - self.cc_amount_untaxed) + amount_tax_signed = fields.Monetary( + string='Tax', currency_field='company_currency_id', + store=True, readonly=True, compute='_compute_amount', + help="Invoice tax amount in the company currency, " + "negative for credit notes.") - cc_amount_untaxed = fields.Float( - compute="_cc_amount_all", digits_compute=dp.get_precision('Account'), - string='Company Cur. Untaxed', - help="Invoice untaxed amount in the company currency (useful when " - "invoice currency is different from company currency).") - cc_amount_tax = fields.Float( - compute="_cc_amount_all", digits_compute=dp.get_precision('Account'), - string='Company Cur. Tax', - help="Invoice tax amount in the company currency (useful when invoice " - "currency is different from company currency).") - cc_amount_total = fields.Float( - compute="_cc_amount_all", digits_compute=dp.get_precision('Account'), - string='Company Cur. Total', - help="Invoice total amount in the company currency (useful when " - "invoice currency is different from company currency).") + @api.one + @api.depends('invoice_line_ids.price_subtotal', 'tax_line_ids.amount', + 'currency_id', 'company_id') + def _compute_amount(self): + super(AccountInvoice, self)._compute_amount() + self.amount_tax_signed = ( + self.amount_total_company_signed - self.amount_untaxed_signed) diff --git a/account_invoice_currency/tests/__init__.py b/account_invoice_currency/tests/__init__.py new file mode 100644 index 000000000..d2a0dfcc5 --- /dev/null +++ b/account_invoice_currency/tests/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import test_account_invoice_currency diff --git a/account_invoice_currency/tests/test_account_invoice_currency.py b/account_invoice_currency/tests/test_account_invoice_currency.py new file mode 100644 index 000000000..f5586d0b5 --- /dev/null +++ b/account_invoice_currency/tests/test_account_invoice_currency.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +# Copyright 2016 Antonio Espinosa +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from openerp.tests.common import TransactionCase + + +class TestAccountInvoiceCurrency(TransactionCase): + def setUp(self, *args, **kwargs): + super(TestAccountInvoiceCurrency, self).setUp(*args, **kwargs) + + type_revenue = self.env.ref('account.data_account_type_revenue') + type_payable = self.env.ref('account.data_account_type_payable') + tax_group_taxes = self.env.ref('account.tax_group_taxes') + self.account_sale = self.env['account.account'].create({ + 'name': 'Sale', + 'code': 'XX_700', + 'user_type_id': type_revenue.id, + 'reconcile': True, + }) + self.account_customer = self.env['account.account'].create({ + 'name': 'Customer', + 'code': 'XX_430', + 'user_type_id': type_payable.id, + 'reconcile': True, + }) + self.journal_sale = self.env['account.journal'].create({ + 'name': 'Test journal for sale', + 'type': 'sale', + 'code': 'TSALE', + 'default_debit_account_id': self.account_sale.id, + 'default_credit_account_id': self.account_sale.id, + }) + self.partner = self.env['res.partner'].create({ + 'name': 'Test partner', + }) + self.tax = self.env['account.tax'].create({ + 'name': 'Tax for sale 10%', + 'type_tax_use': 'sale', + 'tax_group_id': tax_group_taxes.id, + 'amount_type': 'percent', + 'amount': 10.0, + }) + self.invoice = self.env['account.invoice'].create({ + 'partner_id': self.partner.id, + 'account_id': self.account_customer.id, + 'type': 'out_invoice', + 'journal_id': self.journal_sale.id, + 'invoice_line_ids': [(0, 0, { + 'name': 'Test product', + 'account_id': self.account_sale.id, + 'price_unit': 100, + 'quantity': 1, + 'invoice_line_tax_ids': [(6, 0, [self.tax.id])], + })], + }) + + def test_amount_tax_signed(self): + self.assertEqual(10.0, self.invoice.amount_tax_signed) diff --git a/account_invoice_currency/views/account_invoice_view.xml b/account_invoice_currency/views/account_invoice_view.xml index 8603596ef..3951f6b63 100644 --- a/account_invoice_currency/views/account_invoice_view.xml +++ b/account_invoice_currency/views/account_invoice_view.xml @@ -1,42 +1,41 @@ - - + + - - - - - Account invoice supplier (form) - add company currency - account.invoice - - - - - - - - - - - + + + Account invoice supplier (form) - add company currency + account.invoice + + + + + + + + + + + + + + Account invoice (form) - add company currency + account.invoice + + + + + + + + + + + - - - Account invoice (form) - add company currency - account.invoice - - - - - - - - - - - - - - +