diff --git a/mail_chatter_company_tracking/README.rst b/mail_chatter_company_tracking/README.rst new file mode 100644 index 0000000000..2f04523372 --- /dev/null +++ b/mail_chatter_company_tracking/README.rst @@ -0,0 +1,87 @@ +============================= +Mail Chatter Company Tracking +============================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:ca51bb1b96e2d7172d7613e71850bbe20451d0456244169c33db61cee68193eb + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fsocial-lightgray.png?logo=github + :target: https://github.com/OCA/social/tree/14.0/mail_chatter_company_tracking + :alt: OCA/social +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/social-14-0/social-14-0-mail_chatter_company_tracking + :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/social&target_branch=14.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This add-on includes the company name in the email chatter +tracking when it is a company-dependent field. + +**Table of contents** + +.. contents:: + :local: + +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 +~~~~~~~ + +* Binhex + +Contributors +~~~~~~~~~~~~ + +* `Binhex `_: + * Adasat Torres de León + + +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-adasatorres| image:: https://github.com/adasatorres.png?size=40px + :target: https://github.com/adasatorres + :alt: adasatorres + +Current `maintainer `__: + +|maintainer-adasatorres| + +This module is part of the `OCA/social `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/mail_chatter_company_tracking/__init__.py b/mail_chatter_company_tracking/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/mail_chatter_company_tracking/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/mail_chatter_company_tracking/__manifest__.py b/mail_chatter_company_tracking/__manifest__.py new file mode 100644 index 0000000000..42f0db8a27 --- /dev/null +++ b/mail_chatter_company_tracking/__manifest__.py @@ -0,0 +1,16 @@ +{ + "name": "Mail Chatter Company Tracking", + "summary": """ + This add-on includes the company name in the email + chatter tracking when it is a company-dependent field. + """, + "author": "Binhex, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/social", + "license": "AGPL-3", + "category": "social", + "version": "14.0.1.0.0", + "depends": ["mail"], + "data": [], + "qweb": ["static/src/components/message/message.xml"], + "maintainers": ["adasatorres"], +} diff --git a/mail_chatter_company_tracking/models/__init__.py b/mail_chatter_company_tracking/models/__init__.py new file mode 100644 index 0000000000..556ddbdff6 --- /dev/null +++ b/mail_chatter_company_tracking/models/__init__.py @@ -0,0 +1,2 @@ +from . import mail_tracking_value +from . import mail_message diff --git a/mail_chatter_company_tracking/models/mail_message.py b/mail_chatter_company_tracking/models/mail_message.py new file mode 100644 index 0000000000..c9028233a1 --- /dev/null +++ b/mail_chatter_company_tracking/models/mail_message.py @@ -0,0 +1,23 @@ +from odoo import models + + +class Message(models.Model): + _inherit = "mail.message" + + def _message_format(self, fnames): + vals_list = super()._message_format(fnames) + for vals in vals_list: + for tracking_value in vals["tracking_value_ids"]: + tracking = self.env["mail.tracking.value"].browse(tracking_value["id"]) + tracking_value.update( + { + "company_name": ( + tracking.company_id.name + if self.env[tracking.field.model] + ._fields[tracking.field.name] + .company_dependent + else False + ), + } + ) + return vals_list diff --git a/mail_chatter_company_tracking/models/mail_tracking_value.py b/mail_chatter_company_tracking/models/mail_tracking_value.py new file mode 100644 index 0000000000..d13591edc3 --- /dev/null +++ b/mail_chatter_company_tracking/models/mail_tracking_value.py @@ -0,0 +1,31 @@ +from odoo import api, fields, models + + +class MailTrackingValue(models.Model): + _inherit = "mail.tracking.value" + + company_id = fields.Many2one( + "res.company", + default=lambda self: self.env.company, + ) + + @api.model + def create_tracking_values( + self, + initial_value, + new_value, + col_name, + col_info, + tracking_sequence, + model_name, + ): + res = super().create_tracking_values( + initial_value, new_value, col_name, col_info, tracking_sequence, model_name + ) + if res: + res.update( + { + "company_id": self.env.company.id, + } + ) + return res diff --git a/mail_chatter_company_tracking/readme/CONTRIBUTORS.rst b/mail_chatter_company_tracking/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..10a5298420 --- /dev/null +++ b/mail_chatter_company_tracking/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Binhex `_: + * Adasat Torres de León + diff --git a/mail_chatter_company_tracking/readme/DESCRIPTION.rst b/mail_chatter_company_tracking/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..130bd93b9a --- /dev/null +++ b/mail_chatter_company_tracking/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This add-on includes the company name in the email chatter +tracking when it is a company-dependent field. diff --git a/mail_chatter_company_tracking/static/description/icon.png b/mail_chatter_company_tracking/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/mail_chatter_company_tracking/static/description/icon.png differ diff --git a/mail_chatter_company_tracking/static/description/index.html b/mail_chatter_company_tracking/static/description/index.html new file mode 100644 index 0000000000..63720385ef --- /dev/null +++ b/mail_chatter_company_tracking/static/description/index.html @@ -0,0 +1,427 @@ + + + + + +Mail Chatter Company Tracking + + + +
+

Mail Chatter Company Tracking

+ + +

Beta License: AGPL-3 OCA/social Translate me on Weblate Try me on Runboat

+

This add-on includes the company name in the email chatter +tracking when it is a company-dependent field.

+

Table of contents

+ +
+

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

+
    +
  • Binhex
  • +
+
+
+

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 maintainer:

+

adasatorres

+

This module is part of the OCA/social project on GitHub.

+

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

+
+
+
+ + diff --git a/mail_chatter_company_tracking/static/src/components/message/message.xml b/mail_chatter_company_tracking/static/src/components/message/message.xml new file mode 100644 index 0000000000..8ca7d3a6e9 --- /dev/null +++ b/mail_chatter_company_tracking/static/src/components/message/message.xml @@ -0,0 +1,21 @@ + + + + + +
+ + + () + + +
+
+
+
diff --git a/mail_chatter_company_tracking/tests/__init__.py b/mail_chatter_company_tracking/tests/__init__.py new file mode 100644 index 0000000000..0f3459bc62 --- /dev/null +++ b/mail_chatter_company_tracking/tests/__init__.py @@ -0,0 +1 @@ +from . import test_mail_tracking diff --git a/mail_chatter_company_tracking/tests/test_mail_tracking.py b/mail_chatter_company_tracking/tests/test_mail_tracking.py new file mode 100644 index 0000000000..9411eb0458 --- /dev/null +++ b/mail_chatter_company_tracking/tests/test_mail_tracking.py @@ -0,0 +1,61 @@ +from odoo.tests import tagged +from odoo.tests.common import TransactionCase + + +@tagged("post_install", "-at_install") +class TestMailTracking(TransactionCase): + def setUp(self): + super().setUp() + self.company = self.env.ref("base.main_company") + self.user = self.env.ref("base.user_demo") + self.partner = self.env["res.partner"].create( + { + "name": "Test Partner", + } + ) + self.partner_email_field = self.env["ir.model.fields"].search( + [("name", "=", "email"), ("model", "=", "res.partner")] + ) + self.message = self.env["mail.message"].create( + { + "subject": "Message test", + "author_id": self.user.id, + "message_type": "notification", + "subtype_id": self.env.ref("mail.mt_note").id, + "model": "res.partner", + "res_id": self.partner.id, + } + ) + + self.tracking_values = self.env["mail.tracking.value"].create( + { + "field": self.partner_email_field.id, + "field_desc": "Email", + "field_type": "char", + "old_value_char": "", + "new_value_char": "test@companytest.com", + "mail_message_id": self.message.id, + "company_id": self.company.id, + } + ) + self.tracking_values2 = self.env["mail.tracking.value"].create( + { + "field": self.partner_email_field.id, + "field_desc": "Email", + "field_type": "char", + "old_value_char": "test@companytest.com", + "new_value_char": "test10@companytest.com", + "mail_message_id": self.message.id, + "company_id": False, + } + ) + + def test_message_form(self): + self.assertEqual(len(self.message.tracking_value_ids), 2) + self.assertEqual( + self.message.tracking_value_ids[0].company_id.id, self.company.id + ) + format = self.message.with_context( + {"company_id": self.company.id, "allowed_company_ids": [self.company.id]} + )._message_format(self.message._get_message_format_fields())[-1] + self.assertEqual(len(format["tracking_value_ids"]), 2) diff --git a/setup/mail_chatter_company_tracking/odoo/addons/mail_chatter_company_tracking b/setup/mail_chatter_company_tracking/odoo/addons/mail_chatter_company_tracking new file mode 120000 index 0000000000..3a39b09f1f --- /dev/null +++ b/setup/mail_chatter_company_tracking/odoo/addons/mail_chatter_company_tracking @@ -0,0 +1 @@ +../../../../mail_chatter_company_tracking \ No newline at end of file diff --git a/setup/mail_chatter_company_tracking/setup.py b/setup/mail_chatter_company_tracking/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/mail_chatter_company_tracking/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)