Skip to content

Commit

Permalink
[4020][11.0][ADD] partner_edit_restrict: Migration to 11.0 (#365)
Browse files Browse the repository at this point in the history
Co-authored-by: kanda999 <[email protected]>
Co-authored-by: Yoshi Tashiro <[email protected]>
  • Loading branch information
3 people authored Dec 6, 2023
1 parent 923e70d commit b22f937
Show file tree
Hide file tree
Showing 12 changed files with 581 additions and 3 deletions.
54 changes: 54 additions & 0 deletions partner_edit_restrict/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
=====================
Partner Edit Restrict
=====================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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-qrtl%2Fsst--custom-lightgray.png?logo=github
:target: https://github.com/qrtl/sst-custom/tree/11.0/partner_edit_restrict
:alt: qrtl/sst-custom

|badge1| |badge2| |badge3|

This module restricts the editing of 'res.partner' records when
'restrict_edit' is enabled and the user is neither a system user nor a
member of 'group_partner_edit'.

**Table of contents**

.. contents::
:local:

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

Bugs are tracked on `GitHub Issues <https://github.com/qrtl/sst-custom/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/qrtl/sst-custom/issues/new?body=module:%20partner_edit_restrict%0Aversion:%2011.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
~~~~~~~

* Quartile Limited

Maintainers
~~~~~~~~~~~

This module is part of the `qrtl/sst-custom <https://github.com/qrtl/sst-custom/tree/11.0/partner_edit_restrict>`_ project on GitHub.

You are welcome to contribute.
1 change: 1 addition & 0 deletions partner_edit_restrict/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
16 changes: 16 additions & 0 deletions partner_edit_restrict/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2023 Quartile Limited
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Partner Edit Restrict",
"category": "Partner",
"version": "11.0.1.0.0",
"author": "Quartile Limited",
"website": "https://www.quartile.co",
"license": "AGPL-3",
"depends": ["base"],
"data": [
"security/partner_edit_restrict_security.xml",
"views/res_partner_views.xml",
],
"installable": True,
}
44 changes: 44 additions & 0 deletions partner_edit_restrict/i18n/ja.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * partner_edit_restrict
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-12-04 03:21+0000\n"
"PO-Revision-Date: 2023-12-04 03:21+0000\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: partner_edit_restrict
#: model:res.groups,name:partner_edit_restrict.group_partner_edit
msgid "Allow Editing Restricted Partners"
msgstr "制限付き連絡先を編集"

#. module: partner_edit_restrict
#: model:ir.model,name:partner_edit_restrict.model_res_partner
msgid "Contact"
msgstr "連絡先"

#. module: partner_edit_restrict
#: model:ir.model.fields,help:partner_edit_restrict.field_res_partner_restrict_edit
#: model:ir.model.fields,help:partner_edit_restrict.field_res_users_restrict_edit
msgid "Enable to restrict the editing record for non-system users."
msgstr "Enable to restrict the editing record for non-system users."

#. module: partner_edit_restrict
#: model:ir.model.fields,field_description:partner_edit_restrict.field_res_partner_restrict_edit
#: model:ir.model.fields,field_description:partner_edit_restrict.field_res_users_restrict_edit
msgid "Restrict Edit"
msgstr "編集を制限"

#. module: partner_edit_restrict
#: code:addons/partner_edit_restrict/models/res_partner.py:25
#, python-format
msgid "You are not allowed to modify following partner: %s"
msgstr "あなたは次の連絡先の編集を許可されていません: %s"
1 change: 1 addition & 0 deletions partner_edit_restrict/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import res_partner
27 changes: 27 additions & 0 deletions partner_edit_restrict/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2023 Quartile Limited
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

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


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

restrict_edit = fields.Boolean(
help="Enable to restrict the editing record for non-system users."
)

def write(self, values):
if (
self.env.user.has_group("partner_edit_restrict.group_partner_edit")
or self.env.user._is_superuser()
):
return super().write(values)
restricted_recs = self.filtered(lambda x: x.restrict_edit)
if restricted_recs:
names = ", ".join(restricted_recs.mapped("name"))
raise UserError(
_("You are not allowed to modify following partner: %s") % (names)
)
return super().write(values)
3 changes: 3 additions & 0 deletions partner_edit_restrict/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This module restricts the editing of 'res.partner' records when
'restrict_edit' is enabled and the user is neither a system user nor a
member of 'group_partner_edit'.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="group_partner_edit" model="res.groups">
<field name="name">Allow Editing Restricted Partners</field>
<field name="category_id" ref="base.module_category_hidden" />
</record>
</odoo>
Loading

0 comments on commit b22f937

Please sign in to comment.