Skip to content

Commit

Permalink
[MIG] product_configurator: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bizzappdev committed Feb 19, 2025
1 parent f74a867 commit 5faec59
Show file tree
Hide file tree
Showing 22 changed files with 241 additions and 150 deletions.
2 changes: 1 addition & 1 deletion product_configurator/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Odoo Product Configurator
# Odoo Product Configurator

This module is Dynamic configuration wizard for Odoo back-end and the foundation for
external configuration interfaces such 'website_product_configurator'.
Expand Down
10 changes: 5 additions & 5 deletions product_configurator/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Product Configurator
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fproduct--configurator-lightgray.png?logo=github
:target: https://github.com/OCA/product-configurator/tree/17.0/product_configurator
:target: https://github.com/OCA/product-configurator/tree/18.0/product_configurator
:alt: OCA/product-configurator
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/product-configurator-17-0/product-configurator-17-0-product_configurator
:target: https://translation.odoo-community.org/projects/product-configurator-18-0/product-configurator-18-0-product_configurator
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/product-configurator&target_branch=17.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/product-configurator&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand All @@ -42,7 +42,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/product-configurator/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/product-configurator/issues/new?body=module:%20product_configurator%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/product-configurator/issues/new?body=module:%20product_configurator%0Aversion:%2018.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.

Expand Down Expand Up @@ -82,6 +82,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-PCatinean|

