Skip to content

Commit

Permalink
[MIG] product_assortment: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
PieterPaulussen committed Dec 18, 2024
1 parent deff106 commit 4947851
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 42 deletions.
2 changes: 1 addition & 1 deletion product_assortment/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"name": "Product Assortment",
"summary": """
Adds the ability to manage products assortment""",
"version": "16.0.2.0.0",
"version": "18.0.1.0.0",
"license": "AGPL-3",
"development_status": "Production/Stable",
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
Expand Down
2 changes: 0 additions & 2 deletions product_assortment/data/ir_cron.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
/>
<field name="interval_number">1</field>
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field name="doall" eval="False" />
<field name="active" eval="False" />
<field
name="nextcall"
Expand Down
2 changes: 1 addition & 1 deletion product_assortment/i18n/ca.po
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ msgid "Partners to apply"
msgstr "Socis a aplicar"

#. module: product_assortment
#: model_terms:ir.ui.view,arch_db:product_assortment.product_product_view_tree
#: model_terms:ir.ui.view,arch_db:product_assortment.product_product_view_list
msgid "Product"
msgstr "Producte"

Expand Down
2 changes: 1 addition & 1 deletion product_assortment/i18n/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ msgid "Partners to apply"
msgstr ""

#. module: product_assortment
#: model_terms:ir.ui.view,arch_db:product_assortment.product_product_view_tree
#: model_terms:ir.ui.view,arch_db:product_assortment.product_product_view_list
msgid "Product"
msgstr "Produkt"

Expand Down
2 changes: 1 addition & 1 deletion product_assortment/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ msgid "Partners to apply"
msgstr "Contactos a los que aplica"

#. module: product_assortment
#: model_terms:ir.ui.view,arch_db:product_assortment.product_product_view_tree
#: model_terms:ir.ui.view,arch_db:product_assortment.product_product_view_list
msgid "Product"
msgstr "Producto"

Expand Down
2 changes: 1 addition & 1 deletion product_assortment/i18n/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ msgid "Partners to apply"
msgstr "Appliquer aux partenaires"

#. module: product_assortment
#: model_terms:ir.ui.view,arch_db:product_assortment.product_product_view_tree
#: model_terms:ir.ui.view,arch_db:product_assortment.product_product_view_list
msgid "Product"
msgstr "Produit"

Expand Down
2 changes: 1 addition & 1 deletion product_assortment/i18n/it.po
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ msgid "Partners to apply"
msgstr "Partner da applicare"

#. module: product_assortment
#: model_terms:ir.ui.view,arch_db:product_assortment.product_product_view_tree
#: model_terms:ir.ui.view,arch_db:product_assortment.product_product_view_list
msgid "Product"
msgstr "Prodotto"

Expand Down
2 changes: 1 addition & 1 deletion product_assortment/i18n/product_assortment.pot
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ msgid "Partners to apply"
msgstr ""

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

Expand Down
21 changes: 13 additions & 8 deletions product_assortment/models/ir_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright 2023 Tecnativa - Carlos Dauden
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import _, api, fields, models
from odoo import api, fields, models
from odoo.osv import expression
from odoo.tools import ormcache
from odoo.tools.safe_eval import datetime, safe_eval
Expand Down Expand Up @@ -83,7 +83,7 @@ def get_partner_domain_fields(self):
for ir_filter in self.sudo().search([("is_assortment", "=", True)]):
domain = ir_filter._get_eval_partner_domain()
for item in domain:
if isinstance(item, (list, tuple)) and isinstance(item[0], str):
if isinstance(item, list | tuple) and isinstance(item[0], str):
field_set.add(item[0].split(".")[0])
return field_set

Expand Down Expand Up @@ -146,13 +146,18 @@ def _compute_record_count(self):
record.record_count = self.env[record.model_id].search_count(domain)

