Skip to content

Commit

Permalink
Merge PR #700 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by AaronHForgeFlow
  • Loading branch information
OCA-git-bot committed Aug 27, 2024
2 parents a4d1947 + 3f83de6 commit 1525f88
Show file tree
Hide file tree
Showing 17 changed files with 789 additions and 0 deletions.
87 changes: 87 additions & 0 deletions contract_operating_unit/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
=======================
Contract Operating Unit
=======================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:1bf7413f738eb06d7f40c5ea6903fd1ffcb6abe7994c8dfd04afa916149458b7
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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%2Foperating--unit-lightgray.png?logo=github
:target: https://github.com/OCA/operating-unit/tree/16.0/contract_operating_unit
:alt: OCA/operating-unit
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/operating-unit-16-0/operating-unit-16-0-contract_operating_unit
: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/operating-unit&target_branch=16.0
:alt: Try me on Runboat

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

This module introduces the following features:

* Adds the Operating Unit (OU) to Contracts.

* Security rules are defined to ensure that users can only see the Contracts of that Operating Units in which they are allowed access to.

**Table of contents**

.. contents::
:local:

Usage
=====

Assign contracts to specific operating units within the company

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/operating-unit/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/operating-unit/issues/new?body=module:%20contract_operating_unit%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
~~~~~~~

* ForgeFlow S.L.

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

* Aaron Henriquez <ahenriquez@forgeflow.com>
* Kitti U. <kittiu@ecosoft.co.th>
* Pimolnat Suntian <pimolnats@ecosoft.co.th>

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/operating-unit <https://github.com/OCA/operating-unit/tree/16.0/contract_operating_unit>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions contract_operating_unit/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from . import models
14 changes: 14 additions & 0 deletions contract_operating_unit/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2020 ForgeFlow S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

{
"name": "Contract Operating Unit",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "ForgeFlow S.L., Odoo Community Association (OCA)",
"website": "https://github.com/OCA/operating-unit",
"category": "Invoicing",
"depends": ["contract", "account_operating_unit"],
"data": ["views/contract_view.xml", "security/contract_security.xml"],
"installable": True,
}
25 changes: 25 additions & 0 deletions contract_operating_unit/i18n/contract_operating_unit.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * contract_operating_unit
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.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: contract_operating_unit
#: model:ir.model,name:contract_operating_unit.model_contract_contract
msgid "Contract"
msgstr ""

#. module: contract_operating_unit
#: model:ir.model.fields,field_description:contract_operating_unit.field_contract_contract__operating_unit_id
#: model_terms:ir.ui.view,arch_db:contract_operating_unit.contract_contract_search_view
msgid "Operating Unit"
msgstr ""
1 change: 1 addition & 0 deletions contract_operating_unit/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import contract
21 changes: 21 additions & 0 deletions contract_operating_unit/models/contract.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2020 ForgeFlow S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import fields, models


class ContractContract(models.Model):

_inherit = "contract.contract"

operating_unit_id = fields.Many2one(
"operating.unit",
"Operating Unit",
default=lambda self: self.env["res.users"].operating_unit_default_get(),
)

def _prepare_invoice(self, date_invoice, journal=None):
invoice_vals = super()._prepare_invoice(date_invoice, journal=journal)
if self.operating_unit_id:
invoice_vals["operating_unit_id"] = self.operating_unit_id.id
return invoice_vals
3 changes: 3 additions & 0 deletions contract_operating_unit/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* Aaron Henriquez <ahenriquez@forgeflow.com>
* Kitti U. <kittiu@ecosoft.co.th>
* Pimolnat Suntian <pimolnats@ecosoft.co.th>
5 changes: 5 additions & 0 deletions contract_operating_unit/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This module introduces the following features:

* Adds the Operating Unit (OU) to Contracts.

* Security rules are defined to ensure that users can only see the Contracts of that Operating Units in which they are allowed access to.
1 change: 1 addition & 0 deletions contract_operating_unit/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Assign contracts to specific operating units within the company
17 changes: 17 additions & 0 deletions contract_operating_unit/security/contract_security.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<record id="ir_rule_contract_allowed_operating_units" model="ir.rule">
<field name="model_id" ref="contract.model_contract_contract" />
<field
name="domain_force"
>['|',('operating_unit_id','=',False),('operating_unit_id','in',[g.id for g in user.operating_unit_ids])]</field>
<field name="name">Contracts from allowed operating units</field>
<field name="global" eval="True" />
<field eval="0" name="perm_unlink" />
<field eval="0" name="perm_write" />
<field eval="1" name="perm_read" />
<field eval="0" name="perm_create" />
</record>

</odoo>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 1525f88

Please sign in to comment.