Skip to content

Conversation

@eugenios73
Copy link

migration crm_phonecall from 18.0 to 19.0

cubells and others added 30 commits November 28, 2025 09:39
* crm_phonecall module (OCA#131)

This module is the part extracted from Odoo v8 crm module from Odoo that allows to record phone calls. As it has been stripped off from Odoo v9, we add again the feature via this module.

Migration scripts are also included to upgrade a v8 database via OpenUpgrade and don't lose your history.

* [MIG] crm_phone_call: Migrated to 10.0

 - FIX: Correct some lint errors

* [MIG] crm_phone_call: Migrated to 10.0
Currently translated at 100.0% (150 of 150 strings)

Translation: crm-12.0/crm-12.0-crm_phonecall
Translate-URL: https://translation.odoo-community.org/projects/crm-12-0/crm-12-0-crm_phonecall/es/
Currently translated at 86.0% (129 of 150 strings)

Translation: crm-12.0/crm-12.0-crm_phonecall
Translate-URL: https://translation.odoo-community.org/projects/crm-12-0/crm-12-0-crm_phonecall/de/
Currently translated at 92.7% (139 of 150 strings)

Translation: crm-12.0/crm-12.0-crm_phonecall
Translate-URL: https://translation.odoo-community.org/projects/crm-12-0/crm-12-0-crm_phonecall/de/
Currently translated at 98.0% (147 of 150 strings)

Translation: crm-12.0/crm-12.0-crm_phonecall
Translate-URL: https://translation.odoo-community.org/projects/crm-12-0/crm-12-0-crm_phonecall/de/
Currently translated at 27.3% (41 of 150 strings)

Translation: crm-12.0/crm-12.0-crm_phonecall
Translate-URL: https://translation.odoo-community.org/projects/crm-12-0/crm-12-0-crm_phonecall/hr/
Currently translated at 41.3% (62 of 150 strings)

Translation: crm-12.0/crm-12.0-crm_phonecall
Translate-URL: https://translation.odoo-community.org/projects/crm-12-0/crm-12-0-crm_phonecall/hr/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: crm-13.0/crm-13.0-crm_phonecall
Translate-URL: https://translation.odoo-community.org/projects/crm-13-0/crm-13-0-crm_phonecall/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: crm-13.0/crm-13.0-crm_phonecall
Translate-URL: https://translation.odoo-community.org/projects/crm-13-0/crm-13-0-crm_phonecall/
mymage and others added 23 commits November 28, 2025 09:39
Currently translated at 100.0% (161 of 161 strings)

Translation: crm-16.0/crm-16.0-crm_phonecall
Translate-URL: https://translation.odoo-community.org/projects/crm-16-0/crm-16-0-crm_phonecall/it/
Currently translated at 100.0% (161 of 161 strings)

Translation: crm-16.0/crm-16.0-crm_phonecall
Translate-URL: https://translation.odoo-community.org/projects/crm-16-0/crm-16-0-crm_phonecall/es/
Currently translated at 100.0% (155 of 155 strings)

Translation: crm-16.0/crm-16.0-crm_phonecall
Translate-URL: https://translation.odoo-community.org/projects/crm-16-0/crm-16-0-crm_phonecall/it/
Currently translated at 100.0% (155 of 155 strings)

Translation: crm-16.0/crm-16.0-crm_phonecall
Translate-URL: https://translation.odoo-community.org/projects/crm-16-0/crm-16-0-crm_phonecall/es/
Currently translated at 100.0% (154 of 154 strings)

Translation: crm-16.0/crm-16.0-crm_phonecall
Translate-URL: https://translation.odoo-community.org/projects/crm-16-0/crm-16-0-crm_phonecall/es_AR/
Currently translated at 100.0% (154 of 154 strings)

Translation: crm-16.0/crm-16.0-crm_phonecall
Translate-URL: https://translation.odoo-community.org/projects/crm-16-0/crm-16-0-crm_phonecall/it/
Currently translated at 100.0% (153 of 153 strings)

Translation: crm-17.0/crm-17.0-crm_phonecall
Translate-URL: https://translation.odoo-community.org/projects/crm-17-0/crm-17-0-crm_phonecall/it/
Currently translated at 100.0% (153 of 153 strings)

Translation: crm-17.0/crm-17.0-crm_phonecall
Translate-URL: https://translation.odoo-community.org/projects/crm-17-0/crm-17-0-crm_phonecall/it/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: crm-18.0/crm-18.0-crm_phonecall
Translate-URL: https://translation.odoo-community.org/projects/crm-18-0/crm-18-0-crm_phonecall/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: crm-18.0/crm-18.0-crm_phonecall
Translate-URL: https://translation.odoo-community.org/projects/crm-18-0/crm-18-0-crm_phonecall/
Currently translated at 99.3% (152 of 153 strings)

Translation: crm-18.0/crm-18.0-crm_phonecall
Translate-URL: https://translation.odoo-community.org/projects/crm-18-0/crm-18-0-crm_phonecall/es/
Currently translated at 99.3% (152 of 153 strings)

Translation: crm-18.0/crm-18.0-crm_phonecall
Translate-URL: https://translation.odoo-community.org/projects/crm-18-0/crm-18-0-crm_phonecall/es/
@eugenios73 eugenios73 force-pushed the 19.0-mig-crm_phonecall branch 2 times, most recently from dad99bb to d0ec288 Compare December 1, 2025 07:57
@eugenios73 eugenios73 force-pushed the 19.0-mig-crm_phonecall branch from d0ec288 to b5cae86 Compare December 1, 2025 09:01
@eugenios73
Copy link
Author

The precommit command fails because it does not seem to be up to date with the change in v19.0 of the "user_ids" attribute of the base model "ir.filters". This attribute has changed compared to v18.0, where it was "user_id". Here is the commit where the change can be seen: odoo/odoo@414e55c

Copy link

@rrebollo rrebollo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review: Great work! The code looks good to me (LGTM). Thank you for your contribution! I've provided a few suggestions for your consideration—feel free to address them as you see fit.

Comment on lines +21 to +24
for lead in self:
lead.phonecall_count = self.env["crm.phonecall"].search_count(
[("opportunity_id", "=", lead.id)]
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for lead in self:
lead.phonecall_count = self.env["crm.phonecall"].search_count(
[("opportunity_id", "=", lead.id)]
)
phonecall_data = self.env["crm.phonecall"]._read_group(
domain=[("opportunity_id", "in", self.ids)],
groupby=["opportunity_id"],
aggregates=["opportunity_id:count"],
)
mapped_data = {p[0].id: p[1] for p in phonecall_data}
for lead in self:
count = mapped_data.get(lead.id, 0)
lead.phonecall_count = count

Single query

Comment on lines +18 to +20
date_action_last = fields.Datetime(string="Last Action", readonly=True)
date_action_next = fields.Datetime(string="Next Action", readonly=True)
create_date = fields.Datetime(string="Creation Date", readonly=True)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
date_action_last = fields.Datetime(string="Last Action", readonly=True)
date_action_next = fields.Datetime(string="Next Action", readonly=True)
create_date = fields.Datetime(string="Creation Date", readonly=True)
date_action_last = fields.Datetime(string="Last Action")
date_action_next = fields.Datetime(string="Next Action")
create_date = fields.Datetime(string="Creation Date")

readonly=True makes impossible to import these fields. OCA migration guidelines invite us to consider to set the attribute at view level.

"to Cancelled.",
)
email_from = fields.Char(string="Email", help="These people will receive email.")
date_open = fields.Datetime(string="Opened", readonly=True)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
date_open = fields.Datetime(string="Opened", readonly=True)
date_open = fields.Datetime(string="Opened")

selection=[("0", "Low"), ("1", "Normal"), ("2", "High")],
default="1",
)
date_closed = fields.Datetime(string="Closed", readonly=True)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
date_closed = fields.Datetime(string="Closed", readonly=True)
date_closed = fields.Datetime(string="Closed")

