Skip to content

Commit

Permalink
17.0 migraiton
Browse files Browse the repository at this point in the history
  • Loading branch information
onurugur committed Jun 14, 2024
1 parent f216c3a commit 5c0c42c
Show file tree
Hide file tree
Showing 114 changed files with 5,613 additions and 9 deletions.
5 changes: 3 additions & 2 deletions attribute_set/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from . import models, utils, wizard
from . import tests
from . import models
from . import utils
from . import wizard
12 changes: 5 additions & 7 deletions attribute_set/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from . import (
attribute_attribute,
attribute_group,
attribute_option,
attribute_set,
attribute_set_owner,
)
from . import attribute_attribute
from . import attribute_group
from . import attribute_option
from . import attribute_set
from . import attribute_set_owner
93 changes: 93 additions & 0 deletions attribute_set_completeness/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
==========================
Attribute Set Completeness
==========================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:4a8b97de55e91be44fb4f2dbe9496b9c76f1dddacd5a47e3bc39e11759782ab8
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fodoo--pim-lightgray.png?logo=github
:target: https://github.com/OCA/odoo-pim/tree/17.0/attribute_set_completeness
:alt: OCA/odoo-pim
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/odoo-pim-17-0/odoo-pim-17-0-attribute_set_completeness
: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/odoo-pim&target_branch=17.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows the user define a completion rate on the model linked
to an attribute set.

**Table of contents**

.. contents::
:local:

Usage
=====

Go on an attribute set and fill in the section 'Completeness'. Select
the fields you want to take in account and set them their proportion on
the completeness rate. Then on the model linked to the attribute set
you'll get 2 fields: completion rate and completion state

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/odoo-pim/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/odoo-pim/issues/new?body=module:%20attribute_set_completeness%0Aversion:%2017.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.

Credits
=======

Authors
-------

* ACSONE SA/NV

Contributors
------------

- Cédric PIGEON <[email protected]>

- Xavier Bouquiaux <[email protected]>

- `Camptocamp <https://www.camptocamp.com>`__

- Iván Todorovich <[email protected]>

- Dhara Solanki <[email protected]>

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

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

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/odoo-pim <https://github.com/OCA/odoo-pim/tree/17.0/attribute_set_completeness>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions attribute_set_completeness/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import components
from . import models
17 changes: 17 additions & 0 deletions attribute_set_completeness/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2020 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Attribute Set Completeness",
"version": "17.0.1.1.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/odoo-pim",
"depends": ["attribute_set", "component_event"],
"data": [
"views/attribute_set.xml",
"security/attribute_set_completeness.xml",
"views/attribute_set_completeness.xml",
],
"demo": [],
}
3 changes: 3 additions & 0 deletions attribute_set_completeness/components/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright 2020 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import attribute_set_owner_event_listener
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2020 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo.addons.component.core import AbstractComponent
from odoo.addons.component_event import skip_if


class AttributeSetOwnerEventListener(AbstractComponent):
_name = "attribute.set.owner.event.listener"
_inherit = "base.event.listener"

def _get_skip_if_condition_fields(self, record):
"""Return the field names that trigger the condition"""
attribute_set = record.attribute_set_id
attribute_set_completeness = attribute_set.attribute_set_completeness_ids
field_names = attribute_set_completeness.mapped("field_id.name")
field_names.append("attribute_set_id")
return field_names

def _get_skip_if_condition(self, record, **kwargs):
if not record.attribute_set_id:
return True
if set(self._get_skip_if_condition_fields(record)) & set(kwargs["fields"]):
return False
return True

@skip_if(
lambda self, record, **kwargs: self._get_skip_if_condition(record, **kwargs)
)
def on_record_write(self, record, fields=None):
record._compute_attribute_set_completed_ids()
168 changes: 168 additions & 0 deletions attribute_set_completeness/i18n/attribute_set_completeness.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * attribute_set_completeness
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: attribute_set_completeness
#: model:ir.model,name:attribute_set_completeness.model_attribute_set
#: model:ir.model.fields,field_description:attribute_set_completeness.field_attribute_set_completeness__attribute_set_id
msgid "Attribute Set"
msgstr ""

