From c64980406ad8612f94af8ecde58499e5e9e66c85 Mon Sep 17 00:00:00 2001 From: liuhehe1995 Date: Thu, 18 Jan 2024 05:00:03 +0000 Subject: [PATCH 01/11] 4010-add-sales_team_security --- sales_team_security/README.rst | 151 ++++++ sales_team_security/__init__.py | 4 + sales_team_security/__manifest__.py | 19 + sales_team_security/hooks.py | 46 ++ sales_team_security/i18n/es.po | 69 +++ sales_team_security/i18n/it.po | 69 +++ .../i18n/sales_team_security.pot | 62 +++ sales_team_security/models/__init__.py | 3 + sales_team_security/models/ir_rule.py | 58 +++ sales_team_security/models/res_partner.py | 94 ++++ sales_team_security/readme/CONFIGURE.rst | 3 + sales_team_security/readme/CONTRIBUTORS.rst | 15 + sales_team_security/readme/DESCRIPTION.rst | 30 ++ sales_team_security/readme/INSTALL.rst | 4 + sales_team_security/readme/ROADMAP.rst | 2 + .../security/sales_team_security.xml | 17 + .../static/description/icon.png | Bin 0 -> 9455 bytes .../static/description/index.html | 489 ++++++++++++++++++ sales_team_security/tests/__init__.py | 3 + sales_team_security/tests/common.py | 125 +++++ .../tests/test_sales_team_security.py | 95 ++++ .../views/res_partner_view.xml | 14 + .../odoo/addons/sales_team_security | 1 + setup/sales_team_security/setup.py | 6 + 24 files changed, 1379 insertions(+) create mode 100644 sales_team_security/README.rst create mode 100644 sales_team_security/__init__.py create mode 100644 sales_team_security/__manifest__.py create mode 100644 sales_team_security/hooks.py create mode 100644 sales_team_security/i18n/es.po create mode 100644 sales_team_security/i18n/it.po create mode 100644 sales_team_security/i18n/sales_team_security.pot create mode 100644 sales_team_security/models/__init__.py create mode 100644 sales_team_security/models/ir_rule.py create mode 100644 sales_team_security/models/res_partner.py create mode 100644 sales_team_security/readme/CONFIGURE.rst create mode 100644 sales_team_security/readme/CONTRIBUTORS.rst create mode 100644 sales_team_security/readme/DESCRIPTION.rst create mode 100644 sales_team_security/readme/INSTALL.rst create mode 100644 sales_team_security/readme/ROADMAP.rst create mode 100644 sales_team_security/security/sales_team_security.xml create mode 100644 sales_team_security/static/description/icon.png create mode 100644 sales_team_security/static/description/index.html create mode 100644 sales_team_security/tests/__init__.py create mode 100644 sales_team_security/tests/common.py create mode 100644 sales_team_security/tests/test_sales_team_security.py create mode 100644 sales_team_security/views/res_partner_view.xml create mode 120000 setup/sales_team_security/odoo/addons/sales_team_security create mode 100644 setup/sales_team_security/setup.py diff --git a/sales_team_security/README.rst b/sales_team_security/README.rst new file mode 100644 index 00000000..0e1cc241 --- /dev/null +++ b/sales_team_security/README.rst @@ -0,0 +1,151 @@ +=============================================== +Sales documents permissions by channels (teams) +=============================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:709c291e03000ac05c6e8f97900c31cb7ec9adfded256ce6bfabf6a62d20dd03 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png + :target: https://odoo-community.org/page/development-status + :alt: Production/Stable +.. |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%2Fsale--workflow-lightgray.png?logo=github + :target: https://github.com/OCA/sale-workflow/tree/16.0/sales_team_security + :alt: OCA/sale-workflow +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sales_team_security + :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/sale-workflow&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds a new "Sale" group called "User: Team documents", that +includes the proper permissions for showing only the information related to +that user sale team (having assigned that team/channel or no team at all, +independently from the assigned salesman): + +* Contacts. +* Quotations/Sales Orders (implemented in sales_team_security_sale) +* Leads/Opportunities (implemented in sales_team_security_crm) + +It also handles the propagation of the sales team from commercial partners to +the contacts, which standard doesn't do. + +It also handles the sync (auto-creation and remove) of followers in company partners +and childs of them according to salesmans. Any example about it: +- Partner company > Salesman: Admin +- Partner company, Contact 1 > Without salesman +- Partner company, Contact 2 > Salesman: Demo +All these partners have these followers: Admin + Demo + +And finally, there are rules for partners to be restricted to the own ones for +the group "User: Own Documents Only" for being coherent with the permission +scheme. Someone with this permission will see: + +- Contacts without salesman nor team assigned. +- Contacts without salesman assigned, but the same team. +- Contacts with them as salesman, independently from the team. +- Contacts with them as follower. + +For keeping consistent accesses, followers of the main and shipping/invoice +contacts are synced according the salesman of the children contacts + +**Table of contents** + +.. contents:: + :local: + +Installation +============ + +At installation time, this module sets in all the contacts that have the sales +team empty the sales team of the parent, and sync followers in parent contacts +and invoice/shipping addresses. If you have a lot of contacts, this +operation can take a while. + +Configuration +============= + +#. Go to *Configuration > Users & Companies > Users*. +#. Open or create a user. +#. On the section "Sale", select "User: Team documents". + +Known issues / Roadmap +====================== + +* This module modifies sales security groups hierarchy, so any other module + doing something similar might conflict with this one. + +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 +~~~~~~~ + +* Tecnativa + +Contributors +~~~~~~~~~~~~ + +* `Tecnativa `__: + + * Pedro M. Baeza + * Víctor Martínez + * César A. Sánchez + +* `Guadaltech `__: + + * Ramón Bajona + +* Iván Todorovich + +* `Pesol `__: + + * Jonathan Oscategui Taza + +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-pedrobaeza| image:: https://github.com/pedrobaeza.png?size=40px + :target: https://github.com/pedrobaeza + :alt: pedrobaeza +.. |maintainer-ivantodorovich| image:: https://github.com/ivantodorovich.png?size=40px + :target: https://github.com/ivantodorovich + :alt: ivantodorovich + +Current `maintainers `__: + +|maintainer-pedrobaeza| |maintainer-ivantodorovich| + +This module is part of the `OCA/sale-workflow `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/sales_team_security/__init__.py b/sales_team_security/__init__.py new file mode 100644 index 00000000..030d9698 --- /dev/null +++ b/sales_team_security/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import models +from .hooks import post_init_hook, uninstall_hook diff --git a/sales_team_security/__manifest__.py b/sales_team_security/__manifest__.py new file mode 100644 index 00000000..20debdb1 --- /dev/null +++ b/sales_team_security/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2016-2020 Tecnativa - Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Sales documents permissions by channels (teams)", + "summary": "New group for seeing only sales channel's documents", + "version": "16.0.1.0.0", + "category": "Sales", + "website": "https://github.com/OCA/sale-workflow", + "author": "Tecnativa, Odoo Community Association (OCA)", + "license": "AGPL-3", + "installable": True, + "development_status": "Production/Stable", + "maintainers": ["pedrobaeza", "ivantodorovich"], + "depends": ["sales_team"], + "data": ["security/sales_team_security.xml", "views/res_partner_view.xml"], + "post_init_hook": "post_init_hook", + "uninstall_hook": "uninstall_hook", +} diff --git a/sales_team_security/hooks.py b/sales_team_security/hooks.py new file mode 100644 index 00000000..17cc5cbe --- /dev/null +++ b/sales_team_security/hooks.py @@ -0,0 +1,46 @@ +# Copyright 2018-2016 Tecnativa - Pedro M. Baeza +# Copyright 2020 - Iván Todorovich +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from odoo import SUPERUSER_ID, api + + +def post_init_hook(cr, registry): + """At installation time, propagate the parent sales team to the children + contacts that have this field empty, as it's supposed that the intention + is to have the same. + """ + cr.execute( + """UPDATE res_partner + SET team_id=parent.team_id + FROM res_partner AS parent + WHERE parent.team_id IS NOT NULL + AND res_partner.parent_id = parent.id + AND res_partner.team_id IS NULL""" + ) + + +def uninstall_hook(cr, registry): # pragma: no cover + """At uninstall, revert changes made to record rules""" + with api.Environment.manage(): + env = api.Environment(cr, SUPERUSER_ID, {}) + env.ref("sales_team.group_sale_salesman_all_leads").write( + { + "implied_ids": [ + (6, 0, [env.ref("sales_team.group_sale_salesman").id]), + ], + } + ) + # At installation time, we need to sync followers + with api.Environment.manage(): + env = api.Environment(cr, SUPERUSER_ID, {}) + partners = env["res.partner"].search( + [ + ("parent_id", "=", False), + ("is_company", "=", True), + "|", + ("user_id", "!=", False), + ("child_ids.user_id", "!=", False), + ] + ) + partners._add_followers_from_salesmans() diff --git a/sales_team_security/i18n/es.po b/sales_team_security/i18n/es.po new file mode 100644 index 00000000..8dbbccfe --- /dev/null +++ b/sales_team_security/i18n/es.po @@ -0,0 +1,69 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sales_team_security +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2022-06-28 21:00+0000\n" +"PO-Revision-Date: 2022-06-28 21:00+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: sales_team_security +#: model:ir.model,name:sales_team_security.model_res_partner +msgid "Contact" +msgstr "Contacto" + +#. module: sales_team_security +#: model:ir.model.fields,help:sales_team_security.field_res_partner__team_id +#: model:ir.model.fields,help:sales_team_security.field_res_users__team_id +msgid "" +"If set, this Sales Team will be used for sales and assignments related to " +"this partner" +msgstr "" +"Si está configurado, este equipo de ventas será usado para las ventas y " +"asignaciones relacionadas a este partner." + +#. module: sales_team_security +#: model:ir.model,name:sales_team_security.model_ir_rule +msgid "Record Rule" +msgstr "Regla de registro" + +#. module: sales_team_security +#: model:ir.model.fields,field_description:sales_team_security.field_res_partner__team_id +#: model:ir.model.fields,field_description:sales_team_security.field_res_users__team_id +msgid "Sales Team" +msgstr "Equipo de ventas" + +#. module: sales_team_security +#: model:ir.model.fields,field_description:sales_team_security.field_res_partner__user_id +#: model:ir.model.fields,field_description:sales_team_security.field_res_users__user_id +msgid "Salesperson" +msgstr "Comercial" + +#. module: sales_team_security +#: model:ir.model.fields,help:sales_team_security.field_res_partner__user_id +#: model:ir.model.fields,help:sales_team_security.field_res_users__user_id +msgid "The internal user in charge of this contact." +msgstr "El usuario interno a cargo de este contacto." + +#. module: sales_team_security +#: model:res.groups,comment:sales_team_security.group_sale_team_manager +msgid "" +"The user will have an access to the documents of the sales teams he/she " +"belongs to." +msgstr "" +"El usuario tendrá acceso a los documentos de los equipos comerciales a los " +"que pertenece." + +#. module: sales_team_security +#: model:res.groups,name:sales_team_security.group_sale_team_manager +msgid "User: Team Documents Only" +msgstr "Usuario: Solo documentos del equipo" diff --git a/sales_team_security/i18n/it.po b/sales_team_security/i18n/it.po new file mode 100644 index 00000000..8ff77d64 --- /dev/null +++ b/sales_team_security/i18n/it.po @@ -0,0 +1,69 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sales_team_security +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2022-06-28 21:01+0000\n" +"PO-Revision-Date: 2023-12-12 11:01+0000\n" +"Last-Translator: mymage \n" +"Language-Team: \n" +"Language: it\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" +"X-Generator: Weblate 4.17\n" + +#. module: sales_team_security +#: model:ir.model,name:sales_team_security.model_res_partner +msgid "Contact" +msgstr "Contatto" + +#. module: sales_team_security +#: model:ir.model.fields,help:sales_team_security.field_res_partner__team_id +#: model:ir.model.fields,help:sales_team_security.field_res_users__team_id +msgid "" +"If set, this Sales Team will be used for sales and assignments related to " +"this partner" +msgstr "" +"Se impostato, il team di vendita viene utilizzato per vendite e assegnazioni " +"correlate al partner" + +#. module: sales_team_security +#: model:ir.model,name:sales_team_security.model_ir_rule +msgid "Record Rule" +msgstr "Regola su record" + +#. module: sales_team_security +#: model:ir.model.fields,field_description:sales_team_security.field_res_partner__team_id +#: model:ir.model.fields,field_description:sales_team_security.field_res_users__team_id +msgid "Sales Team" +msgstr "Team di vendita" + +#. module: sales_team_security +#: model:ir.model.fields,field_description:sales_team_security.field_res_partner__user_id +#: model:ir.model.fields,field_description:sales_team_security.field_res_users__user_id +msgid "Salesperson" +msgstr "Addetto vendite" + +#. module: sales_team_security +#: model:ir.model.fields,help:sales_team_security.field_res_partner__user_id +#: model:ir.model.fields,help:sales_team_security.field_res_users__user_id +msgid "The internal user in charge of this contact." +msgstr "L'utente interno responsabile di questo contatto." + +#. module: sales_team_security +#: model:res.groups,comment:sales_team_security.group_sale_team_manager +msgid "" +"The user will have an access to the documents of the sales teams he/she " +"belongs to." +msgstr "" +"L'utente avrà accesso ai documenti del team di vendita a cui appartiene." + +#. module: sales_team_security +#: model:res.groups,name:sales_team_security.group_sale_team_manager +msgid "User: Team Documents Only" +msgstr "Utente: solo documenti del team" diff --git a/sales_team_security/i18n/sales_team_security.pot b/sales_team_security/i18n/sales_team_security.pot new file mode 100644 index 00000000..2c927dba --- /dev/null +++ b/sales_team_security/i18n/sales_team_security.pot @@ -0,0 +1,62 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sales_team_security +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.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: sales_team_security +#: model:ir.model,name:sales_team_security.model_res_partner +msgid "Contact" +msgstr "" + +#. module: sales_team_security +#: model:ir.model.fields,help:sales_team_security.field_res_partner__team_id +#: model:ir.model.fields,help:sales_team_security.field_res_users__team_id +msgid "" +"If set, this Sales Team will be used for sales and assignments related to " +"this partner" +msgstr "" + +#. module: sales_team_security +#: model:ir.model,name:sales_team_security.model_ir_rule +msgid "Record Rule" +msgstr "" + +#. module: sales_team_security +#: model:ir.model.fields,field_description:sales_team_security.field_res_partner__team_id +#: model:ir.model.fields,field_description:sales_team_security.field_res_users__team_id +msgid "Sales Team" +msgstr "" + +#. module: sales_team_security +#: model:ir.model.fields,field_description:sales_team_security.field_res_partner__user_id +#: model:ir.model.fields,field_description:sales_team_security.field_res_users__user_id +msgid "Salesperson" +msgstr "" + +#. module: sales_team_security +#: model:ir.model.fields,help:sales_team_security.field_res_partner__user_id +#: model:ir.model.fields,help:sales_team_security.field_res_users__user_id +msgid "The internal user in charge of this contact." +msgstr "" + +#. module: sales_team_security +#: model:res.groups,comment:sales_team_security.group_sale_team_manager +msgid "" +"The user will have an access to the documents of the sales teams he/she " +"belongs to." +msgstr "" + +#. module: sales_team_security +#: model:res.groups,name:sales_team_security.group_sale_team_manager +msgid "User: Team Documents Only" +msgstr "" diff --git a/sales_team_security/models/__init__.py b/sales_team_security/models/__init__.py new file mode 100644 index 00000000..eb10d8b1 --- /dev/null +++ b/sales_team_security/models/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from . import ir_rule +from . import res_partner diff --git a/sales_team_security/models/ir_rule.py b/sales_team_security/models/ir_rule.py new file mode 100644 index 00000000..2644158c --- /dev/null +++ b/sales_team_security/models/ir_rule.py @@ -0,0 +1,58 @@ +# Copyright 2020 Tecnativa - Pedro M. Baeza +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from odoo import api, models, tools +from odoo.osv import expression +from odoo.tools import config + + +class IrRule(models.Model): + _inherit = "ir.rule" + + @api.model + @tools.conditional( + "xml" not in config["dev_mode"], + tools.ormcache( + "self.env.uid", + "self.env.su", + "model_name", + "mode", + "tuple(self._compute_domain_context_values())", + ), + ) + def _compute_domain(self, model_name, mode="read"): + """Inject extra domain for restricting partners when the user + has the group 'Sales / User: Own Documents Only'. + """ + res = super()._compute_domain(model_name, mode=mode) + user = self.env.user + group1 = "sales_team.group_sale_salesman" + group2 = "sales_team_security.group_sale_team_manager" + group3 = "sales_team.group_sale_salesman_all_leads" + if model_name == "res.partner" and not self.env.su: + if user.has_group(group1) and not user.has_group(group3): + extra_domain = [ + "|", + ("message_partner_ids", "in", user.partner_id.ids), + "|", + ("id", "=", user.partner_id.id), + ] + if user.has_group(group2): + extra_domain += [ + "|", + ("team_id", "=", user.sale_team_id.id), + ("team_id", "=", False), + ] + else: + extra_domain += [ + "|", + ("user_id", "=", user.id), + "&", + ("user_id", "=", False), + "|", + ("team_id", "=", False), + ("team_id", "=", user.sale_team_id.id), + ] + extra_domain = expression.normalize_domain(extra_domain) + res = expression.AND([extra_domain] + [res]) + return res diff --git a/sales_team_security/models/res_partner.py b/sales_team_security/models/res_partner.py new file mode 100644 index 00000000..a3fb68a6 --- /dev/null +++ b/sales_team_security/models/res_partner.py @@ -0,0 +1,94 @@ +# Copyright 2016-2018 Tecnativa - Pedro M. Baeza +# Copyright 2021 Tecnativa - Víctor Martínez +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from lxml import etree + +from odoo import api, fields, models + + +class ResPartner(models.Model): + _inherit = "res.partner" + + # add indexes for better performance on record rules + user_id = fields.Many2one(index=True) + team_id = fields.Many2one(index=True) + + @api.model + def get_view(self, view_id=None, view_type="form", **options): + """ + Patch view to inject the default value for the team_id and user_id. + """ + # FIXME: Use base_view_inheritance_extension when available + res = super().get_view(view_id, view_type, **options) + if view_type == "form": + eview = etree.fromstring(res["arch"]) + xml_fields = eview.xpath("//field[@name='child_ids']") + if xml_fields: + context_str = ( + xml_fields[0] + .get("context", "{}") + .replace( + "{", + "{'default_team_id': team_id, 'default_user_id': user_id,", + 1, + ) + ) + xml_fields[0].set("context", context_str) + res["arch"] = etree.tostring(eview) + return res + + @api.onchange("parent_id") + def _onchange_parent_id_sales_team_security(self): + """If assigning a parent partner and the contact doesn't have + team or salesman, we put the parent's one (if any). + """ + if self.parent_id and self.parent_id.team_id and not self.team_id: + self.team_id = self.parent_id.team_id.id + if self.parent_id and self.parent_id.user_id and not self.user_id: + self.user_id = self.parent_id.user_id.id + + @api.onchange("user_id") + def _onchange_user_id_sales_team_security(self): + if self.user_id.sale_team_id: + self.team_id = self.user_id.sale_team_id + + def _remove_key_followers(self, partner): + for record in self.mapped("commercial_partner_id"): + # Look for delivery and invoice addresses + childrens = record.child_ids.filtered( + lambda x: x.type in {"invoice", "delivery"} + ) + (childrens + record).message_unsubscribe(partner_ids=partner.ids) + + def _add_followers_from_salesmans(self): + """Sync followers in commercial partner + delivery/invoice contacts.""" + for record in self.mapped("commercial_partner_id"): + followers = (record.child_ids + record).mapped("user_id.partner_id") + # Look for delivery and invoice addresses + childrens = record.child_ids.filtered( + lambda x: x.type in {"invoice", "delivery"} + ) + (childrens + record).message_subscribe(partner_ids=followers.ids) + + @api.model_create_multi + def create(self, vals_list): + """Sync followers on contact creation.""" + records = super().create(vals_list) + records._add_followers_from_salesmans() + return records + + def write(self, vals): + """If the salesman is changed, first remove the old salesman as follower + of the key contacts (commercial + delivery/invoice), and then sync for + the new ones. + + It performs as well the followers sync on contact type change. + """ + if "user_id" in vals: + for record in self.filtered("user_id"): + record._remove_key_followers(record.user_id.partner_id) + result = super().write(vals) + if "user_id" in vals or vals.get("type") in {"invoice", "delivery"}: + self._add_followers_from_salesmans() + return result diff --git a/sales_team_security/readme/CONFIGURE.rst b/sales_team_security/readme/CONFIGURE.rst new file mode 100644 index 00000000..eb17eca5 --- /dev/null +++ b/sales_team_security/readme/CONFIGURE.rst @@ -0,0 +1,3 @@ +#. Go to *Configuration > Users & Companies > Users*. +#. Open or create a user. +#. On the section "Sale", select "User: Team documents". diff --git a/sales_team_security/readme/CONTRIBUTORS.rst b/sales_team_security/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..8077b7f7 --- /dev/null +++ b/sales_team_security/readme/CONTRIBUTORS.rst @@ -0,0 +1,15 @@ +* `Tecnativa `__: + + * Pedro M. Baeza + * Víctor Martínez + * César A. Sánchez + +* `Guadaltech `__: + + * Ramón Bajona + +* Iván Todorovich + +* `Pesol `__: + + * Jonathan Oscategui Taza diff --git a/sales_team_security/readme/DESCRIPTION.rst b/sales_team_security/readme/DESCRIPTION.rst new file mode 100644 index 00000000..72f44aae --- /dev/null +++ b/sales_team_security/readme/DESCRIPTION.rst @@ -0,0 +1,30 @@ +This module adds a new "Sale" group called "User: Team documents", that +includes the proper permissions for showing only the information related to +that user sale team (having assigned that team/channel or no team at all, +independently from the assigned salesman): + +* Contacts. +* Quotations/Sales Orders (implemented in sales_team_security_sale) +* Leads/Opportunities (implemented in sales_team_security_crm) + +It also handles the propagation of the sales team from commercial partners to +the contacts, which standard doesn't do. + +It also handles the sync (auto-creation and remove) of followers in company partners +and childs of them according to salesmans. Any example about it: +- Partner company > Salesman: Admin +- Partner company, Contact 1 > Without salesman +- Partner company, Contact 2 > Salesman: Demo +All these partners have these followers: Admin + Demo + +And finally, there are rules for partners to be restricted to the own ones for +the group "User: Own Documents Only" for being coherent with the permission +scheme. Someone with this permission will see: + +- Contacts without salesman nor team assigned. +- Contacts without salesman assigned, but the same team. +- Contacts with them as salesman, independently from the team. +- Contacts with them as follower. + +For keeping consistent accesses, followers of the main and shipping/invoice +contacts are synced according the salesman of the children contacts diff --git a/sales_team_security/readme/INSTALL.rst b/sales_team_security/readme/INSTALL.rst new file mode 100644 index 00000000..113b9671 --- /dev/null +++ b/sales_team_security/readme/INSTALL.rst @@ -0,0 +1,4 @@ +At installation time, this module sets in all the contacts that have the sales +team empty the sales team of the parent, and sync followers in parent contacts +and invoice/shipping addresses. If you have a lot of contacts, this +operation can take a while. diff --git a/sales_team_security/readme/ROADMAP.rst b/sales_team_security/readme/ROADMAP.rst new file mode 100644 index 00000000..3f40e5bd --- /dev/null +++ b/sales_team_security/readme/ROADMAP.rst @@ -0,0 +1,2 @@ +* This module modifies sales security groups hierarchy, so any other module + doing something similar might conflict with this one. diff --git a/sales_team_security/security/sales_team_security.xml b/sales_team_security/security/sales_team_security.xml new file mode 100644 index 00000000..01d532a4 --- /dev/null +++ b/sales_team_security/security/sales_team_security.xml @@ -0,0 +1,17 @@ + + + + + User: Team Documents Only + The user will have an access to the documents of the sales teams he/she belongs to. + + + + + + + + + diff --git a/sales_team_security/static/description/icon.png b/sales_team_security/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..3a0328b516c4980e8e44cdb63fd945757ddd132d GIT binary patch literal 9455 zcmW++2RxMjAAjx~&dlBk9S+%}OXg)AGE&Cb*&}d0jUxM@u(PQx^-s)697TX`ehR4?GS^qbkof1cslKgkU)h65qZ9Oc=ml_0temigYLJfnz{IDzUf>bGs4N!v3=Z3jMq&A#7%rM5eQ#dc?k~! zVpnB`o+K7|Al`Q_U;eD$B zfJtP*jH`siUq~{KE)`jP2|#TUEFGRryE2`i0**z#*^6~AI|YzIWy$Cu#CSLW3q=GA z6`?GZymC;dCPk~rBS%eCb`5OLr;RUZ;D`}um=H)BfVIq%7VhiMr)_#G0N#zrNH|__ zc+blN2UAB0=617@>_u;MPHN;P;N#YoE=)R#i$k_`UAA>WWCcEVMh~L_ zj--gtp&|K1#58Yz*AHCTMziU1Jzt_jG0I@qAOHsk$2}yTmVkBp_eHuY$A9)>P6o~I z%aQ?!(GqeQ-Y+b0I(m9pwgi(IIZZzsbMv+9w{PFtd_<_(LA~0H(xz{=FhLB@(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y_H7G22M~ApVFTRHMI_3be)Lkn#0F*V8Pq zc}`Cjy$bE;FJ6H7p=0y#R>`}-m4(0F>%@P|?7fx{=R^uFdISRnZ2W_xQhD{YuR3t< z{6yxu=4~JkeA;|(J6_nv#>Nvs&FuLA&PW^he@t(UwFFE8)|a!R{`E`K`i^ZnyE4$k z;(749Ix|oi$c3QbEJ3b~D_kQsPz~fIUKym($a_7dJ?o+40*OLl^{=&oq$<#Q(yyrp z{J-FAniyAw9tPbe&IhQ|a`DqFTVQGQ&Gq3!C2==4x{6EJwiPZ8zub-iXoUtkJiG{} zPaR&}_fn8_z~(=;5lD-aPWD3z8PZS@AaUiomF!G8I}Mf>e~0g#BelA-5#`cj;O5>N Xviia!U7SGha1wx#SCgwmn*{w2TRX*I literal 0 HcmV?d00001 diff --git a/sales_team_security/static/description/index.html b/sales_team_security/static/description/index.html new file mode 100644 index 00000000..71306a99 --- /dev/null +++ b/sales_team_security/static/description/index.html @@ -0,0 +1,489 @@ + + + + + + +Sales documents permissions by channels (teams) + + + +
+

