Skip to content
Draft
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
119 changes: 119 additions & 0 deletions account_move_tier_validation_approver_group/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

===========================================
Account Move Tier Validation Approver Group
===========================================

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

.. |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/license-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%2Ftier--validation-lightgray.png?logo=github
:target: https://github.com/OCA/tier-validation/tree/20.0/account_move_tier_validation_approver_group
:alt: OCA/tier-validation
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/tier-validation-20-0/tier-validation-20-0-account_move_tier_validation_approver_group
: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/tier-validation&target_branch=20.0
:alt: Try me on Runboat

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

This module extends *Account Move Tier Validation Approver* so that a
group of users, and not only a single user, can be responsible for
approving a vendor bill.

You can set a default *Approver of Vendor Bills group* on the vendor.
New vendor bills take this group as *Group responsible for approval*.

**Table of contents**

.. contents::
:local:

Configuration
=============

1. Go to *Invoicing > Configuration > Settings*.
2. In the *Vendor Bills* section, enable *Require Approver Group In
Vendor Bills*. This creates (or activates) the tier definition
"Validation with Approver field (group)". This tier only applies to
bills that have a *Group responsible for approval*.
3. On the vendor, in the *Sales & Purchase* tab, set the *Approver of
Vendor Bills group*.

If you also enable *Require Approver In Vendor Bills* (the individual
approver), a bill can be posted when it has a user OR a group
responsible for approval. In this case, add a domain to the individual
tier definition ("Validation with Approver field") so that it only
applies when no group is set, for example
``[('move_type', '=', 'in_invoice'), ('approver_group_id', '=', False)]``.

Usage
=====

1. Create a vendor bill for a vendor with an *Approver of Vendor Bills
group*. The *Group responsible for approval* is filled in. You can
change it if needed.
2. Click on *Request Validation*. Any member of the group can approve
the bill.
3. Once approved, post the bill.

Known issues / Roadmap
======================

- Add the individual approver tier domain automatically when both
options are enabled.

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

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

* 360 ERP

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

- Kevin Khao kevinkhao@gmail.com (https://www.360erp.com)

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/tier-validation <https://github.com/OCA/tier-validation/tree/20.0/account_move_tier_validation_approver_group>`_ 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 account_move_tier_validation_approver_group/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .hooks import pre_init_hook
from . import models
21 changes: 21 additions & 0 deletions account_move_tier_validation_approver_group/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2025 360ERP
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Account Move Tier Validation Approver Group",
"summary": "Allow a group of users to be responsible for approving vendor bills",
"version": "20.0.1.0.0",
"category": "Accounting",
"license": "AGPL-3",
"author": "360 ERP,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/tier-validation",
"depends": [
"account_move_tier_validation_approver",
],
"data": [
"views/account_move.xml",
"views/res_partner.xml",
"views/res_config_settings_views.xml",
],
"pre_init_hook": "pre_init_hook",
}
11 changes: 11 additions & 0 deletions account_move_tier_validation_approver_group/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from odoo.tools import sql


def pre_init_hook(env):
"""Prepare new account.move.approver_group_id computed field.

Add column to avoid MemoryError on an existing Odoo instance
with lots of data.
"""
if not sql.column_exists(env.cr, "account_move", "approver_group_id"):
sql.create_column(env.cr, "account_move", "approver_group_id", "int4")
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from . import account_move
from . import res_partner
from . import res_company
from . import res_config_settings
55 changes: 55 additions & 0 deletions account_move_tier_validation_approver_group/models/account_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Copyright 2025 360 ERP
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields, models
from odoo.exceptions import UserError


class AccountMove(models.Model):
_inherit = "account.move"

approver_group_id = fields.Many2one(
"res.groups",
string="Group responsible for approval",
compute="_compute_approver_group_id",
readonly=False,
store=True,
)

@api.depends("partner_id")
def _compute_approver_group_id(self):
for rec in self:
if rec.approver_group_id:
# assign a value in any case
rec.approver_group_id = rec.approver_group_id
elif rec.partner_id.approver_group_id:
rec.approver_group_id = rec.partner_id.approver_group_id
else:
rec.approver_group_id = False

