Skip to content

Commit

Permalink
[MIG] crm_salesperson_planner: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
BernatObrador committed Jul 22, 2024
1 parent 3869422 commit ccf6f8f
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 60 deletions.
4 changes: 4 additions & 0 deletions crm_salesperson_planner/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ Contributors

- Víctor Martínez

- `APSL-Nagarro <https://apsl.tech>`__:

- Bernat Obrador <[email protected]>

Maintainers
-----------

Expand Down
2 changes: 1 addition & 1 deletion crm_salesperson_planner/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
{
"name": "Crm Salesperson Planner",
"version": "16.0.2.0.0",
"version": "17.0.1.0.0",
"development_status": "Beta",
"category": "Customer Relationship Management",
"author": "Sygel Technology," "Odoo Community Association (OCA)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class CrmSalespersonPlannerVisit(models.Model):
string="Visit Number",
required=True,
default="/",
readonly=True,
copy=False,
)
partner_id = fields.Many2one(
Expand Down Expand Up @@ -60,7 +59,6 @@ class CrmSalespersonPlannerVisit(models.Model):
state = fields.Selection(
string="Status",
required=True,
readonly=True,
copy=False,
tracking=True,
selection=[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class CrmSalespersonPlannerVisitTemplate(models.Model):
name = fields.Char(
string="Visit Template Number",
default="/",
readonly=True,
copy=False,
)
description = fields.Html()
Expand All @@ -48,7 +47,6 @@ class CrmSalespersonPlannerVisitTemplate(models.Model):
comodel_name="res.partner",
string="Scheduled by",
related="user_id.partner_id",
readonly=True,
)
partner_ids = fields.Many2many(
comodel_name="res.partner",
Expand Down Expand Up @@ -107,7 +105,6 @@ class CrmSalespersonPlannerVisitTemplate(models.Model):
tracking=True,
default=lambda self: fields.Datetime.today() + timedelta(hours=1),
compute="_compute_stop",
readonly=False,
store=True,
help="Stop date of an event, without time for full days events",
)
Expand Down
2 changes: 2 additions & 0 deletions crm_salesperson_planner/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
- Gerardo Marin Parra \<<[email protected]>\>
- [Tecnativa](https://www.tecnativa.com):
- Víctor Martínez
- [APSL-Nagarro](<https://apsl.tech>):
- Bernat Obrador \<<[email protected]>\>
4 changes: 4 additions & 0 deletions crm_salesperson_planner/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,10 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<li>Víctor Martínez</li>
</ul>
</li>
<li><a class="reference external" href="https://apsl.tech">APSL-Nagarro</a>:<ul>
<li>Bernat Obrador &lt;<a class="reference external" href="mailto:bobrador&#64;apsl.net">bobrador&#64;apsl.net</a>&gt;</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,27 +197,33 @@ def test_04_cancel_visit(self):
def test_05_repeat_weeks(self):
self.visit_template_base.write(
{
"start_date": "2024-03-08",
"start_date": fields.Date.today(),
"interval": 1,
"rrule_type": "weekly",
"tue": True,
"end_type": "end_date",
"until": "2024-07-02",
"until": fields.Date.today() + timedelta(days=90),
}
)

dates = [
self.visit_template_base.start_date + timedelta(days=i) for i in range(91)
]
filtered_tue_dates = [d for d in dates if d.weekday() == 1]

self.visit_template_base.action_validate()
self.assertFalse(self.visit_template_base.visit_ids)
create_model = self.env["crm.salesperson.planner.visit.template.create"]
create_item = create_model.with_context(
active_id=self.visit_template_base.id
).create({"date_to": "2024-07-02"})
).create({"date_to": filtered_tue_dates[2]})
create_item.create_visits()
self.assertEqual(self.visit_template_base.state, "done")
visit_dates = self.visit_template_base.visit_ids.mapped("date")
self.assertIn(fields.Date.from_string("2024-03-19"), visit_dates)
self.assertIn(fields.Date.from_string(filtered_tue_dates[4]), visit_dates)
self.assertEqual(
self.visit_template_base.last_visit_date,
fields.Date.from_string("2024-07-02"),
fields.Date.from_string(filtered_tue_dates[len(filtered_tue_dates) - 1]),
)

def test_06_repeat_months_count_01(self):
Expand Down
4 changes: 1 addition & 3 deletions crm_salesperson_planner/views/crm_lead.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
<field name="arch" type="xml">
<notebook position="inside">
<page string="Salesperson Visits">
<group>
<field name="crm_salesperson_planner_visit_ids" nolabel="1" />
</group>
<field name="crm_salesperson_planner_visit_ids" nolabel="1" />
</page>
</notebook>
</field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<field name="model">crm.salesperson.planner.visit.template</field>
<field name="arch" type="xml">
<tree>
<field name="name" />
<field name="partner_id" />
<field name="name" readonly="1" />
<field name="partner_id" readonly="1" />
<field name="start_date" />
<field name="sequence" />
<field name="user_id" />
Expand All @@ -28,25 +28,25 @@
name="action_validate"
string="Validate"
type="object"
attrs="{'invisible': [('state', '!=', 'draft')]}"
invisible="state != 'draft'"
/>
<button
name="%(crm_salesperson_planner_visit_template_create_action)d"
string="Manually Create Visits"
type="action"
attrs="{'invisible': [('state', '!=', 'in-progress')]}"
invisible="state != 'in-progress'"
/>
<button
name="action_cancel"
string="Cancel"
type="object"
attrs="{'invisible': [('state', '!=', 'in-progress')]}"
invisible="state != 'in-progress'"
/>
<button
name="action_draft"
string="Send to Draft"
type="object"
attrs="{'invisible': [('state', '!=', 'cancel')]}"
invisible="state != 'cancel'"
/>
<field
name="state"
Expand Down Expand Up @@ -76,11 +76,11 @@
</div>
<group>
<group>
<field name="partner_id" invisible="1" />
<field name="partner_id" invisible="1" readonly="1" />
<field name="partner_ids" widget="many2many_tags" />
<field name="start_date" required="1" />
<field name="start" invisible="1" />
<field name="stop" invisible="1" />
<field name="stop" invisible="1" readonly="1" />
<field name="stop_date" invisible="1" />
<field name="start" invisible="1" />
<field name="sequence" />
Expand Down Expand Up @@ -109,7 +109,7 @@
</div>
<widget
name="week_days"
attrs="{'invisible': [('rrule_type', '!=', 'weekly')]}"
invisible="rrule_type != 'weekly'"
/>
</div>
<label string="Until" for="end_type" />
Expand All @@ -118,31 +118,35 @@
<field
name="count"
required="1"
attrs="{'invisible': [('end_type', '!=', 'count')]}"
invisible="end_type != 'count'"
/>
<field
name="until"
attrs="{'invisible': [('end_type', '!=', 'end_date')], 'required': [('end_type', '=', 'end_date')]}"
invisible="end_type != 'end_date'"
required="end_type == 'end_date'"
/>
</div>
</group>
<group attrs="{'invisible': [('rrule_type', '!=', 'monthly')]}">
<group invisible="rrule_type == 'monthly'">
<label string="Day of Month" for="month_by" />
<div class="o_row">
<field name="month_by" />
<field
name="day"
attrs="{'required': [('month_by', '=', 'date'), ('rrule_type', '=', 'monthly')], 'invisible': [('month_by', '!=', 'date')]}"
required="month_by == 'date' and rrule_type == 'monthly'"
invisible="month_by != 'date'"
/>
<field
name="byday"
string="The"
attrs="{'required': [('month_by', '=', 'day'), ('rrule_type', '=', 'monthly')], 'invisible': [('month_by', '!=', 'day')]}"
required="month_by == 'day' and rrule_type == 'monthly'"
invisible="month_by != 'day'"
/>
<field
name="weekday"
nolabel="1"
attrs="{'required': [('month_by', '=', 'day'), ('rrule_type', '=', 'monthly')], 'invisible': [('month_by', '!=', 'day')]}"
required="month_by == 'day' and rrule_type == 'monthly'"
invisible="month_by != 'day'"
/>
</div>
</group>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,44 +12,44 @@
decoration-warning="state == 'incident'"
decoration-muted="state == 'cancel'"
>
<field name="name" />
<field name="name" readonly="1" />
<field name="sequence" />
<field name="date" />
<field name="partner_id" />
<field name="user_id" />
<field name="company_id" groups="base.group_multi_company" />
<field name="state" />
<field name="state" readonly="1" />
<button
name="action_draft"
type="object"
attrs="{'invisible': [('state', 'not in', ['cancel','incident', 'done'])]}"
invisible="state not in ['cancel','incident', 'done']"
icon="fa-undo"
/>
<button
name="action_confirm"
type="object"
icon="fa-calendar text-success"
attrs="{'invisible': [('state', '!=', 'draft')]}"
invisible="state != 'draft'"
/>
<button
name="action_done"
type="object"
icon="fa-check"
attrs="{'invisible': [('state', '!=', 'confirm')]}"
invisible="state != 'confirm'"
/>
<button
name="%(crm_salesperson_planner_visit_close_wiz_action)d"
type="action"
icon="fa-ban text-danger"
attrs="{'invisible': [('state', 'in', ['cancel','incident', 'done'])]}"
invisible="state in ['cancel','incident', 'done']"
context="{'att_close_type':'cancel'}"
title="Close Reasons"
/>
<button
name="%(crm_salesperson_planner_visit_close_wiz_action)d"
type="action"
icon="fa-exclamation-triangle"
attrs="{'invisible': [('state', '!=', 'confirm')]}"
invisible="state != 'confirm'"
context="{'att_close_type':'incident'}"
title="Close Reasons"
/>
Expand All @@ -67,44 +67,45 @@
id="action_draft"
string="Draft"
type="object"
attrs="{'invisible': [('state', 'not in', ['cancel','incident', 'done'])]}"
invisible="state not in ['cancel','incident', 'done']"
/>
<button
name="action_confirm"
id="action_confirm"
string="Confirm"
class="btn-primary"
type="object"
attrs="{'invisible': [('state', '!=', 'draft')]}"
invisible="state != 'draft'"
/>
<button
name="action_done"
id="action_done"
string="Done"
class="btn-primary"
type="object"
attrs="{'invisible': [('state', '!=', 'confirm')]}"
invisible="state != 'confirm'"
/>
<button
name="%(crm_salesperson_planner_visit_close_wiz_action)d"
id="action_cancel"
string="Cancel"
type="action"
attrs="{'invisible': [('state', 'in', ['cancel','incident', 'done'])]}"
invisible="state in ['cancel','incident', 'done']"
context="{'att_close_type':'cancel'}"
/>
<button
name="%(crm_salesperson_planner_visit_close_wiz_action)d"
id="action_incident"
string="Incident"
type="action"
attrs="{'invisible': [('state', '!=', 'confirm')]}"
invisible="state != 'confirm'"
context="{'att_close_type':'incident'}"
/>
<field
name="state"
widget="statusbar"
statusbar_visible="draft,confirm,done,cancel"
readonly="1"
/>
</header>
<sheet string="Visit">
Expand All @@ -126,12 +127,12 @@
<field
name="partner_phone"
widget="phone"
attrs="{'invisible': [('partner_id', '=', False)]}"
invisible="not partner_id"
/>
<field
name="partner_mobile"
widget="phone"
attrs="{'invisible': [('partner_id', '=', False)]}"
invisible="not partner_id"
/>
</group>
<group>
Expand All @@ -148,7 +149,7 @@
<notebook>
<page
string="Close Info"
attrs="{'invisible': [('state', 'not in', ['cancel', 'incident'])]}"
invisible="state not in ['cancel', 'incident']"
>
<group>
<field
Expand All @@ -161,7 +162,7 @@
name="close_reason_image"
widget="image"
readonly="1"
attrs="{'invisible': [('close_reason_image', '=', False)]}"
invisible="not close_reason_image"
/>
</group>
</page>
Expand All @@ -172,13 +173,11 @@
/>
</page>
<page string="Opportunities">
<group>
<field
name="opportunity_ids"
nolabel="1"
options="{'no_create': True}"
/>
</group>
name="opportunity_ids"
nolabel="1"
options="{'no_create': True}"
/>
</page>
</notebook>
</sheet>
Expand All @@ -199,7 +198,7 @@
<field name="model">crm.salesperson.planner.visit</field>
<field name="arch" type="xml">
<search string="Search Visits">
<field name="name" />
<field name="name" readonly="1" />
<field
name="partner_id"
filter_domain="[('partner_id','child_of',self)]"
Expand Down
Loading

0 comments on commit ccf6f8f

Please sign in to comment.