Sales documents permissions by channels (teams)

+ + +

Production/Stable License: AGPL-3 OCA/sale-workflow Translate me on Weblate Try me on Runboat

+

This module adds a new “Sale” group called “User: Team documents”, that +includes the proper permissions for showing only the information related to +that user sale team (having assigned that team/channel or no team at all, +independently from the assigned salesman):

+
    +
  • Contacts.
  • +
  • Quotations/Sales Orders (implemented in sales_team_security_sale)
  • +
  • Leads/Opportunities (implemented in sales_team_security_crm)
  • +
+

It also handles the propagation of the sales team from commercial partners to +the contacts, which standard doesn’t do.

+

It also handles the sync (auto-creation and remove) of followers in company partners +and childs of them according to salesmans. Any example about it: +- Partner company > Salesman: Admin +- Partner company, Contact 1 > Without salesman +- Partner company, Contact 2 > Salesman: Demo +All these partners have these followers: Admin + Demo

+

And finally, there are rules for partners to be restricted to the own ones for +the group “User: Own Documents Only” for being coherent with the permission +scheme. Someone with this permission will see:

+
    +
  • Contacts without salesman nor team assigned.
  • +
  • Contacts without salesman assigned, but the same team.
  • +
  • Contacts with them as salesman, independently from the team.
  • +
  • Contacts with them as follower.
  • +
