Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[13.0][MIG] product_assortment #517

Merged
merged 10 commits into from Jan 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
98 changes: 98 additions & 0 deletions product_assortment/README.rst
@@ -0,0 +1,98 @@
==================
Product Assortment
==================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge2| image:: https://img.shields.io/badge/github-OCA%2Fproduct--attribute-lightgray.png?logo=github
:target: https://github.com/OCA/product-attribute/tree/12.0/product_assortment
:alt: OCA/product-attribute
.. |badge3| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/product-attribute-12-0/product-attribute-12-0-product_assortment
:alt: Translate me on Weblate
.. |badge4| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/135/12.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4|

This addon intends to manage product assortment. In Odoo you can only define
some filters defined by a domain but it can be sometimes really complicated.
With this addon you will be able to define a domain but also add some
products to include or to exclude through a white list and a black list.
This is done by overriding ir.capability but without influencing its standard
behaviour.

**Table of contents**

.. contents::
:local:

Usage
=====


To use this module, you need to:

#. Enter the menu through Product Assortment Icon
#. Create a new filter where you can define your domain and add whitelisted and blacklisted products

Changelog
=========

10.0.1.0.0 (2018-08-27)
~~~~~~~~~~~~~~~~~~~~~~~

* [10.0][ADD] product_assortment

12.0.1.0.0 (2019-06-03)
~~~~~~~~~~~~~~~~~~~~~~~

* [12.0][MIG] product_assortment

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/product-attribute/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/product-attribute/issues/new?body=module:%20product_assortment%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* ACSONE SA/NV

Contributors
~~~~~~~~~~~~

* Denis Roussel <denis.roussel@acsone.eu>
* Cédric Pigeon <cedric.pigeon@acsone.eu>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

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.

