Skip to content

Commit

Permalink
[MIG] product_abc_classification: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fgaviiria committed Jul 18, 2024
1 parent b47c2de commit d8e3c8b
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 20 deletions.
2 changes: 1 addition & 1 deletion product_abc_classification/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"name": "Product Abc Classification",
"summary": """
ABC classification for sales and warehouse management""",
"version": "16.0.1.0.1",
"version": "17.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV, ForgeFlow, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/product-attribute",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ def write(self, vals):
else:
# If profile is not modified, filter levels per profile
# if it has auto_apply_computed_value True and modify only
# those ones
# those
auto_applied_profiles_levels = self.filtered(
lambda l: l.profile_id.auto_apply_computed_value
lambda level: level.profile_id.auto_apply_computed_value
)
new_self = self - auto_applied_profiles_levels
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ class AbcClassificationProfile(models.Model):

auto_apply_computed_value = fields.Boolean(
default=False,
help="Check this if you want to apply the computed level on each product that has this "
help="Check this if you want to apply "
"the computed level on each product that has this "
"profile.",
)

Expand Down Expand Up @@ -105,7 +106,7 @@ def _cron_compute_abc_classification(self):
self.search([])._compute_abc_classification()

Check warning on line 106 in product_abc_classification/models/abc_classification_profile.py

View check run for this annotation

Codecov / codecov/patch

product_abc_classification/models/abc_classification_profile.py#L106

Added line #L106 was not covered by tests

def write(self, vals):
res = super(AbcClassificationProfile, self).write(vals)
res = super().write(vals)
if "auto_apply_computed_value" in vals and vals["auto_apply_computed_value"]:
self._auto_apply_computed_value_for_product_levels()
return res
Expand Down
14 changes: 9 additions & 5 deletions product_abc_classification/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ def setUpClass(cls):
)

levels = cls.classification_profile.level_ids
cls.classification_level_a = levels.filtered(lambda l: l.name == "a")
cls.classification_level_b = levels.filtered(lambda l: l.name == "b")
cls.classification_level_a = levels.filtered(lambda level: level.name == "a")
cls.classification_level_b = levels.filtered(lambda level: level.name == "b")
cls.classification_profile_bis = cls.ABCClassificationProfile.create(
{
"name": "Profile test bis",
Expand Down Expand Up @@ -79,11 +79,15 @@ def setUpClass(cls):
}
)
levels = cls.classification_profile_bis.level_ids
cls.classification_level_bis_a = levels.filtered(lambda l: l.name == "a")
cls.classification_level_bis_a = levels.filtered(
lambda level: level.name == "a"
)

cls.classification_level_bis_b = levels.filtered(lambda l: l.name == "b")
cls.classification_level_bis_b = levels.filtered(
lambda level: level.name == "b"
)
# create a template with one variant adn declare attributes to create
# an other variant on demand
# another variant on demand
cls.size_attr = cls.env["product.attribute"].create(
{
"name": "Size",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<div
class="alert alert-danger"
role="alert"
attrs="{'invisible': [('flag','=',False)]}"
invisible="not flag"
>Computed level differs from the specified level</div>
<group name="main_info">
<field name="display_name" />
Expand Down Expand Up @@ -45,11 +45,11 @@
<field name="model">abc.classification.product.level</field>
<field name="arch" type="xml">
<tree decoration-danger="flag == True" editable="bottom">
<field name="profile_id" invisible="1" />
<field name="profile_id" column_invisible="1" />
<field name="product_id" />
<field name="manual_level_id" />
<field name="computed_level_id" />
<field name="flag" invisible="1" />
<field name="flag" column_invisible="1" />
</tree>
</field>
</record>
Expand Down
6 changes: 3 additions & 3 deletions product_abc_classification/views/product_product.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
<field name="abc_classification_product_level_ids" position="attributes">
<attribute
name="context"
>{'default_product_id': active_id, 'default_profile_id': abc_classification_profile_ids and abc_classification_profile_ids[0] or False}</attribute>
<attribute name="attrs">{'read_only': False}</attribute>
<attribute name="domain">[('product_id', '=', active_id)]</attribute>
>{'default_product_id': id, 'default_profile_id': abc_classification_profile_ids and abc_classification_profile_ids[0] or False}</attribute>
<attribute name="readonly">context</attribute>
<attribute name="domain">[('product_id', '=', id)]</attribute>
</field>
</field>
</record>
Expand Down
8 changes: 4 additions & 4 deletions product_abc_classification/views/product_template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
<page
string="ABC Classification"
name="abc_classification"
attrs="{'invisible':[('type','!=','product')]}"
invisible="type != 'product'"
>
<group>
<group>
<field
name="abc_classification_product_level_ids"
widget="many2many_tags"
context="{'default_product_tmpl_id': active_id, 'default_profile_id': abc_classification_profile_ids and abc_classification_profile_ids[0] or False}"
attrs="{'readonly': [('product_variant_count', '&gt;', 1)]}"
domain="[('product_tmpl_id', '=', active_id)]"
context="{'default_product_tmpl_id': id, 'default_profile_id': abc_classification_profile_ids and abc_classification_profile_ids[0] or False}"
readonly="product_variant_count &gt; 1"
domain="[('product_tmpl_id', '=', id)]"
/>
<field name="abc_classification_profile_ids" widget="many2many_tags" />
</group>
Expand Down

0 comments on commit d8e3c8b

Please sign in to comment.