openerp-community-reviewer team mailing list archive
-
openerp-community-reviewer team
-
Mailing list archive
-
Message #02671
[Merge] lp:~akretion-team/sale-wkfl/70-add-sale_fiscal_position_update into lp:sale-wkfl
Alexis de Lattre has proposed merging lp:~akretion-team/sale-wkfl/70-add-sale_fiscal_position_update into lp:sale-wkfl.
Requested reviews:
Sale Core Editors (sale-core-editors)
For more details, see:
https://code.launchpad.net/~akretion-team/sale-wkfl/70-add-sale_fiscal_position_update/+merge/200611
Add sale_fiscal_position_update module. Extract from the description :
With this module, when a user changes the fiscal position of a sale order, the taxes on all the sale order lines which have a product are automatically updated. The sale order lines without a product are not updated and a warning is displayed to the user in this case.
The module is the equivalent of the module invoice_fiscal_position_update, which is under final review here : https://code.launchpad.net/~akretion-team/account-invoicing/70-add-invoice_fiscal_position_update/+merge/200358
--
https://code.launchpad.net/~akretion-team/sale-wkfl/70-add-sale_fiscal_position_update/+merge/200611
Your team Sale Core Editors is requested to review the proposed merge of lp:~akretion-team/sale-wkfl/70-add-sale_fiscal_position_update into lp:sale-wkfl.
=== added directory 'sale_fiscal_position_update'
=== added file 'sale_fiscal_position_update/__init__.py'
--- sale_fiscal_position_update/__init__.py 1970-01-01 00:00:00 +0000
+++ sale_fiscal_position_update/__init__.py 2014-01-06 23:32:02 +0000
@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Sale 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 sale
=== added file 'sale_fiscal_position_update/__openerp__.py'
--- sale_fiscal_position_update/__openerp__.py 1970-01-01 00:00:00 +0000
+++ sale_fiscal_position_update/__openerp__.py 2014-01-06 23:32:02 +0000
@@ -0,0 +1,40 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Sale 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': 'Sale Fiscal Position Update',
+ 'version': '1.0',
+ 'category': 'Sales Management',
+ 'license': 'AGPL-3',
+ 'summary': 'Changing the fiscal position of a sale order will auto-update sale order lines',
+ 'description': """
+Sale Fiscal Position Update
+===========================
+
+With this module, when a user changes the fiscal position of a sale order, the taxes on all the sale order lines which have a product are automatically updated. The sale order lines without a product are not updated and a warning is displayed to the user in this case.
+""",
+ 'author': 'Julius Network Solutions, Akretion',
+ 'depends': ['sale'],
+ 'data': ['sale_view.xml'],
+ 'installable': True,
+ 'active': False,
+}
=== added directory 'sale_fiscal_position_update/i18n'
=== added file 'sale_fiscal_position_update/i18n/fr.po'
--- sale_fiscal_position_update/i18n/fr.po 1970-01-01 00:00:00 +0000
+++ sale_fiscal_position_update/i18n/fr.po 2014-01-06 23:32:02 +0000
@@ -0,0 +1,51 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+# * sale_fiscal_position_update
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 7.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2014-01-06 23:11+0000\n"
+"PO-Revision-Date: 2014-01-06 23:11+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: sale_fiscal_position_update
+#: model:ir.model,name:sale_fiscal_position_update.model_sale_order
+msgid "Sales Order"
+msgstr "Bon de commande"
+
+#. module: sale_fiscal_position_update
+#: view:sale.order:0
+msgid "fiscal_position_change(fiscal_position, order_line, context)"
+msgstr "fiscal_position_change(fiscal_position, order_line, context)"
+
+#. module: sale_fiscal_position_update
+#: code:addons/sale_fiscal_position_update/sale.py:69
+#, python-format
+msgid "Warning"
+msgstr "Avertissement"
+
+#. module: sale_fiscal_position_update
+#: code:addons/sale_fiscal_position_update/sale.py:71
+#, python-format
+msgid "The Sale Order Lines were not updated to the new Fiscal Position because they don't have Products.\n"
+"You should update the Taxes of each Sale Order Line manually."
+msgstr "Les lignes de commande n'ont pas été mise-à-jour suite au changement de la position fiscale car elle ne contiennent pas de produit.\n"
+"Vous devez mettre à jour manuellement les taxes sur chaque ligne de commande."
+
+#. module: sale_fiscal_position_update
+#: code:addons/sale_fiscal_position_update/sale.py:80
+#, python-format
+msgid "The following Sale Order Lines were not updated to the new Fiscal Position because they don't have a Product:\n"
+" %s\n"
+"You should update the Taxes of these Sale Order Lines manually."
+msgstr "Les lignes de commande suivantes n'ont pas été mise-à-jour suite au changement de la position fiscale car elle ne contiennent pas de produit :\n"
+" %s\n"
+"Vous devez mettre à jour manuellement les taxes sur ces lignes de commande."
+
=== added file 'sale_fiscal_position_update/i18n/sale_fiscal_position_update.pot'
--- sale_fiscal_position_update/i18n/sale_fiscal_position_update.pot 1970-01-01 00:00:00 +0000
+++ sale_fiscal_position_update/i18n/sale_fiscal_position_update.pot 2014-01-06 23:32:02 +0000
@@ -0,0 +1,48 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+# * sale_fiscal_position_update
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 7.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2014-01-06 23:10+0000\n"
+"PO-Revision-Date: 2014-01-06 23:10+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: sale_fiscal_position_update
+#: model:ir.model,name:sale_fiscal_position_update.model_sale_order
+msgid "Sales Order"
+msgstr ""
+
+#. module: sale_fiscal_position_update
+#: view:sale.order:0
+msgid "fiscal_position_change(fiscal_position, order_line, context)"
+msgstr ""
+
+#. module: sale_fiscal_position_update
+#: code:addons/sale_fiscal_position_update/sale.py:69
+#, python-format
+msgid "Warning"
+msgstr ""
+
+#. module: sale_fiscal_position_update
+#: code:addons/sale_fiscal_position_update/sale.py:71
+#, python-format
+msgid "The Sale Order Lines were not updated to the new Fiscal Position because they don't have Products.\n"
+"You should update the Taxes of each Sale Order Line manually."
+msgstr ""
+
+#. module: sale_fiscal_position_update
+#: code:addons/sale_fiscal_position_update/sale.py:80
+#, python-format
+msgid "The following Sale Order Lines were not updated to the new Fiscal Position because they don't have a Product:\n"
+" %s\n"
+"You should update the Taxes of these Sale Order Lines manually."
+msgstr ""
+
=== added file 'sale_fiscal_position_update/sale.py'
--- sale_fiscal_position_update/sale.py 1970-01-01 00:00:00 +0000
+++ sale_fiscal_position_update/sale.py 2014-01-06 23:32:02 +0000
@@ -0,0 +1,84 @@
+# -*- coding: utf-8 -*-
+#############################################################################
+#
+# Sale 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 sale_order(orm.Model):
+ _inherit = "sale.order"
+
+ def fiscal_position_change(
+ self, cr, uid, ids, fiscal_position, order_line,
+ context=None):
+ '''Function executed by the on_change on the fiscal_position field
+ of a sale order ; it updates taxes on all order lines'''
+ assert len(ids) in (0, 1), 'One ID max'
+ fp_obj = self.pool['account.fiscal.position']
+ res = {}
+ line_dict = self.resolve_2many_commands(
+ cr, uid, 'order_line', order_line, context=context)
+ lines_without_product = []
+ if fiscal_position:
+ fp = fp_obj.browse(cr, uid, fiscal_position, context=context)
+ else:
+ fp = False
+ for line in line_dict:
+ # Reformat line_dict so as to be compatible with what is
+ # accepted in res['value']
+ for key, value in line.iteritems():
+ if isinstance(value, tuple) and len(value) == 2:
+ line[key] = value[0]
+ if line.get('product_id'):
+ product = self.pool['product.product'].browse(
+ cr, uid, line.get('product_id'), context=context)
+ taxes = product.taxes_id
+ tax_ids = fp_obj.map_tax(
+ cr, uid, fp, taxes, context=context)
+
+ line['tax_id'] = [(6, 0, tax_ids)]
+ else:
+ lines_without_product.append(line.get('name'))
+ res['value'] = {}
+ res['value']['order_line'] = line_dict
+
+ if lines_without_product:
+ res['warning'] = {'title': _('Warning')}
+ if len(lines_without_product) == len(line_dict):
+ res['warning']['message'] = _(
+ "The Sale Order Lines were not updated to the new "
+ "Fiscal Position because they don't have Products.\n"
+ "You should update the Taxes of each "
+ "Sale Order Line manually.")
+ else:
+ display_line_names = ''
+ for name in lines_without_product:
+ display_line_names += "- %s\n" % name
+ res['warning']['message'] = _(
+ "The following Sale Order Lines were not updated "
+ "to the new Fiscal Position because they don't have a "
+ "Product:\n %s\nYou should update the "
+ "Taxes of these Sale Order Lines manually."
+ ) % display_line_names,
+ return res
=== added file 'sale_fiscal_position_update/sale_view.xml'
--- sale_fiscal_position_update/sale_view.xml 1970-01-01 00:00:00 +0000
+++ sale_fiscal_position_update/sale_view.xml 2014-01-06 23:32:02 +0000
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+<data>
+
+<!--
+ Copyright (C) 2014 Akretion (http://www.akretion.com/)
+ @author Alexis de Lattre <alexis.delattre@xxxxxxxxxxxx>
+ The licence is in the file __openerp__.py
+-->
+
+<record id="view_order_form" model="ir.ui.view">
+ <field name="name">fiscal.position.update.sale.order.form</field>
+ <field name="model">sale.order</field>
+ <field name="inherit_id" ref="sale.view_order_form"/>
+ <field name="arch" type="xml">
+ <field name="fiscal_position" position="attributes">
+ <attribute name="on_change">fiscal_position_change(fiscal_position, order_line, context)</attribute>
+ </field>
+ </field>
+</record>
+
+</data>
+</openerp>
Follow ups