Skip to content

Commit

Permalink
[IMP] sale_planner_calendar: Design improves and new buttons in calen…
Browse files Browse the repository at this point in the history
…dar planner event

Improvements made:

- Profile for calendar events that will allow an icon to be displayed in the kanban view of the visit. It can also be configured from a recurring event.
- Tree view to edit and add new profiles with their icons which will be fontawesome text strings (e.g fa-user).
- New buttons in the kanban view of the visit: Location, Whatsapp
- Some improvements in the structure to make it responsive with the new addition of buttons that may or may not be visible.

TT48632
  • Loading branch information
pilarvargas-tecnativa committed Apr 18, 2024
1 parent ef0fefb commit 29a9c84
Show file tree
Hide file tree
Showing 14 changed files with 205 additions and 41 deletions.
3 changes: 2 additions & 1 deletion sale_planner_calendar/README.rst
Expand Up @@ -7,7 +7,7 @@ Sale planner calendar
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:cfd0ce2a5ed3d1a8e2b49546e6d74254c85209fa116fa26c3cb04f2edee45c6a
!! source digest: sha256:0789fd8a1074029f8b9ae3d1162aaf160959f561fbe8d3fb30f1db2b21520ef5
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down Expand Up @@ -118,6 +118,7 @@ Contributors
* Sergio Teruel
* Carlos Dauden
* Carlos Roca
* Pilar Vargas

Maintainers
~~~~~~~~~~~
Expand Down
4 changes: 3 additions & 1 deletion sale_planner_calendar/__manifest__.py
Expand Up @@ -18,16 +18,18 @@
"data/sale_planner_calendar_action_server.xml",
"data/sale_planner_calendar_cron.xml",
"data/sale_planner_calendar_data.xml",
"data/sale_planner_calendar_event_profile.xml",
"views/calendar_event_type_view.xml",
"views/calendar_view.xml",
"views/res_config_settings_views.xml",
"views/res_partner_view.xml",
"views/sale_planner_calendar_event_profile_view.xml",
"views/sale_planner_calendar_event_view.xml",
"views/sale_planner_calendar_issue_type_view.xml",
"views/sale_planner_calendar_summary_view.xml",
"wizard/sale_planner_calendar_reassign.xml",
"wizard/sale_planner_calendar_wizard.xml",
# # Menu position fixed
# Menu position fixed
"views/sale_planner_calendar_menu.xml",
],
"assets": {
Expand Down
15 changes: 15 additions & 0 deletions sale_planner_calendar/data/sale_planner_calendar_event_profile.xml
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">
<record id="event_profile_face_to_face" model="sale.planner.calendar.event.profile">
<field name="name">Face-to-Face</field>
<field name="icon">fa-car</field>
</record>
<record id="event_profile_telephone" model="sale.planner.calendar.event.profile">
<field name="name">Telephone</field>
<field name="icon">fa-phone</field>
</record>
<record id="event_profile_message" model="sale.planner.calendar.event.profile">
<field name="name">Message</field>
<field name="icon">fa-envelope</field>
</record>
</odoo>
1 change: 1 addition & 0 deletions sale_planner_calendar/models/__init__.py
Expand Up @@ -6,6 +6,7 @@
from . import res_partner
from . import sale_order
from . import sale_payment_sheet
from . import sale_planner_calendar_event_profile
from . import sale_planner_calendar_event
from . import sale_planner_calendar_issue_type
from . import sale_planner_calendar_summary
4 changes: 4 additions & 0 deletions sale_planner_calendar/models/calendar.py
Expand Up @@ -19,6 +19,9 @@ class CalendarEvent(models.Model):
string="Sale planner partner",
help="Is the partner used in planner",
)
calendar_event_profile_id = fields.Many2one(
comodel_name="sale.planner.calendar.event.profile"
)
currency_id = fields.Many2one(
comodel_name="res.currency", related="target_partner_id.currency_id"
)
Expand Down Expand Up @@ -122,6 +125,7 @@ def _create_event_planner(self):
"user_id": self.user_id.id,
"calendar_event_date": self.start,
"calendar_event_id": self.id,
"calendar_event_profile_id": self.calendar_event_profile_id.id,
}
)

Expand Down
33 changes: 32 additions & 1 deletion sale_planner_calendar/models/sale_planner_calendar_event.py
@@ -1,6 +1,8 @@
# Copyright 2021 Tecnativa - Sergio Teruel
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

import re

from odoo import api, fields, models
from odoo.tools.safe_eval import safe_eval

Expand Down Expand Up @@ -45,6 +47,9 @@ class SalePlannerCalendarEvent(models.Model):
calendar_issue_type_id = fields.Many2one(
comodel_name="sale.planner.calendar.issue.type", ondelete="restrict"
)
calendar_event_profile_id = fields.Many2one(
comodel_name="sale.planner.calendar.event.profile"
)
comment = fields.Text()
sale_order_subtotal = fields.Monetary(
compute="_compute_sale_order_subtotal", currency_field="currency_id"
Expand Down Expand Up @@ -73,6 +78,9 @@ class SalePlannerCalendarEvent(models.Model):
partner_mobile = fields.Char(compute="_compute_contact")
partner_contact_name = fields.Char(compute="_compute_contact")
partner_city = fields.Char(related="partner_id.city")
sanitized_partner_mobile = fields.Char(compute="_compute_sanitized_partner_mobile")
location_url = fields.Char(compute="_compute_location_url")
profile_icon = fields.Char(related="calendar_event_profile_id.icon")

@api.depends("sale_ids.amount_untaxed")
def _compute_sale_order_subtotal(self):
Expand Down Expand Up @@ -130,6 +138,30 @@ def _compute_contact(self):
)
rec.partner_contact_name = contact.name