#. module: attribute_set_completeness
#: model:ir.model,name:attribute_set_completeness.model_attribute_set_completeness
msgid "Attribute Set Completeness"
msgstr ""

#. module: attribute_set_completeness
#: model:ir.model.fields,field_description:attribute_set_completeness.field_attribute_set_owner_mixin__attribute_set_completion_rate
msgid "Attribute Set Completion Rate"
msgstr ""

#. module: attribute_set_completeness
#: model:ir.model.fields,field_description:attribute_set_completeness.field_attribute_set_owner_mixin__attribute_set_completion_state
msgid "Attribute Set Completion State"
msgstr ""

#. module: attribute_set_completeness
#: model:ir.model.fields,field_description:attribute_set_completeness.field_attribute_set_owner_mixin__attribute_set_completed_ids
msgid "Attribute Set completed criterias"
msgstr ""

#. module: attribute_set_completeness
#: model:ir.model.fields,field_description:attribute_set_completeness.field_attribute_set_owner_mixin__attribute_set_not_completed_ids
msgid "Attribute Set not completed criterias"
msgstr ""

#. module: attribute_set_completeness
#: model:ir.model.fields,field_description:attribute_set_completeness.field_attribute_set_completeness__available_field_ids
msgid "Attribute Set's fields"
msgstr ""

#. module: attribute_set_completeness
#: model:ir.model.fields,help:attribute_set_completeness.field_attribute_set_owner_mixin__attribute_set_completion_rate
msgid "Attribute set completeness percentage"
msgstr ""

#. module: attribute_set_completeness
#: model:ir.model.fields,help:attribute_set_completeness.field_attribute_set_owner_mixin__attribute_set_completion_state
msgid "Attribute set completeness status"
msgstr ""

#. module: attribute_set_completeness
#: model:ir.model,name:attribute_set_completeness.model_attribute_set_owner_mixin
msgid "Attribute set owner mixin"
msgstr ""

#. module: attribute_set_completeness
#: model:ir.model.fields.selection,name:attribute_set_completeness.selection__attribute_set_owner_mixin__attribute_set_completion_state__complete
msgid "Complete"
msgstr ""

#. module: attribute_set_completeness
#: model_terms:ir.ui.view,arch_db:attribute_set_completeness.attribute_set_form_view
msgid "Completeness"
msgstr ""

#. module: attribute_set_completeness
#: model:ir.model.fields,field_description:attribute_set_completeness.field_attribute_set__attribute_set_completeness_ids
#: model:ir.model.fields,field_description:attribute_set_completeness.field_attribute_set_owner_mixin__attribute_set_completeness_ids
msgid "Completeness Requirements"
msgstr ""

#. module: attribute_set_completeness
#: model:ir.model.fields,field_description:attribute_set_completeness.field_attribute_set_completeness__completion_rate
msgid "Completion Rate"
msgstr ""

#. module: attribute_set_completeness
#: model:ir.model.fields,field_description:attribute_set_completeness.field_attribute_set_completeness__completion_rate_progress
msgid "Completion Rate Progress"
msgstr ""

#. module: attribute_set_completeness
#: model:ir.model.fields,field_description:attribute_set_completeness.field_attribute_set_completeness__create_uid
msgid "Created by"
msgstr ""

#. module: attribute_set_completeness
#: model:ir.model.fields,field_description:attribute_set_completeness.field_attribute_set_completeness__create_date
msgid "Created on"
msgstr ""

#. module: attribute_set_completeness
#: model:ir.model.fields,field_description:attribute_set_completeness.field_attribute_set__display_name
#: model:ir.model.fields,field_description:attribute_set_completeness.field_attribute_set_completeness__display_name
#: model:ir.model.fields,field_description:attribute_set_completeness.field_attribute_set_owner_mixin__display_name
msgid "Display Name"
msgstr ""

#. module: attribute_set_completeness
#: model:ir.model.fields,field_description:attribute_set_completeness.field_attribute_set_completeness__field_description
msgid "Field Description"
msgstr ""

