← Back to team overview

openerp-community-reviewer team mailing list archive

lp:~akretion-team/account-invoicing/70-add-invoice_fiscal_position_update into lp:account-invoicing

 

Alexis de Lattre has proposed merging lp:~akretion-team/account-invoicing/70-add-invoice_fiscal_position_update into lp:account-invoicing.

Requested reviews:
  Account Core Editors (account-core-editors)

For more details, see:
https://code.launchpad.net/~akretion-team/account-invoicing/70-add-invoice_fiscal_position_update/+merge/200358

Add the module invoice_fiscal_position_update. Here is the description :

When the invoice is in draft state, you can change the fiscal position and click on a button "(update)" next to the fiscal position to update the taxes and the accounts on all the invoice lines.

-- 
https://code.launchpad.net/~akretion-team/account-invoicing/70-add-invoice_fiscal_position_update/+merge/200358
Your team Account Core Editors is requested to review the proposed merge of lp:~akretion-team/account-invoicing/70-add-invoice_fiscal_position_update into lp:account-invoicing.
=== added directory 'invoice_fiscal_position_update'
=== added file 'invoice_fiscal_position_update/__init__.py'
--- invoice_fiscal_position_update/__init__.py	1970-01-01 00:00:00 +0000
+++ invoice_fiscal_position_update/__init__.py	2014-01-02 23:23:00 +0000
@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Invoice Fiscal Position Update module for OpenERP
+#    Copyright (C) 2011-2014 Julius Network Solutions SARL <contact@xxxxxxxxx>
+#    Copyright (C) 2014 Akretion (http://www.akretion.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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from . import account_invoice

=== added file 'invoice_fiscal_position_update/__openerp__.py'
--- invoice_fiscal_position_update/__openerp__.py	1970-01-01 00:00:00 +0000
+++ invoice_fiscal_position_update/__openerp__.py	2014-01-02 23:23:00 +0000
@@ -0,0 +1,42 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Invoice Fiscal Position Update module for OpenERP
+#    Copyright (C) 2011-2014 Julius Network Solutions SARL <contact@xxxxxxxxx>
+#    Copyright (C) 2014 Akretion (http://www.akretion.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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+{
+    'name': 'Invoice Fiscal Position Update',
+    'version': '1.0',
+    'category': 'Accounting & Finance',
+    'license': 'AGPL-3',
+    'summary': 'Update the fiscal position of an invoice in one click',
+    'description': """
+Invoice Fiscal Position Update
+==============================
+
+When the invoice is in draft state, you can change the fiscal position and click on a button *(update)* next to the fiscal position to update the taxes and the accounts on all the invoice lines.
+""",
+    'author': 'Julius Network Solutions',
+    'website': 'http://www.julius.fr/',
+    'depends': ['account'],
+    'data': ['account_invoice_view.xml'],
+    'images': ['images/invoice_fiscal_position_update.jpg'],
+    'installable': True,
+    'active': False,
+}

=== added file 'invoice_fiscal_position_update/account_invoice.py'
--- invoice_fiscal_position_update/account_invoice.py	1970-01-01 00:00:00 +0000
+++ invoice_fiscal_position_update/account_invoice.py	2014-01-02 23:23:00 +0000
@@ -0,0 +1,70 @@
+# -*- coding: utf-8 -*-
+#############################################################################
+#
+#    Invoice Fiscal Position Update module for OpenERP
+#    Copyright (C) 2011-2014 Julius Network Solutions SARL <contact@xxxxxxxxx>
+#    Copyright (C) 2014 Akretion (http://www.akretion.com)
+#    @author Mathieu Vatel <mathieu _at_ julius.fr>
+#    @author Alexis de Lattre <alexis.delattre@xxxxxxxxxxxx>
+#
+#    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
+from openerp.tools.translate import _
+
+
+class account_invoice(orm.Model):
+    _inherit = "account.invoice"
+
+    def update_fiscal_position(self, cr, uid, ids, context=None):
+        '''Function executed by the "(update)" button on invoices
+        If the invoices are in draft state, it updates taxes and accounts
+        on all invoice lines'''
+        fp_obj = self.pool['account.fiscal.position']
+        for invoice in self.browse(cr, uid, ids, context=context):
+            if invoice.state != 'draft':
+                raise orm.except_orm(
+                    _('Error:'),
+                    _('You cannot update the fiscal position because the '
+                        'invoice is not in draft state.'))
+            fp = invoice.fiscal_position
+            for line in invoice.invoice_line:
+                if line.product_id:
+                    product = self.pool['product.product'].browse(
+                        cr, uid, line.product_id.id, context=context)
+                    if invoice.type in ('out_invoice', 'out_refund'):
+                        account_id = product.property_account_income.id or \
+                            product.categ_id.property_account_income_categ.id
+                        taxes = product.taxes_id
+                    else:
+                        account_id = product.property_account_expense.id or \
+                            product.categ_id.property_account_expense_categ.id
+                        taxes = product.supplier_taxes_id
+                    taxes = taxes or (
+                        account_id
+                        and self.pool['account.account'].browse(
+                            cr, uid, account_id, context=context).tax_ids
+                        or False)
+                    account_id = fp_obj.map_account(
+                        cr, uid, fp, account_id, context=context)
+                    tax_ids = fp_obj.map_tax(
+                        cr, uid, fp, taxes, context=context)
+
+                    line.write({
+                        'invoice_line_tax_id': [(6, 0, tax_ids)],
+                        'account_id': account_id,
+                        })
+        return True

