Browse Source

Merge pull request #40 from grap/8.0_PORT_pos_order_pricelist_change

[PORT][8.0] pos_order_pricelist_change
pull/110/merge
Rafael Blasco 9 years ago
committed by GitHub
parent
commit
3db6adde4e
  1. 43
      pos_order_pricelist_change/README.rst
  2. 23
      pos_order_pricelist_change/__init__.py
  3. 40
      pos_order_pricelist_change/__openerp__.py
  4. 47
      pos_order_pricelist_change/demo/demo.xml
  5. 29
      pos_order_pricelist_change/demo/res_groups.yml
  6. 33
      pos_order_pricelist_change/i18n/fr.po
  7. 56
      pos_order_pricelist_change/i18n/pos_order_pricelist_change.pot
  8. 23
      pos_order_pricelist_change/models/__init__.py
  9. 50
      pos_order_pricelist_change/models/pos_order.py
  10. BIN
      pos_order_pricelist_change/static/description/icon.png
  11. BIN
      pos_order_pricelist_change/static/src/img/screenshot_warning.png
  12. 23
      pos_order_pricelist_change/tests/__init__.py
  13. 117
      pos_order_pricelist_change/tests/test_pos_order_pricelist_change.py
  14. 34
      pos_order_pricelist_change/views/view.xml

43
pos_order_pricelist_change/README.rst

@ -0,0 +1,43 @@
Improve pricelist changes for POS Order in back office
======================================================
* 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;
Installation
============
Regular installation.
Configuration
=============
No configuration needed.
Usage
=====
.. image:: ./static/src/img/screenshot_warning.png
Credits
=======
Contributors
------------
* Sylvain LE GAL (https://twitter.com/legalsylvain);
Maintainer
----------
.. image:: http://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: http://odoo-community.org
This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.
To contribute to this module, please visit http://odoo-community.org.

23
pos_order_pricelist_change/__init__.py

@ -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 models

40
pos_order_pricelist_change/__openerp__.py

@ -0,0 +1,40 @@
# -*- 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': 'Improve pricelist changes for POS Order in back office',
'version': '1.0',
'category': 'Point Of Sale',
'author': 'GRAP,Odoo Community Association (OCA)',
'website': 'http://www.grap.coop',
'license': 'AGPL-3',
'depends': [
'point_of_sale',
],
'data': [
'views/view.xml',
],
'demo': [
'demo/demo.xml',
'demo/res_groups.yml',
],
}

47
pos_order_pricelist_change/demo/demo.xml

@ -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>

29
pos_order_pricelist_change/demo/res_groups.yml

@ -0,0 +1,29 @@
# -*- encoding: utf-8 -*-
###############################################################################
#
# Point Of Sale - Order Pricelist Change for Odoo
# Copyright (C) 2014-Today 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/>.
#
###############################################################################
- !record {model: res.groups, id: base.group_no_one}:
users:
- base.user_root
- !record {model: res.groups, id: product.group_sale_pricelist}:
users:
- base.user_root

33
pos_order_pricelist_change/i18n/fr.po

@ -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
pos_order_pricelist_change/i18n/pos_order_pricelist_change.pot

@ -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
pos_order_pricelist_change/models/__init__.py

@ -0,0 +1,23 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Point Of Sale - Order Pricelist Change for Odoo
# Copyright (C) 2014-Today 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

50
pos_order_pricelist_change/models/pos_order.py

@ -0,0 +1,50 @@
# -*- 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.models import Model
from openerp import api, _
class PosOrder(Model):
_inherit = 'pos.order'
@api.multi
def action_recompute_pricelist(self):
for po in self:
for pol in po.lines:
res = pol.onchange_product_id(
po.pricelist_id.id, pol.product_id.id, qty=pol.qty,
partner_id=po.partner_id.id)
pol.write(res['value'])
@api.onchange('pricelist_id')
def onchange_pricelist_id(self):
if not self.pricelist_id or not self.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}

BIN
pos_order_pricelist_change/static/description/icon.png

After

Width: 128  |  Height: 128  |  Size: 7.6 KiB

BIN
pos_order_pricelist_change/static/src/img/screenshot_warning.png