#. module: attribute_set_completeness
#: model:ir.model.fields,field_description:attribute_set_completeness.field_attribute_set_completeness__field_id
msgid "Field Name"
msgstr ""

#. module: attribute_set_completeness
#: model:ir.model.fields,help:attribute_set_completeness.field_attribute_set_completeness__available_field_ids
msgid "Fields related to the Attribute set's attributes"
msgstr ""

#. module: attribute_set_completeness
#: model:ir.model.fields,field_description:attribute_set_completeness.field_attribute_set__id
#: model:ir.model.fields,field_description:attribute_set_completeness.field_attribute_set_completeness__id
#: model:ir.model.fields,field_description:attribute_set_completeness.field_attribute_set_owner_mixin__id
msgid "ID"
msgstr ""

#. module: attribute_set_completeness
#: model:ir.model.fields,field_description:attribute_set_completeness.field_attribute_set____last_update
#: model:ir.model.fields,field_description:attribute_set_completeness.field_attribute_set_completeness____last_update
#: model:ir.model.fields,field_description:attribute_set_completeness.field_attribute_set_owner_mixin____last_update
msgid "Last Modified on"
msgstr ""

#. module: attribute_set_completeness
#: model:ir.model.fields,field_description:attribute_set_completeness.field_attribute_set_completeness__write_uid
msgid "Last Updated by"
msgstr ""

#. module: attribute_set_completeness
#: model:ir.model.fields,field_description:attribute_set_completeness.field_attribute_set_completeness__write_date
msgid "Last Updated on"
msgstr ""

#. module: attribute_set_completeness
#: model:ir.model.fields,field_description:attribute_set_completeness.field_attribute_set_completeness__model_id
msgid "Model"
msgstr ""

#. module: attribute_set_completeness
#: model:ir.model.fields.selection,name:attribute_set_completeness.selection__attribute_set_owner_mixin__attribute_set_completion_state__not_complete
msgid "Not complete"
msgstr ""

#. module: attribute_set_completeness
#: model_terms:ir.ui.view,arch_db:attribute_set_completeness.attribute_set_completeness_tree_view
msgid "Total"
msgstr ""

#. module: attribute_set_completeness
#: code:addons/attribute_set_completeness/models/attribute_set.py:0
#, python-format
msgid "Total of completion rate must be 100 %"
msgstr ""
27 changes: 27 additions & 0 deletions attribute_set_completeness/migrations/14.0.1.0.1/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2022 Acsone SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

# when migrating to v14, 2 fields have been renamed
# completion_rate -> attribute_set_completion_rate
# completion_state -> attribute_set_completion_state
from openupgradelib import openupgrade

field_renames = [
(
"attribute.set.owner.mixin",
"attribute.set.owner.mixin",
"completion_rate",
"attribute_set_completion_rate",
),
(
"attribute.set.owner.mixin",
"attribute.set.owner.mixin",
"completion_state",
"attribute_set_completion_state",
),
]


@openupgrade.migrate()
def migrate(env, version):
openupgrade.rename_fields(env, field_renames)
3 changes: 3 additions & 0 deletions attribute_set_completeness/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import attribute_set_completeness
from . import attribute_set
from . import attribute_set_owner_mixin
25 changes: 25 additions & 0 deletions attribute_set_completeness/models/attribute_set.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2020 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

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


class AttributeSet(models.Model):
_inherit = "attribute.set"

attribute_set_completeness_ids = fields.One2many(
comodel_name="attribute.set.completeness",
inverse_name="attribute_set_id",
string="Completeness Requirements",
auto_join=True,
)

@api.constrains("attribute_set_completeness_ids")
def _check_attribute_set_completeness_ids(self):
for attr_set in self:
completion_config = attr_set.attribute_set_completeness_ids
if completion_config:
total = sum([rule.completion_rate for rule in completion_config])
if total != 100.0:
raise ValidationError(_("Total of completion rate must be 100 %"))
Loading

0 comments on commit 5c0c42c

Please sign in to comment.