def _check_has_approver(self):
"""Take the approver group into account.

When an approver (user) or an approver group is required, a vendor
bill can be posted if it has a user OR a group responsible for
the approval.
"""
self.ensure_one()
company = self.company_id
approver_required = (
company.require_approver_in_vendor_bills
or company.require_approver_group_in_vendor_bills
)
if (
self.is_purchase_document(include_receipts=True)
and approver_required
and not self.approver_id
and not self.approver_group_id
):
raise UserError(
self.env._(
"It is mandatory to indicate a Responsible for Approval "
"(user or group) (in %s)",
self.name,
)
)
15 changes: 15 additions & 0 deletions account_move_tier_validation_approver_group/models/res_company.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2020 ForgeFlow, S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import fields, models


class ResCompany(models.Model):
_inherit = "res.company"

require_approver_group_in_vendor_bills = fields.Boolean(
string="Require approver in vendor bills (group)"
)
validation_approver_group_tier_definition_id = fields.Many2one(
comodel_name="tier.definition", string="Bill approval tier definition (group)"
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright 2020 ForgeFlow, S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import fields, models


class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"

require_approver_group_in_vendor_bills = fields.Boolean(
string="Require Approver Group In Vendor Bills",
help="Requires adding an approver group before a vendor bill can be posted. "
"Note: If you combine both rules, be sure to configure the appropriate domains "
"on the tier definitions",
related="company_id.require_approver_group_in_vendor_bills",
readonly=False,
)

def set_values(self):
company = self.company_id
tier_definition = company.validation_approver_group_tier_definition_id
if not tier_definition:
field = self.env["ir.model.fields"]._get(
"account.move", "approver_group_id"
)
tier_definition = self.env["tier.definition"].create(
self._prepare_tier_approver_group_definition_values(field)
)
company.validation_approver_group_tier_definition_id = tier_definition
if self.require_approver_group_in_vendor_bills:
tier_definition.action_unarchive()
else:
tier_definition.action_archive()
return super().set_values()

def _prepare_tier_approver_group_definition_values(self, field):
return {
"model_id": self.env["ir.model"]._get_id("account.move"),
"review_type": "field",
"name": "Validation with Approver field (group)",
"reviewer_field_id": field.id,
"definition_domain": (
"[('move_type', '=', 'in_invoice'), ('approver_group_id', '!=', False)]"
),
"approve_sequence": True,
"active": self.require_approver_group_in_vendor_bills,
}
12 changes: 12 additions & 0 deletions account_move_tier_validation_approver_group/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2025 360 ERP
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ResPartner(models.Model):
_inherit = "res.partner"

approver_group_id = fields.Many2one(
"res.groups", string="Approver of Vendor Bills group"
)
3 changes: 3 additions & 0 deletions account_move_tier_validation_approver_group/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
14 changes: 14 additions & 0 deletions account_move_tier_validation_approver_group/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
1. Go to *Invoicing \> Configuration \> Settings*.
2. In the *Vendor Bills* section, enable *Require Approver Group In
Vendor Bills*. This creates (or activates) the tier definition
"Validation with Approver field (group)". This tier only applies to
bills that have a *Group responsible for approval*.
3. On the vendor, in the *Sales & Purchase* tab, set the *Approver of
Vendor Bills group*.

If you also enable *Require Approver In Vendor Bills* (the individual
approver), a bill can be posted when it has a user OR a group
responsible for approval. In this case, add a domain to the individual
tier definition ("Validation with Approver field") so that it only
applies when no group is set, for example
`[('move_type', '=', 'in_invoice'), ('approver_group_id', '=', False)]`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Kevin Khao <kevinkhao@gmail.com> (https://www.360erp.com)

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
This module extends *Account Move Tier Validation Approver* so that a
group of users, and not only a single user, can be responsible for
approving a vendor bill.

You can set a default *Approver of Vendor Bills group* on the vendor.
New vendor bills take this group as *Group responsible for approval*.
2 changes: 2 additions & 0 deletions account_move_tier_validation_approver_group/readme/ROADMAP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Add the individual approver tier domain automatically when both
options are enabled.
6 changes: 6 additions & 0 deletions account_move_tier_validation_approver_group/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
1. Create a vendor bill for a vendor with an *Approver of Vendor Bills
group*. The *Group responsible for approval* is filled in. You can
change it if needed.
2. Click on *Request Validation*. Any member of the group can approve
the bill.
3. Once approved, post the bill.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading