Skip to content

Commit

Permalink
[MIG][16.0] product_abc_classification_base
Browse files Browse the repository at this point in the history
  • Loading branch information
rousseldenis committed Nov 10, 2022
1 parent ea0a87d commit 482ce30
Show file tree
Hide file tree
Showing 15 changed files with 53 additions and 48 deletions.
17 changes: 9 additions & 8 deletions product_abc_classification_base/README.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
==============================
Alc Product Abc Classification
==============================
==========================
Product Abc Classification
==========================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
Expand All @@ -14,13 +14,13 @@ Alc Product Abc Classification
: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--attribute-lightgray.png?logo=github
:target: https://github.com/OCA/product-attribute/tree/10.0/product_abc_classification_base
:target: https://github.com/OCA/product-attribute/tree/16.0/product_abc_classification_base
:alt: OCA/product-attribute
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/product-attribute-10-0/product-attribute-10-0-product_abc_classification_base
:target: https://translation.odoo-community.org/projects/product-attribute-16-0/product-attribute-16-0-product_abc_classification_base
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/135/10.0
:target: https://runbot.odoo-community.org/runbot/135/16.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -63,7 +63,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/product-attribute/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/product-attribute/issues/new?body=module:%20product_abc_classification_base%0Aversion:%2010.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/product-attribute/issues/new?body=module:%20product_abc_classification_base%0Aversion:%2016.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 All @@ -82,6 +82,7 @@ Contributors
* Miquel Raïch <miquel.raich@eficent.com>
* Lindsay Marion <lindsay.marion@acsone.eu>
* Laurent Mignon <laurent.mignon@acsone.eu>
* Denis Roussel <denis.roussel@acsone.eu>

