Skip to content

Commit

Permalink
[MIG] lighting_review: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
KNVx authored and eantones committed Mar 27, 2024
1 parent 3ae70b7 commit c9a5929
Show file tree
Hide file tree
Showing 21 changed files with 606 additions and 440 deletions.
15 changes: 2 additions & 13 deletions lighting_review/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,7 @@ Lighting Review

|badge1| |badge2| |badge3|

The "connector_extension" module is an add-on for the Odoo ERP system that enhances the functionality of the base "connector" module. This extension provides additional features, tools, and integrations, making it easier for developers to create, manage, and maintain connections between Odoo and various third-party systems, APIs, or services.

The module aims to simplify the connector development process by providing a robust and flexible framework. The "connector_extension" module allows developers to focus on implementing specific business logic and requirements, while the extension handles common tasks.


* Extended connector framework: The module extends the base connector framework by providing new classes, methods, and utilities for easier integration with third-party systems.
* Reusable components: Pre-built components for handling common tasks such error handling, and data synchronization.
* Enhanced data mapping: Advanced data mapping capabilities to transform and adapt data between Odoo and external systems seamlessly.
* Scalability and performance improvements: Optimized for handling large datasets and concurrent connections, ensuring smooth and efficient data synchronization.
* Linking with existing records: Enables linking with existing records, using alternate keys, which allows for easier data management and reduced redundancy.
Tools for reviewing data

**Table of contents**

Expand All @@ -54,9 +45,7 @@ Credits
Authors
~~~~~~~

* NuoBiT Solutions
* S.L.
* Eric Antones
* NuoBiT Solutions SL

Contributors
~~~~~~~~~~~~
Expand Down
4 changes: 0 additions & 4 deletions lighting_review/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
# Copyright NuoBiT Solutions, S.L. (<https://www.nuobit.com>)
# Eric Antones <eantones@nuobit.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from . import models
13 changes: 5 additions & 8 deletions lighting_review/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
# Copyright NuoBiT Solutions, S.L. (<https://www.nuobit.com>)
# Eric Antones <eantones@nuobit.com>
# Copyright NuoBiT Solutions - Eric Antones <eantones@nuobit.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

{
"name": "Lighting Review",
"description": "Tools for reviewing data",
"version": "11.0.1.1.1",
"author": "NuoBiT Solutions, S.L., Eric Antones",
"version": "16.0.1.0.0",
"author": "NuoBiT Solutions SL",
"license": "AGPL-3",
"category": "Custom",
"category": "Lighting",
"website": "https://github.com/NuoBiT/lighting-vertical",
"depends": ["mail", "lighting"],
"data": [
"security/review_security.xml",
"security/ir.model.access.csv",
"views/review_menuitems.xml",
"views/review_package_views.xml",
"views/product_views.xml",
"views/product_source_line_views.xml",
"views/product_review_views.xml",
"views/review_menuitems.xml",
],
"installable": True,
}
568 changes: 402 additions & 166 deletions lighting_review/i18n/es.po

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions lighting_review/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# Copyright NuoBiT Solutions, S.L. (<https://www.nuobit.com>)
# Eric Antones <eantones@nuobit.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from . import res_users
from . import product_review
from . import review_package
Expand Down
31 changes: 14 additions & 17 deletions lighting_review/models/lighting_product.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
# Copyright NuoBiT Solutions, S.L. (<https://www.nuobit.com>)
# Eric Antones <eantones@nuobit.com>
# Copyright NuoBiT Solutions - Eric Antones <eantones@nuobit.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from odoo import api, fields, models

from . import mixin


class LightingProduct(models.Model, mixin.LightingReviewMixin):
_inherit = "lighting.product"
# class LightingProduct(models.Model, mixin.LightingReviewMixin):
class LightingProduct(models.Model):
_name = "lighting.product"
_inherit = ["lighting.product", "lighting.review.mixin"]
# _inherit = "lighting.product"

# TODO find this data autoamtically
_toreview_related_models = ["source_ids.line_ids"]

# review fields
review_ids = fields.One2many(
comodel_name="lighting.product.review",
inverse_name="product_id",
string="Reviews",
)

# to review layout
def show_fields_toreview(self):
# TODO show wizard with only the fields to review and
# be able to edit from there
pass

# to review count
def _get_toreview_count_fields(self):
return ["toreview_count"] + [
"%s.toreview_count" % x for x in self._toreview_related_models
Expand All @@ -40,34 +39,32 @@ def _compute_toreview_fields_count(self):
)

toreview_fields_count = fields.Integer(
string="To review", compute="_compute_toreview_fields_count", store=True
string="To review",
compute="_compute_toreview_fields_count",
store=True,
)

# to review fields
toreview_lifetime = fields.Boolean(
string=mixin.get_string("Lifetime (h)"),
help=mixin.TOREVIEW_HELP,
track_visibility="onchange",
tracking=True,
)

toreview_led_lifetime_l = fields.Boolean(
string=mixin.get_string("LED lifetime L"),
help=mixin.TOREVIEW_HELP,
track_visibility="onchange",
tracking=True,
)

toreview_led_lifetime_b = fields.Boolean(
string=mixin.get_string("LED lifetime B"),
help=mixin.TOREVIEW_HELP,
track_visibility="onchange",
tracking=True,
)
toreview_dimmable_ids = fields.Boolean(
string=mixin.get_string("Dimmables"),
help=mixin.TOREVIEW_HELP,
track_visibility="onchange",
tracking=True,
)
toreview_input_voltage_id = fields.Boolean(
string=mixin.get_string("Input voltage"),
help=mixin.TOREVIEW_HELP,
track_visibility="onchange",
tracking=True,
)
14 changes: 6 additions & 8 deletions lighting_review/models/lighting_source_line.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
# Copyright NuoBiT Solutions, S.L. (<https://www.nuobit.com>)
# Eric Antones <eantones@nuobit.com>
# Copyright NuoBiT Solutions - Eric Antones <eantones@nuobit.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from odoo import fields, models

