Skip to content

Commit a5e30e0

Browse files
committed
[MIG] sale_planner_calendar: Migration to 18.0
TT54296
1 parent 6fe0353 commit a5e30e0

33 files changed

+236
-667
lines changed

sale_planner_calendar/README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ Contributors
123123
- Carlos Dauden
124124
- Carlos Roca
125125
- Pilar Vargas
126+
- Víctor Martínez
126127

127128
Maintainers
128129
-----------

sale_planner_calendar/__manifest__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{
44
"name": "Sale planner calendar",
55
"summary": "Sale planner calendar",
6-
"version": "16.0.3.0.0",
6+
"version": "18.0.1.0.0",
77
"development_status": "Beta",
88
"category": "Sale",
99
"website": "https://github.com/OCA/sale-workflow",
@@ -34,7 +34,6 @@
3434
"web.assets_backend": [
3535
"sale_planner_calendar/static/src/xml/categ_icons_widget_template.xml",
3636
"sale_planner_calendar/static/src/xml/sale_planner_calendar_event_sales.xml",
37-
"sale_planner_calendar/static/src/xml/activity_menu_view.xml",
3837
"sale_planner_calendar/static/src/scss/sale_planner_calendar.scss",
3938
"sale_planner_calendar/static/src/js/*.js",
4039
],

sale_planner_calendar/data/sale_planner_calendar_cron.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
<field name="user_id" ref="base.user_root" />
1313
<field name="interval_number">1</field>
1414
<field name="interval_type">days</field>
15-
<field name="numbercall">-1</field>
1615
<field name="active" eval="True" />
17-
<field name="doall" eval="False" />
1816
</record>
1917
<record forcecreate="True" id="cron_update_dynamic_final_date" model="ir.cron">
2018
<field
@@ -26,8 +24,6 @@
2624
<field name="user_id" ref="base.user_root" />
2725
<field name="interval_number">1</field>
2826
<field name="interval_type">months</field>
29-
<field name="numbercall">-1</field>
3027
<field name="active" eval="True" />
31-
<field name="doall" eval="False" />
3228
</record>
3329
</odoo>

sale_planner_calendar/i18n/it.po

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,46 +1224,3 @@ msgstr "Giorno della settimana"
12241224
#: model_terms:ir.ui.view,arch_db:sale_planner_calendar.view_sale_planner_calendar_kanban
12251225
msgid "Whatsapp"
12261226
msgstr "Whatsapp"
1227-
1228-
#~ msgid "Assign new commercial to selected lines"
1229-
#~ msgstr "Assegna nuovo commerciale alle righe selezionate"
1230-
1231-
#~ msgid "Partner User"
1232-
#~ msgstr "Utente partner"
1233-
1234-
#~ msgid "Planned user"
1235-
#~ msgstr "Utente pianificato"
1236-
1237-
#~ msgid "Responsible"
1238-
#~ msgstr "Responsabile"
1239-
1240-
#~ msgid ""
1241-
#~ "<i class=\"fa fa-pencil-square-o\"/>\n"
1242-
#~ " <span>Event</span>"
1243-
#~ msgstr ""
1244-
#~ "<i class=\"fa fa-pencil-square-o\"/>\n"
1245-
#~ " <span>Evento</span>"
1246-
1247-
#~ msgid "Calendar Event Date"
1248-
#~ msgstr "Data evento calendario"
1249-
1250-
#~ msgid "Calendar Event Profile"
1251-
#~ msgstr "Profilo evento calendario"
1252-
1253-
#~ msgid "Event Planner State"
1254-
#~ msgstr "Stato pianificatore evento"
1255-
1256-
#~ msgid "Event Profile"
1257-
#~ msgstr "Profilo evento"
1258-
1259-
#~ msgid "Event schedule"
1260-
#~ msgstr "Schedulazione evento"
1261-
1262-
#~ msgid "Planner event"
1263-
#~ msgstr "Evento pianificatore"
1264-
1265-
#~ msgid "Process"
1266-
#~ msgstr "Elabora"
1267-
1268-
#~ msgid "Sale Planner Calendar Event Profile"
1269-
#~ msgstr "Profilo evento calendario pianificatore vendite"

sale_planner_calendar/migrations/16.0.2.0.0/post-migration.py

Lines changed: 0 additions & 110 deletions
This file was deleted.

sale_planner_calendar/migrations/16.0.2.0.0/pre-migration.py

Lines changed: 0 additions & 37 deletions
This file was deleted.

sale_planner_calendar/models/calendar_event.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,10 @@ def _compute_invoice_amount_residual(self):
126126
("payment_state", "!=", "paid"),
127127
("partner_id", "in", partner_ids),
128128
],
129-
fields=["amount_residual_signed"],
129+
aggregates=["amount_residual_signed:sum"],
130130
groupby=["partner_id"],
131131
)
132-
invoice_dic = {g["partner_id"][0]: g["amount_residual_signed"] for g in groups}
132+
invoice_dic = {partner.id: data for partner, data in groups}
133133
for rec in self:
134134
amount_residual = invoice_dic.get(
135135
rec.target_partner_id.commercial_partner_id.id, 0.0
@@ -179,10 +179,10 @@ def _compute_sanitized_partner_mobile(self):
179179
@api.depends("target_partner_id")
180180
def _compute_location_url(self):
181181
# The url is built to access the location from a google link. This will be done
182-
# taking into account the location of the calendar event associated with the calendar
183-
# planner event. If this location is not defined, the client's coordinates will
184-
# be taken into account if they are defined, otherwise the client's address
185-
# will be taken into account.
182+
# taking into account the location of the calendar event associated with the
183+
# calendar planner event. If this location is not defined, the client's
184+
# coordinates will be taken into account if they are defined, otherwise the
185+
# client's address will be taken into account.
186186
self.location_url = False
187187
for event in self:
188188
event_location = event.location
@@ -241,10 +241,11 @@ def _onchange_duration(self):
241241
)
242242
)
243243
if max_duration and self.duration > max_duration:
244+
msg = f"Max duration set in config parameters is {max_duration} hours"
244245
return {
245246
"warning": {
246247
"title": "Max duration exceeded",
247-
"message": f"Max duration set in config parameters is {max_duration} hours",
248+
"message": msg,
248249
"type": "notification",
249250
}
250251
}

