Skip to content

Commit

Permalink
Merge pull request #4 from grap/7.0-pos_order_pricelist_change
Browse files Browse the repository at this point in the history
[ADD] 7.0 'pos_order_pricelist_change'
  • Loading branch information
legalsylvain committed Nov 18, 2014
2 parents 0db2791 + 526be43 commit ef6b4ae
Show file tree
Hide file tree
Showing 11 changed files with 543 additions and 0 deletions.
23 changes: 23 additions & 0 deletions pos_order_pricelist_change/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Point Of Sale - Order Pricelist Change for Odoo
# Copyright (C) 2014 GRAP (http://www.grap.coop)
# @author Sylvain LE GAL (https://twitter.com/legalsylvain)
#
# 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 model
56 changes: 56 additions & 0 deletions pos_order_pricelist_change/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Point Of Sale - Order Pricelist Change for Odoo
# Copyright (C) 2014 GRAP (http://www.grap.coop)
# @author Sylvain LE GAL (https://twitter.com/legalsylvain)
#
# 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': 'Point Of Sale - Order Pricelist Change',
'summary': """Fix an incorrect behaviour when changing pricelist on"""
""" pos order""",
'version': '1.0',
'category': 'Point Of Sale',
'description': """
Fix an incorrect behaviour when changing pricelist on pos order
===============================================================
Features:
---------
* On a POS order, when changing a pricelist, warn the user as in sale"""
""" module, when doing a quotation;
* On a POS order, provide a 'Recompute With pricelist' button to update"""
""" when pricelist has changed;
Copyright, Authors and Licence:
-------------------------------
* Copyright: 2014, GRAP: Groupement Régional Alimentaire de Proximité;
* Author:
* Sylvain LE GAL (https://twitter.com/legalsylvain);""",
'author': 'GRAP',
'website': 'http://www.grap.coop',
'license': 'AGPL-3',
'depends': [
'point_of_sale',
],
'data': [
'view/view.xml',
],
'demo': [
'demo/demo.xml',
],
}
47 changes: 47 additions & 0 deletions pos_order_pricelist_change/demo/demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- ********************************************************************** -->
<!--Point Of Sale - Order Pricelist Change for Odoo -->
<!--Copyright (C) 2014 GRAP (http://www.grap.coop) -->
<!--@author Sylvain LE GAL (https://twitter.com/legalsylvain) -->

<!--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/>. -->
<!-- ********************************************************************** -->
<openerp>
<data noupdate="1">

<!-- Price List -->
<record id="pricelist_surcharge" model="product.pricelist">
<field name="name">Surcharge Pricelist</field>
<field name="type">sale</field>
</record>
<record id="pricelist_version_surcharge" model="product.pricelist.version">
<field name="pricelist_id" ref="pricelist_surcharge"/>
<field name="name">Surcharge Pricelist Version</field>
</record>
<record id="pricelist_item_surcharge" model="product.pricelist.item">
<field name="price_version_id" ref="pricelist_version_surcharge"/>
<field name="base" ref="product.list_price"/>
<field name="price_surcharge">10</field>
<field name="name">Surcharge Pricelist Line</field>
</record>

<!-- Partner -->
<record id="partner_surcharge" model="res.partner">
<field name="name">Surcharge Customer</field>
<field name="customer" eval="True" />
<field name="property_product_pricelist" eval="ref('pricelist_surcharge')" />
</record>

</data>
</openerp>
33 changes: 33 additions & 0 deletions pos_order_pricelist_change/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * pos_order_pricelist_change
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-07-16 13:01+0000\n"
"PO-Revision-Date: 2014-07-16 13:01+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: pos_order_pricelist_change
#: code:addons/pos_order_pricelist_change/model/pos_order.py:47
#, python-format
msgid "If you change the pricelist of this order, prices of existing order lines will not be updated. Please click on the 'Recompute With Pricelist'."
msgstr "Si vous changez la liste de prix de cette vente, les prix des lignes existantes ne seront pas mis à jour. Merci de cliquer sur le bouton 'Recalculer avec la liste de prix."

#. module: pos_order_pricelist_change
#: code:addons/pos_order_pricelist_change/model/pos_order.py:46
#, python-format
msgid "Pricelist Warning!"
msgstr "Attention à la liste de Prix !"

#. module: pos_order_pricelist_change
#: view:pos.order:0
msgid "Recompute With Pricelist"
msgstr "Recalculer avec la Liste de Prix"
56 changes: 56 additions & 0 deletions pos_order_pricelist_change/i18n/pos_order_pricelist_change.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * pos_order_pricelist_change
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-11-16 02:05+0000\n"
"PO-Revision-Date: 2014-11-16 02:05+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: pos_order_pricelist_change
#: code:addons/pos_order_pricelist_change/model/pos_order.py:47
#, python-format
msgid "If you change the pricelist of this order, prices of existing order lines will not be updated. Please click on the 'Recompute With Pricelist'."
msgstr ""

#. module: pos_order_pricelist_change
#: code:_description:0
#: model:ir.model,name:pos_order_pricelist_change.model_pos_order
#, python-format
msgid "Point of Sale"
msgstr ""

#. module: pos_order_pricelist_change
#: code:addons/pos_order_pricelist_change/model/pos_order.py:46
#, python-format
msgid "Pricelist Warning!"
msgstr ""

#. module: pos_order_pricelist_change
#: view:pos.order:0
msgid "Recompute With Pricelist"
msgstr ""

#. module: pos_order_pricelist_change
#: model:product.pricelist,name:pos_order_pricelist_change.pricelist_surcharge
msgid "Surcharge Pricelist"
msgstr ""

#. module: pos_order_pricelist_change
#: model:product.pricelist.version,name:pos_order_pricelist_change.pricelist_version_surcharge
msgid "Surcharge Pricelist Version"
msgstr ""

#. module: pos_order_pricelist_change
#: view:pos.order:0
msgid "onchange_pricelist_id(pricelist_id, lines)"
msgstr ""

23 changes: 23 additions & 0 deletions pos_order_pricelist_change/model/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Point Of Sale - Order Pricelist Change for Odoo
# Copyright (C) 2014 GRAP (http://www.grap.coop)
# @author Sylvain LE GAL (https://twitter.com/legalsylvain)
#
# 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 pos_order
52 changes: 52 additions & 0 deletions pos_order_pricelist_change/model/pos_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Point Of Sale - Order Pricelist Change for Odoo
# Copyright (C) 2014 GRAP (http://www.grap.coop)
# @author Sylvain LE GAL (https://twitter.com/legalsylvain)
#
# 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.orm import Model
from openerp.tools.translate import _


class pos_order(Model):
_inherit = 'pos.order'

def action_recompute_pricelist(self, cr, uid, ids, context=None):
pol_obj = self.pool.get('pos.order.line')
for po in self.browse(cr, uid, ids, context=context):
for pol in po.lines:
res = pol_obj.onchange_product_id(
cr, uid, [pol.id], po.pricelist_id.id, pol.product_id.id,
pol.qty, po.partner_id.id)
if res['value']['price_unit'] != pol.price_unit:
pol_obj.write(
cr, uid, [pol.id], res['value'], context=context)

def onchange_pricelist_id(
self, cr, uid, ids, pricelist_id, lines, context=None):
if not pricelist_id or not lines:
return {}
warning = {
'title': _('Pricelist Warning!'),
'message': _(
"""If you change the pricelist of this order,"""
""" prices of existing order lines will not be updated."""
""" Please click on the 'Recompute With Pricelist'.""")
}
return {'warning': warning}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions pos_order_pricelist_change/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Point Of Sale - Order Pricelist Change for Odoo
# Copyright (C) 2013-2014 GRAP (http://www.grap.coop)
# @author Sylvain LE GAL (https://twitter.com/legalsylvain)
#
# 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 test_pos_order_pricelist_change

fast_suite = [
test_pos_order_pricelist_change,
]

0 comments on commit ef6b4ae

Please sign in to comment.