forked from OCA/partner-contact
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit 'refs/pull/1343/head' of https://github.com/oca/partner-…
…contact into 15.0-15
- Loading branch information
Showing
24 changed files
with
899 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
============================== | ||
Portal Partner Block Data Edit | ||
============================== | ||
|
||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! 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-OCA%2Fpartner--contact-lightgray.png?logo=github | ||
:target: https://github.com/OCA/partner-contact/tree/13.0/portal_partner_data_no_edit | ||
:alt: OCA/partner-contact | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/partner-contact-13-0/partner-contact-13-0-portal_partner_data_no_edit | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png | ||
:target: https://runbot.odoo-community.org/runbot/134/13.0 | ||
:alt: Try me on Runbot | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module allows to block portal users info editing to prevent unproper | ||
changes. We can configure it on every partner. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Configuration | ||
============= | ||
|
||
To test this module, you need to: | ||
|
||
#. Block portal info editing for a partner: | ||
|
||
- Go to *Contacts* and choose the partner. | ||
- In the the *Sales and Purchases* tab, *Misc* section there is a field named | ||
*Block Portal Info Edit*. Enable or disable at your convenience. | ||
|
||
Usage | ||
===== | ||
|
||
Once configured log in with that user and: | ||
|
||
- Go to `/my/account/` | ||
- If the editing is blocked, you won't be able to edit any detail or submit | ||
the form. | ||
|
||
Known issues / Roadmap | ||
====================== | ||
|
||
- Add the `block_portal_data_edit` flag to the invite to portal popup. | ||
- Add a text on the page highlighted (for example with info BS class), saying for those | ||
blocked users that they should contact the company for any modification. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/partner-contact/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/OCA/partner-contact/issues/new?body=module:%20portal_partner_data_no_edit%0Aversion:%2013.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 | ||
~~~~~~~ | ||
|
||
* Tecnativa | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* `Tecnativa <https://www.tecnativa.com>`_: | ||
|
||
* David Vidal | ||
* Carlos Roca | ||
|
||
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/partner-contact <https://github.com/OCA/partner-contact/tree/13.0/portal_partner_data_no_edit>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import controllers | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright 2021 Tecnativa - David Vidal | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
{ | ||
"name": "Portal Partner Block Data Edit", | ||
"version": "15.0.1.0.0", | ||
"category": "Customer Relationship Management", | ||
"author": "Tecnativa," "Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/partner-contact", | ||
"license": "AGPL-3", | ||
"depends": ["portal"], | ||
"data": [ | ||
"views/res_partner_views.xml", | ||
"views/portal_template.xml", | ||
], | ||
"assets": { | ||
"web.assets_tests": [ | ||
"portal_partner_data_no_edit/static/src/js/portal_partner_data_no_edit_tour.js", | ||
], | ||
}, | ||
"installable": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import portal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright 2021 Tecnativa - David Vidal | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
from odoo.http import request, route | ||
|
||
from odoo.addons.portal.controllers.portal import CustomerPortal | ||
|
||
|
||
class PortalBlockEdit(CustomerPortal): | ||
def _prepare_portal_layout_values(self): | ||
"""So we can change the edit link text in the view""" | ||
values = super()._prepare_portal_layout_values() | ||
values["block_portal_data_edit"] = request.env.user.block_portal_data_edit | ||
return values | ||
|
||
@route() | ||
def account(self, redirect=None, **post): | ||
"""Inject a context that we later we catch in the template `render`""" | ||
if request.env.user.block_portal_data_edit: | ||
context = dict(request.env.context, block_portal_data_edit=True) | ||
request.env.context = context | ||
return super().account(redirect, **post) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * portal_partner_data_no_edit | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 12.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2021-02-04 10:16+0000\n" | ||
"PO-Revision-Date: 2021-02-04 11:18+0100\n" | ||
"Last-Translator: <>\n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Plural-Forms: \n" | ||
"Language: es\n" | ||
"X-Generator: Poedit 2.3\n" | ||
|
||
#. module: portal_partner_data_no_edit | ||
#: model_terms:ir.ui.view,arch_db:portal_partner_data_no_edit.o_portal_my_details | ||
msgid "<i class=\"fa fa-eye\"/> View" | ||
msgstr "<i class=\"fa fa-eye\"/> Ver" | ||
|
||
#. module: portal_partner_data_no_edit | ||
#: model:ir.model.fields,help:portal_partner_data_no_edit.field_res_partner__block_portal_data_edit | ||
#: model:ir.model.fields,help:portal_partner_data_no_edit.field_res_users__block_portal_data_edit | ||
msgid "Block portal info editing for the portal user linked to this partner" | ||
msgstr "Bloquea la edición de la información al usuario de portal vinculado a este contacto" | ||
|
||
#. module: portal_partner_data_no_edit | ||
#: model:ir.model.fields,field_description:portal_partner_data_no_edit.field_res_partner__block_portal_data_edit | ||
#: model:ir.model.fields,field_description:portal_partner_data_no_edit.field_res_users__block_portal_data_edit | ||
msgid "Block Customer Info Edit" | ||
msgstr "Bloquear edición de datos de portal" | ||
|
||
#. module: portal_partner_data_no_edit | ||
#: model:ir.model,name:portal_partner_data_no_edit.model_res_partner | ||
msgid "Contact" | ||
msgstr "Contacto" | ||
|
||
#. module: portal_partner_data_no_edit | ||
#: model:ir.model,name:portal_partner_data_no_edit.model_ir_ui_view | ||
msgid "View" | ||
msgstr "Ver" |
41 changes: 41 additions & 0 deletions
41
portal_partner_data_no_edit/i18n/portal_partner_data_no_edit.pot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * portal_partner_data_no_edit | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 13.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: portal_partner_data_no_edit | ||
#: model_terms:ir.ui.view,arch_db:portal_partner_data_no_edit.o_portal_my_details | ||
msgid "<i class=\"fa fa-eye\"/> View" | ||
msgstr "" | ||
|
||
#. module: portal_partner_data_no_edit | ||
#: model:ir.model.fields,field_description:portal_partner_data_no_edit.field_res_partner__block_portal_data_edit | ||
#: model:ir.model.fields,field_description:portal_partner_data_no_edit.field_res_users__block_portal_data_edit | ||
msgid "Block Customer Info Edit" | ||
msgstr "" | ||
|
||
#. module: portal_partner_data_no_edit | ||
#: model:ir.model.fields,help:portal_partner_data_no_edit.field_res_partner__block_portal_data_edit | ||
#: model:ir.model.fields,help:portal_partner_data_no_edit.field_res_users__block_portal_data_edit | ||
msgid "Block portal info editing for the portal user linked to this partner" | ||
msgstr "" | ||
|
||
#. module: portal_partner_data_no_edit | ||
#: model:ir.model,name:portal_partner_data_no_edit.model_res_partner | ||
msgid "Contact" | ||
msgstr "" | ||
|
||
#. module: portal_partner_data_no_edit | ||
#: model:ir.model,name:portal_partner_data_no_edit.model_ir_ui_view | ||
msgid "View" | ||
msgstr "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import ir_ui_view | ||
from . import res_partner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Copyright 2021 Tecnativa - David Vidal | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
from lxml import html | ||
|
||
from odoo import models | ||
|
||
|
||
class IrUiView(models.Model): | ||
_inherit = "ir.ui.view" | ||
|
||
def render(self, values=None, engine="ir.qweb", minimal_qcontext=False): | ||
"""Disable inputs converting them into paragraphs and clear form | ||
buttons. This way, we don't need to go input by input and we can | ||
support any view extension without further patching""" | ||
res = super().render( | ||
values=values, engine=engine, minimal_qcontext=minimal_qcontext | ||
) | ||
if not self.env.context.get("block_portal_data_edit"): | ||
return res | ||
fragments = html.fromstring(res.decode("utf-8")) | ||
for fragment in fragments: | ||
# The result is a page that looks the same way as the original form | ||
# but with the input fields shadowed and not editable as they're | ||
# just `<p>` paragraphs in `form-control` classes disguise. | ||
for _input in fragment.iterfind(".//form[@action='/my/account']//input"): | ||
if _input.type in ["text", "tel", "email"]: | ||
attrs = _input.attrib | ||
text = attrs.pop("value", "") | ||
# We don't want this attribute in the `<p>` | ||
del attrs["type"] | ||
attrs["readonly"] = "1" | ||
p_readonly = _input.makeelement("p", attrib=attrs) | ||
p_readonly.text = text | ||
_input.addprevious(p_readonly) | ||
_input.getparent().remove(_input) | ||
for _select in fragment.iterfind(".//form[@action='/my/account']//select"): | ||
# Maybe there's a prettier way to extract the selected value | ||
option = [ | ||
x | ||
for x in _select.getchildren() | ||
if x.attrib.get("value", "") == _select.value | ||
] | ||
text = option and option[0].text or "" | ||
attrs = _select.attrib | ||
attrs["readonly"] = "1" | ||
p_readonly = _select.makeelement("p", attrib=attrs) | ||
p_readonly.text = text | ||
_select.addprevious(p_readonly) | ||
_select.getparent().remove(_select) | ||
for _button in fragment.iterfind(".//form[@action='/my/account']//button"): | ||
_button.getparent().remove(_button) | ||
return b"".join(html.tostring(f) for f in fragments) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Copyright 2021 Tecnativa - David Vidal | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
from odoo import fields, models | ||
|
||
|
||
class ResPartner(models.Model): | ||
_inherit = "res.partner" | ||
|
||
block_portal_data_edit = fields.Boolean( | ||
string="Block Customer Info Edit", | ||
help="Block portal info editing for the portal " "user linked to this partner", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
To test this module, you need to: | ||
|
||
#. Block portal info editing for a partner: | ||
|
||
- Go to *Contacts* and choose the partner. | ||
- In the the *Sales and Purchases* tab, *Misc* section there is a field named | ||
*Block Portal Info Edit*. Enable or disable at your convenience. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
* `Tecnativa <https://www.tecnativa.com>`_: | ||
|
||
* David Vidal | ||
* Carlos Roca |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
This module allows to block portal users info editing to prevent unproper | ||
changes. We can configure it on every partner. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
- Add the `block_portal_data_edit` flag to the invite to portal popup. | ||
- Add a text on the page highlighted (for example with info BS class), saying for those | ||
blocked users that they should contact the company for any modification. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Once configured log in with that user and: | ||
|
||
- Go to `/my/account/` | ||
- If the editing is blocked, you won't be able to edit any detail or submit | ||
the form. |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.