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 + 870e3ab commit 227adbd
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 43 deletions.
24 changes: 12 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ repos:
language: fail
files: '[a-zA-Z0-9_]*/i18n/en\.po$'
- repo: https://github.com/oca/maintainer-tools
rev: 969238e47c07d0c40573acff81d170f63245d738
rev: 451de41fa3e8aa81d077c804322d48632eb5ff74
hooks:
# update the NOT INSTALLABLE ADDONS section above
- id: oca-update-pre-commit-excluded-addons
Expand All @@ -49,12 +49,12 @@ repos:
- --repo-name=crm
- --if-source-changed
- repo: https://github.com/OCA/odoo-pre-commit-hooks
rev: v0.0.25
rev: v0.0.30
hooks:
- id: oca-checks-odoo-module
- id: oca-checks-po
- repo: https://github.com/myint/autoflake
rev: v1.4
rev: v2.3.0
hooks:
- id: autoflake
args:
Expand All @@ -65,11 +65,11 @@ repos:
- --remove-duplicate-keys
- --remove-unused-variables
- repo: https://github.com/psf/black
rev: 22.3.0
rev: 24.2.0
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.4.1
rev: v4.0.0-alpha.8
hooks:
- id: prettier
name: prettier (with plugin-xml)
Expand All @@ -80,15 +80,15 @@ repos:
- --plugin=@prettier/plugin-xml
files: \.(css|htm|html|js|json|jsx|less|md|scss|toml|ts|xml|yaml|yml)$
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v7.32.0
rev: v9.0.0-beta.1
hooks:
- id: eslint
verbose: true
args:
- --color
- --fix
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v4.5.0
hooks:
- id: trailing-whitespace
# exclude autogenerated files
Expand All @@ -110,20 +110,20 @@ repos:
- id: mixed-line-ending
args: ["--fix=lf"]
- repo: https://github.com/asottile/pyupgrade
rev: v2.29.0
rev: v3.15.1
hooks:
- id: pyupgrade
args: ["--keep-percent-format"]
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
name: isort except __init__.py
args:
- --settings=.
exclude: /__init__\.py$
- repo: https://github.com/acsone/setuptools-odoo
rev: 3.1.8
rev: 3.2.1
hooks:
- id: setuptools-odoo-make-default
- id: setuptools-odoo-get-requirements
Expand All @@ -133,13 +133,13 @@ repos:
- --header
- "# generated from manifests external_dependencies"
- repo: https://github.com/PyCQA/flake8
rev: 3.9.2
rev: 7.0.0
hooks:
- id: flake8
name: flake8
additional_dependencies: ["flake8-bugbear==21.9.2"]
- repo: https://github.com/OCA/pylint-odoo
rev: 7.0.5
rev: v9.0.5
hooks:
- id: pylint_odoo
name: pylint with optional checks
Expand Down
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 227adbd

Please sign in to comment.