from . import mixin


class LightingProductSourceLine(models.Model, mixin.LightingReviewMixin):
_inherit = "lighting.product.source.line"
class LightingProductSourceLine(models.Model):
_name = "lighting.product.source.line"
_inherit = ["lighting.product.source.line", "lighting.review.mixin"]

# to review fields
toreview_cri_min = fields.Boolean(
string=mixin.get_string("CRI"),
help=mixin.TOREVIEW_HELP,
track_visibility="onchange",
tracking=True,
)

toreview_color_consistency = fields.Boolean(
string=mixin.get_string("Color consistency (SDCM)"),
help=mixin.TOREVIEW_HELP,
track_visibility="onchange",
tracking=True,
)
30 changes: 17 additions & 13 deletions lighting_review/models/mixin.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Copyright NuoBiT Solutions, S.L. (<https://www.nuobit.com>)
# Eric Antones <eantones@nuobit.com>
# Copyright NuoBiT Solutions - Eric Antones <eantones@nuobit.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

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

TOREVIEW_STRING = _("%s (to review)")
TOREVIEW_HELP = _("Enabled if the field value has not been validated yet")
Expand All @@ -12,22 +11,23 @@ def get_string(field_name):
return TOREVIEW_STRING % _(field_name)


# I have to use Python inheritance, surprisingly it does not work with Odoo inheritance
class LightingReviewMixin:
# to review layout
class LightingReviewMixin(models.Model):
_name = "lighting.review.mixin"
review_mode = fields.Boolean(
compute="_compute_review_mode",
default=False,
store=False,
readonly=False,
)

def _compute_review_mode(self):
for rec in self:
rec.review_mode = self.env.user.review_mode

review_mode = fields.Boolean(
string="Review mode", compute="_compute_review_mode", default=False, store=False
)

def toggle_review_mode(self):
self.ensure_one()
self.env.user.review_mode = not self.env.user.review_mode

# to review count
@api.model
def _get_toreview_fields(self):
return {
Expand All @@ -38,10 +38,14 @@ def _get_toreview_fields(self):
)
}

toreview_count = fields.Integer(
compute="_compute_toreview_count",
store=True,
)

@api.depends(_get_toreview_fields)
def _compute_toreview_count(self):
for rec in self:
# TODO: REVIEW: Modify this getattr?
rec_vals = [getattr(rec, x) for x in rec._get_toreview_fields()]
rec.toreview_count = len(list(filter(lambda x: x, rec_vals)))

toreview_count = fields.Integer(compute="_compute_toreview_count", store=True)
50 changes: 25 additions & 25 deletions lighting_review/models/product_review.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,41 @@
# Copyright NuoBiT Solutions, S.L. (<https://www.nuobit.com>)
# Eric Antones <eantones@nuobit.com>
# Copyright NuoBiT Solutions - Eric Antones <eantones@nuobit.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from odoo import api, fields, models


class LightingProductReview(models.Model):
_name = "lighting.product.review"

_inherit = ["mail.thread", "mail.activity.mixin"]

_order = "package_id,product_id"

package_id = fields.Many2one(
comodel_name="lighting.review.package",
ondelete="restrict",
required=True,
track_visibility="onchange",
tracking=True,
)
reviewed = fields.Boolean(
tracking=True,
)
date = fields.Datetime(readonly=True, tracking=True, compute="_compute_date")

reviewed = fields.Boolean(string="Reviewed", track_visibility="onchange")

date = fields.Datetime(string="Date", readonly=True, track_visibility="onchange")

comment = fields.Text(string="Comment", track_visibility="onchange")
@api.depends("reviewed")
def _compute_date(self):
for rec in self:
if not rec.reviewed:
rec.date = False
else:
rec.date = fields.Datetime.now()

comment = fields.Text(
tracking=True,
)
product_id = fields.Many2one(
comodel_name="lighting.product",
ondelete="cascade",
required=True,
track_visibility="onchange",
tracking=True,
)

_sql_constraints = [
Expand All @@ -40,17 +46,11 @@ class LightingProductReview(models.Model):
),
]

@api.onchange("reviewed")
def onchange_reviewed(self):
if not self.reviewed:
self.date = False

@api.multi
def write(self, values):
if "reviewed" in values:
if values["reviewed"]:
values.update({"date": fields.Datetime.now()})
else:
values.update({"date": None})
res = super().write(values)
return res
# def write(self, values):
# if "reviewed" in values:
# if values["reviewed"]:
# values.update({"date": fields.Datetime.now()})
# else:
# values.update({"date": None})
# res = super().write(values)
# return res
6 changes: 3 additions & 3 deletions lighting_review/models/res_users.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Copyright NuoBiT Solutions, S.L. (<https://www.nuobit.com>)
# Eric Antones <eantones@nuobit.com>
# Copyright NuoBiT Solutions - Eric Antones <eantones@nuobit.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

from odoo import fields, models
Expand All @@ -9,5 +8,6 @@ class Users(models.Model):
_inherit = "res.users"

review_mode = fields.Boolean(
string="Review mode", help="Enable or disable review mode", default=False
help="Enable or disable review mode",
default=False,
)
Loading

0 comments on commit c9a5929

Please sign in to comment.