Maintainers
~~~~~~~~~~~
Expand All @@ -96,6 +97,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/product-attribute <https://github.com/OCA/product-attribute/tree/10.0/product_abc_classification_base>`_ project on GitHub.
This module is part of the `OCA/product-attribute <https://github.com/OCA/product-attribute/tree/16.0/product_abc_classification_base>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 2 additions & 2 deletions product_abc_classification_base/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
"name": "Product Abc Classification",
"summary": """
ABC classification for sales and warehouse management""",
"version": "10.0.1.0.0",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV, ForgeFlow, Odoo Community Association (OCA)",
"depends": ["product", "stock", "web_m2x_options"],
"website": "https://github.com/OCA/product-attribute",
"data": [
"views/abc_classification_product_level.xml",
"views/abc_classification_profile.xml",
Expand All @@ -18,5 +19,4 @@
"security/ir.model.access.csv",
"data/ir_cron.xml",
],
"demo": [],
}
6 changes: 3 additions & 3 deletions product_abc_classification_base/data/ir_cron.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<field name="interval_type">months</field>
<field name="numbercall">-1</field>
<field name="doall" eval="False" />
<field name="model">abc.classification.profile</field>
<field name="function">_cron_compute_abc_classification</field>
<field name="args">()</field>
<field name="model_id" ref="model_abc_classification_profile" />
<field name="code">model._cron_compute_abc_classification()</field>
<field name="state">code</field>
</record>
</odoo>
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
class AbcClassificationLevel(models.Model):

_name = "abc.classification.level"
_description = "ABC Classification Level"
_order = "percentage desc, id desc"
_rec_name = "name"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class AbcClassificationProductLevel(models.Model):
manual_level_id = fields.Many2one(
"abc.classification.level",
string="Manual classification level",
track_visibility="onchange",
tracking=True,
domain="[('profile_id', '=', profile_id)]",
)
computed_level_id = fields.Many2one(
Expand Down Expand Up @@ -129,18 +129,21 @@ def _compute_flag(self):
rec.computed_level_id and rec.manual_level_id != rec.computed_level_id
)

@api.model
def create(self, vals):
if "manual_level_id" not in vals and "computed_level_id" in vals:
# at creation the manual level is set to the same value as the
# computed one
vals["manual_level_id"] = vals["computed_level_id"]

if "profile_id" in vals:
profile = self.env["abc.classification.profile"].browse(vals["profile_id"])
if profile.auto_apply_computed_value and "computed_level_id" in vals:
@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:
if "manual_level_id" not in vals and "computed_level_id" in vals:
# at creation the manual level is set to the same value as the
# computed one
vals["manual_level_id"] = vals["computed_level_id"]
return super(AbcClassificationProductLevel, self).create(vals)

if "profile_id" in vals:
profile = self.env["abc.classification.profile"].browse(
vals["profile_id"]
)
if profile.auto_apply_computed_value and "computed_level_id" in vals:
vals["manual_level_id"] = vals["computed_level_id"]
return super().create(vals_list)

def write(self, vals):
values = vals.copy()
Expand All @@ -153,4 +156,4 @@ def write(self, vals):

if profile.auto_apply_computed_value and "computed_level_id" in values:
values["manual_level_id"] = values["computed_level_id"]
return super(AbcClassificationProductLevel, self).write(values)
return super().write(values)
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def _check_levels(self):
)
)

@api.multi
def _compute_abc_classification(self):
raise NotImplementedError()

Expand Down Expand Up @@ -94,4 +93,4 @@ def _auto_apply_computed_value_for_product_levels(self):
modified_levels = self.env["abc.classification.product.level"].browse(level_ids)
# mark field as modified and trigger recompute of dependent fields.
modified_levels.modified(["manual_level_id"])
modified_levels.recompute()
modified_levels._recompute_recordset()
1 change: 1 addition & 0 deletions product_abc_classification_base/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
* Miquel Raïch <miquel.raich@eficent.com>
* Lindsay Marion <lindsay.marion@acsone.eu>
* Laurent Mignon <laurent.mignon@acsone.eu>
* Denis Roussel <denis.roussel@acsone.eu>
15 changes: 8 additions & 7 deletions product_abc_classification_base/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<title>Alc Product Abc Classification</title>
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>Product Abc Classification</title>
<style type="text/css">

/*
Expand Down Expand Up @@ -360,14 +360,14 @@
</style>
</head>
<body>
<div class="document" id="alc-product-abc-classification">
<h1 class="title">Alc Product Abc Classification</h1>
<div class="document" id="product-abc-classification">
<h1 class="title">Product Abc Classification</h1>

<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/product-attribute/tree/10.0/product_abc_classification_base"><img alt="OCA/product-attribute" src="https://img.shields.io/badge/github-OCA%2Fproduct--attribute-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/product-attribute-10-0/product-attribute-10-0-product_abc_classification_base"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/135/10.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/product-attribute/tree/16.0/product_abc_classification_base"><img alt="OCA/product-attribute" src="https://img.shields.io/badge/github-OCA%2Fproduct--attribute-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/product-attribute-16-0/product-attribute-16-0-product_abc_classification_base"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/135/16.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This modules provides the bases to build ABC analysis (or ABC classification)
addons. These classification are used by inventory management teams to help
identify the most important products in their portfolio and ensure they
Expand Down Expand Up @@ -406,7 +406,7 @@ <h1><a class="toc-backref" href="#id2">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/product-attribute/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/product-attribute/issues/new?body=module:%20product_abc_classification_base%0Aversion:%2010.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/product-attribute/issues/new?body=module:%20product_abc_classification_base%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand All @@ -424,6 +424,7 @@ <h2><a class="toc-backref" href="#id5">Contributors</a></h2>
<li>Miquel Raïch &lt;<a class="reference external" href="mailto:miquel.raich&#64;eficent.com">miquel.raich&#64;eficent.com</a>&gt;</li>
<li>Lindsay Marion &lt;<a class="reference external" href="mailto:lindsay.marion&#64;acsone.eu">lindsay.marion&#64;acsone.eu</a>&gt;</li>
<li>Laurent Mignon &lt;<a class="reference external" href="mailto:laurent.mignon&#64;acsone.eu">laurent.mignon&#64;acsone.eu</a>&gt;</li>
<li>Denis Roussel &lt;<a class="reference external" href="mailto:denis.roussel&#64;acsone.eu">denis.roussel&#64;acsone.eu</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand All @@ -433,7 +434,7 @@ <h2><a class="toc-backref" href="#id6">Maintainers</a></h2>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/product-attribute/tree/10.0/product_abc_classification_base">OCA/product-attribute</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/product-attribute/tree/16.0/product_abc_classification_base">OCA/product-attribute</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
15 changes: 8 additions & 7 deletions product_abc_classification_base/tests/common.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Copyright 2021 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

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


class ABCClassificationCase(SavepointCase):
class ABCClassificationCase(TransactionCase):
@classmethod
def setUpClass(cls):
super(ABCClassificationCase, cls).setUpClass()
super().setUpClass()
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True))
# add a fake profile_type
cls.ABCClassificationProfile = cls.env["abc.classification.profile"]
cls.ABCClassificationProfile._fields["profile_type"].selection = [
Expand All @@ -21,7 +22,7 @@ def setUpClass(cls):
class ABCClassificationLevelCase(ABCClassificationCase):
@classmethod
def setUpClass(cls):
super(ABCClassificationLevelCase, cls).setUpClass()
super().setUpClass()
cls.classification_profile.write(
{
"level_ids": [
Expand Down Expand Up @@ -85,13 +86,13 @@ def setUpClass(cls):
cls.size_attr = cls.env["product.attribute"].create(
{
"name": "Size",
"create_variant": False,
"create_variant": "no_variant",
"value_ids": [(0, 0, {"name": "S"}), (0, 0, {"name": "M"})],
}
)
cls.size_attr_value_s = cls.size_attr.value_ids[0]
cls.size_attr_value_m = cls.size_attr.value_ids[1]
cls.uom_unit = cls.env.ref("product.product_uom_unit")
cls.uom_unit = cls.env.ref("uom.product_uom_unit")
cls.product_template = cls.env["product.template"].create(
{
"name": "Test sized",
Expand All @@ -117,6 +118,6 @@ def _create_variant(cls, size_value):
return cls.env["product.product"].create(
{
"product_tmpl_id": cls.product_template.id,
"attribute_value_ids": [(6, 0, size_value.ids)],
"product_template_attribute_value_ids": [(6, 0, size_value.ids)],
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class TestABCClassificationProductLevel(ABCClassificationLevelCase):
@classmethod
def setUpClass(cls):
super(TestABCClassificationProductLevel, cls).setUpClass()
super().setUpClass()
cls.product_1 = cls.env["product.product"].create(
{
"name": "Test 1",
Expand Down
2 changes: 1 addition & 1 deletion product_abc_classification_base/tests/test_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class TestProduct(ABCClassificationLevelCase):
@classmethod
def setUpClass(cls):
super(TestProduct, cls).setUpClass()
super().setUpClass()

def test_00(self):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<field name="allowed_profile_ids" invisible="1" />
<field
name="profile_id"
domain="[('id', 'in', allowed_profile_ids and allowed_profile_ids[0] and allowed_profile_ids[0][2] or False))]"
domain="[('id', 'in', allowed_profile_ids and allowed_profile_ids[0] and allowed_profile_ids[0][2] or False)]"
/>
<field name="product_id" />
<field name="product_tmpl_id" invisible="1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
>abc.classification.profile.tree (in product_abc_classification_base)</field>
<field name="model">abc.classification.profile</field>
<field name="arch" type="xml">
<tree string="ABC Profiles">
<tree>
<field name="name" />
</tree>
</field>
Expand Down
1 change: 0 additions & 1 deletion setup/product_abc_classification_base/odoo/__init__.py

This file was deleted.

This file was deleted.

0 comments on commit 482ce30

Please sign in to comment.