Alexis de Lattre has proposed merging lp:~akretion-team/purchase-wkfl/70-add-purchase_fiscal_position_update into lp:purchase-wkfl.
Requested reviews: Purchase Core Editors (purchase-core-editors) For more details, see: https://code.launchpad.net/~akretion-team/purchase-wkfl/70-add-purchase_fiscal_position_update/+merge/201115 Add purchase_fiscal_position_update module. Extract from the description : With this module, when a user changes the fiscal position of a purchase order, the taxes on all the purchase order lines which have a product are automatically updated. The purchase 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 review here : https://code.launchpad.net/~akretion-team/account-invoicing/70-add-invoice_fiscal_position_update/+merge/200358 - the module sale_fiscal_position_update, which is under review here : https://code.launchpad.net/~akretion-team/sale-wkfl/70-add-sale_fiscal_position_update/+merge/200611 So, with this MP, the family of fiscal_position_update is complete : sale + purchase + invoice ! -- https://code.launchpad.net/~akretion-team/purchase-wkfl/70-add-purchase_fiscal_position_update/+merge/201115 Your team Purchase Core Editors is requested to review the proposed merge of lp:~akretion-team/purchase-wkfl/70-add-purchase_fiscal_position_update into lp:purchase-wkfl.
=== added directory 'purchase_fiscal_position_update' === added file 'purchase_fiscal_position_update/__init__.py' --- purchase_fiscal_position_update/__init__.py 1970-01-01 00:00:00 +0000 +++ purchase_fiscal_position_update/__init__.py 2014-01-09 22:36:59 +0000 @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Purchase Fiscal Position Update module for OpenERP +# Copyright (C) 2011-2014 Julius Network Solutions SARL <cont...@julius.fr> +# 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 purchase === added file 'purchase_fiscal_position_update/__openerp__.py' --- purchase_fiscal_position_update/__openerp__.py 1970-01-01 00:00:00 +0000 +++ purchase_fiscal_position_update/__openerp__.py 2014-01-09 22:36:59 +0000 @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Purchase Fiscal Position Update module for OpenERP +# Copyright (C) 2011-2014 Julius Network Solutions SARL <cont...@julius.fr> +# 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': 'Purchase Fiscal Position Update', + 'version': '1.0', + 'category': 'Purchase Management', + 'license': 'AGPL-3', + 'summary': 'Changing the fiscal position of a purchase order will auto-update purchase order lines', + 'description': """ +Purchase Fiscal Position Update +=============================== + +With this module, when a user changes the fiscal position of a purchase order, the taxes on all the purchase order lines which have a product are automatically updated. The purchase 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': ['purchase'], + 'data': ['purchase_view.xml'], + 'installable': True, + 'active': False, +} === added directory 'purchase_fiscal_position_update/i18n' === added file 'purchase_fiscal_position_update/i18n/fr.po' --- purchase_fiscal_position_update/i18n/fr.po 1970-01-01 00:00:00 +0000 +++ purchase_fiscal_position_update/i18n/fr.po 2014-01-09 22:36:59 +0000 @@ -0,0 +1,51 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * purchase_fiscal_position_update +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-01-09 22:16+0000\n" +"PO-Revision-Date: 2014-01-09 22:16+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: purchase_fiscal_position_update +#: code:addons/purchase_fiscal_position_update/purchase.py:70 +#, python-format +msgid "The Purchase Order Lines were not updated to the new Fiscal Position because they don't have Products.\n" +"You should update the Taxes of each Purchase 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: purchase_fiscal_position_update +#: code:addons/purchase_fiscal_position_update/purchase.py:79 +#, python-format +msgid "The following Purchase 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 Purchase 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." + +#. module: purchase_fiscal_position_update +#: view:purchase.order:0 +msgid "fiscal_position_change(fiscal_position, order_line, context)" +msgstr "fiscal_position_change(fiscal_position, order_line, context)" + +#. module: purchase_fiscal_position_update +#: code:addons/purchase_fiscal_position_update/purchase.py:68 +#, python-format +msgid "Warning" +msgstr "Avertissement" + +#. module: purchase_fiscal_position_update +#: model:ir.model,name:purchase_fiscal_position_update.model_purchase_order +msgid "Purchase Order" +msgstr "Bon de commande" + === added file 'purchase_fiscal_position_update/i18n/purchase_fiscal_position_update.pot' --- purchase_fiscal_position_update/i18n/purchase_fiscal_position_update.pot 1970-01-01 00:00:00 +0000 +++ purchase_fiscal_position_update/i18n/purchase_fiscal_position_update.pot 2014-01-09 22:36:59 +0000 @@ -0,0 +1,48 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * purchase_fiscal_position_update +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-01-09 22:15+0000\n" +"PO-Revision-Date: 2014-01-09 22:15+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: purchase_fiscal_position_update +#: code:addons/purchase_fiscal_position_update/purchase.py:70 +#, python-format +msgid "The Purchase Order Lines were not updated to the new Fiscal Position because they don't have Products.\n" +"You should update the Taxes of each Purchase Order Line manually." +msgstr "" + +#. module: purchase_fiscal_position_update +#: code:addons/purchase_fiscal_position_update/purchase.py:79 +#, python-format +msgid "The following Purchase 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 Purchase Order Lines manually." +msgstr "" + +#. module: purchase_fiscal_position_update +#: view:purchase.order:0 +msgid "fiscal_position_change(fiscal_position, order_line, context)" +msgstr "" + +#. module: purchase_fiscal_position_update +#: code:addons/purchase_fiscal_position_update/purchase.py:68 +#, python-format +msgid "Warning" +msgstr "" + +#. module: purchase_fiscal_position_update +#: model:ir.model,name:purchase_fiscal_position_update.model_purchase_order +msgid "Purchase Order" +msgstr "" + === added file 'purchase_fiscal_position_update/purchase.py' --- purchase_fiscal_position_update/purchase.py 1970-01-01 00:00:00 +0000 +++ purchase_fiscal_position_update/purchase.py 2014-01-09 22:36:59 +0000 @@ -0,0 +1,84 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Purchase Fiscal Position Update module for OpenERP +# Copyright (C) 2011-2014 Julius Network Solutions SARL <cont...@julius.fr> +# Copyright (C) 2014 Akretion (http://www.akretion.com) +# @author Mathieu Vatel <mathieu _at_ julius.fr> +# @author Alexis de Lattre <alexis.delat...@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 openerp.osv import orm +from openerp.tools.translate import _ + + +class purchase_order(orm.Model): + _inherit = "purchase.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 purchase 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.supplier_taxes_id + tax_ids = fp_obj.map_tax( + cr, uid, fp, taxes, context=context) + + line['taxes_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 Purchase Order Lines were not updated to the new " + "Fiscal Position because they don't have Products.\n" + "You should update the Taxes of each " + "Purchase Order Line manually.") + else: + display_line_names = '' + for name in lines_without_product: + display_line_names += "- %s\n" % name + res['warning']['message'] = _( + "The following Purchase 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 Purchase Order Lines manually." + ) % display_line_names, + return res === added file 'purchase_fiscal_position_update/purchase_view.xml' --- purchase_fiscal_position_update/purchase_view.xml 1970-01-01 00:00:00 +0000 +++ purchase_fiscal_position_update/purchase_view.xml 2014-01-09 22:36:59 +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.delat...@akretion.com> + The licence is in the file __openerp__.py +--> + +<record id="purchase_order_form" model="ir.ui.view"> + <field name="name">fiscal.position.update.purchase.order.form</field> + <field name="model">purchase.order</field> + <field name="inherit_id" ref="purchase.purchase_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>
-- Mailing list: https://launchpad.net/~openerp-community-reviewer Post to : openerp-community-reviewer@lists.launchpad.net Unsubscribe : https://launchpad.net/~openerp-community-reviewer More help : https://help.launchpad.net/ListHelp