sale_planner_calendar/models/res_partner.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from dateutil.relativedelta import relativedelta
66

7-
from odoo import _, fields, models
7+
from odoo import Command, fields, models
88
from odoo.exceptions import ValidationError
99

1010

@@ -20,10 +20,13 @@ def action_calendar_planner(self):
2020
)
2121
sale_planner_forward_months = self.env.company.sale_planner_forward_months
2222
# TODO: Get default values from res.config.settings
23+
f_name_day_of_week = fields.Date.today().strftime("%A")[:3].lower()
2324
action["context"] = {
2425
"default_target_partner_id": self.id,
25-
"default_categ_ids": [(4, categ.id)],
26-
# Passing True omits the partner name, ensuring precise calculation of GPS location.
26+
"default_categ_ids": [Command.link(categ.id)],
27+
# Passing True omits the partner name, ensuring precise calculation of GPS
28+
# location.
29+
"default_active": True,
2730
"default_location": self._display_address(True).replace("\n", " "),
2831
"default_duration": categ.duration,
2932
"default_name": categ.name,
@@ -32,19 +35,17 @@ def action_calendar_planner(self):
3235
+ timedelta(minutes=round((categ.duration or 1.0) * 60)),
3336
"default_recurrency": True,
3437
"default_rrule_type": "weekly",
38+
"default_rrule_type_ui": "weekly",
39+
f"default_{f_name_day_of_week}": True,
40+
"default_interval": 1,
3541
"default_end_type": "end_date",
3642
"default_until": fields.Date.today()
3743
+ relativedelta(months=sale_planner_forward_months),
3844
"default_is_dynamic_end_date": True,
3945
"default_user_id": self.user_id.id or self.env.user.id,
4046
"default_partner_ids": [
41-
(
42-
6,
43-
0,
44-
[
45-
self.id,
46-
self.user_id.partner_id.id or self.env.user.partner_id.id,
47-
],
47+
Command.set(
48+
(self + (self.user_id.partner_id or self.env.user.partner_id)).ids
4849
)
4950
],
5051
"choose_unlink_method": True,
@@ -56,7 +57,7 @@ def action_calendar_planner(self):
5657
"dont_notify": True,
5758
}
5859
)
59-
action["view_mode"] = "tree,form"
60+
action["view_mode"] = "list,form"
6061
action["view_id"] = False
6162
action["views"] = []
6263
action["domain"] = [
@@ -82,7 +83,7 @@ def write(self, vals):
8283
]
8384
)
8485
if calendar_events:
85-
msg = _(
86+
msg = self.env._(
8687
"This partner has sale planned events\n"
8788
"You must change salesperson from the planner wizard"
8889
)

sale_planner_calendar/models/res_users.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# Copyright 2024 Tecnativa - Carlos Roca
22
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3-
import json
43
from datetime import datetime
54

65
import pytz
76

8-
from odoo import _, api, fields, models, modules
7+
from odoo import api, fields, models, modules
98

109

1110
class ResUsers(models.Model):
@@ -25,8 +24,8 @@ def get_action_sale_planner_calendar_event(self):
2524
)
2625

2726
@api.model
28-
def systray_get_activities(self):
29-
res = super().systray_get_activities()
27+
def _get_activity_groups(self):
28+
res = super()._get_activity_groups()
3029
# Get user timezone or UTC if not set
3130
user_tz = pytz.timezone(self.env.user.tz or "UTC")
3231
# Get current time in user's timezone
@@ -57,7 +56,7 @@ def systray_get_activities(self):
5756
{
5857
"id": self.env["ir.model"]._get("calendar.event").id,
5958
"type": "activity",
60-
"name": _("Sale planner calendar events"),
59+
"name": self.env._("Sale planner calendar events"),
6160
"model": "calendar.event",
6261
"icon": modules.module.get_module_icon(
6362
self.env["calendar.event"]._original_module
@@ -67,7 +66,6 @@ def systray_get_activities(self):
6766
"overdue_count": events_overdue_count,
6867
"planned_count": events_planned_count,
6968
"is_planner": True,
70-
"domain": json.dumps(domain),
7169
}
7270
)
7371
return res

0 commit comments

Comments
 (0)