Skip to content

Commit

Permalink
Merge PR #553 into 15.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Mar 8, 2024
2 parents 213a246 + 384496e commit 6bde3bc
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 31 deletions.
5 changes: 4 additions & 1 deletion crm_salesperson_planner/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Crm Salesperson Planner
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:76851d296a93e21d31374cac7458506bbbab7b48e25ed9a23e519a8dfaf74c6a
!! source digest: sha256:223707ca4fea07ed4be26ebfdff779a40a91a024a52606071846142d0e1b2236
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down Expand Up @@ -79,6 +79,9 @@ Contributors

* Valentin Vinagre
* Manuel Regidor
* `Tecnativa <https://www.tecnativa.com>`_:

* Víctor Martínez

Maintainers
~~~~~~~~~~~
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright 2021 Sygel - Valentin Vinagre
# Copyright 2021 Sygel - Manuel Regidor
# Copyright 2024 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)

from datetime import timedelta
Expand Down Expand Up @@ -68,14 +69,31 @@ class CrmSalespersonPlannerVisitTemplate(models.Model):
string="Number of Sales Person Visits", compute="_compute_visit_ids_count"
)
auto_validate = fields.Boolean(default=True)
rrule_type = fields.Selection(
default="daily",
required=True,
)
last_visit_date = fields.Date(compute="_compute_last_visit_date", store=True)
final_date = fields.Date(string="Repeat Until")
allday = fields.Boolean(default=True)
recurrency = fields.Boolean(default=True)
# Set all compute=_compute_recurrence fields of calendar.event as store=True.
# We want to manage the value of the fields manually and we don't want to depend
# on recurrence_id field (only possible with calendar.event).
# We don't use the recurrency field either because it is unnecessary.
rrule = fields.Char(store=True)
rrule_type = fields.Selection(store=True, default="daily", required=True)
event_tz = fields.Selection(store=True)
end_type = fields.Selection(store=True)
interval = fields.Integer(store=True)
count = fields.Integer(store=True)
mon = fields.Boolean(store=True)
tue = fields.Boolean(store=True)
wed = fields.Boolean(store=True)
thu = fields.Boolean(store=True)
fri = fields.Boolean(store=True)
sat = fields.Boolean(store=True)
sun = fields.Boolean(store=True)
month_by = fields.Selection(store=True)
day = fields.Integer(store=True)
weekday = fields.Selection(store=True)
byday = fields.Selection(store=True)
until = fields.Date(store=True)

_sql_constraints = [
(
Expand Down Expand Up @@ -108,6 +126,17 @@ def _constrains_partner_ids(self):
if len(item.partner_ids) > 1:
raise ValidationError(_("Only one customer is allowed"))

@api.onchange("end_type")
def _onchange_end_type(self):
"""Avoid inconsistent data if you switch from one thing to another."""
if self.end_type == "count":
self.until = False
elif self.end_type == "end_date":
self.count = 0
elif self.end_type == "forever":
self.count = 0
self.until = False

@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:
Expand Down Expand Up @@ -161,7 +190,7 @@ def _prepare_crm_salesperson_planner_visit_vals(self, dates):
]

def _get_max_date(self):
return self._increase_date(self.start_date, self.count)
return self.until or self._increase_date(self.start_date, self.count)

def _increase_date(self, date, value):
if self.rrule_type == "daily":
Expand Down
3 changes: 3 additions & 0 deletions crm_salesperson_planner/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@

* Valentin Vinagre
* Manuel Regidor
* `Tecnativa <https://www.tecnativa.com>`_:

* Víctor Martínez
6 changes: 5 additions & 1 deletion crm_salesperson_planner/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ <h1 class="title">Crm Salesperson Planner</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:76851d296a93e21d31374cac7458506bbbab7b48e25ed9a23e519a8dfaf74c6a
!! source digest: sha256:223707ca4fea07ed4be26ebfdff779a40a91a024a52606071846142d0e1b2236
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/crm/tree/15.0/crm_salesperson_planner"><img alt="OCA/crm" src="https://img.shields.io/badge/github-OCA%2Fcrm-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/crm-15-0/crm-15-0-crm_salesperson_planner"><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/crm&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 application allows you to track and schedule salespeople visits to your customers, allowing you to determine which opportunities are going to be dealt on each visit. Visits create an all day event in calendar, and they can be easily rescheduled.
Expand Down Expand Up @@ -426,6 +426,10 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<li>Manuel Regidor</li>
</ul>
</li>
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
<li>Víctor Martínez</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,41 +91,41 @@
/>
<field name="last_visit_date" />
<field name="auto_validate" />
<field name="recurrence_update" invisible="1" />
<field name="recurrence_id" invisible="1" />
<field name="event_tz" invisible="1" />
<field name="allday" force_save="1" />
<field name="rrule" invisible="1" />
</group>
<!-- Display fields similar to calendar.event (Display data similar to calendar.event (for UX is better)). -->
<group>
<div>
<group>
<label for="interval" />
<div class="o_row">
<field name="interval" />
<field name="rrule_type" />
<div class="o_col">
<div class="o_row">
<field name="interval" required="1" />
<field name="rrule_type" required="1" />
</div>
<widget
name="week_days"
attrs="{'invisible': [('rrule_type', '!=', 'weekly')]}"
/>
</div>
<label string="Until" for="end_type" />
<div class="o_row">
<field name="end_type" />
<field name="end_type" required="1" />
<field
name="count"
required="1"
attrs="{'invisible': [('end_type', '!=', 'count')]}"
/>
<field
name="final_date"
name="until"
attrs="{'invisible': [('end_type', '!=', 'end_date')], 'required': [('end_type', '=', 'end_date')]}"
/>
</div>
</group>
<group
attrs="{'invisible': [('rrule_type', '!=', 'weekly')]}"
name="weekdays"
>
<field name="mon" />
<field name="tue" />
<field name="wed" />
<field name="thu" />
<field name="fri" />
<field name="sat" />
<field name="sun" />
</group>
<group
attrs="{'invisible': [('rrule_type', '!=', 'monthly')]}"
>
Expand All @@ -134,20 +134,17 @@
<field name="month_by" />
<field
name="day"
attrs="{'required': [('month_by', '=', 'date'), ('rrule_type', '=', 'monthly')],
'invisible': [('month_by', '!=', 'date')]}"
attrs="{'required': [('month_by', '=', 'date'), ('rrule_type', '=', 'monthly')], 'invisible': [('month_by', '!=', 'date')]}"
/>
<field
name="byday"
string="The"
attrs="{'required': [('month_by', '=', 'day'), ('rrule_type', '=', 'monthly')],
'invisible': [('month_by', '!=', 'day')]}"
attrs="{'required': [('month_by', '=', 'day'), ('rrule_type', '=', 'monthly')], 'invisible': [('month_by', '!=', 'day')]}"
/>
<field
name="weekday"
nolabel="1"
attrs="{'required': [('month_by', '=', 'day'), ('rrule_type', '=', 'monthly')],
'invisible': [('month_by', '!=', 'day')]}"
attrs="{'required': [('month_by', '=', 'day'), ('rrule_type', '=', 'monthly')], 'invisible': [('month_by', '!=', 'day')]}"
/>
</div>
</group>
Expand Down

0 comments on commit 6bde3bc

Please sign in to comment.