After

Width: 925  |  Height: 438  |  Size: 50 KiB

23
pos_order_pricelist_change/tests/__init__.py

@ -0,0 +1,23 @@
# -*- 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

117
pos_order_pricelist_change/tests/test_pos_order_pricelist_change.py

@ -0,0 +1,117 @@
# -*- 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.tests.common import TransactionCase
class TestPosOrderPricelistChange(TransactionCase):
"""Tests for Point Of Sale - Order Pricelist Change Module"""
def setUp(self):
super(TestPosOrderPricelistChange, self).setUp()
self.imd_obj = self.env['ir.model.data']
self.pp_obj = self.env['product.product']
self.ppl_obj = self.env['product.pricelist']
self.po_obj = self.env['pos.order']
self.pol_obj = self.env['pos.order.line']
self.pc_obj = self.env['pos.config']
self.ps_obj = self.env['pos.session']
self.pc = self.env.ref('point_of_sale.pos_config_main')
self.rp_c2c = self.env.ref('base.res_partner_12')
self.ppl_c2c = self.env.ref('product.list0')
self.pp_usb = self.env.ref('product.product_product_48')
self.rp_spe = self.env.ref(
'pos_order_pricelist_change.partner_surcharge')
self.ppl_spe = self.env.ref(
'pos_order_pricelist_change.pricelist_surcharge')
# Test Section
def test_01_default_price_list(self):
"""[Regression Test] Sale with default Pricelist"""
# Opening Session
self.ps_obj.create({'config_id': self.pc.id})
# create Pos Order
po = self.po_obj.create({
'partner_id': self.rp_c2c.id,
'pricelist_id': self.ppl_c2c.id,
'lines': [[0, False, {
'product_id': self.pp_usb.id,
'qty': 1,
}]],
})
res = po.lines[0].onchange_product_id(
po.pricelist_id.id, po.lines[0].product_id.id, po.lines[0].qty)
self.assertEquals(
res['value']['price_subtotal'], self.pp_usb.list_price,
"Incorrect price for default pricelist!")
def test_02_partner_with_price_list_before(self):
"""[Regression Test] Sale with specific Pricelist"""
# Opening Session
self.ps_obj.create({'config_id': self.pc.id})
# create Pos Order
po = self.po_obj.create({
'partner_id': self.rp_spe.id,
'pricelist_id': self.ppl_spe.id,
'lines': [[0, False, {
'product_id': self.pp_usb.id,
'qty': 1,
}]],
})
res = po.lines[0].onchange_product_id(
po.pricelist_id.id, po.lines[0].product_id.id, po.lines[0].qty)
self.assertEquals(
res['value']['price_subtotal'], self.pp_usb.list_price + 10,
"Incorrect price for specific pricelist!")
def test_03_partner_with_price_list_after(self):
"""[Functional Test] Change pricelist after have set lines."""
# Opening Session
self.ps_obj.create({'config_id': self.pc.id})
# create Pos Order
po = self.po_obj.create({
'pricelist_id': self.ppl_c2c.id,
'lines': [[0, False, {
'product_id': self.pp_usb.id,
'qty': 1,
}]],
})
res = po.onchange_pricelist_id()
self.assertNotEquals(
res.get('warning', False), False,
"Need warning!")
# Change now pricelist
po.write({'pricelist_id': self.ppl_spe.id})
po.action_recompute_pricelist()
po = self.po_obj.browse(po.id)
self.assertEquals(
po.amount_total, self.pp_usb.list_price + 10,
"Recompute with pricelist error.")

34
pos_order_pricelist_change/views/view.xml

@ -0,0 +1,34 @@
<?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>
<!-- View : pos.order -->
<record id="view_pos_order_form" model="ir.ui.view">
<field name="name">pos.order.form</field>
<field name="model">pos.order</field>
<field name="inherit_id" ref="point_of_sale.view_pos_pos_form" />
<field name="arch" type="xml">
<xpath expr="//button[@string='Payment']" position="after">
<button name="action_recompute_pricelist" string="Recompute With Pricelist" type="object" states="draft"/>
</xpath>
</field>
</record>
</data>
</openerp>
Loading…
Cancel
Save