def _compute_sanitized_partner_mobile(self):
self.sanitized_partner_mobile = False
for rec in self.filtered("partner_mobile"):
rec.sanitized_partner_mobile = re.sub(r"\W+", "", rec.partner_mobile)

def _compute_location_url(self):
# The url is built to access the location from a google link. This will be done
# taking into account the location of the calendar event associated with the calendar
# planner event. If this location is not defined, the client's coordinates will
# be taken into account if they are defined, otherwise the client's address
# will be taken into account.
self.location_url = False
for rec in self:
event_location = rec.calendar_event_id.location
partner_latitude = str(rec.partner_id.partner_latitude).replace(",", ".")
partner_longitude = str(rec.partner_id.partner_longitude).replace(",", ".")
partner_location = f"{rec.partner_city}+{rec.partner_street}"
if event_location:
self.location_url = event_location.replace(" ", "+")
elif partner_latitude != "0.0" or partner_longitude != "0.0":
self.location_url = f"{partner_latitude}%2C{partner_longitude}"
elif partner_location:
self.location_url = partner_location.replace(" ", "+")

def action_open_sale_order(self, new_order=False):
"""
Search or Create an event planner linked to sale order
Expand Down Expand Up @@ -176,7 +208,6 @@ def action_open_invoices(self):
action = self.env["ir.actions.act_window"]._for_xml_id(
"sale_payment_sheet.action_invoice_sale_payment_sheet"
)

ctx = safe_eval(action["context"])
ctx.update(
{
Expand Down
@@ -0,0 +1,18 @@
# Copyright 2024 Tecnativa - Pilar Vargas
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class CalendarEventType(models.Model):
"""
Calendar planner event profiles are used to categorise such events. Each type is a
type of activity, e.g. face-to-face, telephone, message. This will allow an icon
identifying the event to be displayed
"""

_name = "sale.planner.calendar.event.profile"
_description = "Sale Planner Calendar Event Profile"

name = fields.Char(required=True)
icon = fields.Char(help="Font awesome icon e.g. fa-tasks")
1 change: 1 addition & 0 deletions sale_planner_calendar/readme/CONTRIBUTORS.rst
Expand Up @@ -3,3 +3,4 @@
* Sergio Teruel
* Carlos Dauden
* Carlos Roca
* Pilar Vargas
1 change: 1 addition & 0 deletions sale_planner_calendar/security/ir.model.access.csv
Expand Up @@ -5,3 +5,4 @@ access_sale_planner_calendar_issue_type,access_sale_planner_calendar_issue_type,
access_sale_planner_calendar_reassign_wiz,access_sale_planner_calendar_reassign_wiz,model_sale_planner_calendar_reassign_wiz,sales_team.group_sale_salesman,1,1,1,1
access_sale_planner_calendar_reassign_line_wiz,access_sale_planner_calendar_reassign_line_wiz,model_sale_planner_calendar_reassign_line_wiz,sales_team.group_sale_salesman,1,1,1,1
access_sale_planner_calendar_wizard,access_sale_planner_calendar_wizard,model_sale_planner_calendar_wizard,sales_team.group_sale_salesman,1,1,1,1
sale_planner_calendar.access_sale_planner_calendar_event_profile,access_sale_planner_calendar_event_profile,sale_planner_calendar.model_sale_planner_calendar_event_profile,sales_team.group_sale_salesman,1,1,1,1
4 changes: 3 additions & 1 deletion sale_planner_calendar/static/description/index.html
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand Down Expand Up @@ -366,7 +367,7 @@ <h1 class="title">Sale planner calendar</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:cfd0ce2a5ed3d1a8e2b49546e6d74254c85209fa116fa26c3cb04f2edee45c6a
!! source digest: sha256:0789fd8a1074029f8b9ae3d1162aaf160959f561fbe8d3fb30f1db2b21520ef5
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/sale-workflow/tree/15.0/sale_planner_calendar"><img alt="OCA/sale-workflow" src="https://img.shields.io/badge/github-OCA%2Fsale--workflow-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/sale-workflow-15-0/sale-workflow-15-0-sale_planner_calendar"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/sale-workflow&amp;target_branch=15.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module allows to manage commercial visits to partners by using recurrence events.</p>
Expand Down Expand Up @@ -452,6 +453,7 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<li>Sergio Teruel</li>
<li>Carlos Dauden</li>
<li>Carlos Roca</li>
<li>Pilar Vargas</li>
</ul>
</li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion sale_planner_calendar/views/calendar_view.xml
Expand Up @@ -77,7 +77,7 @@
<field name="user_id" position="after">
<label for="target_partner_id" string="Sale planner partner" />
<field name="target_partner_id" nolabel="1" />

<field name="calendar_event_profile_id" />
</field>
<field name="recurrence_id" position="after">
<group attrs="{'invisible': [('recurrency', '=', False)]}">
Expand Down
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<record id="view_sale_planner_calendar_event_profile_tree" model="ir.ui.view">
<field name="name">sale.planner.calendar.event.profile.tree</field>
<field name="model">sale.planner.calendar.event.profile</field>
<field name="arch" type="xml">
<tree editable="bottom">
<field name="name" />
<field name="icon" />
</tree>
</field>
</record>

<record
id="action_sale_planner_calendar_event_profile"
model="ir.actions.act_window"
>
<field name="name">Event Profile</field>
<field name="res_model">sale.planner.calendar.event.profile</field>
<field name="view_mode">tree</field>
</record>

</odoo>

0 comments on commit 29a9c84

Please sign in to comment.