Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][ADD] check_current_company_for_validation module #700

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from
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
90 changes: 90 additions & 0 deletions check_current_company_for_validation/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
====================================
Check Current Company For Validation
====================================

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

.. |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%2Fmulti--company-lightgray.png?logo=github
:target: https://github.com/OCA/multi-company/tree/16.0/check_current_company_for_validation
:alt: OCA/multi-company
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/multi-company-16-0/multi-company-16-0-check_current_company_for_validation
: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/multi-company&target_branch=16.0
:alt: Try me on Runboat

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

This module check if the current company is the same as the record company.
It's come with the check on sale orders and a mixin which can be plugged to others models.

**Table of contents**

.. contents::
:local:

Usage
=====

* see sale_order.py example.

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/multi-company/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/multi-company/issues/new?body=module:%20check_current_company_for_validation%0Aversion:%2016.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
~~~~~~~

* Akretion

Contributors
~~~~~~~~~~~~

* Kévin Roche <[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.

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

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-Kev-Roche|

This module is part of the `OCA/multi-company <https://github.com/OCA/multi-company/tree/16.0/check_current_company_for_validation>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions check_current_company_for_validation/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
20 changes: 20 additions & 0 deletions check_current_company_for_validation/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2024 Akretion (https://www.akretion.com).
# @author Kévin Roche <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Check Current Company For Validation",
"summary": "Check Current Company For Validation",
"version": "16.0.1.0.0",
"category": "multi-company",
"website": "https://github.com/OCA/multi-company",
"author": "Akretion, Odoo Community Association (OCA)",
"license": "AGPL-3",
"maintainers": ["Kev-Roche"],
"application": False,
"installable": True,
"depends": [
"sale",
],
"data": [],
}
35 changes: 35 additions & 0 deletions check_current_company_for_validation/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * check_current_company_for_validation
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-09-25 13:56+0000\n"
"PO-Revision-Date: 2024-09-25 15:57+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"X-Generator: Poedit 3.4.2\n"

#. module: check_current_company_for_validation
#: model:ir.model,name:check_current_company_for_validation.model_check_current_company_mixin
msgid "Check Current Company Mixin"
msgstr ""

#. module: check_current_company_for_validation
#: model:ir.model,name:check_current_company_for_validation.model_sale_order
msgid "Sales Order"
msgstr "Bon de commande"

#. module: check_current_company_for_validation
#. odoo-python
#: code:addons/check_current_company_for_validation/models/check_current_company_mixin.py:0
#, python-format
msgid "You can't validate a record from another company"
msgstr "Vous ne pouvez pas valider cet enregistrement à partir d'une société différente"
2 changes: 2 additions & 0 deletions check_current_company_for_validation/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import check_current_company_mixin
from . import sale_order
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2024 Akretion (https://www.akretion.com).
# @author Kévin Roche <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import _, models
from odoo.exceptions import UserError


class CheckCurrentCompanyMixin(models.AbstractModel):
_name = "check.current.company.mixin"
_description = "Check Current Company Mixin"

def check_current_company(self):
if self.env.company != self.company_id:
raise UserError(_("You can't validate a record from another company"))
return True
14 changes: 14 additions & 0 deletions check_current_company_for_validation/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2024 Akretion (https://www.akretion.com).
# @author Kévin Roche <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import models


class SaleOrder(models.Model):
_inherit = ["sale.order", "check.current.company.mixin"]
_name = "sale.order"

def action_confirm(self):
self.check_current_company()
return super().action_confirm()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Kévin Roche <[email protected]>
2 changes: 2 additions & 0 deletions check_current_company_for_validation/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module check if the current company is the same as the record company.
It's come with the check on sale orders and a mixin which can be plugged to others models.
1 change: 1 addition & 0 deletions check_current_company_for_validation/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* see sale_order.py example.
Loading
Loading