Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions base_tier_validation_multi/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
==========================
Base Tier Validation Multi
==========================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:e3abddd269846c54665f60abd07b92c8f56d7f279ffbe6c0f068670781d68699
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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-ecosoft--odoo%2Fecosoft--addons-lightgray.png?logo=github
:target: https://github.com/ecosoft-odoo/ecosoft-addons/tree/18.0/base_tier_validation_multi
:alt: ecosoft-odoo/ecosoft-addons

|badge1| |badge2| |badge3|

This module add Multi Validation for tier definition in Odoo

**Table of contents**

.. contents::
:local:

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

Bugs are tracked on `GitHub Issues <https://github.com/ecosoft-odoo/ecosoft-addons/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/ecosoft-odoo/ecosoft-addons/issues/new?body=module:%20base_tier_validation_multi%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.

Credits
=======

Authors
-------

* Ecosoft

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

- Saran Lim. <saranl@ecosoft.co.th>

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

.. |maintainer-Saran440| image:: https://github.com/Saran440.png?size=40px
:target: https://github.com/Saran440
:alt: Saran440

Current maintainer:

|maintainer-Saran440|

This module is part of the `ecosoft-odoo/ecosoft-addons <https://github.com/ecosoft-odoo/ecosoft-addons/tree/18.0/base_tier_validation_multi>`_ project on GitHub.

You are welcome to contribute.
4 changes: 4 additions & 0 deletions base_tier_validation_multi/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).

from . import models
from . import wizard
21 changes: 21 additions & 0 deletions base_tier_validation_multi/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2026 Ecosoft Co., Ltd. (http://ecosoft.co.th)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
"name": "Base Tier Validation Multi",
"summary": "Approve/Reject multiple records at once via tier validation",
"version": "18.0.1.0.0",
"category": "Tools",
"author": "Ecosoft",
"website": "https://github.com/ecosoft-odoo/ecosoft-addons",
"license": "AGPL-3",
"depends": [
"base_tier_validation",
],
"data": [
"security/ir.model.access.csv",
"wizard/tier_validation_multi_wizard_view.xml",
"views/tier_definition_views.xml",
],
"maintainers": ["Saran440"],
}
5 changes: 5 additions & 0 deletions base_tier_validation_multi/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import tier_definition
from . import tier_multi_validation_binding
from . import tier_validation
94 changes: 94 additions & 0 deletions base_tier_validation_multi/models/tier_definition.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Copyright 2026 Ecosoft Co., Ltd. (http://ecosoft.co.th)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import api, fields, models


class TierDefinition(models.Model):
_inherit = "tier.definition"

allow_multi_validate = fields.Boolean(
string="Allow Multi Validation",
help="When enabled, automatically adds Validate/Reject Selected actions "
"to this model's list view.",
)

@api.model_create_multi
def create(self, vals_list):
records = super().create(vals_list)
models_to_sync = {v.get("model") for v in vals_list if v.get("model")}
for model_name in models_to_sync:
self._sync_multi_actions_for_model(model_name)
return records

def write(self, vals):
old_models = set(self.mapped("model")) if "model" in vals else set()
res = super().write(vals)
if "allow_multi_validate" in vals or "model" in vals:
new_models = set(self.mapped("model"))
for model_name in old_models | new_models:
self._sync_multi_actions_for_model(model_name)
return res

def unlink(self):
models_to_sync = set(self.mapped("model"))
res = super().unlink()
for model_name in models_to_sync:
self._sync_multi_actions_for_model(model_name)
return res

@api.model
def _sync_multi_actions_for_model(self, model_name):
if not model_name:
return
has_multi = bool(
self.search(
[("model", "=", model_name), ("allow_multi_validate", "=", True)],
limit=1,
)
)
binding = self.env["tier.multi.validation.binding"].search(
[("model_name", "=", model_name)], limit=1
)
if has_multi and not binding:
self._create_multi_binding(model_name)
elif not has_multi and binding:
binding.unlink()

@api.model
def _create_multi_binding(self, model_name):
ir_model = self.env["ir.model"].search([("model", "=", model_name)], limit=1)
if not ir_model:
return

def _make_action(name, code):
return (
self.env["ir.actions.server"]
.sudo()
.create(
{
"name": name,
"model_id": ir_model.id,
"binding_model_id": ir_model.id,
"binding_view_types": "list",
"state": "code",
"code": code,
}
)
)

request_action = _make_action(
"Request Validation",
"action = records.action_multi_request_validation()",
)
review_action = _make_action(
"Review Selected",
"action = records.action_multi_review()",
)
self.env["tier.multi.validation.binding"].create(
{
"model_name": model_name,
"request_action_id": request_action.id,
"review_action_id": review_action.id,
}
)
25 changes: 25 additions & 0 deletions base_tier_validation_multi/models/tier_multi_validation_binding.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2026 Ecosoft Co., Ltd. (http://ecosoft.co.th)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import fields, models


class TierMultiValidationBinding(models.Model):
_name = "tier.multi.validation.binding"
_description = "Tracks auto-created multi-validation server actions per model"

model_name = fields.Char(required=True, index=True)
request_action_id = fields.Many2one(
comodel_name="ir.actions.server",
ondelete="set null",
)
review_action_id = fields.Many2one(
comodel_name="ir.actions.server",
ondelete="set null",
)

def unlink(self):
actions = self.mapped("request_action_id") | self.mapped("review_action_id")
res = super().unlink()
actions.sudo().unlink()
return res
32 changes: 32 additions & 0 deletions base_tier_validation_multi/models/tier_validation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2026 Ecosoft Co., Ltd. (http://ecosoft.co.th)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import models


class TierValidation(models.AbstractModel):
_inherit = "tier.validation"

def action_multi_request_validation(self):
return self._open_multi_tier_wizard("request")

def action_multi_review(self):
return self._open_multi_tier_wizard("review")

def _open_multi_tier_wizard(self, validate_reject):
names = {
"request": self.env._("Request Validation Multiple"),
"review": self.env._("Review Multiple"),
}
return {
"name": names[validate_reject],
"type": "ir.actions.act_window",
"view_mode": "form",
"res_model": "tier.validation.multi.wizard",
"target": "new",
"context": {
"default_res_model": self._name,
"default_res_ids": str(self.ids),
"default_validate_reject": validate_reject,
},
}
3 changes: 3 additions & 0 deletions base_tier_validation_multi/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
1 change: 1 addition & 0 deletions base_tier_validation_multi/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Saran Lim. \<<saranl@ecosoft.co.th>\>
1 change: 1 addition & 0 deletions base_tier_validation_multi/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module add Multi Validation for tier definition in Odoo
3 changes: 3 additions & 0 deletions base_tier_validation_multi/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_tier_validation_multi_wizard,access.tier.validation.multi.wizard,model_tier_validation_multi_wizard,base.group_user,1,1,1,1
access_tier_multi_validation_binding,access.tier.multi.validation.binding,model_tier_multi_validation_binding,base.group_erp_manager,1,1,1,1
Loading
Loading