This module is part of the `OCA/product-attribute <https://github.com/OCA/product-attribute/tree/12.0/product_assortment>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions product_assortment/__init__.py
@@ -0,0 +1 @@
from . import models
16 changes: 16 additions & 0 deletions product_assortment/__manifest__.py
@@ -0,0 +1,16 @@
# Copyright 2018-2019 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Product Assortment",
"summary": """
Adds the ability to manage products assortment""",
"version": "13.0.1.0.0",
"license": "AGPL-3",
"development_status": "Stable/Production",
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/product-attribute",
"depends": ["base", "product"],
"data": ["views/product_assortment.xml"],
"installable": True,
}
93 changes: 93 additions & 0 deletions product_assortment/i18n/product_assortment.pot
@@ -0,0 +1,93 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_assortment
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \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: product_assortment
#: model_terms:ir.ui.view,arch_db:product_assortment.product_assortment_view_form
msgid "<span class=\"o_stat_text\">Products</span>"
msgstr ""

#. module: product_assortment
#: model_terms:ir.ui.view,arch_db:product_assortment.product_assortment_view_form
#: model_terms:ir.ui.view,arch_db:product_assortment.product_assortment_view_search
msgid "Assortment Name"
msgstr ""

#. module: product_assortment
#: model_terms:ir.ui.view,arch_db:product_assortment.product_assortment_view_search
msgid "Assortments"
msgstr ""

#. module: product_assortment
#: model:ir.model.fields,field_description:product_assortment.field_ir_filters__blacklist_product_ids
msgid "Blacklist Product"
msgstr ""

#. module: product_assortment
#: model:ir.model,name:product_assortment.model_ir_filters
#: model_terms:ir.ui.view,arch_db:product_assortment.product_assortment_view_form
msgid "Filters"
msgstr ""

#. module: product_assortment
#: model:ir.model.fields,field_description:product_assortment.field_ir_filters__is_assortment
msgid "Is Assortment"
msgstr ""

#. module: product_assortment
#: model:ir.model.fields,field_description:product_assortment.field_ir_filters__model_id
msgid "Model"
msgstr ""

#. module: product_assortment
#: model_terms:ir.ui.view,arch_db:product_assortment.product_assortment_view_form
msgid "Product"
msgstr ""

#. module: product_assortment
#: model:ir.ui.menu,name:product_assortment.menu_product_assortments
msgid "Product Assortment"
msgstr ""

#. module: product_assortment
#: model:ir.actions.act_window,name:product_assortment.actions_product_assortment_view
msgid "Product assortment"
msgstr ""

#. module: product_assortment
#: code:addons/product_assortment/models/ir_filters.py:78
#, python-format
msgid "Products"
msgstr ""

#. module: product_assortment
#: model_terms:ir.ui.view,arch_db:product_assortment.product_assortment_view_form
msgid "Products to exclude"
msgstr ""

#. module: product_assortment
#: model_terms:ir.ui.view,arch_db:product_assortment.product_assortment_view_form
msgid "Products to include"
msgstr ""

#. module: product_assortment
#: model:ir.model.fields,field_description:product_assortment.field_ir_filters__record_count
msgid "Record Count"
msgstr ""

#. module: product_assortment
#: model:ir.model.fields,field_description:product_assortment.field_ir_filters__whitelist_product_ids
msgid "Whitelist Product"
msgstr ""

1 change: 1 addition & 0 deletions product_assortment/models/__init__.py
@@ -0,0 +1 @@
from . import ir_filters
75 changes: 75 additions & 0 deletions product_assortment/models/ir_filters.py
@@ -0,0 +1,75 @@
# Copyright 2018-2019 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import _, api, fields, models
from odoo.osv import expression


class IrFilters(models.Model):
_inherit = "ir.filters"

@api.model
def _get_default_model(self):
if self.env.context.get("product_assortment", False):
model = self.env.ref("product.model_product_product")
return model.model
return False

@api.model
def _get_default_is_assortment(self):
if self.env.context.get("product_assortment", False):
return True
return False

model_id = fields.Selection(default=lambda x: x._get_default_model())

blacklist_product_ids = fields.Many2many(
comodel_name="product.product", relation="assortment_product_blacklisted"
)

whitelist_product_ids = fields.Many2many(
comodel_name="product.product", relation="assortment_product_whitelisted"
)

record_count = fields.Integer(compute="_compute_record_count")

is_assortment = fields.Boolean(default=lambda x: x._get_default_is_assortment())

def _get_eval_domain(self):
res = super()._get_eval_domain()

if self.whitelist_product_ids and res:
result_domain = [("id", "in", self.whitelist_product_ids.ids)]
res = expression.OR([result_domain, res])

if self.blacklist_product_ids:
result_domain = [("id", "not in", self.blacklist_product_ids.ids)]
res = expression.AND([result_domain, res])

return res

def _compute_record_count(self):
for record in self:
domain = record._get_eval_domain()
record.record_count = self.env[record.model_id].search_count(domain)

@api.model
def _get_action_domain(self, action_id=None):
# tricky way to act on get_filter method to prevent returning
# assortment in search view filters
domain = super()._get_action_domain(action_id=action_id)
domain = expression.AND([[("is_assortment", "=", False)], domain])

return domain

def show_products(self):
self.ensure_one()
return {
"type": "ir.actions.act_window",
"name": _("Products"),
"res_model": "product.product",
"domain": self._get_eval_domain(),
"view_type": "form",
"view_mode": "tree, form",
"context": self.env.context,
"target": "current",
}
2 changes: 2 additions & 0 deletions product_assortment/readme/CONTRIBUTORS.rst
@@ -0,0 +1,2 @@
* Denis Roussel <denis.roussel@acsone.eu>
* Cédric Pigeon <cedric.pigeon@acsone.eu>
6 changes: 6 additions & 0 deletions product_assortment/readme/DESCRIPTION.rst
@@ -0,0 +1,6 @@
This addon intends to manage product assortment. In Odoo you can only define
some filters defined by a domain but it can be sometimes really complicated.
With this addon you will be able to define a domain but also add some
products to include or to exclude through a white list and a black list.
This is done by overriding ir.capability but without influencing its standard
behaviour.
9 changes: 9 additions & 0 deletions product_assortment/readme/HISTORY.rst
@@ -0,0 +1,9 @@
10.0.1.0.0 (2018-08-27)
~~~~~~~~~~~~~~~~~~~~~~~

* [10.0][ADD] product_assortment

12.0.1.0.0 (2019-06-03)
~~~~~~~~~~~~~~~~~~~~~~~

* [12.0][MIG] product_assortment
5 changes: 5 additions & 0 deletions product_assortment/readme/USAGE.rst
@@ -0,0 +1,5 @@

To use this module, you need to:

#. Enter the menu through Product Assortment Icon
#. Create a new filter where you can define your domain and add whitelisted and blacklisted products
Binary file added product_assortment/static/description/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.