Skip to content

Commit

Permalink
[15.0][MIG] fieldservice_recurring
Browse files Browse the repository at this point in the history
  • Loading branch information
Freni-OSI committed Oct 17, 2022
1 parent a1e10ea commit 8273bcb
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 33 deletions.
42 changes: 20 additions & 22 deletions fieldservice_recurring/models/fsm_frequency.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ class FSMFrequency(models.Model):
)
is_exclusive = fields.Boolean(
string="Exclusive Rule?",
default=False,
help="""Checking this box will make this an exclusive rule. Exclusive
rules prevent the configured days from being a schedule option""",
)
Expand All @@ -69,27 +68,27 @@ class FSMFrequency(models.Model):
help="""When selected you will be able to choose which days of the
week the scheduler will include (or exclude if Exclusive rule)""",
)
mo = fields.Boolean("Monday", default=False)
tu = fields.Boolean("Tuesday", default=False)
we = fields.Boolean("Wednesday", default=False)
th = fields.Boolean("Thursday", default=False)
fr = fields.Boolean("Friday", default=False)
sa = fields.Boolean("Saturday", default=False)
su = fields.Boolean("Sunday", default=False)
mo = fields.Boolean("Monday")
tu = fields.Boolean("Tuesday")
we = fields.Boolean("Wednesday")
th = fields.Boolean("Thursday")
fr = fields.Boolean("Friday")
sa = fields.Boolean("Saturday")
su = fields.Boolean("Sunday")

use_bymonth = fields.Boolean(string="Use Months")
jan = fields.Boolean("January", default=False)
feb = fields.Boolean("February", default=False)
mar = fields.Boolean("March", default=False)
apr = fields.Boolean("April", default=False)
may = fields.Boolean(default=False)
jun = fields.Boolean("June", default=False)
jul = fields.Boolean("July", default=False)
aug = fields.Boolean("August", default=False)
sep = fields.Boolean("September", default=False)
oct = fields.Boolean("October", default=False)
nov = fields.Boolean("November", default=False)
dec = fields.Boolean("December", default=False)
jan = fields.Boolean("January")
feb = fields.Boolean("February")
mar = fields.Boolean("March")
apr = fields.Boolean("April")
may = fields.Boolean()
jun = fields.Boolean("June")
jul = fields.Boolean("July")
aug = fields.Boolean("August")
sep = fields.Boolean("September")
oct = fields.Boolean("October")
nov = fields.Boolean("November")
dec = fields.Boolean("December")

use_setpos = fields.Boolean(string="Use Position")
set_pos = fields.Integer(
Expand Down Expand Up @@ -163,8 +162,7 @@ def _bymonth(self):
"nov",
"dec",
]
bymonth = [months.index(field) + 1 for field in months if self[field]]
return bymonth
return [months.index(field) + 1 for field in months if self[field]]

def _bymonthday(self):
self.ensure_one()
Expand Down
9 changes: 3 additions & 6 deletions fieldservice_recurring/models/fsm_recurring.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,19 @@ def _compute_order_count(self):
def onchange_recurring_template_id(self):
if not self.fsm_recurring_template_id:
return
values = self.populate_from_template()
self.update(values)
self.update(self.populate_from_template())

def populate_from_template(self, template=False):
if not template:
template = self.fsm_recurring_template_id
vals = {
return {
"fsm_frequency_set_id": template.fsm_frequency_set_id,
"max_orders": template.max_orders,
"description": template.description,
"fsm_order_template_id": template.fsm_order_template_id,
"scheduled_duration": template.fsm_order_template_id.duration,
"company_id": template.company_id,
}
return vals

@api.model
def create(self, vals):
Expand Down Expand Up @@ -209,14 +207,13 @@ def _generate_orders(self):
"""
orders = self.env["fsm.order"]
for rec in self:
schedule_dates = rec._get_rruleset()
order_dates = []
for order in rec.fsm_order_ids:
if order.scheduled_date_start:
order_dates.append(order.scheduled_date_start.date())
max_orders = rec.max_orders if rec.max_orders > 0 else False
order_count = rec.fsm_order_count
for date in schedule_dates:
for date in rec._get_rruleset():
if date.date() in order_dates:
continue
if max_orders > order_count or not max_orders:
Expand Down
1 change: 1 addition & 0 deletions fieldservice_recurring/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
* Brian McMaster <brian@mcmpest.com>
* Kitti Upariphutthiphone <kittiu@ecosoft.co.th>
* Raphaël Reverdy <raphael.reverdy@akretion.com>
* Freni Patel <fpatel@opensourceintegrators.com>
1 change: 0 additions & 1 deletion fieldservice_recurring/views/fsm_frequency.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<!-- Field Service Frequency -->
<record id="fsm_frequency_tree_view" model="ir.ui.view">
Expand Down
1 change: 0 additions & 1 deletion fieldservice_recurring/views/fsm_frequency_set.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<!-- Field Service Frequency Rule Set -->
<record id="fsm_frequency_set_tree_view" model="ir.ui.view">
Expand Down
1 change: 0 additions & 1 deletion fieldservice_recurring/views/fsm_order.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="view_fsm_order_form" model="ir.ui.view">
<field name="model">fsm.order</field>
Expand Down
1 change: 0 additions & 1 deletion fieldservice_recurring/views/fsm_recurring.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<!-- Field Service Recurring Order -->
<record id="fsm_recurring_tree_view" model="ir.ui.view">
Expand Down
1 change: 0 additions & 1 deletion fieldservice_recurring/views/fsm_recurring_template.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<!-- Field Service Recurring Template -->
<record id="fsm_recurring_template_tree_view" model="ir.ui.view">
Expand Down

0 comments on commit 8273bcb

Please sign in to comment.