Skip to content

Commit

Permalink
[MIG] product_variant_multi_link: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
thienvh332 committed Dec 4, 2024
1 parent 504d5c7 commit 0c1427e
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 12 deletions.
4 changes: 4 additions & 0 deletions product_variant_multi_link/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Contributors
------------

- Simone Orsi <[email protected]>
- Thien Vo <[email protected]>

Other credits
-------------
Expand All @@ -72,6 +73,9 @@ The development of this module has been financially supported by:
- Camptocamp
- Cosanum

The migration of this module from 14.0 to 18.0 was financially supported
by Camptocamp.

Maintainers
-----------

Expand Down
2 changes: 1 addition & 1 deletion product_variant_multi_link/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{
"name": "Product Multi Links (Variant)",
"version": "14.0.1.1.0",
"version": "18.0.1.0.0",
"category": "Generic Modules",
"author": "Camptocamp SA, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/e-commerce",
Expand Down
8 changes: 4 additions & 4 deletions product_variant_multi_link/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Simone Orsi <[email protected]>
# 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.exceptions import AccessError


Expand All @@ -24,7 +24,7 @@ def _compute_product_product_link_count(self):
link_model = self.env["product.template.link"]
# Set product_template_link_qty to 0 if user has no access on the model
try:
link_model.check_access_rights("read")
link_model.check_access("read")
except AccessError:
self.update({"product_product_link_count": 0})
return
Expand Down Expand Up @@ -72,9 +72,9 @@ def show_product_product_links(self):
self.ensure_one()

return {
"name": _("Product links"),
"name": self.env._("Product links"),
"type": "ir.actions.act_window",
"view_mode": "tree,form",
"view_mode": "list,form",
"res_model": "product.template.link",
"domain": [
"|",
Expand Down
11 changes: 6 additions & 5 deletions product_variant_multi_link/models/product_template_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Simone Orsi <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import _, api, exceptions, fields, models
from odoo import api, exceptions, fields, models


class ProductTemplateLink(models.Model):
Expand Down Expand Up @@ -37,9 +37,9 @@ def _check_products(self):
# to avoid issues w/ existing table and existing records
if not rec.left_product_id or not rec.right_product_id:
raise exceptions.ValidationError(
_("Source and target variants are required!")
self.env._("Source and target variants are required!")
)
super()._check_products()
return super()._check_products()

def _check_product_not_different(self):
res = super()._check_product_not_different()
Expand All @@ -62,5 +62,6 @@ def _check_products_query_params(self):
return params

def _invalidate_links(self):
super()._invalidate_links()
self.env["product.product"].invalidate_cache(["product_variant_link_ids"])
res = super()._invalidate_links()
self.env["product.product"].invalidate_model(["product_variant_link_ids"])
return res
1 change: 1 addition & 0 deletions product_variant_multi_link/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
- Simone Orsi \<<[email protected]>\>
- Thien Vo \<<[email protected]>\>
2 changes: 2 additions & 0 deletions product_variant_multi_link/readme/CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ The development of this module has been financially supported by:

- Camptocamp
- Cosanum

The migration of this module from 14.0 to 18.0 was financially supported by Camptocamp.
3 changes: 3 additions & 0 deletions product_variant_multi_link/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ <h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<ul class="simple">
<li>Simone Orsi &lt;<a class="reference external" href="mailto:simahawk&#64;gmail.com">simahawk&#64;gmail.com</a>&gt;</li>
<li>Thien Vo &lt;<a class="reference external" href="mailto:thienvh&#64;trobz.com">thienvh&#64;trobz.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="other-credits">
Expand All @@ -419,6 +420,8 @@ <h2><a class="toc-backref" href="#toc-entry-6">Other credits</a></h2>
<li>Camptocamp</li>
<li>Cosanum</li>
</ul>
<p>The migration of this module from 14.0 to 18.0 was financially supported
by Camptocamp.</p>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo.exceptions import ValidationError
from odoo.tests.common import SavepointCase
from odoo.tests.common import TransactionCase


class TestProductVariantLink(SavepointCase):
class TestProductVariantLink(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<field
name="left_product_id"
string="Variant"
groups="product.group_product_variant"
filter_domain="['|',('left_product_id','ilike',self),('right_product_id','ilike',self)]"
/>
</field>
Expand All @@ -26,12 +27,14 @@
<field name="left_product_tmpl_id" position="after">
<field
name="left_product_id"
groups="product.group_product_variant"
domain="[('product_tmpl_id','=',left_product_tmpl_id)]"
/>
</field>
<field name="right_product_tmpl_id" position="after">
<field
name="right_product_id"
groups="product.group_product_variant"
domain="[('product_tmpl_id','=',right_product_tmpl_id)]"
/>
</field>
Expand All @@ -47,12 +50,14 @@
<field name="left_product_tmpl_id" position="after">
<field
name="left_product_id"
groups="product.group_product_variant"
domain="[('product_tmpl_id','=',left_product_tmpl_id)]"
/>
</field>
<field name="right_product_tmpl_id" position="after">
<field
name="right_product_id"
groups="product.group_product_variant"
domain="[('product_tmpl_id','=',right_product_tmpl_id)]"
/>
</field>
Expand All @@ -68,12 +73,14 @@
<field name="left_product_tmpl_id" position="after">
<field
name="left_product_id"
groups="product.group_product_variant"
domain="[('product_tmpl_id','=',left_product_tmpl_id)]"
/>
</field>
<field name="right_product_tmpl_id" position="after">
<field
name="right_product_id"
groups="product.group_product_variant"
domain="[('product_tmpl_id','=',right_product_tmpl_id)]"
/>
</field>
Expand Down

0 comments on commit 0c1427e

Please sign in to comment.