diff --git a/account_invoice_currency/__init__.py b/account_invoice_currency/__init__.py new file mode 100644 index 000000000..8e877eba3 --- /dev/null +++ b/account_invoice_currency/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (C) 2004-2011 Zikzakmedia S.L. (http://zikzakmedia.com) All Rights Reserved. +# +# 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 invoice diff --git a/account_invoice_currency/__openerp__.py b/account_invoice_currency/__openerp__.py new file mode 100644 index 000000000..2ea0bbf62 --- /dev/null +++ b/account_invoice_currency/__openerp__.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP - Account invoice currency +# Copyright (C) 2004-2011 Zikzakmedia S.L. (http://zikzakmedia.com) All Rights Reserved. +# Jordi Esteve +# Copyright (c) 2013 Joaquin Gutierrez (http://www.gutierrezweb.es) +# +# 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 . +# +############################################################################## + +{ + 'name': "Company currency in invoices", + 'version': "1.0", + 'author': "Zikzakmedia SL", + 'website': "http://www.zikzakmedia.com", + 'category': "Localisation / Accounting", + 'contributors': ['Joaquín Gutierrez'], + "description": """ +This Module adds functional fields to show invoice in the company currency +========================================================================== + +Amount Untaxed, Amount Tax and Amount Total invoice fields in the company currency. +These fields are shown in "Other information" tab in invoice form. + """, + 'license': "AGPL-3", + 'depends': ["account"], + 'data': [ + "account_invoice_view.xml" + ], + 'installable': True, + 'active': False, +} + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/account_invoice_currency/account_invoice_view.xml b/account_invoice_currency/account_invoice_view.xml new file mode 100644 index 000000000..9eddc4cdc --- /dev/null +++ b/account_invoice_currency/account_invoice_view.xml @@ -0,0 +1,44 @@ + + + + + + + + + Account invoice supplier (form) - add company currency + account.invoice + form + + + + + + + + + + + + + + + Account invoice (form) - add company currency + account.invoice + form + + + + + + + + + + + + + + diff --git a/account_invoice_currency/i18n/account_invoice_currency.pot b/account_invoice_currency/i18n/account_invoice_currency.pot new file mode 100644 index 000000000..07b9e1152 --- /dev/null +++ b/account_invoice_currency/i18n/account_invoice_currency.pot @@ -0,0 +1,57 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * account_invoice_currency +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0-20130927-231103\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-11-18 11:53+0000\n" +"PO-Revision-Date: 2013-11-18 11:53+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_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 "Invoice total amount in the company currency (useful when invoice currency is different from company currency)." + +#. module: account_invoice_currency +#: field:account.invoice,cc_amount_total:0 +msgid "Company Cur. Total" +msgstr "Company Cur. Total" + +#. module: account_invoice_currency +#: field:account.invoice,cc_amount_tax:0 +msgid "Company Cur. Tax" +msgstr "Company Cur. Tax" + +#. 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 "Invoice tax amount in the company currency (useful when invoice currency is different from company currency)." + +#. 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 "Invoice untaxed amount in the company currency(useful when invoice currency is different from company currency)." + +#. module: account_invoice_currency +#: view:account.invoice:0 +msgid "Amounts in company currency" +msgstr "Amounts in company currency" + +#. module: account_invoice_currency +#: model:ir.model,name:account_invoice_currency.model_account_invoice +msgid "Invoice" +msgstr "Invoice" + +#. module: account_invoice_currency +#: field:account.invoice,cc_amount_untaxed:0 +msgid "Company Cur. Untaxed" +msgstr "Company Cur. Untaxed" + diff --git a/account_invoice_currency/i18n/ca.po b/account_invoice_currency/i18n/ca.po new file mode 100644 index 000000000..9651fb150 --- /dev/null +++ b/account_invoice_currency/i18n/ca.po @@ -0,0 +1,83 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * account_invoice_currency +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 5.0.9\n" +"Report-Msgid-Bugs-To: support@openerp.com\n" +"POT-Creation-Date: 2010-04-25 20:36+0000\n" +"PO-Revision-Date: 2011-03-08 07:53+0000\n" +"Last-Translator: Jordi Esteve (www.zikzakmedia.com) " +"\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Launchpad-Export-Date: 2011-10-28 05:57+0000\n" +"X-Generator: Launchpad (build 14197)\n" + +#. module: account_invoice_currency +#: constraint:ir.ui.view:0 +msgid "Invalid XML for View Architecture!" +msgstr "XML invàlid per a la definició de la vista!" + +#. module: account_invoice_currency +#: field:account.invoice,cc_amount_total:0 +msgid "Company Cur. Total" +msgstr "Total moneda companyia" + +#. module: account_invoice_currency +#: field:account.invoice,cc_amount_tax:0 +msgid "Company Cur. Tax" +msgstr "Impostos moneda companyia" + +#. 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 de la factura en la moneda de la companyia (útil quan les monedes de la " +"factura i de la companyia són diferents)." + +#. module: account_invoice_currency +#: model:ir.module.module,shortdesc:account_invoice_currency.module_meta_information +msgid "Company currency in invoices" +msgstr "Moneda de la companyia en factures" + +#. 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 de la factura en la moneda de la companyia (útil quan les monedes de " +"la factura i de la companyia són diferents)." + +#. 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 "" +"Impostos de la factura en la moneda de la companyia (útil quan les monedes " +"de la factura i de la companyia són diferents)." + +#. module: account_invoice_currency +#: model:ir.module.module,description:account_invoice_currency.module_meta_information +msgid "" +"\n" +"Adds functional fields to show Amount Untaxed, Amount Tax and Amount Total " +"invoice fields in the company currency. These fields are shown in \"Other " +"information\" tab in invoice form. \n" +msgstr "" +"\n" +"Afegeix camps funcionals per a mostrar els camps Base, Impostos i Total en " +"la moneda de la companyia. Aquests camps es mostren a la pestanya \"Altra " +"informació\" del formulari factura. \n" + +#. module: account_invoice_currency +#: field:account.invoice,cc_amount_untaxed:0 +msgid "Company Cur. Untaxed" +msgstr "Base moneda companyia" diff --git a/account_invoice_currency/i18n/es.po b/account_invoice_currency/i18n/es.po new file mode 100644 index 000000000..0963f0d46 --- /dev/null +++ b/account_invoice_currency/i18n/es.po @@ -0,0 +1,76 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * account_invoice_currency +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 5.0.9\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-11-18 11:53+0000\n" +"PO-Revision-Date: 2013-11-18 12:57+0100\n" +"Last-Translator: Joaquin Gutierrez \n" +"Language-Team: \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Launchpad-Export-Date: 2011-10-28 05:57+0000\n" +"X-Generator: Launchpad (build 14197)\n" + +#. 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 de la factura en la moneda de la compañía (útil cuando las monedas de la factura y de la compañía son distintas)." + +#. 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_tax:0 +msgid "Company Cur. Tax" +msgstr "Impuestos moneda compañía" + +#. 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 de la factura en la moneda de la compañía (útil cuando las monedas de la factura y de la compañía son distintas)." + +#. module: account_invoice_currency +#: help:account.invoice,cc_amount_untaxed:0 +#, fuzzy +msgid "Invoice untaxed amount in the company currency(useful when invoice currency is different from company currency)." +msgstr "Base de la factura en la moneda de la compañía (útil cuando las monedas de la factura y de la compañía son distintas)." + +#. module: account_invoice_currency +#: view:account.invoice:0 +msgid "Amounts in company currency" +msgstr "Importes moneda empresa" + +#. module: account_invoice_currency +#: model:ir.model,name:account_invoice_currency.model_account_invoice +msgid "Invoice" +msgstr "Factura" + +#. module: account_invoice_currency +#: field:account.invoice,cc_amount_untaxed:0 +msgid "Company Cur. Untaxed" +msgstr "Base moneda compañía" + +#~ msgid "Invalid XML for View Architecture!" +#~ msgstr "¡XML inválido para la definición de la vista!" + +#~ msgid "Company currency in invoices" +#~ msgstr "Moneda de la compañía en facturas" + +#~ msgid "" +#~ "\n" +#~ "Adds functional fields to show Amount Untaxed, Amount Tax and Amount " +#~ "Total invoice fields in the company currency. These fields are shown in " +#~ "\"Other information\" tab in invoice form. \n" +#~ msgstr "" +#~ "\n" +#~ "Añade campos funcionales para mostrar los campos Base, Impuestos y Total " +#~ "en la moneda de la compañía. Estos campos se muestran en la pestaña " +#~ "\"Otra información\" del formulario factura. \n" diff --git a/account_invoice_currency/i18n/pt.po b/account_invoice_currency/i18n/pt.po new file mode 100644 index 000000000..337ffdc0b --- /dev/null +++ b/account_invoice_currency/i18n/pt.po @@ -0,0 +1,84 @@ +# Portuguese translation for openobject-addons +# Copyright (c) 2011 Rosetta Contributors and Canonical Ltd 2011 +# This file is distributed under the same license as the openobject-addons package. +# FIRST AUTHOR , 2011. +# +msgid "" +msgstr "" +"Project-Id-Version: openobject-addons\n" +"Report-Msgid-Bugs-To: FULL NAME \n" +"POT-Creation-Date: 2010-04-25 20:36+0000\n" +"PO-Revision-Date: 2011-03-08 07:53+0000\n" +"Last-Translator: FULL NAME \n" +"Language-Team: Portuguese \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Launchpad-Export-Date: 2011-10-28 05:57+0000\n" +"X-Generator: Launchpad (build 14197)\n" + +#. module: account_invoice_currency +#: constraint:ir.ui.view:0 +msgid "Invalid XML for View Architecture!" +msgstr "XML Inválido para a Arquitectura de Vista!" + +#. module: account_invoice_currency +#: field:account.invoice,cc_amount_total:0 +msgid "Company Cur. Total" +msgstr "Total Moeda da Empresas" + +#. module: account_invoice_currency +#: field:account.invoice,cc_amount_tax:0 +msgid "Company Cur. Tax" +msgstr "Imposto da Moeda da Empresa" + +#. 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 "" +"Montante da factura não tributado na moeda da empresa (útil quando moeda de " +"facturação é diferente da moeda da empresa)." + +#. module: account_invoice_currency +#: model:ir.module.module,shortdesc:account_invoice_currency.module_meta_information +msgid "Company currency in invoices" +msgstr "Moedas da empresa em facturas" + +#. 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 "" +"Montante da factura total na moeda da empresa (útil quando moeda de " +"facturação é diferente da moeda da empresa)." + +#. 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 "" +"Montante de factura de imposto na moeda da empresa(Útil quando moeda de " +"facturação é diferente da moeda da empresa)." + +#. module: account_invoice_currency +#: model:ir.module.module,description:account_invoice_currency.module_meta_information +msgid "" +"\n" +"Adds functional fields to show Amount Untaxed, Amount Tax and Amount Total " +"invoice fields in the company currency. These fields are shown in \"Other " +"information\" tab in invoice form. \n" +msgstr "" +"\n" +"Adicionar um campo funcional para mostrar Montante Não Tributável, " +"Montante do Imposto e campos da factura do Montante total na moeda da " +"empresa. Estes campos são apresentados no separador \"Outras informações \" " +"no formulário de factura. \n" + +#. module: account_invoice_currency +#: field:account.invoice,cc_amount_untaxed:0 +msgid "Company Cur. Untaxed" +msgstr "Moeda da Empresa não Tributada" diff --git a/account_invoice_currency/invoice.py b/account_invoice_currency/invoice.py new file mode 100644 index 000000000..724bf4b23 --- /dev/null +++ b/account_invoice_currency/invoice.py @@ -0,0 +1,148 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (C) 2004-2011 +# Pexego Sistemas Informáticos. (http://pexego.es) All Rights Reserved +# Zikzakmedia S.L. (http://zikzakmedia.com) All Rights Reserved. +# +# 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.osv import fields +from openerp.osv import orm +from openerp.tools.translate import _ +import openerp.addons.decimal_precision as dp + + +class account_invoice(orm.Model): + """ + Inheritance of account invoice to add company currency amounts + """ + + _inherit = "account.invoice" + + def _get_invoice_line2(self, cr, uid, ids, context=None): + result = {} + for line in self.pool.get('account.invoice.line').browse(cr, + uid, + ids, + context=context): + result[line.invoice_id.id] = True + return result.keys() + + def _get_invoice_tax2(self, cr, uid, ids, context=None): + result = {} + for tax in self.pool.get('account.invoice.tax').browse(cr, + uid, + ids, + context=context): + result[tax.invoice_id.id] = True + return result.keys() + + def _cc_amount_all(self, cr, uid, ids, name, args, context=None): + res = {} + for invoice in self.browse(cr, uid, ids, context=context): + if invoice.company_id.currency_id == invoice.currency_id: + res[invoice.id] = { + 'cc_amount_untaxed': invoice.amount_untaxed, + 'cc_amount_tax': invoice.amount_tax, + 'cc_amount_total': invoice.amount_total, + } + else: + res[invoice.id] = { + 'cc_amount_untaxed': 0.0, + 'cc_amount_tax': 0.0, + 'cc_amount_total': 0.0, + } + + ## It could be computed only in open or paid invoices with a generated account move + if invoice.move_id: + ## Accounts to compute amount_untaxed + line_account = [] + for line in invoice.invoice_line: + if line.account_id.id not in line_account: + line_account.append(line.account_id.id) + + ## Accounts to compute amount_tax + tax_account = [] + for line in invoice.tax_line: + if line.account_id.id not in tax_account and line.amount != 0: + tax_account.append(line.account_id.id) + + ## The company currency amounts are the debit-credit amounts in the account moves + for line in invoice.move_id.line_id: + if line.account_id.id in line_account: + res[invoice.id]['cc_amount_untaxed'] += line.debit - line.credit + if line.account_id.id in tax_account: + res[invoice.id]['cc_amount_tax'] += line.debit - line.credit + if invoice.type in ('out_invoice', 'in_refund'): + res[invoice.id]['cc_amount_untaxed'] = -res[invoice.id]['cc_amount_untaxed'] + res[invoice.id]['cc_amount_tax'] = -res[invoice.id]['cc_amount_tax'] + res[invoice.id]['cc_amount_total'] = res[invoice.id]['cc_amount_tax'] + res[invoice.id]['cc_amount_untaxed'] + return res + + _columns = { + 'cc_amount_untaxed': fields.function(_cc_amount_all, + method=True, + 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).", + store={ + 'account.invoice': (lambda self, cr, uid, ids, c={}: ids, ['invoice_line', + 'currency_id', + 'move_id'], 20), + 'account.invoice.tax': (_get_invoice_tax2, None, 20), + 'account.invoice.line': (_get_invoice_line2, ['price_unit', + 'invoice_line_tax_id', + 'quantity', 'discount'], 20), + }, + multi='cc_all'), + 'cc_amount_tax': fields.function(_cc_amount_all, + method=True, + 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).", + store={ + 'account.invoice': (lambda self, cr, uid, ids, c={}: ids, ['invoice_line', + 'currency_id', + 'move_id'], 20), + 'account.invoice.tax': (_get_invoice_tax2, None, 20), + 'account.invoice.line': (_get_invoice_line2, ['price_unit', + 'invoice_line_tax_id', + 'quantity', 'discount'], 20), + }, + multi='cc_all'), + 'cc_amount_total': fields.function(_cc_amount_all, + method=True, + 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).", + store={ + 'account.invoice': (lambda self, cr, uid, ids, c={}: ids, ['invoice_line', + 'currency_id', + 'move_id'], 20), + 'account.invoice.tax': (_get_invoice_tax2, None, 20), + 'account.invoice.line': (_get_invoice_line2, ['price_unit', + 'invoice_line_tax_id', + 'quantity', 'discount'], 20), + }, + multi='cc_all'), + } + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: