Skip to content

Commit

Permalink
Merge PR #1461 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by hbrunn
OCA-git-bot committed Dec 6, 2024
2 parents c0681f5 + eb208f3 commit 95eba18
Showing 15 changed files with 682 additions and 0 deletions.
87 changes: 87 additions & 0 deletions mail_chatter_company_tracking/README.rst
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/OCA/social/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/social/issues/new?body=module:%20mail_chatter_company_tracking%0Aversion:%2014.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
~~~~~~~

* Binhex

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

* `Binhex <https://www.binhex.cloud>`_:
* Adasat Torres de León <a.torres@binhex.cloud>


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 <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-adasatorres|

This module is part of the `OCA/social <https://github.com/OCA/social/tree/14.0/mail_chatter_company_tracking>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions mail_chatter_company_tracking/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
16 changes: 16 additions & 0 deletions mail_chatter_company_tracking/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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"],
}
2 changes: 2 additions & 0 deletions mail_chatter_company_tracking/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import mail_tracking_value
from . import mail_message
23 changes: 23 additions & 0 deletions mail_chatter_company_tracking/models/mail_message.py
Original file line number Diff line number Diff line change
@@ -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
31 changes: 31 additions & 0 deletions mail_chatter_company_tracking/models/mail_tracking_value.py
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions mail_chatter_company_tracking/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* `Binhex <https://www.binhex.cloud>`_:
* Adasat Torres de León <a.torres@binhex.cloud>

2 changes: 2 additions & 0 deletions mail_chatter_company_tracking/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This add-on includes the company name in the email chatter
tracking when it is a company-dependent field.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
427 changes: 427 additions & 0 deletions mail_chatter_company_tracking/static/description/index.html

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">
<t t-name="Message" t-inherit="mail.Message" t-inherit-mode="extension" owl="1">
<xpath
expr="//div[hasclass('o_Message_trackingValueFieldName')]"
position="before"
>
<t t-log="value" />
<div
t-if="value.company_name"
class="o_Message_trackingValueFieldCompanyName o_Message_trackingValueItem"
>
<span style="font-weight:bold;">
<!-- prettier-ignore-start -->
(<span t-esc="value.company_name"/>)
<!-- prettier-ignore-end -->
</span>
</div>
</xpath>
</t>
</templates>
1 change: 1 addition & 0 deletions mail_chatter_company_tracking/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_mail_tracking
61 changes: 61 additions & 0 deletions mail_chatter_company_tracking/tests/test_mail_tracking.py
Original file line number Diff line number Diff line change
@@ -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)
6 changes: 6 additions & 0 deletions setup/mail_chatter_company_tracking/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit 95eba18

Please sign in to comment.