@api.model
def _get_action_domain(self, action_id=None):
def _get_action_domain(
self, action_id=None, embedded_action_id=None, embedded_parent_res_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
res = super()._get_action_domain(
action_id=action_id,
embedded_action_id=embedded_action_id,
embedded_parent_res_id=embedded_parent_res_id,
)
res[0] = expression.AND([[("is_assortment", "=", False)], res[0]])
return res

def write(self, vals):
res = super().write(vals)
Expand All @@ -167,7 +172,7 @@ def show_products(self):
action.update(
{
"domain": self._get_eval_domain(),
"name": _("Products"),
"name": self.env._("Products"),
"context": self.env.context,
"target": "current",
}
Expand Down
4 changes: 2 additions & 2 deletions product_assortment/tests/test_product_assortment.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class TestProductAssortment(TransactionCase):
def setUp(self):
super(TestProductAssortment, self).setUp()
super().setUp()
self.filter_obj = self.env["ir.filters"]
self.product_obj = self.env["product.product"]
self.assortment = self.filter_obj.create(
Expand Down Expand Up @@ -111,7 +111,7 @@ def test_assortment_with_partner_domain(self):
assortment = self.filter_obj.with_context(product_assortment=True).create(
{
"name": "Test Assortment Partner domain",
"partner_domain": "[('id', '=', %s)]" % self.partner.id,
"partner_domain": f"[('id', '=', {self.partner.id})]",
"partner_ids": [(4, self.partner2.id)],
}
)
Expand Down
41 changes: 18 additions & 23 deletions product_assortment/views/product_assortment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
</search>
</field>
</record>
<record id="product_assortment_view_tree" model="ir.ui.view">
<record id="product_assortment_view_list" model="ir.ui.view">
<field name="model">ir.filters</field>
<field name="arch" type="xml">
<tree>
<list>
<field name="name" />
</tree>
</list>
</field>
</record>

Expand All @@ -39,24 +39,20 @@
<span class="o_stat_value">
<field name="record_count" />
</span>
<span
attrs="{'invisible': [('record_count', '&lt;=', 1)]}"
>
Products
</span>
<span
attrs="{'invisible': [('record_count', '&gt;', 1)]}"
>
Product
</span>
<span invisible="record_count &lt;= 1">
Products
</span>
<span invisible="record_count &lt;= 1">
Product
</span>
</div>
</button>
</div>
<widget
name="web_ribbon"
title="Archived"
bg_color="bg-danger"
attrs="{'invisible': [('active', '=', True)]}"
invisible="active"
/>
<div class="oe_title">
<label for="name" string="Assortment Name" />
Expand Down Expand Up @@ -85,7 +81,7 @@
</group>
<group
string="Restricted product domain"
attrs="{'invisible': [('apply_black_list_product_domain', '=', False)]}"
invisible="not apply_black_list_product_domain"
>
<field
name="black_list_product_domain"
Expand All @@ -110,17 +106,16 @@
name="whitelist_product_ids"
nolabel="1"
colspan="2"
context="{'tree_view_ref': 'product_assortment.product_product_view_tree'}"
context="{'list_view_ref': 'product_assortment.product_product_view_list'}"
/>
</group>
<group name="to_exclude" string="Products to exclude">
<field
name="blacklist_product_ids"
nolabel="1"
colspan="2"
context="{'tree_view_ref': 'product_assortment.product_product_view_tree'}"
>>
</field>
context="{'list_view_ref': 'product_assortment.product_product_view_list'}"
/>
</group>
</group>
<group
Expand All @@ -133,12 +128,12 @@
</form>
</field>
</record>
<record id="product_product_view_tree" model="ir.ui.view">
<record id="product_product_view_list" model="ir.ui.view">
<field name="model">product.product</field>
<field name="arch" type="xml">
<tree>
<list>
<field name="display_name" string="Product" />
</tree>
</list>
</field>
</record>
<record id="actions_product_assortment_view" model="ir.actions.act_window">
Expand All @@ -151,7 +146,7 @@
<field
name="view_ids"
eval="[(5, 0, 0),
(0, 0, {'view_mode': 'tree', 'view_id': ref('product_assortment_view_tree')}),
(0, 0, {'view_mode': 'list', 'view_id': ref('product_assortment_view_list')}),
(0, 0, {'view_mode': 'form', 'view_id': ref('product_assortment_view_form')})]"
/>
</record>
Expand Down

0 comments on commit 4947851

Please sign in to comment.