Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][ADD] mail_chatter_company_tracking #1461

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
31 changes: 31 additions & 0 deletions mail_chatter_company_tracking/models/mail_message.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from odoo import models


class Message(models.Model):
_inherit = "mail.message"

def _message_format(self, fnames):
vals_list = super()._message_format(fnames)
for pos, vals in enumerate(vals_list):
tracking_ids = map(lambda x: x.get("id"), vals["tracking_value_ids"])
trackings = self.env["mail.tracking.value"].browse(tracking_ids)
tracking_value_ids = []
for tracking in trackings:
tracking_value_ids.append(
{
"id": tracking.id,
"changed_field": tracking.field_desc,
"old_value": tracking.get_old_display_value()[0],
"new_value": tracking.get_new_display_value()[0],
"field_type": tracking.field_type,
"company_name": (
tracking.company_id.name
if self.env[tracking.field.model]
._fields[tracking.field.name]
.company_dependent
else False
),
}
)
vals_list[pos]["tracking_value_ids"] = tracking_value_ids
adasatorres marked this conversation as resolved.
Show resolved Hide resolved
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.
Loading
Loading