=== added file 'invoice_fiscal_position_update/account_invoice_view.xml'
--- invoice_fiscal_position_update/account_invoice_view.xml	1970-01-01 00:00:00 +0000
+++ invoice_fiscal_position_update/account_invoice_view.xml	2014-01-02 23:23:00 +0000
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+<data>
+
+<record id="invoice_form" model="ir.ui.view">
+    <field name="name">fiscal.position.update.invoice.form</field>
+    <field name="model">account.invoice</field>
+    <field name="inherit_id" ref="account.invoice_form"/>
+    <field name="arch" type="xml">
+        <field name="fiscal_position" position="before">
+            <div>
+                <label for="fiscal_position"/>
+                <button name="update_fiscal_position" type="object" states="draft" string="(update)" class="oe_link oe_edit_only" help="Apply new fiscal position on all invoice lines" />
+            </div>
+        </field>
+        <field name="fiscal_position" position="attributes">
+            <attribute name="nolabel">1</attribute>
+        </field>
+    </field>
+</record>
+
+<record id="invoice_supplier_form" model="ir.ui.view">
+    <field name="name">fiscal.position.update.invoice.supplier.form</field>
+    <field name="model">account.invoice</field>
+    <field name="inherit_id" ref="account.invoice_supplier_form"/>
+    <field name="arch" type="xml">
+        <field name="fiscal_position" position="before">
+            <div>
+                <label for="fiscal_position"/>
+                <button name="update_fiscal_position" type="object" states="draft" string="(update)" class="oe_link oe_edit_only" help="Apply new fiscal position on all invoice lines" />
+            </div>
+        </field>
+        <field name="fiscal_position" position="attributes">
+            <attribute name="nolabel">1</attribute>
+        </field>
+    </field>
+</record>
+
+</data>
+</openerp>

=== added directory 'invoice_fiscal_position_update/i18n'
=== added file 'invoice_fiscal_position_update/i18n/fr.po'
--- invoice_fiscal_position_update/i18n/fr.po	1970-01-01 00:00:00 +0000
+++ invoice_fiscal_position_update/i18n/fr.po	2014-01-02 23:23:00 +0000
@@ -0,0 +1,44 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+#	* invoice_fiscal_position_update
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 7.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2014-01-02 22:55+0000\n"
+"PO-Revision-Date: 2014-01-02 22:55+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: invoice_fiscal_position_update
+#: view:account.invoice:0
+msgid "(update)"
+msgstr "(mettre à jour)"
+
+#. module: invoice_fiscal_position_update
+#: code:addons/invoice_fiscal_position_update/account_invoice.py:41
+#, python-format
+msgid "You cannot update the fiscal position because the invoice is not in draft state."
+msgstr "Vous ne pouvez pas mettre à jour la position fiscale car la facture n'est pas à l'état brouillon."
+
+#. module: invoice_fiscal_position_update
+#: code:addons/invoice_fiscal_position_update/account_invoice.py:40
+#, python-format
+msgid "Error:"
+msgstr "Erreur :"
+
+#. module: invoice_fiscal_position_update
+#: view:account.invoice:0
+msgid "Apply new fiscal position on all invoice lines"
+msgstr "Applique la nouvelle position fiscale sur toutes les lignes de facture"
+
+#. module: invoice_fiscal_position_update
+#: model:ir.model,name:invoice_fiscal_position_update.model_account_invoice
+msgid "Invoice"
+msgstr "Facture"
+

=== added file 'invoice_fiscal_position_update/i18n/invoice_fiscal_position_update.pot'
--- invoice_fiscal_position_update/i18n/invoice_fiscal_position_update.pot	1970-01-01 00:00:00 +0000
+++ invoice_fiscal_position_update/i18n/invoice_fiscal_position_update.pot	2014-01-02 23:23:00 +0000
@@ -0,0 +1,44 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+#	* invoice_fiscal_position_update
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 7.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2014-01-02 22:53+0000\n"
+"PO-Revision-Date: 2014-01-02 22: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: invoice_fiscal_position_update
+#: view:account.invoice:0
+msgid "(update)"
+msgstr ""
+
+#. module: invoice_fiscal_position_update
+#: code:addons/invoice_fiscal_position_update/account_invoice.py:41
+#, python-format
+msgid "You cannot update the fiscal position because the invoice is not in draft state."
+msgstr ""
+
+#. module: invoice_fiscal_position_update
+#: code:addons/invoice_fiscal_position_update/account_invoice.py:40
+#, python-format
+msgid "Error:"
+msgstr ""
+
+#. module: invoice_fiscal_position_update
+#: view:account.invoice:0
+msgid "Apply new fiscal position on all invoice lines"
+msgstr ""
+
+#. module: invoice_fiscal_position_update
+#: model:ir.model,name:invoice_fiscal_position_update.model_account_invoice
+msgid "Invoice"
+msgstr ""
+

=== added directory 'invoice_fiscal_position_update/images'
=== added file 'invoice_fiscal_position_update/images/invoice_fiscal_position_update.jpg'
Binary files invoice_fiscal_position_update/images/invoice_fiscal_position_update.jpg	1970-01-01 00:00:00 +0000 and invoice_fiscal_position_update/images/invoice_fiscal_position_update.jpg	2014-01-02 23:23:00 +0000 differ

Follow ups