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

[10.0][FIX] action server in tree view must play on all selected records #458

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions shopinvader_search_engine/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import test_action_server
from . import test_delete_product
34 changes: 34 additions & 0 deletions shopinvader_search_engine/tests/test_action_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
# Copyright 2020 Akretion (http://www.akretion.com).
# @author Sébastien BEAU <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo.addons.queue_job.tests.common import JobMixin
from odoo.addons.shopinvader.tests.common import ProductCommonCase


class ActionServerCase(ProductCommonCase, JobMixin):
def test_action_server_on_product_template(self):
job = self.job_counter()
bindings = self.env["shopinvader.product"].search([], limit=4)
action = self.env.ref(
"shopinvader_search_engine.action_recompute_shopinvader_product"
)
action.with_context(
active_model="product.template",
active_ids=bindings.mapped("record_id").ids,
).run()
self.assertEqual(job.count_created(), 4)

def test_action_server_on_product_category(self):
self.backend.bind_all_category()
job = self.job_counter()
bindings = self.env["shopinvader.category"].search([], limit=4)
action = self.env.ref(
"shopinvader_search_engine.action_recompute_shopinvader_category"
)
action.with_context(
active_model="product.category",
active_ids=bindings.mapped("record_id").ids,
).run()
self.assertEqual(job.count_created(), 4)
3 changes: 1 addition & 2 deletions shopinvader_search_engine/views/product_category_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@
<field name="name">Recompute shopinvader category</field>
<field name="model_id" ref="product.model_product_category"/>
<field name="code">
for categ in object:
categ.shopinvader_bind_ids._jobify_recompute_json(force_export=True)
records.mapped("shopinvader_bind_ids")._jobify_recompute_json(force_export=True)
</field>
</record>

Expand Down
4 changes: 1 addition & 3 deletions shopinvader_search_engine/views/product_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@
<field name="name">Recompute shopinvader product</field>
<field name="model_id" ref="product.model_product_template"/>
<field name="code">
for template in object:
for variant in obj.product_variant_ids:
variant.shopinvader_bind_ids._jobify_recompute_json(force_export=True)
records.mapped("product_variant_ids.shopinvader_bind_ids")._jobify_recompute_json(force_export=True)
</field>
</record>

Expand Down