Skip to content

Commit

Permalink
[MIG] mail_activity_done: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
achulii committed Nov 27, 2024
1 parent 495f95e commit b368e67
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 14 deletions.
2 changes: 1 addition & 1 deletion mail_activity_done/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
{
"name": "Mail Activity Done",
"version": "17.0.1.0.0",
"version": "18.0.1.0.0",
"author": "ForgeFlow, Odoo Community Association (OCA)",
"license": "LGPL-3",
"category": "Discuss",
Expand Down
4 changes: 2 additions & 2 deletions mail_activity_done/models/mail_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ class MailActivityMixin(models.AbstractModel):
domain=lambda self: [("res_model", "=", self._name), ("active", "=", True)]
)

def _read_progress_bar(self, domain, group_by, progress_bar):
def read_progress_bar(self, domain, group_by, progress_bar):
"""
Exclude completed activities from progress bar result.
Pass an extra domain to super to filter out records with only done activities.
"""
domain = expression.AND([domain, [("activity_ids.done", "=", False)]])
return super()._read_progress_bar(domain, group_by, progress_bar)
return super().read_progress_bar(domain, group_by, progress_bar)
2 changes: 1 addition & 1 deletion mail_activity_done/models/res_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def systray_get_activities(self):
"planned_count": 0,
"type": "activity",
}
user_activities[activity["model"]]["%s_count" % activity["states"]] += (
user_activities[activity["model"]][f"{activity['states']}_count"] += (
activity["count"]
)
if activity["states"] in ("today", "overdue"):
Expand Down
15 changes: 11 additions & 4 deletions mail_activity_done/tests/test_mail_activity_done.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,19 @@ def test_read_progress_bar(self):
params = {
"domain": [],
"group_by": "id",
"progress_bar": {"field": "activity_state"},
"progress_bar": {
"field": "activity_state",
"colors": {
"overdue": "danger",
"today": "warning",
"planned": "success",
},
},
}
result = res_partner._read_progress_bar(**params)
self.assertEqual(result[0]["__count"], 1)
result = res_partner.read_progress_bar(**params)
self.assertEqual(len(result), 1)

self.act1._action_done()
self.assertEqual(self.act1.state, "done")
result = res_partner._read_progress_bar(**params)
result = res_partner.read_progress_bar(**params)
self.assertEqual(len(result), 0)
12 changes: 6 additions & 6 deletions mail_activity_done/views/mail_activity_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@
domain="[('active', '=', False), ('state', '=', 'done')]"
/>
</field>
<filter name="activities_overdue" position="attributes">
<filter name="filter_date_deadline_past" position="attributes">
<attribute
name="domain"
>[('date_deadline', '&lt;', context_today().strftime('%Y-%m-%d'))]</attribute>
</filter>
<filter name="activities_today" position="attributes">
<filter name="filter_date_deadline_today" position="attributes">
<attribute
name="domain"
>[('date_deadline', '=', context_today().strftime('%Y-%m-%d'))]</attribute>
</filter>
<filter name="activities_upcoming_all" position="attributes">
<filter name="filter_date_deadline_future" position="attributes">
<attribute
name="domain"
>[('date_deadline', '&gt;', context_today().strftime('%Y-%m-%d'))]</attribute>
Expand Down Expand Up @@ -88,23 +88,23 @@
</record>

<record id="mail_activity_view_tree" model="ir.ui.view">
<field name="name">mail.activity.view.tree</field>
<field name="name">mail.activity.view.list</field>
<field name="model">mail.activity</field>
<field name="inherit_id" ref="mail.mail_activity_view_tree" />
<field name="arch" type="xml">
<field name="date_deadline" position="after">
<field name="state" />
<field name="date_done" readonly="1" />
</field>
<tree position="attributes">
<list position="attributes">
<attribute name="decoration-muted">state == 'done'</attribute>
<attribute
name="decoration-danger"
>date_deadline &lt; current_date and state != 'done'</attribute>
<attribute
name="decoration-success"
>date_deadline == current_date and state != 'done'</attribute>
</tree>
</list>
</field>
</record>

Expand Down

0 comments on commit b368e67

Please sign in to comment.