phonecall.write(values)
else:
phonecall.duration = 0.0
phonecall_no_dates.write({"duration": 0.0})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
phonecall_no_dates.write({"duration": 0.0})
phonecall_no_dates.duration = 0.0

ORM now has no problem assigning same val to a recordset

values = call.get_values_schedule_another_phonecall(vals)
new_id = self.create(values)
if vals.get("action") == "log":
call.write({"state": "done"})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
call.write({"state": "done"})
call.state = "done"

self.ensure_one()
opportunity = self.env["crm.lead"]
opportunity_id = opportunity.create(self._prepare_opportunity_vals())
self.write({"opportunity_id": opportunity_id.id, "state": "done"})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.write({"opportunity_id": opportunity_id.id, "state": "done"})
self.update({"opportunity_id": opportunity_id.id, "state": "done"})

Comment on lines +20 to +23
for partner in self:
partner.phonecall_count = self.env["crm.phonecall"].search_count(
[("partner_id", "=", partner.id)]
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something similar to my suggestion in the crm.lead model could be done to make a single query.

Comment on lines +89 to +96
self.env.cr.execute(
"""
create or replace view %s as (
%s
%s
)""",
(AsIs(self._table), AsIs(self._select()), AsIs(self._from())),
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't be odoo.tools import SQL, Query used over here?

@rrebollo
Copy link

@eugenios73 could you review mine? #661

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.