diff --git a/account_move_tier_validation_approver/README.rst b/account_move_tier_validation_approver/README.rst new file mode 100644 index 00000000000..47a689ffdac --- /dev/null +++ b/account_move_tier_validation_approver/README.rst @@ -0,0 +1,112 @@ +===================================== +Account Move Tier Validation Approver +===================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:6417488b101536a3a97ee3b8daccdb426f184aedf9d884f364f29e6952a0278c + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Faccount--invoicing-lightgray.png?logo=github + :target: https://github.com/OCA/account-invoicing/tree/18.0/account_move_tier_validation_approver + :alt: OCA/account-invoicing +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/account-invoicing-18-0/account-invoicing-18-0-account_move_tier_validation_approver + :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/account-invoicing&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to select a Responsible for approval in the partner +form. If a tier definition is set and configured with the "Responsible +for Approval" field, the approver will be the one chosen in the partner +form. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +To configure this module, you need to: + +1. Go to *Settings > Technical > Tier Validations > Tier Definition*. +2. Create a new tier or edit an existing one. +3. Set the "Validated by" field to "Field in related record". +4. Set the "Reviewer field" to "Responsible for Approval". + +A default tier validation called "Validation with Approver field" is set +with this configuration. + +Usage +===== + +You can assign a default user for approval associated to a supplier. In +the partner form view, go to the *Sales and Purchase* tab, and into the +*Purchase* section, and fill the field *Approver of Vendor Bills*. + +When you create a vendor bill the field *Responsible for Approval* will +be filled in with the partner's default. You can change it if needed. + +Be aware that you won't be able to post a vendor bill unless you have +indicated a Responsible for Approval. + +Used in connection with the module *Account Move Tier Validation* you +can set up approvals specific to a department. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* ForgeFlow + +Contributors +------------ + +- Lois Rilo +- Adrià Gil Sorribes +- [360ERP](https://www.360erp.com): + + - Kevin Khao <> + +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/account-invoicing `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_move_tier_validation_approver/__init__.py b/account_move_tier_validation_approver/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/account_move_tier_validation_approver/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/account_move_tier_validation_approver/__manifest__.py b/account_move_tier_validation_approver/__manifest__.py new file mode 100644 index 00000000000..e89ba3b773f --- /dev/null +++ b/account_move_tier_validation_approver/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2021 ForgeFlow, S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +{ + "name": "Account Move Tier Validation Approver", + "version": "18.0.1.0.0", + "author": "ForgeFlow, Odoo Community Association (OCA)", + "category": "Accounting", + "license": "AGPL-3", + "depends": ["account_move_tier_validation"], + "website": "https://github.com/OCA/account-invoicing", + "data": [ + "views/account_move_views.xml", + "views/res_partner_views.xml", + "views/res_config_settings_views.xml", + ], + "installable": True, +} diff --git a/account_move_tier_validation_approver/i18n/account_move_tier_validation_approver.pot b/account_move_tier_validation_approver/i18n/account_move_tier_validation_approver.pot new file mode 100644 index 00000000000..230d2c4d06e --- /dev/null +++ b/account_move_tier_validation_approver/i18n/account_move_tier_validation_approver.pot @@ -0,0 +1,109 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_move_tier_validation_approver +# +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: account_move_tier_validation_approver +#: model_terms:ir.ui.view,arch_db:account_move_tier_validation_approver.res_config_settings_view_form +msgid "" +"" +msgstr "" + +#. module: account_move_tier_validation_approver +#: model:ir.model.fields,field_description:account_move_tier_validation_approver.field_res_partner__approver_id +#: model:ir.model.fields,field_description:account_move_tier_validation_approver.field_res_users__approver_id +msgid "Approver of Vendor Bills" +msgstr "" + +#. module: account_move_tier_validation_approver +#: model:ir.model.fields,field_description:account_move_tier_validation_approver.field_res_company__validation_approver_tier_definition_id +msgid "Bill approval tier definition" +msgstr "" + +#. module: account_move_tier_validation_approver +#: model:ir.model,name:account_move_tier_validation_approver.model_res_company +msgid "Companies" +msgstr "" + +#. module: account_move_tier_validation_approver +#: model:ir.model,name:account_move_tier_validation_approver.model_res_config_settings +msgid "Config Settings" +msgstr "" + +#. module: account_move_tier_validation_approver +#: model:ir.model,name:account_move_tier_validation_approver.model_res_partner +msgid "Contact" +msgstr "" + +#. module: account_move_tier_validation_approver +#: model:ir.model.fields,field_description:account_move_tier_validation_approver.field_account_move__display_name +#: model:ir.model.fields,field_description:account_move_tier_validation_approver.field_res_company__display_name +#: model:ir.model.fields,field_description:account_move_tier_validation_approver.field_res_config_settings__display_name +#: model:ir.model.fields,field_description:account_move_tier_validation_approver.field_res_partner__display_name +msgid "Display Name" +msgstr "" + +#. module: account_move_tier_validation_approver +#: model:ir.model.fields,field_description:account_move_tier_validation_approver.field_account_move__id +#: model:ir.model.fields,field_description:account_move_tier_validation_approver.field_res_company__id +#: model:ir.model.fields,field_description:account_move_tier_validation_approver.field_res_config_settings__id +#: model:ir.model.fields,field_description:account_move_tier_validation_approver.field_res_partner__id +msgid "ID" +msgstr "" + +#. module: account_move_tier_validation_approver +#: code:addons/account_move_tier_validation_approver/models/account_move.py:0 +#, python-format +msgid "It is mandatory to indicate a Responsible for Approval (in {})" +msgstr "" + +#. module: account_move_tier_validation_approver +#: model:ir.model,name:account_move_tier_validation_approver.model_account_move +msgid "Journal Entry" +msgstr "" + +#. module: account_move_tier_validation_approver +#: model:ir.model.fields,field_description:account_move_tier_validation_approver.field_account_move____last_update +#: model:ir.model.fields,field_description:account_move_tier_validation_approver.field_res_company____last_update +#: model:ir.model.fields,field_description:account_move_tier_validation_approver.field_res_config_settings____last_update +#: model:ir.model.fields,field_description:account_move_tier_validation_approver.field_res_partner____last_update +msgid "Last Modified on" +msgstr "" + +#. module: account_move_tier_validation_approver +#: model:ir.model.fields,field_description:account_move_tier_validation_approver.field_res_config_settings__require_approver_in_vendor_bills +msgid "Require Approver In Vendor Bills" +msgstr "" + +#. module: account_move_tier_validation_approver +#: model_terms:ir.ui.view,arch_db:account_move_tier_validation_approver.res_config_settings_view_form +msgid "Require approver before posting vendor bills" +msgstr "" + +#. module: account_move_tier_validation_approver +#: model:ir.model.fields,field_description:account_move_tier_validation_approver.field_res_company__require_approver_in_vendor_bills +msgid "Require approver in vendor bills" +msgstr "" + +#. module: account_move_tier_validation_approver +#: model:ir.model.fields,help:account_move_tier_validation_approver.field_res_config_settings__require_approver_in_vendor_bills +msgid "Requires adding an approver before a vendor bill can be posted." +msgstr "" + +#. module: account_move_tier_validation_approver +#: model:ir.model.fields,field_description:account_move_tier_validation_approver.field_account_bank_statement_line__approver_id +#: model:ir.model.fields,field_description:account_move_tier_validation_approver.field_account_move__approver_id +#: model:ir.model.fields,field_description:account_move_tier_validation_approver.field_account_payment__approver_id +msgid "Responsible for Approval" +msgstr "" diff --git a/account_move_tier_validation_approver/i18n/es_PA.po b/account_move_tier_validation_approver/i18n/es_PA.po new file mode 100644 index 00000000000..9f81ac04231 --- /dev/null +++ b/account_move_tier_validation_approver/i18n/es_PA.po @@ -0,0 +1,84 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_move_tier_validation_approver +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: es_PA\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" + +#. module: account_move_tier_validation_approver +#: model_terms:ir.ui.view,arch_db:account_move_tier_validation_approver.res_config_settings_view_form +msgid "" +"" +msgstr "" + +#. module: account_move_tier_validation_approver +#: model:ir.model.fields,field_description:account_move_tier_validation_approver.field_res_partner__approver_id +#: model:ir.model.fields,field_description:account_move_tier_validation_approver.field_res_users__approver_id +msgid "Approver of Vendor Bills" +msgstr "" + +#. module: account_move_tier_validation_approver +#: model:ir.model.fields,field_description:account_move_tier_validation_approver.field_res_company__validation_approver_tier_definition_id +msgid "Bill approval tier definition" +msgstr "" + +#. module: account_move_tier_validation_approver +#: model:ir.model,name:account_move_tier_validation_approver.model_res_company +msgid "Companies" +msgstr "" + +#. module: account_move_tier_validation_approver +#: model:ir.model,name:account_move_tier_validation_approver.model_res_config_settings +msgid "Config Settings" +msgstr "" + +#. module: account_move_tier_validation_approver +#: model:ir.model,name:account_move_tier_validation_approver.model_res_partner +msgid "Contact" +msgstr "" + +#. module: account_move_tier_validation_approver +#: code:addons/account_move_tier_validation_approver/models/account_move.py:0 +#, python-format +msgid "It is mandatory to indicate a Responsible for Approval" +msgstr "" + +#. module: account_move_tier_validation_approver +#: model:ir.model,name:account_move_tier_validation_approver.model_account_move +msgid "Journal Entries" +msgstr "" + +#. module: account_move_tier_validation_approver +#: model:ir.model.fields,field_description:account_move_tier_validation_approver.field_res_config_settings__require_approver_in_vendor_bills +msgid "Require Approver In Vendor Bills" +msgstr "" + +#. module: account_move_tier_validation_approver +#: model_terms:ir.ui.view,arch_db:account_move_tier_validation_approver.res_config_settings_view_form +msgid "Require approver before posting vendor bills" +msgstr "" + +#. module: account_move_tier_validation_approver +#: model:ir.model.fields,field_description:account_move_tier_validation_approver.field_res_company__require_approver_in_vendor_bills +msgid "Require approver in vendor bills" +msgstr "" + +#. module: account_move_tier_validation_approver +#: model:ir.model.fields,help:account_move_tier_validation_approver.field_res_config_settings__require_approver_in_vendor_bills +msgid "Requires adding an approver before a vendor bill can be posted." +msgstr "" + +#. module: account_move_tier_validation_approver +#: model:ir.model.fields,field_description:account_move_tier_validation_approver.field_account_move__approver_id +msgid "Responsible for Approval" +msgstr "" diff --git a/account_move_tier_validation_approver/models/__init__.py b/account_move_tier_validation_approver/models/__init__.py new file mode 100644 index 00000000000..516c5ccbdef --- /dev/null +++ b/account_move_tier_validation_approver/models/__init__.py @@ -0,0 +1,4 @@ +from . import account_move +from . import res_partner +from . import res_config_settings +from . import res_company diff --git a/account_move_tier_validation_approver/models/account_move.py b/account_move_tier_validation_approver/models/account_move.py new file mode 100644 index 00000000000..39f5fa9c865 --- /dev/null +++ b/account_move_tier_validation_approver/models/account_move.py @@ -0,0 +1,33 @@ +# Copyright 2021 ForgeFlow, S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models +from odoo.exceptions import UserError + + +class AccountMove(models.Model): + _inherit = "account.move" + + approver_id = fields.Many2one("res.users", string="Responsible for Approval") + + @api.onchange("partner_id") + def _onchange_partner_approver_id(self): + if self.partner_id: + self.approver_id = self.partner_id.approver_id.id + + def _post(self, soft=True): + for move in self: + require_approver_in_vendor_bills = ( + move.company_id.require_approver_in_vendor_bills + ) + if ( + move.is_purchase_document(include_receipts=True) + and require_approver_in_vendor_bills + and not move.approver_id + ): + raise UserError( + self.env._( + "It is mandatory to indicate a Responsible for Approval (in {})" + ).format(move.name) + ) + return super()._post(soft) diff --git a/account_move_tier_validation_approver/models/res_company.py b/account_move_tier_validation_approver/models/res_company.py new file mode 100644 index 00000000000..d905721d177 --- /dev/null +++ b/account_move_tier_validation_approver/models/res_company.py @@ -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_in_vendor_bills = fields.Boolean( + string="Require approver in vendor bills" + ) + validation_approver_tier_definition_id = fields.Many2one( + comodel_name="tier.definition", string="Bill approval tier definition" + ) diff --git a/account_move_tier_validation_approver/models/res_config_settings.py b/account_move_tier_validation_approver/models/res_config_settings.py new file mode 100644 index 00000000000..1addb19992e --- /dev/null +++ b/account_move_tier_validation_approver/models/res_config_settings.py @@ -0,0 +1,41 @@ +# 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_in_vendor_bills = fields.Boolean( + string="Require Approver In Vendor Bills", + help="Requires adding an approver before a vendor bill can be posted.", + related="company_id.require_approver_in_vendor_bills", + readonly=False, + ) + + def set_values(self): + tier_definition = self.company_id.validation_approver_tier_definition_id + if not tier_definition: + field = self.env["ir.model.fields"].search( + [("model", "=", "account.move"), ("name", "=", "approver_id")] + ) + tier_definition = self.env["tier.definition"].create( + { + "model_id": self.env["ir.model"] + .search([("model", "=", "account.move")]) + .id, + "review_type": "field", + "name": "Validation with Approver field", + "reviewer_field_id": field.id, + "definition_domain": "[('move_type', '=', 'in_invoice')]", + "approve_sequence": True, + "active": self.require_approver_in_vendor_bills, + } + ) + self.company_id.validation_approver_tier_definition_id = tier_definition + if self.require_approver_in_vendor_bills: + tier_definition.action_unarchive() + else: + tier_definition.action_archive() + return super().set_values() diff --git a/account_move_tier_validation_approver/models/res_partner.py b/account_move_tier_validation_approver/models/res_partner.py new file mode 100644 index 00000000000..e8df37e6aa6 --- /dev/null +++ b/account_move_tier_validation_approver/models/res_partner.py @@ -0,0 +1,10 @@ +# Copyright 2021 ForgeFlow, S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class Partner(models.Model): + _inherit = "res.partner" + + approver_id = fields.Many2one("res.users", string="Approver of Vendor Bills") diff --git a/account_move_tier_validation_approver/pyproject.toml b/account_move_tier_validation_approver/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/account_move_tier_validation_approver/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/account_move_tier_validation_approver/readme/CONFIGURE.md b/account_move_tier_validation_approver/readme/CONFIGURE.md new file mode 100644 index 00000000000..565bf10fbfe --- /dev/null +++ b/account_move_tier_validation_approver/readme/CONFIGURE.md @@ -0,0 +1,10 @@ +To configure this module, you need to: + +1. Go to *Settings \> Technical \> Tier Validations \> Tier + Definition*. +2. Create a new tier or edit an existing one. +3. Set the "Validated by" field to "Field in related record". +4. Set the "Reviewer field" to "Responsible for Approval". + +A default tier validation called "Validation with Approver field" is set +with this configuration. diff --git a/account_move_tier_validation_approver/readme/CONTRIBUTORS.md b/account_move_tier_validation_approver/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..9d2ecd5477b --- /dev/null +++ b/account_move_tier_validation_approver/readme/CONTRIBUTORS.md @@ -0,0 +1,4 @@ +- Lois Rilo \<\> +- Adrià Gil Sorribes \<\> +- \[360ERP\](): + - Kevin Khao \<\<\>\> diff --git a/account_move_tier_validation_approver/readme/DESCRIPTION.md b/account_move_tier_validation_approver/readme/DESCRIPTION.md new file mode 100644 index 00000000000..088cf8d5ae5 --- /dev/null +++ b/account_move_tier_validation_approver/readme/DESCRIPTION.md @@ -0,0 +1,4 @@ +This module allows to select a Responsible for approval in the partner +form. If a tier definition is set and configured with the "Responsible +for Approval" field, the approver will be the one chosen in the partner +form. diff --git a/account_move_tier_validation_approver/readme/USAGE.md b/account_move_tier_validation_approver/readme/USAGE.md new file mode 100644 index 00000000000..0d7b786e263 --- /dev/null +++ b/account_move_tier_validation_approver/readme/USAGE.md @@ -0,0 +1,12 @@ +You can assign a default user for approval associated to a supplier. In +the partner form view, go to the *Sales and Purchase* tab, and into the +*Purchase* section, and fill the field *Approver of Vendor Bills*. + +When you create a vendor bill the field *Responsible for Approval* will +be filled in with the partner's default. You can change it if needed. + +Be aware that you won't be able to post a vendor bill unless you have +indicated a Responsible for Approval. + +Used in connection with the module *Account Move Tier Validation* you +can set up approvals specific to a department. diff --git a/account_move_tier_validation_approver/static/description/icon.png b/account_move_tier_validation_approver/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/account_move_tier_validation_approver/static/description/icon.png differ diff --git a/account_move_tier_validation_approver/static/description/index.html b/account_move_tier_validation_approver/static/description/index.html new file mode 100644 index 00000000000..2748f5de5bf --- /dev/null +++ b/account_move_tier_validation_approver/static/description/index.html @@ -0,0 +1,457 @@ + + + + + +Account Move Tier Validation Approver + + + +
+

