Skip to content

Commit

Permalink
[ADD] website_sale_pricelist_hide: Create new module
Browse files Browse the repository at this point in the history
* Add new module to hide items from website sales when they are not in the current pricelist
  • Loading branch information
lasley committed Jun 9, 2017
1 parent 2d3d646 commit 630afd3
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 0 deletions.
57 changes: 57 additions & 0 deletions website_sale_pricelist_hide/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
.. image:: https://img.shields.io/badge/license-LGPL--3-blue.svg
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3

===========================
Website Sale Pricelist Hide
===========================

This module hides items from website sale view that are not within the
current pricelist, instead of the default behavior of showing non-discounted
price.

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/113/50

Known Issues / Roadmap
======================

* No tests
* Does not account for expired, or not yet active pricelists

Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/e-commerce/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smash it by providing detailed and welcomed feedback.

Credits
=======

Images
------

* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.

Contributors
------------

* Dave Lasley <dave@laslabs.com>

Maintainer
----------

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://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 https://odoo-community.org.
4 changes: 4 additions & 0 deletions website_sale_pricelist_hide/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).

from . import controllers
18 changes: 18 additions & 0 deletions website_sale_pricelist_hide/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
# Copyright 2016-2017 LasLabs Inc.
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).

{
'name': 'Website Sale Pricelist Hide',
'summary': 'Hide items from website sale view that are not in pricelist.',
'version': '9.0.1.0.0',
'category': 'Website',
'website': 'https://laslabs.com/',
'author': 'LasLabs',
'license': 'LGPL-3',
'application': False,
'installable': True,
'depends': [
'website_sale',
],
}
4 changes: 4 additions & 0 deletions website_sale_pricelist_hide/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).

from . import main
28 changes: 28 additions & 0 deletions website_sale_pricelist_hide/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
# Copyright 2016-2017 LasLabs Inc.
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).

from openerp import http
from openerp.addons.website_sale.controllers.main import website_sale


class WebsiteSale(website_sale):

def _get_search_domain(self, search, category, attrib_values):
""" Overload to inject pricelist item ids if necessary. """

context = http.request.env.context
domain = super(WebsiteSale, self)._get_search_domain(
search, category, attrib_values
)

if not context.get('pricelist'):
pricelist_id_int = self.get_pricelist().id
else:
pricelist_id_int = context['pricelist']

domain.extend([
('item_ids.pricelist_id', '=', pricelist_id_int),
])

return domain
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 630afd3

Please sign in to comment.