+

For keeping consistent accesses, followers of the main and shipping/invoice +contacts are synced according the salesman of the children contacts

+

Table of contents

+ +
+

Installation

+

At installation time, this module sets in all the contacts that have the sales +team empty the sales team of the parent, and sync followers in parent contacts +and invoice/shipping addresses. If you have a lot of contacts, this +operation can take a while.

+
+
+

Configuration

+
    +
  1. Go to Configuration > Users & Companies > Users.
  2. +
  3. Open or create a user.
  4. +
  5. On the section “Sale”, select “User: Team documents”.
  6. +
+
+
+

Known issues / Roadmap

+
    +
  • This module modifies sales security groups hierarchy, so any other module +doing something similar might conflict with this one.
  • +
+
+
+

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

+
    +
  • Tecnativa
  • +
+
+
+

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.

+

Current maintainers:

+

pedrobaeza ivantodorovich

+

This module is part of the OCA/sale-workflow project on GitHub.

+

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

+
+
+
+ + diff --git a/sales_team_security/tests/__init__.py b/sales_team_security/tests/__init__.py new file mode 100644 index 00000000..9430eda6 --- /dev/null +++ b/sales_team_security/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import test_sales_team_security diff --git a/sales_team_security/tests/common.py b/sales_team_security/tests/common.py new file mode 100644 index 00000000..70aab444 --- /dev/null +++ b/sales_team_security/tests/common.py @@ -0,0 +1,125 @@ +# Copyright 2016-2020 Tecnativa - Pedro M. Baeza +# Copyright 2021 Tecnativa - Víctor Martínez +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from odoo.tests import common + + +class TestCommon(common.TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.team = cls.env["crm.team"].create({"name": "Test channel"}) + cls.team2 = cls.env["crm.team"].create({"name": "Test channel 2"}) + cls.user = cls.env["res.users"].create( + { + "login": "sales_team_security", + "name": "Test sales_team_security user", + "groups_id": [(4, cls.env.ref("sales_team.group_sale_salesman").id)], + } + ) + cls.crm_team_member = cls.env["crm.team.member"].create( + { + "user_id": cls.user.id, + "crm_team_id": cls.team.id, + } + ) + cls.partner = cls.env["res.partner"].create( + {"name": "Test partner", "team_id": cls.team.id} + ) + cls.partner_child_1 = cls.env["res.partner"].create( + {"name": "Child 1", "parent_id": cls.partner.id} + ) + cls.partner_child_2 = cls.env["res.partner"].create( + {"name": "Child 2", "parent_id": cls.partner.id, "type": "invoice"} + ) + cls.partner2 = cls.env["res.partner"].create( + {"name": "Test partner 2", "user_id": cls.user.id} + ) + cls.user2 = cls.env["res.users"].create( + { + "login": "sales_team_security2", + "name": "Test sales_team_security user 2", + "groups_id": [(4, cls.env.ref("sales_team.group_sale_salesman").id)], + } + ) + cls.crm_team_member2 = cls.env["crm.team.member"].create( + { + "user_id": cls.user2.id, + "crm_team_id": cls.team.id, + } + ) + cls.check_permission_subscribe = False + + def _check_permission(self, salesman, team, expected): + self.record.write( + { + "user_id": salesman.id if salesman else salesman, + "team_id": team.id if team else team, + } + ) + domain = [("id", "=", self.record.id)] + if ( + self.check_permission_subscribe + ): # Force unsubscription for not interfering with real test + self.record.message_subscribe(partner_ids=self.user.partner_id.ids) + else: + self.record.message_unsubscribe(partner_ids=self.user.partner_id.ids) + obj = self.env[self.record._name].with_user(self.user) + self.assertEqual(bool(obj.search(domain)), expected) + + def _check_whole_permission_set(self, extra_checks=True): + self._check_permission(False, False, True) + self._check_permission(self.user, False, True) + self._check_permission(self.user2, False, False) + self._check_permission(False, self.team, True) + if extra_checks: + self._check_permission(False, self.team2, False) + self._check_permission(self.user, self.team, True) + self._check_permission(self.user, self.team2, True) + self._check_permission(self.user2, self.team2, False) + self._check_permission(self.user2, self.team, False) + # Add to group "Team manager" + self.user.groups_id = [ + (4, self.env.ref("sales_team_security.group_sale_team_manager").id) + ] + self._check_permission(False, False, True) + self._check_permission(self.user, False, True) + self._check_permission(self.user2, False, True) + self._check_permission(False, self.team, True) + if extra_checks: + self._check_permission(False, self.team2, False) + self._check_permission(self.user, self.team, True) + if self.record._name == "res.partner": + self.check_permission_subscribe = True + self._check_permission(self.user, self.team2, True) + self.check_permission_subscribe = False + else: + self._check_permission(self.user, self.team2, True) + self._check_permission(self.user2, self.team2, False) + self._check_permission(self.user2, self.team, True) + # Add to group "See all leads" + self.user.groups_id = [ + (4, self.env.ref("sales_team.group_sale_salesman_all_leads").id) + ] + self._check_permission(False, False, True) + self._check_permission(self.user, False, True) + self._check_permission(self.user2, False, True) + self._check_permission(False, self.team, True) + self._check_permission(False, self.team2, True) + self._check_permission(self.user, self.team, True) + self._check_permission(self.user, self.team2, True) + self._check_permission(self.user2, self.team2, True) + self._check_permission(self.user2, self.team, True) + # Regular internal user + if extra_checks: + self.user.groups_id = [(6, 0, [self.env.ref("base.group_user").id])] + self._check_permission(False, False, True) + self._check_permission(self.user, False, True) + self._check_permission(self.user2, False, True) + self._check_permission(False, self.team, True) + self._check_permission(False, self.team2, True) + self._check_permission(self.user, self.team, True) + self._check_permission(self.user, self.team2, True) + self._check_permission(self.user2, self.team2, True) + self._check_permission(self.user2, self.team, True) diff --git a/sales_team_security/tests/test_sales_team_security.py b/sales_team_security/tests/test_sales_team_security.py new file mode 100644 index 00000000..63dd2a6e --- /dev/null +++ b/sales_team_security/tests/test_sales_team_security.py @@ -0,0 +1,95 @@ +# Copyright 2016-2020 Tecnativa - Pedro M. Baeza +# Copyright 2021 Tecnativa - Víctor Martínez +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from lxml import etree + +from ..hooks import post_init_hook +from .common import TestCommon + + +class TestSalesTeamSecurity(TestCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.user_partner = cls.user.partner_id + cls.user2_partner = cls.user2.partner_id + cls.record = cls.partner + + def test_onchange_parent_id(self): + contact = self.env["res.partner"].create( + {"name": "Test contact", "parent_id": self.partner.id} + ) + contact._onchange_parent_id_sales_team_security() + self.assertEqual(contact.team_id, self.team) + + contact2 = self.env["res.partner"].create( + {"name": "Test contact", "parent_id": self.partner2.id} + ) + contact2._onchange_parent_id_sales_team_security() + self.assertEqual(contact2.user_id, self.user) + + def test_onchange_user_id(self): + contact = self.env["res.partner"].create( + { + "name": "Test contact", + "user_id": self.user.id, + } + ) + contact._onchange_user_id_sales_team_security() + self.assertEqual(contact.team_id, self.team) + + def test_assign_contacts_team(self): + contact = self.env["res.partner"].create( + {"name": "Test contact", "parent_id": self.partner.id, "team_id": False} + ) + post_init_hook(self.env.cr, self.env.registry) + contact.env.invalidate_all() + self.assertEqual(contact.team_id, self.partner.team_id) + + def test_change_user_id_partner(self): + self.partner.write({"user_id": self.user.id}) + self.assertIn(self.user_partner, self.partner.message_partner_ids) + self.assertNotIn(self.user_partner, self.partner_child_1.message_partner_ids) + self.assertIn(self.user_partner, self.partner_child_2.message_partner_ids) + # Change salesman + self.partner.write({"user_id": self.user2.id}) + self.assertNotIn(self.user_partner, self.partner.message_partner_ids) + self.assertIn(self.user2_partner, self.partner.message_partner_ids) + self.assertNotIn(self.user_partner, self.partner_child_2.message_partner_ids) + self.assertIn(self.user2_partner, self.partner_child_2.message_partner_ids) + + def test_change_user_id_partner_child_1(self): + self.partner_child_1.write({"user_id": self.user.id}) + self.assertIn(self.user_partner, self.partner.message_partner_ids) + self.assertIn(self.user_partner, self.partner_child_2.message_partner_ids) + # Change salesman + self.partner_child_1.write({"user_id": self.user2.id}) + self.assertNotIn(self.user_partner, self.partner.message_partner_ids) + self.assertIn(self.user2_partner, self.partner.message_partner_ids) + self.assertNotIn(self.user_partner, self.partner_child_2.message_partner_ids) + self.assertIn(self.user2_partner, self.partner_child_2.message_partner_ids) + + def test_partner_fields_view_get(self): + res = self.env["res.partner"].get_view( + view_id=self.ref("base.view_partner_form") + ) + eview = etree.fromstring(res["arch"]) + xml_fields = eview.xpath("//field[@name='child_ids']") + self.assertTrue(xml_fields) + self.assertTrue("default_team_id" in xml_fields[0].get("context", "")) + + def test_partner_permissions(self): + self._check_whole_permission_set() + + def test_partner_permissions_subscription(self): + self.check_permission_subscribe = True + self._check_permission(self.user2, False, True) + + def test_partner_permissions_own_partner(self): + self.user.partner_id.write({"user_id": self.user2.id}) + domain = [("id", "in", self.user.partner_id.ids)] + Partner = self.env["res.partner"].with_user(self.user) + # Make sure the acces is not due to the subscription + self.partner.message_unsubscribe(partner_ids=self.user.partner_id.ids) + self.assertEqual(bool(Partner.search(domain)), True) diff --git a/sales_team_security/views/res_partner_view.xml b/sales_team_security/views/res_partner_view.xml new file mode 100644 index 00000000..1b70930c --- /dev/null +++ b/sales_team_security/views/res_partner_view.xml @@ -0,0 +1,14 @@ + + + + Partner form (with sales info in contacts) + res.partner + + + + + + + + + diff --git a/setup/sales_team_security/odoo/addons/sales_team_security b/setup/sales_team_security/odoo/addons/sales_team_security new file mode 120000 index 00000000..00ab9e3e --- /dev/null +++ b/setup/sales_team_security/odoo/addons/sales_team_security @@ -0,0 +1 @@ +../../../../sales_team_security \ No newline at end of file diff --git a/setup/sales_team_security/setup.py b/setup/sales_team_security/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/sales_team_security/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) From d389e6025ed01eb6e7c160b5625ad1272dd8edec Mon Sep 17 00:00:00 2001 From: Aungkokolin1997 Date: Thu, 28 Mar 2024 07:58:34 +0000 Subject: [PATCH 02/11] adj --- stock_picking_line_sequence/tests/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stock_picking_line_sequence/tests/__init__.py b/stock_picking_line_sequence/tests/__init__.py index 63659fda..ecabc34e 100644 --- a/stock_picking_line_sequence/tests/__init__.py +++ b/stock_picking_line_sequence/tests/__init__.py @@ -1,3 +1,3 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from . import test_move_lines_sequence +# from . import test_move_lines_sequence From 30721f5a86bc09e28cdaf81c45a31269e91abe80 Mon Sep 17 00:00:00 2001 From: Aungkokolin1997 Date: Fri, 29 Mar 2024 02:52:42 +0000 Subject: [PATCH 03/11] adj --- stock_picking_line_sequence/models/stock.py | 30 ++++++++++--------- stock_picking_line_sequence/tests/__init__.py | 2 +- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/stock_picking_line_sequence/models/stock.py b/stock_picking_line_sequence/models/stock.py index c610b046..2af17a50 100644 --- a/stock_picking_line_sequence/models/stock.py +++ b/stock_picking_line_sequence/models/stock.py @@ -34,25 +34,27 @@ def create(self, values): class StockMoveLine(models.Model): _inherit = "stock.move.line" - def _get_aggregated_product_quantities(self, **kwargs): - def get_aggregated_properties(move_line=False, move=False): - move = move or move_line.move_id - uom = move.product_uom or move_line.product_uom_id - name = move.product_id.display_name - description = move.description_picking - if description == name or description == move.product_id.name: - description = False - product = move.product_id - line_key = ( - f"{product.id}_{product.display_name}_" f'{description or ""}_{uom.id}' - ) - return line_key + def _get_aggregated_properties(self, move_line=False, move=False): + aggregated_properties = super()._get_aggregated_properties(move_line, move) + move = move or move_line.move_id + uom = move.product_uom or move_line.product_uom_id + name = move.product_id.display_name + description = move.description_picking + if description == name or description == move.product_id.name: + description = False + product = move.product_id + line_key = ( + f"{product.id}_{product.display_name}_" f'{description or ""}_{uom.id}' + ) + aggregated_properties["line_key"] = line_key + return aggregated_properties + def _get_aggregated_product_quantities(self, **kwargs): aggregated_move_lines = super( StockMoveLine, self )._get_aggregated_product_quantities(**kwargs) for move_line in self: - line_key = get_aggregated_properties(move_line=move_line) + line_key = self._get_aggregated_properties(move_line=move_line)["line_key"] sequence2 = move_line.move_id.sequence2 if line_key in aggregated_move_lines: aggregated_move_lines[line_key]["sequence2"] = sequence2 diff --git a/stock_picking_line_sequence/tests/__init__.py b/stock_picking_line_sequence/tests/__init__.py index ecabc34e..63659fda 100644 --- a/stock_picking_line_sequence/tests/__init__.py +++ b/stock_picking_line_sequence/tests/__init__.py @@ -1,3 +1,3 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -# from . import test_move_lines_sequence +from . import test_move_lines_sequence From 93e18dd077c1eaa6f168af8cfd4540f9c0e960e9 Mon Sep 17 00:00:00 2001 From: Aungkokolin1997 Date: Fri, 29 Mar 2024 09:16:03 +0000 Subject: [PATCH 04/11] upd --- .github/workflows/test.yml | 4 +-- stock_picking_line_sequence/models/stock.py | 30 ++++++++++----------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5d6f11de..d1514978 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -36,11 +36,11 @@ jobs: matrix: include: - container: ghcr.io/oca/oca-ci/py3.10-ocb16.0:latest - include: "stock_owner_restriction,mrp_stock_owner_restriction,purchase_order_owner,mrp_subcontracting_owner" + include: "stock_owner_restriction,mrp_stock_owner_restriction,purchase_order_owner,mrp_subcontracting_owner,auditlog" name: test with OCB makepot: "false" - container: ghcr.io/oca/oca-ci/py3.10-ocb16.0:latest - exclude: "stock_owner_restriction,mrp_stock_owner_restriction,purchase_order_owner,mrp_subcontracting_owner" + exclude: "stock_owner_restriction,mrp_stock_owner_restriction,purchase_order_owner,mrp_subcontracting_owner,auditlog" name: test with OCB makepot: "false" services: diff --git a/stock_picking_line_sequence/models/stock.py b/stock_picking_line_sequence/models/stock.py index 2af17a50..c610b046 100644 --- a/stock_picking_line_sequence/models/stock.py +++ b/stock_picking_line_sequence/models/stock.py @@ -34,27 +34,25 @@ def create(self, values): class StockMoveLine(models.Model): _inherit = "stock.move.line" - def _get_aggregated_properties(self, move_line=False, move=False): - aggregated_properties = super()._get_aggregated_properties(move_line, move) - move = move or move_line.move_id - uom = move.product_uom or move_line.product_uom_id - name = move.product_id.display_name - description = move.description_picking - if description == name or description == move.product_id.name: - description = False - product = move.product_id - line_key = ( - f"{product.id}_{product.display_name}_" f'{description or ""}_{uom.id}' - ) - aggregated_properties["line_key"] = line_key - return aggregated_properties - def _get_aggregated_product_quantities(self, **kwargs): + def get_aggregated_properties(move_line=False, move=False): + move = move or move_line.move_id + uom = move.product_uom or move_line.product_uom_id + name = move.product_id.display_name + description = move.description_picking + if description == name or description == move.product_id.name: + description = False + product = move.product_id + line_key = ( + f"{product.id}_{product.display_name}_" f'{description or ""}_{uom.id}' + ) + return line_key + aggregated_move_lines = super( StockMoveLine, self )._get_aggregated_product_quantities(**kwargs) for move_line in self: - line_key = self._get_aggregated_properties(move_line=move_line)["line_key"] + line_key = get_aggregated_properties(move_line=move_line) sequence2 = move_line.move_id.sequence2 if line_key in aggregated_move_lines: aggregated_move_lines[line_key]["sequence2"] = sequence2 From 1b76bd44ad7a73597621543bc1e32f9ce4c54e38 Mon Sep 17 00:00:00 2001 From: Aungkokolin1997 Date: Fri, 29 Mar 2024 09:27:04 +0000 Subject: [PATCH 05/11] upd --- .github/workflows/test.yml | 4 +- auditlog/README.rst | 15 +- auditlog/__manifest__.py | 2 +- auditlog/i18n/es.po | 44 +++--- auditlog/i18n/es_AR.po | 4 +- auditlog/i18n/it.po | 119 ++++++++------- auditlog/models/rule.py | 19 +++ auditlog/static/description/index.html | 45 +++--- auditlog/tests/__init__.py | 1 + auditlog/tests/test_auditlog.py | 196 +++++++++++++++++++++---- auditlog/tests/test_multi_company.py | 115 +++++++++++++++ 11 files changed, 432 insertions(+), 132 deletions(-) create mode 100644 auditlog/tests/test_multi_company.py diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d1514978..5d6f11de 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -36,11 +36,11 @@ jobs: matrix: include: - container: ghcr.io/oca/oca-ci/py3.10-ocb16.0:latest - include: "stock_owner_restriction,mrp_stock_owner_restriction,purchase_order_owner,mrp_subcontracting_owner,auditlog" + include: "stock_owner_restriction,mrp_stock_owner_restriction,purchase_order_owner,mrp_subcontracting_owner" name: test with OCB makepot: "false" - container: ghcr.io/oca/oca-ci/py3.10-ocb16.0:latest - exclude: "stock_owner_restriction,mrp_stock_owner_restriction,purchase_order_owner,mrp_subcontracting_owner,auditlog" + exclude: "stock_owner_restriction,mrp_stock_owner_restriction,purchase_order_owner,mrp_subcontracting_owner" name: test with OCB makepot: "false" services: diff --git a/auditlog/README.rst b/auditlog/README.rst index 66125fa9..eedb1859 100644 --- a/auditlog/README.rst +++ b/auditlog/README.rst @@ -2,10 +2,13 @@ Audit Log ========= -.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:a36a2948051d9d51bd2cbf4139b57cde8de52b573c9c641864d17f9c86d1c2c4 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png :target: https://odoo-community.org/page/development-status @@ -19,11 +22,11 @@ Audit Log .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png :target: https://translation.odoo-community.org/projects/server-tools-16-0/server-tools-16-0-auditlog :alt: Translate me on Weblate -.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/149/16.0 - :alt: Try me on Runbot +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/server-tools&target_branch=16.0 + :alt: Try me on Runboat -|badge1| |badge2| |badge3| |badge4| |badge5| +|badge1| |badge2| |badge3| |badge4| |badge5| This module allows the administrator to log user operations performed on data models such as ``create``, ``read``, ``write`` and ``delete``. @@ -79,7 +82,7 @@ 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 smashing it by providing a detailed and welcomed +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. diff --git a/auditlog/__manifest__.py b/auditlog/__manifest__.py index 0918a2e7..acc65327 100644 --- a/auditlog/__manifest__.py +++ b/auditlog/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Audit Log", - "version": "16.0.2.0.1", + "version": "16.0.2.1.0", "author": "ABF OSIELL, Odoo Community Association (OCA)", "license": "AGPL-3", "website": "https://github.com/OCA/server-tools", diff --git a/auditlog/i18n/es.po b/auditlog/i18n/es.po index c810178a..d257ddce 100644 --- a/auditlog/i18n/es.po +++ b/auditlog/i18n/es.po @@ -10,15 +10,15 @@ msgstr "" "Project-Id-Version: Odoo Server 11.0\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2018-03-03 10:08+0000\n" -"PO-Revision-Date: 2018-07-14 08:45+0000\n" -"Last-Translator: Enric Tobella \n" +"PO-Revision-Date: 2023-09-03 00:14+0000\n" +"Last-Translator: Ivorra78 \n" "Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n" "Language: es\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" -"X-Generator: Weblate 3.0.1\n" +"X-Generator: Weblate 4.17\n" #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_rule__action_id @@ -64,17 +64,17 @@ msgstr "Auditlog - Regla" #. module: auditlog #: model:res.groups,name:auditlog.group_auditlog_manager msgid "Auditlog Manager" -msgstr "" +msgstr "Gerente de registros de auditoría" #. module: auditlog #: model:ir.module.category,name:auditlog.security_auditlog_groups msgid "Auditlog Rights" -msgstr "" +msgstr "Derechos de auditoría" #. module: auditlog #: model:res.groups,name:auditlog.group_auditlog_user msgid "Auditlog User" -msgstr "" +msgstr "Usuario de registro de auditoría" #. module: auditlog #: model:ir.actions.server,name:auditlog.ir_cron_auditlog_autovacuum_ir_actions_server @@ -85,7 +85,7 @@ msgstr "Limpiar automáticamente los auditlogs" #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_rule__capture_record msgid "Capture Record" -msgstr "" +msgstr "Capturar registro" #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_http_request__user_context @@ -161,12 +161,12 @@ msgstr "Campo" #: code:addons/auditlog/models/rule.py:0 #, python-format msgid "Field 'model_id' cannot be empty." -msgstr "" +msgstr "El campo 'model_id' no puede estar vacío." #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_rule__fields_to_exclude_ids msgid "Fields to Exclude" -msgstr "" +msgstr "Campos a excluir" #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_log__line_ids @@ -297,7 +297,7 @@ msgstr "Borrar registros" #: model:ir.ui.menu,name:auditlog.menu_auditlog_line #: model_terms:ir.ui.view,arch_db:auditlog.view_auditlog_line_search msgid "Log Lines" -msgstr "" +msgstr "Líneas de registro" #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_rule__log_read @@ -336,14 +336,14 @@ msgstr "Modelo" #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_log_line_view__model_model msgid "Model Model" -msgstr "" +msgstr "Modelo Modelo" #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_log__model_name #: model:ir.model.fields,field_description:auditlog.field_auditlog_log_line_view__model_name #: model:ir.model.fields,field_description:auditlog.field_auditlog_rule__model_name msgid "Model Name" -msgstr "" +msgstr "Nombre del modelo" #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_http_request__display_name @@ -370,21 +370,21 @@ msgstr "Texto del valor nuevo" #: code:addons/auditlog/models/log.py:0 #, python-format msgid "No field defined to create line." -msgstr "" +msgstr "No se ha definido ningún campo para crear la línea." #. module: auditlog #. odoo-python #: code:addons/auditlog/models/rule.py:0 #, python-format msgid "No model defined to create line." -msgstr "" +msgstr "No hay modelo definido para crear la línea." #. module: auditlog #. odoo-python #: code:addons/auditlog/models/log.py:0 #, python-format msgid "No model defined to create log." -msgstr "" +msgstr "No se ha definido ningún modelo para crear el registro." #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_log_line__old_value @@ -407,7 +407,7 @@ msgstr "Ruta" #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_log_line_view__res_id msgid "Res" -msgstr "" +msgstr "Resolución" #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_log__res_id @@ -448,6 +448,8 @@ msgstr "Seleccione el modelo al que quiere generar un registro." #: model:ir.model.fields,help:auditlog.field_auditlog_rule__capture_record msgid "Select this if you want to keep track of Unlink Record" msgstr "" +"Seleccione esta opción si desea realizar un seguimiento del registro de " +"desvinculación" #. module: auditlog #: model:ir.model.fields,help:auditlog.field_auditlog_rule__log_create @@ -464,7 +466,7 @@ msgid "" "Select this if you want to keep track of deletion on any record of the model " "of this rule" msgstr "" -"Marque esta casilla si desea hacer un seguimiento del borrado de los " +"Marque esta casilla si desea hacer un seguimiento del borrado de los " "registros del modelo de esta regla" #. module: auditlog @@ -518,7 +520,7 @@ msgstr "Suscrito" #: model:ir.model.fields,field_description:auditlog.field_auditlog_log__model_model #: model:ir.model.fields,field_description:auditlog.field_auditlog_rule__model_model msgid "Technical Model Name" -msgstr "" +msgstr "Nombre técnico del modelo" #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_log_line__field_name @@ -531,14 +533,14 @@ msgstr "Nombre técnico" #: code:addons/auditlog/models/log.py:0 #, python-format msgid "The field 'field_id' cannot be empty." -msgstr "" +msgstr "El campo 'field_id' no puede estar vacío." #. module: auditlog #. odoo-python #: code:addons/auditlog/models/log.py:0 #, python-format msgid "The field 'model_id' cannot be empty." -msgstr "" +msgstr "El campo 'model_id' no puede estar vacío." #. module: auditlog #: model:ir.model.constraint,message:auditlog.constraint_auditlog_rule_model_uniq @@ -596,7 +598,7 @@ msgstr "Usuarios" #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_rule__users_to_exclude_ids msgid "Users to Exclude" -msgstr "" +msgstr "Usuarios a excluir" #. module: auditlog #: model_terms:ir.ui.view,arch_db:auditlog.view_auditlog_log_form diff --git a/auditlog/i18n/es_AR.po b/auditlog/i18n/es_AR.po index 4462b097..6f8c719e 100644 --- a/auditlog/i18n/es_AR.po +++ b/auditlog/i18n/es_AR.po @@ -11,8 +11,8 @@ msgstr "" "POT-Creation-Date: 2016-11-26 01:45+0000\n" "PO-Revision-Date: 2023-01-01 21:45+0000\n" "Last-Translator: Ignacio Buioli \n" -"Language-Team: Spanish (Argentina) (https://www.transifex.com/oca/teams/" -"23907/es_AR/)\n" +"Language-Team: Spanish (Argentina) (https://www.transifex.com/oca/" +"teams/23907/es_AR/)\n" "Language: es_AR\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" diff --git a/auditlog/i18n/it.po b/auditlog/i18n/it.po index e6df9599..1b63c80a 100644 --- a/auditlog/i18n/it.po +++ b/auditlog/i18n/it.po @@ -10,7 +10,7 @@ msgstr "" "Project-Id-Version: Odoo Server 9.0c\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2016-11-26 01:45+0000\n" -"PO-Revision-Date: 2023-06-07 15:49+0000\n" +"PO-Revision-Date: 2024-01-09 22:36+0000\n" "Last-Translator: mymage \n" "Language-Team: Italian (https://www.transifex.com/oca/teams/23907/it/)\n" "Language: it\n" @@ -28,64 +28,64 @@ msgstr "Azione" #. module: auditlog #: model:ir.ui.menu,name:auditlog.menu_audit msgid "Audit" -msgstr "" +msgstr "Audit" #. module: auditlog #: model:ir.model,name:auditlog.model_auditlog_autovacuum msgid "Auditlog - Delete old logs" -msgstr "" +msgstr "Log verifica - elimina vecchi log" #. module: auditlog #: model:ir.model,name:auditlog.model_auditlog_http_session msgid "Auditlog - HTTP User session log" -msgstr "" +msgstr "Log verifica - log sessione utente HTTP" #. module: auditlog #: model:ir.model,name:auditlog.model_auditlog_http_request msgid "Auditlog - HTTP request log" -msgstr "" +msgstr "Log verifica - log richiesta HTTP" #. module: auditlog #: model:ir.model,name:auditlog.model_auditlog_log msgid "Auditlog - Log" -msgstr "" +msgstr "Log verifica - log" #. module: auditlog #: model:ir.model,name:auditlog.model_auditlog_log_line #: model:ir.model,name:auditlog.model_auditlog_log_line_view msgid "Auditlog - Log details (fields updated)" -msgstr "" +msgstr "Log verifica - dettagli log (campi aggiornati)" #. module: auditlog #: model:ir.model,name:auditlog.model_auditlog_rule msgid "Auditlog - Rule" -msgstr "" +msgstr "Log verifica - regola" #. module: auditlog #: model:res.groups,name:auditlog.group_auditlog_manager msgid "Auditlog Manager" -msgstr "" +msgstr "Responsabile log verifica" #. module: auditlog #: model:ir.module.category,name:auditlog.security_auditlog_groups msgid "Auditlog Rights" -msgstr "" +msgstr "Autorizzazioni log verifica" #. module: auditlog #: model:res.groups,name:auditlog.group_auditlog_user msgid "Auditlog User" -msgstr "" +msgstr "Utente log verifica" #. module: auditlog #: model:ir.actions.server,name:auditlog.ir_cron_auditlog_autovacuum_ir_actions_server #: model:ir.cron,cron_name:auditlog.ir_cron_auditlog_autovacuum msgid "Auto-vacuum audit logs" -msgstr "" +msgstr "Svuota automaticamente log verifica" #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_rule__capture_record msgid "Capture Record" -msgstr "" +msgstr "Registra record" #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_http_request__user_context @@ -147,7 +147,7 @@ msgstr "Bozza" #: model:ir.model.fields.selection,name:auditlog.selection__auditlog_log__log_type__fast #: model:ir.model.fields.selection,name:auditlog.selection__auditlog_rule__log_type__fast msgid "Fast log" -msgstr "" +msgstr "Log rapido" #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_log_line__field_id @@ -161,12 +161,12 @@ msgstr "Campo" #: code:addons/auditlog/models/rule.py:0 #, python-format msgid "Field 'model_id' cannot be empty." -msgstr "" +msgstr "Il campo \"model_id\" non può essere vuoto." #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_rule__fields_to_exclude_ids msgid "Fields to Exclude" -msgstr "" +msgstr "Campi da escludere" #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_log__line_ids @@ -178,7 +178,7 @@ msgstr "Campi aggiornati" #: model:ir.model.fields.selection,name:auditlog.selection__auditlog_log__log_type__full #: model:ir.model.fields.selection,name:auditlog.selection__auditlog_rule__log_type__full msgid "Full log" -msgstr "" +msgstr "Log completo" #. module: auditlog #: model:ir.model.fields,help:auditlog.field_auditlog_rule__log_type @@ -188,6 +188,11 @@ msgid "" "Fast log: only log the changes made through the create and write operations " "(less information, but it is faster)" msgstr "" +"Log completo: verifica differenze tra i dati prima e dopo l'operazione (" +"registra più info come campi calcolati che sono stati aggiornati, ma è più " +"lento)\n" +"Log rapido: registra solo le modifiche fatte tramite le operazioni crea e " +"scrivi (meno info, ma più veloce)" #. module: auditlog #: model_terms:ir.ui.view,arch_db:auditlog.view_auditlog_http_request_search @@ -210,7 +215,7 @@ msgstr "Contesto HTTP" #: model_terms:ir.ui.view,arch_db:auditlog.view_auditlog_line_search #: model_terms:ir.ui.view,arch_db:auditlog.view_auditlog_log_search msgid "HTTP Request" -msgstr "" +msgstr "Richiesta HTTP" #. module: auditlog #: model:ir.actions.act_window,name:auditlog.action_auditlog_http_request_tree @@ -270,39 +275,39 @@ msgstr "Ultimo aggiornamento il" #: model:ir.model.fields,field_description:auditlog.field_auditlog_log_line_view__log_id #: model_terms:ir.ui.view,arch_db:auditlog.view_auditlog_log_form msgid "Log" -msgstr "" +msgstr "Log" #. module: auditlog #: model_terms:ir.ui.view,arch_db:auditlog.view_auditlog_log_form msgid "Log - Field updated" -msgstr "" +msgstr "Log - campo aggiornato" #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_rule__log_create msgid "Log Creates" -msgstr "" +msgstr "Log creazioni" #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_rule__log_unlink msgid "Log Deletes" -msgstr "" +msgstr "Log eliminazioni" #. module: auditlog #: model:ir.actions.act_window,name:auditlog.action_auditlog_line #: model:ir.ui.menu,name:auditlog.menu_auditlog_line #: model_terms:ir.ui.view,arch_db:auditlog.view_auditlog_line_search msgid "Log Lines" -msgstr "" +msgstr "Log righe" #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_rule__log_read msgid "Log Reads" -msgstr "" +msgstr "Log letture" #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_rule__log_write msgid "Log Writes" -msgstr "" +msgstr "Log scritture" #. module: auditlog #: model:ir.actions.act_window,name:auditlog.action_auditlog_log_tree @@ -311,7 +316,7 @@ msgstr "" #: model_terms:ir.ui.view,arch_db:auditlog.view_auditlog_http_request_form #: model_terms:ir.ui.view,arch_db:auditlog.view_auditlog_log_search msgid "Logs" -msgstr "" +msgstr "Log" #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_log__method @@ -331,14 +336,14 @@ msgstr "Modello" #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_log_line_view__model_model msgid "Model Model" -msgstr "" +msgstr "Model Model" #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_log__model_name #: model:ir.model.fields,field_description:auditlog.field_auditlog_log_line_view__model_name #: model:ir.model.fields,field_description:auditlog.field_auditlog_rule__model_name msgid "Model Name" -msgstr "" +msgstr "Nome modello" #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_http_request__display_name @@ -352,46 +357,46 @@ msgstr "Nome" #: model:ir.model.fields,field_description:auditlog.field_auditlog_log_line__new_value #: model:ir.model.fields,field_description:auditlog.field_auditlog_log_line_view__new_value msgid "New Value" -msgstr "" +msgstr "Nuovo valore" #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_log_line__new_value_text #: model:ir.model.fields,field_description:auditlog.field_auditlog_log_line_view__new_value_text msgid "New value Text" -msgstr "" +msgstr "Testo nuovo valore" #. module: auditlog #. odoo-python #: code:addons/auditlog/models/log.py:0 #, python-format msgid "No field defined to create line." -msgstr "" +msgstr "Nessun campo definito per creare una riga." #. module: auditlog #. odoo-python #: code:addons/auditlog/models/rule.py:0 #, python-format msgid "No model defined to create line." -msgstr "" +msgstr "Nessun modello definito per creare una riga." #. module: auditlog #. odoo-python #: code:addons/auditlog/models/log.py:0 #, python-format msgid "No model defined to create log." -msgstr "" +msgstr "Nessun modello definito per creare un log." #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_log_line__old_value #: model:ir.model.fields,field_description:auditlog.field_auditlog_log_line_view__old_value msgid "Old Value" -msgstr "" +msgstr "Vecchio valore" #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_log_line__old_value_text #: model:ir.model.fields,field_description:auditlog.field_auditlog_log_line_view__old_value_text msgid "Old value Text" -msgstr "" +msgstr "Testo vecchio valore" #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_http_request__name @@ -402,7 +407,7 @@ msgstr "Percorso" #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_log_line_view__res_id msgid "Res" -msgstr "" +msgstr "Res" #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_log__res_id @@ -414,35 +419,35 @@ msgstr "ID Risorsa" #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_log__name msgid "Resource Name" -msgstr "Nome della Risorsa" +msgstr "Nome risorsa" #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_http_request__root_url #: model_terms:ir.ui.view,arch_db:auditlog.view_auditlog_http_request_search msgid "Root URL" -msgstr "" +msgstr "URL root" #. module: auditlog #: model_terms:ir.ui.view,arch_db:auditlog.view_auditlog_rule_form msgid "Rule" -msgstr "" +msgstr "Regola" #. module: auditlog #: model:ir.actions.act_window,name:auditlog.action_auditlog_rule_tree #: model:ir.ui.menu,name:auditlog.menu_action_auditlog_rule_tree #: model_terms:ir.ui.view,arch_db:auditlog.view_auditlog_rule_search msgid "Rules" -msgstr "" +msgstr "Regole" #. module: auditlog #: model:ir.model.fields,help:auditlog.field_auditlog_rule__model_id msgid "Select model for which you want to generate log." -msgstr "" +msgstr "Seleziona modello per il quale vuoi generare un log." #. module: auditlog #: model:ir.model.fields,help:auditlog.field_auditlog_rule__capture_record msgid "Select this if you want to keep track of Unlink Record" -msgstr "" +msgstr "Seleziona se vuoi seguire \"scollega record\"" #. module: auditlog #: model:ir.model.fields,help:auditlog.field_auditlog_rule__log_create @@ -450,6 +455,8 @@ msgid "" "Select this if you want to keep track of creation on any record of the model " "of this rule" msgstr "" +"Seleziona se vuoi tenere traccia della creazione di qualsiasi record del " +"modello di questa regola" #. module: auditlog #: model:ir.model.fields,help:auditlog.field_auditlog_rule__log_unlink @@ -457,6 +464,8 @@ msgid "" "Select this if you want to keep track of deletion on any record of the model " "of this rule" msgstr "" +"Seleziona se vuoi tenere traccia dell'eliminazione di qualsiasi record del " +"modello di questa regola" #. module: auditlog #: model:ir.model.fields,help:auditlog.field_auditlog_rule__log_write @@ -464,6 +473,8 @@ msgid "" "Select this if you want to keep track of modification on any record of the " "model of this rule" msgstr "" +"Seleziona se vuoi tenere traccia della modifica di qualsiasi record del " +"modello di questa regola" #. module: auditlog #: model:ir.model.fields,help:auditlog.field_auditlog_rule__log_read @@ -471,6 +482,8 @@ msgid "" "Select this if you want to keep track of read/open on any record of the " "model of this rule" msgstr "" +"Seleziona se vuoi tenere traccia della lettura/apertura di qualsiasi record " +"del modello di questa regola" #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_http_request__http_session_id @@ -505,27 +518,27 @@ msgstr "Sottoscritto" #: model:ir.model.fields,field_description:auditlog.field_auditlog_log__model_model #: model:ir.model.fields,field_description:auditlog.field_auditlog_rule__model_model msgid "Technical Model Name" -msgstr "" +msgstr "Nome tecnico modello" #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_log_line__field_name #: model:ir.model.fields,field_description:auditlog.field_auditlog_log_line_view__field_name msgid "Technical name" -msgstr "" +msgstr "Nome tecnico" #. module: auditlog #. odoo-python #: code:addons/auditlog/models/log.py:0 #, python-format msgid "The field 'field_id' cannot be empty." -msgstr "" +msgstr "Il campo 'field_id' non può essere vuoto." #. module: auditlog #. odoo-python #: code:addons/auditlog/models/log.py:0 #, python-format msgid "The field 'model_id' cannot be empty." -msgstr "" +msgstr "Il campo 'model_id' non può essere vuoto." #. module: auditlog #: model:ir.model.constraint,message:auditlog.constraint_auditlog_rule_model_uniq @@ -533,6 +546,8 @@ msgid "" "There is already a rule defined on this model\n" "You cannot define another: please edit the existing one." msgstr "" +"Esiste già una regola definita per questo modello\n" +"Non puoi definirne un'altra; modifica quella esistente." #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_log__log_type @@ -544,7 +559,7 @@ msgstr "Tipo" #. module: auditlog #: model_terms:ir.ui.view,arch_db:auditlog.view_auditlog_rule_form msgid "Unsubscribe" -msgstr "" +msgstr "Disiscrivi" #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_http_request__user_id @@ -564,14 +579,14 @@ msgstr "Utente" #: model_terms:ir.ui.view,arch_db:auditlog.view_auditlog_line_search #: model_terms:ir.ui.view,arch_db:auditlog.view_auditlog_log_search msgid "User session" -msgstr "" +msgstr "Sessione utente" #. module: auditlog #: model:ir.actions.act_window,name:auditlog.action_auditlog_http_session_tree #: model:ir.ui.menu,name:auditlog.menu_action_auditlog_http_session_tree #: model_terms:ir.ui.view,arch_db:auditlog.view_auditlog_http_session_search msgid "User sessions" -msgstr "" +msgstr "Sessioni utente" #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_rule__user_ids @@ -581,7 +596,7 @@ msgstr "Utenti" #. module: auditlog #: model:ir.model.fields,field_description:auditlog.field_auditlog_rule__users_to_exclude_ids msgid "Users to Exclude" -msgstr "" +msgstr "Utenti da escludere" #. module: auditlog #: model_terms:ir.ui.view,arch_db:auditlog.view_auditlog_log_form @@ -593,9 +608,9 @@ msgstr "Valori" #: code:addons/auditlog/models/rule.py:0 #, python-format msgid "View logs" -msgstr "" +msgstr "Visualizza log" #. module: auditlog #: model:ir.model.fields,help:auditlog.field_auditlog_rule__user_ids msgid "if User is not added then it will applicable for all users" -msgstr "" +msgstr "se l'utente non è aggiunto, sarà applicabile per tutti gli utenti" diff --git a/auditlog/models/rule.py b/auditlog/models/rule.py index 1eb482de..5ed7f42a 100644 --- a/auditlog/models/rule.py +++ b/auditlog/models/rule.py @@ -311,6 +311,7 @@ def create_full(self, vals_list, **kwargs): def create_fast(self, vals_list, **kwargs): self = self.with_context(auditlog_disabled=True) rule_model = self.env["auditlog.rule"] + vals_list = rule_model._update_vals_list(vals_list) vals_list2 = copy.deepcopy(vals_list) new_records = create_fast.origin(self, vals_list, **kwargs) new_values = {} @@ -386,6 +387,12 @@ def write_full(self, vals, **kwargs): .with_context(prefetch_fields=False) .read(fields_list) } + # invalidate_recordset method must be called with existing fields + if self._name == "res.users": + vals = self._remove_reified_groups(vals) + # Prevent the cache of modified fields from being poisoned by + # x2many items inaccessible to the current user. + self.invalidate_recordset(vals.keys()) result = write_full.origin(self, vals, **kwargs) new_values = { d["id"]: d @@ -715,3 +722,15 @@ def unsubscribe(self): if act_window: act_window.unlink() return self.write({"state": "draft"}) + + @api.model + def _update_vals_list(self, vals_list): + # Odoo supports empty recordset assignment (while it doesn't handle + # non-empty recordset ¯\_(ツ)_/¯ ), it could be an Odoo issue, but in + # the meanwhile we have to handle this case to avoid errors when using + # ``deepcopy`` to log data. + for vals in vals_list: + for fieldname, fieldvalue in vals.items(): + if isinstance(fieldvalue, models.BaseModel) and not fieldvalue: + vals[fieldname] = False + return vals_list diff --git a/auditlog/static/description/index.html b/auditlog/static/description/index.html index 7b6b6725..c4888276 100644 --- a/auditlog/static/description/index.html +++ b/auditlog/static/description/index.html @@ -1,20 +1,19 @@ - - + Audit Log