Account Move Tier Validation Approver

+ + +

Beta License: AGPL-3 OCA/account-invoicing Translate me on Weblate Try me on Runboat

+

This module allows to select a Responsible for approval in the partner +form. If a tier definition is set and configured with the “Responsible +for Approval” field, the approver will be the one chosen in the partner +form.

+

Table of contents

+ +
+

Configuration

+

To configure this module, you need to:

+
    +
  1. Go to Settings > Technical > Tier Validations > Tier Definition.
  2. +
  3. Create a new tier or edit an existing one.
  4. +
  5. Set the “Validated by” field to “Field in related record”.
  6. +
  7. Set the “Reviewer field” to “Responsible for Approval”.
  8. +
+

A default tier validation called “Validation with Approver field” is set +with this configuration.

+
+
+

Usage

+

You can assign a default user for approval associated to a supplier. In +the partner form view, go to the Sales and Purchase tab, and into the +Purchase section, and fill the field Approver of Vendor Bills.

+

When you create a vendor bill the field Responsible for Approval will +be filled in with the partner’s default. You can change it if needed.

+

Be aware that you won’t be able to post a vendor bill unless you have +indicated a Responsible for Approval.

+

Used in connection with the module Account Move Tier Validation you +can set up approvals specific to a department.

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • ForgeFlow
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

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/account-invoicing project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/account_move_tier_validation_approver/tests/__init__.py b/account_move_tier_validation_approver/tests/__init__.py new file mode 100644 index 00000000000..2de1f82ab83 --- /dev/null +++ b/account_move_tier_validation_approver/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import test_account_move_tier_validation_approver diff --git a/account_move_tier_validation_approver/tests/test_account_move_tier_validation_approver.py b/account_move_tier_validation_approver/tests/test_account_move_tier_validation_approver.py new file mode 100644 index 00000000000..1c5220a956a --- /dev/null +++ b/account_move_tier_validation_approver/tests/test_account_move_tier_validation_approver.py @@ -0,0 +1,79 @@ +# Copyright 2021 ForgeFlow (http://www.forgeflow.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.exceptions import ValidationError +from odoo.tests.common import TransactionCase + +from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT + + +class TestAccountMoveTierValidationApprover(TransactionCase): + def setUp(self): + super().setUp() + self.env = self.env(context=dict(self.env.context, **DISABLED_MAIL_CONTEXT)) + self.res_partner_1 = self.env["res.partner"].create( + {"name": "Wood Corner", "email": "example@yourcompany.com"} + ) + self.product_1 = self.env["product.product"].create( + {"name": "Desk Combination"} + ) + self.currency_usd = self.env["res.currency"].search([("name", "=", "USD")]) + self.test_user_1 = self.env["res.users"].create( + {"name": "User", "login": "test1", "email": "example@yourcompany.com"} + ) + self.test_approver = self.env["res.users"].create( + {"name": "Approver", "login": "test2", "email": "example@yourcompany.com"} + ) + self.vendor_bill = self.env["account.move"].create( + [ + { + "move_type": "in_invoice", + "partner_id": self.res_partner_1.id, + "currency_id": self.currency_usd.id, + "approver_id": self.test_approver.id, + "invoice_line_ids": [ + ( + 0, + None, + { + "product_id": self.product_1.id, + "product_uom_id": self.product_1.uom_id.id, + "quantity": 12, + "price_unit": 1000, + }, + ), + ], + } + ] + ) + self.model_id = self.env["ir.model"].search( + [("model", "=", "account.move")], limit=1 + ) + self.field_id = self.env["ir.model.fields"].search( + [("name", "=", "approver_id")], limit=1 + ) + + def test_field_validation_approver(self): + tiers = self.env["tier.definition"].search([]) + for tier in tiers: + tier.action_archive() + self.tier_definition = self.env["tier.definition"].create( + { + "name": "Test Tier", + "model_id": self.model_id.id, + "review_type": "field", + "reviewer_field_id": self.field_id.id, + "definition_type": "domain", + "definition_domain": "[('move_type', '=', 'in_invoice')]", + } + ) + record = self.vendor_bill + record.write( + {"approver_id": self.test_approver.id, "invoice_date": record.date} + ) + record.with_user(self.test_user_1.id).request_validation() + record.with_user(self.test_user_1.id).validate_tier() + with self.assertRaises(ValidationError): + record.action_post() + record.with_user(self.test_approver.id).validate_tier() + record.action_post() diff --git a/account_move_tier_validation_approver/views/account_move_views.xml b/account_move_tier_validation_approver/views/account_move_views.xml new file mode 100644 index 00000000000..c8669a6a04b --- /dev/null +++ b/account_move_tier_validation_approver/views/account_move_views.xml @@ -0,0 +1,29 @@ + + + + + account.move.form + account.move + + + + + + + + + account.move.select - account_move_tier_validation + account.move + + + + + + + + diff --git a/account_move_tier_validation_approver/views/res_config_settings_views.xml b/account_move_tier_validation_approver/views/res_config_settings_views.xml new file mode 100644 index 00000000000..1ffdb4d527e --- /dev/null +++ b/account_move_tier_validation_approver/views/res_config_settings_views.xml @@ -0,0 +1,19 @@ + + + + res.config.settings.view.form.inherit + res.config.settings + + + + + + + + + + diff --git a/account_move_tier_validation_approver/views/res_partner_views.xml b/account_move_tier_validation_approver/views/res_partner_views.xml new file mode 100644 index 00000000000..8ab4af16c13 --- /dev/null +++ b/account_move_tier_validation_approver/views/res_partner_views.xml @@ -0,0 +1,18 @@ + + + + + + res.partner.move_approve.user + res.partner + + + + + + + + diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 00000000000..9eee3eb208d --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,2 @@ +odoo-addon-base_tier_validation @ git+https://github.com/OCA/server-ux.git@refs/pull/966/head#subdirectory=base_tier_validation +odoo-addon-account_move_tier_validation @ git+https://github.com/OCA/account-invoicing.git@refs/pull/1830/head#subdirectory=account_move_tier_validation