Skip to content

Commit

Permalink
fieldservice_recurring: adapt to RFC OCA#735
Browse files Browse the repository at this point in the history
  • Loading branch information
hparfr authored and mourad-ehm committed Jan 27, 2022
1 parent 343a96a commit c7f58bd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
7 changes: 4 additions & 3 deletions fieldservice_recurring/models/fsm_recurring.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ def _default_team_id(self):
)
description = fields.Text(string="Description")
fsm_frequency_set_id = fields.Many2one(
"fsm.frequency.set", "Frequency Set", required=True
"fsm.frequency.set",
"Frequency Set",
)
start_date = fields.Datetime(string="Start Date")
end_date = fields.Datetime(
Expand Down Expand Up @@ -143,7 +144,7 @@ def action_cancel(self):
def _get_rruleset(self):
self.ensure_one()
ruleset = rruleset()
if self.state != "progress":
if self.state != "progress" or not self.fsm_frequency_set_id:
return ruleset
# set next_date which is used as the rrule 'dtstart' parameter
next_date = self.start_date
Expand Down Expand Up @@ -184,7 +185,7 @@ def _prepare_order_values(self, date=None):
"request_early": str(earliest_date),
"description": self.description,
"template_id": self.fsm_order_template_id.id,
"scheduled_duration": self.fsm_order_template_id.hours,
"scheduled_duration": self.fsm_order_template_id.duration,
"category_ids": [(6, False, self.fsm_order_template_id.category_ids.ids)],
"company_id": self.company_id.id,
"person_id": self.person_id.id,
Expand Down
8 changes: 2 additions & 6 deletions fieldservice_recurring/models/fsm_recurring_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ class FSMRecurringTemplate(models.Model):
name = fields.Char(string="Name", required=True)
active = fields.Boolean(default=True)
description = fields.Text(string="Description")
fsm_frequency_set_id = fields.Many2one(
"fsm.frequency.set", "Frequency Set", required=True
)
fsm_frequency_set_id = fields.Many2one("fsm.frequency.set", "Frequency Set")
max_orders = fields.Integer(
string="Maximum Orders", help="Maximium number of orders that will be created"
)
Expand All @@ -23,6 +21,4 @@ class FSMRecurringTemplate(models.Model):
string="Order Template",
help="This is the order template that will be recurring",
)
company_id = fields.Many2one(
"res.company", "Company", default=lambda self: self.env.user.company_id
)
company_id = fields.Many2one("res.company", "Company")
2 changes: 1 addition & 1 deletion fieldservice_recurring/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
* Brian McMaster <brian@mcmpest.com>
* Kitti Upariphutthiphone <kittiu@ecosoft.co.th>
* Rapha??l Reverdy <raphael.reverdy@akretion.com>
* Raphaël Reverdy <raphael.reverdy@akretion.com>

0 comments on commit c7f58bd

Please sign in to comment.