This module is part of the `OCA/product-configurator <https://github.com/OCA/product-configurator/tree/17.0/product_configurator>`_ project on GitHub.
This module is part of the `OCA/product-configurator <https://github.com/OCA/product-configurator/tree/18.0/product_configurator>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion product_configurator/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Product Configurator",
"version": "17.0.1.0.1",
"version": "18.0.1.0.0",
"category": "Generic Modules/Base",
"summary": "Base for product configuration interface modules",
"author": "Pledra, Odoo Community Association (OCA)",
Expand Down
10 changes: 5 additions & 5 deletions product_configurator/data/menu_configurable_product.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<field name="name">Configurable Templates</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">product.template</field>
<field name="view_mode">kanban,tree,form</field>
<field name="view_mode">kanban,list,form</field>
<field name="view_id" ref="product.product_template_kanban_view" />
<field
name="context"
Expand All @@ -42,7 +42,7 @@
<field name="name">Configured Variants</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">product.product</field>
<field name="view_mode">kanban,form,tree</field>
<field name="view_mode">kanban,form,list</field>
<field name="search_view_id" ref="product.product_search_form_view" />
<field name="view_id" eval="False" />
<!-- Force empty -->
Expand Down Expand Up @@ -88,7 +88,7 @@
<field name="name">Configuration Steps</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">product.config.step</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
</record>

<menuitem
Expand All @@ -103,7 +103,7 @@
<field name="name">Configuration Restrictions</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">product.config.domain</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
</record>

<menuitem
Expand All @@ -118,7 +118,7 @@
<field name="name">Configuration Sessions</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">product.config.session</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
</record>

<menuitem
Expand Down
30 changes: 17 additions & 13 deletions product_configurator/models/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from mako.runtime import Context
from mako.template import Template

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

_logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -49,7 +49,7 @@ def check_attr_value_ids(self):
attr_val_ids = attr_val_lines.mapped("value_ids")
if not attr_val_ids <= product_tmpl.attribute_line_val_ids:
raise ValidationError(
_(
self.env._(
"All attribute values used in attribute value lines "
"must be defined in the attribute lines of the "
"template"
Expand All @@ -70,7 +70,9 @@ def _validate_unique_config(self):
]
if len(set(attr_val_line_vals)) != len(attr_val_line_vals):
raise ValidationError(
_("You cannot have a duplicate configuration for the same value")
self.env._(
"You cannot have a duplicate configuration for the same value"
)
)

config_ok = fields.Boolean(string="Can be Configured")
Expand Down Expand Up @@ -162,7 +164,7 @@ def _check_default_values(self):
raise ValidationError(exc.args[0]) from exc
except Exception as exc:

Check warning on line 165 in product_configurator/models/product.py

View check run for this annotation

Codecov / codecov/patch

product_configurator/models/product.py#L165

Added line #L165 was not covered by tests
raise ValidationError(
_("Default values provided generate an invalid configuration")
self.env._("Default values provided generate an invalid configuration")
) from exc

@api.constrains("config_line_ids", "attribute_line_ids")
Expand All @@ -172,7 +174,7 @@ def _check_default_value_domains(self):
template._check_default_values()
except ValidationError as exc:
raise ValidationError(

Check warning on line 176 in product_configurator/models/product.py

View check run for this annotation

Codecov / codecov/patch

product_configurator/models/product.py#L175-L176

Added lines #L175 - L176 were not covered by tests
_(
self.env._(
"Restrictions added make the current default values "
"generate an invalid configuration.\
\n%s"
Expand Down Expand Up @@ -312,7 +314,7 @@ def check_config_user_access(self):
):
return True
raise ValidationError(

Check warning on line 316 in product_configurator/models/product.py

View check run for this annotation

Codecov / codecov/patch

product_configurator/models/product.py#L316

Added line #L316 was not covered by tests
_(
self.env._(
"Sorry, you are not allowed to create/change this kind of "
"document. For more information please contact your manager."
)
Expand Down Expand Up @@ -350,22 +352,24 @@ def _check_config_line_domain(self):
if not invalid_attribute_ids and not invalid_value_ids:
continue
if not error_message:
error_message = _(
error_message = self.env._(
"Following Attribute/Value from restriction "
"are not present in template attributes/values. "
"Please make sure you are adding right restriction"
)
error_message += _("\nRestriction: %s", domain_id.name)
error_message += self.env._("\nRestriction: %s", domain_id.name)
error_message += (
invalid_attribute_ids
and _(
and self.env._(
"\nAttribute/s: %s", ", ".join(invalid_attribute_ids.mapped("name"))
)
or ""
)
error_message += (
invalid_value_ids
and _("\nValue/s: %s\n", ", ".join(invalid_value_ids.mapped("name")))
and self.env._(
"\nValue/s: %s\n", ", ".join(invalid_value_ids.mapped("name"))
)
or ""
)
if error_message:
Expand Down Expand Up @@ -400,7 +404,7 @@ def _check_duplicate_product(self):

if duplicates:
raise ValidationError(
_(
self.env._(
"Configurable Products cannot have duplicates "
"(identical attribute values)"
)
Expand Down Expand Up @@ -440,7 +444,7 @@ def _get_mako_tmpl_name(self):
return buf.getvalue()
except Exception:
_logger.error(
_("Error while calculating mako product name: %s")
self.env._("Error while calculating mako product name: %s")
% self.display_name
)
return self.display_name
Expand Down Expand Up @@ -522,7 +526,7 @@ def check_config_user_access(self, mode):
):
return True
raise ValidationError(

Check warning on line 528 in product_configurator/models/product.py

View check run for this annotation

Codecov / codecov/patch

product_configurator/models/product.py#L528

Added line #L528 was not covered by tests
_(
self.env._(
"Sorry, you are not allowed to create/change this kind of "
"document. For more information please contact your manager."
)
Expand Down
20 changes: 10 additions & 10 deletions product_configurator/models/product_attribute.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from ast import literal_eval

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


Expand Down Expand Up @@ -93,7 +93,7 @@ def check_searchable_field(self):
nosearch_fields = attribute._get_nosearch_fields()
if attribute.custom_type in nosearch_fields and attribute.search_ok:
raise ValidationError(
_(
self.env._(
"Selected custom field type '%s' is not searchable",
attribute.custom_type,
)
Expand All @@ -110,7 +110,7 @@ def validate_custom_val(self, val):
val = literal_eval(str(val))
if minv and maxv and (val < minv or val > maxv):
raise ValidationError(
_(
self.env._(
"Selected custom value '%(name)s' must be "
"between %(min_val)s and %(max_val)s",
**{
Expand All @@ -122,14 +122,14 @@ def validate_custom_val(self, val):
)
elif minv and val < minv:
raise ValidationError(
_(
self.env._(
"Selected custom value '%(name)s' must be at least %(min_val)s",
**{"name": self.name, "min_val": self.min_val},
)
)
elif maxv and val > maxv:
raise ValidationError(
_(
self.env._(
"Selected custom value '%(name)s' "
"must be lower than %(max_value)s",
**{"name": self.name, "max_value": self.max_val + 1},
Expand All @@ -146,7 +146,7 @@ def _check_constraint_min_max_value(self):
maxv = attribute.max_val
if maxv and minv and maxv < minv:
raise ValidationError(
_("Maximum value must be greater than Minimum value")
self.env._("Maximum value must be greater than Minimum value")
)

def _configurator_value_ids(self):
Expand Down Expand Up @@ -194,7 +194,7 @@ def _check_default_values(self):
for line in self.filtered(lambda line: line.default_val):
if line.default_val not in line.value_ids:
raise ValidationError(
_(
self.env._(
"Default values for each attribute line must exist in "
"the attribute values (%(attr_name)s: %(default_val)s)",
**{
Expand All @@ -215,7 +215,7 @@ def _check_valid_values(self):
# if ptal.active and not ptal.value_ids:
# Customization End
raise ValidationError(

Check warning on line 217 in product_configurator/models/product_attribute.py

View check run for this annotation

Codecov / codecov/patch

product_configurator/models/product_attribute.py#L217

Added line #L217 was not covered by tests
_(
self.env._(
"The attribute %(attr)s must have at least one value for "
"the product %(product)s.",
**{
Expand All @@ -227,7 +227,7 @@ def _check_valid_values(self):
for pav in ptal.value_ids:
if pav.attribute_id != ptal.attribute_id:
raise ValidationError(

Check warning on line 229 in product_configurator/models/product_attribute.py

View check run for this annotation

Codecov / codecov/patch

product_configurator/models/product_attribute.py#L229

Added line #L229 was not covered by tests
_(
self.env._(
"On the product %(product)s you cannot associate the "
"value %(value)s with the attribute %(attr)s because they "
"do not match.",
Expand Down Expand Up @@ -438,7 +438,7 @@ def _validate_configuration(self):
)
if not valid:
raise ValidationError(
_(
self.env._(
"Values provided to the attribute value line are "
"incompatible with the current rules"
)
Expand Down
Loading

0 comments on commit 5faec59

Please sign in to comment.