OCA / field-service

Field Service Management
https://odoo-community.org/psc-teams/field-service-126
GNU Affero General Public License v3.0
146 stars 239 forks source link

Make work order recurrent #164

Closed babatoko closed 5 years ago

babatoko commented 5 years ago

I guess for many company or at least in my company, we do have recurrent work to do.

They can be as follow:

Work every 3 weeks Work once a month the first week on Monday between 14:15 - 15:30.

Work can be everyday (weekdays Monday to Friday) for 2 hours except days such as Christmas or national days or any other legal days off.

Could be nice to get a wizard to make change on work order to set new worker or move the date or time on one or many work order.

brian10048 commented 5 years ago

We have similar needs for recurring work orders. Sometimes we have the same order template recurring on a set frequency and sometimes we have a series of different order templates that must be completed in sequence (which the series overall recurs annually).

My thoughts are to create a new data model that when configured will create new work orders with a cron task.

@max3903 if your team has any input on this please let me know. I can migrate this from a project I started before this OCA repo, just looking for any suggestions beforehand.

max3903 commented 5 years ago

Option 1

I was thinking of extending product.template to allow to define a "calendar" of field service orders.

Similar to Google Calendar, the calendar can be defined as a list of:

Fields Work every 3 weeks Work once a month the first week on Monday between 14:15 - 15:30.
a fsm order template Template 1 Template 1
a frequency 3 1
a unit of measure for the frequency Week(s) Month(s)
a list of weeks of the month Week 1
a list of days of the week Monday
a start time and end time 14:15 - 15:30
an end date or a number of occurrences 12 12

When the SO is confirmed with that product, the field service orders are created based on that calendar and the data from the SO.

We can create them all at once or maybe have a configuration to only create the one in the next X days and have a scheduler to scan those calendar everyday and create new orders that enters that X-days window.

wolfhall commented 5 years ago

Option 2

In my original design, I used the term "Activities". One Order has one or more activities. Each Activity (or visit) has a duration, scheduled start and end as well as actual start and end. It also has a worker assignment. Usually these fields are all inherited from the Order.
The order has a frequency field that sets daily, monthly, weekly, etc. For this, we need a new object called frequencies. Each frequency record describes the min and max duration in days between activities. E.g. a weekly activity needs to be scheduled with 7 days +/- 1 day from the previous visit (activity). The Earliest and latest start times will reflect these day ranges. the scheduled ETA will be set to the exact date based on the original Order (first activity) I have done these recurring visits many times in the past. I can create a model for it with some technical help

babatoko commented 5 years ago

In my company we actualy use project and task (witch seems to be some sort of activities) as planner tool. A customer may have one or more project and project may have one or more tasks. The only things missing seems to be tasks reccurency or task management (assign new worker, change task date, etc)

For Each worker, we have a timesheet per week on witch we records task completion with the effective start and end that could differ from the initial time.

Like this with project-tasks and timesheet record, we know the initial time planned (tasks) and the real time to get the job done (timesheet). The difference may underline some organisational mismatch that may need explaination.

Moreover, it would be great to have a mobile app that worker could use to see work order or activities and allow him to record the activities with the use of a RFID or QR code to identify the customer, the mobile date and time for the start and date and time for the end of activity when start time already recorded.

babatoko commented 5 years ago

From comments I understand that work order may be considered as template.

I think a work order may contain one or more activities.

Each activities get it's own time frequency and exclusion (national holiday, legal or religious days). It get also time schedule according the customer opening schedule. (Activities have to be done outside business hours)

Each activities has a worker assigned (if available according to holidays or sick leave or what ever event. Otherwise could be empty or assign an other worker that knows the job and available.

wolfhall commented 5 years ago

following up on babatoko's comment: We also started out using projects and tasks but quickly ran into limitations since tasks are not designed to tie to locations (an activity could be digging a trench at sub-location 1 and another activity may be installing solar panels in sub-location 2: all tied to the same work order)

We are working on a design for a mobile app as well - but we may not be able to add it to OCA anytime soon.

Regarding the second comment: Orders are more like mini-projects where the activities relate to tasks. we actually thought about allowing each activity to tie to tasks. So if you have a monthly inspection activity it may include a list of tasks to complete before each inspection is done.

the frequency lives on the order level. The activity is created based on the order frequency. on holidays, the activities can be moved to the next working day - or deleted if that is desired based on business rules. The time windows usually live on an order level but can be overwritten manually if needed on selected activities. By default, all activities are assigned to the same worker. But as you said, a dispatcher can change the assignments for selected activities.

brian10048 commented 5 years ago

I think we need solutions for both Options 1 & 2.

I agree we should extend product.template to have a link to fsm.order.template that creates a new order once the SO is confirmed. What do you think about having the recurring configuration fields be on the fsm.order.template rather than the product.template? The product.template and fsm.order.template link is more of a sales integration and sometimes it would be necessary to create recurring work that doesn't originate from a sales order.

Could the activities also be configured at the order template level? This way they are populated anytime that specific order template is selected. The frequency which these activities would recur is based on configuration of the order template.

babatoko commented 5 years ago

For my case, a SO could make a single activity and that SO will be invoiced after delivery or in most cases for my my, SO will be a contract with make my recurrent invoices for recurrent activities (managed manually as task in project).

brian10048 commented 5 years ago

@max3903 @wolfhall @babatoko Any comments, suggestions, clarifications on this spec? Anyone already working on this or planning something different?

Recurring Work Orders

Create a new module fieldservice_recurring

Configuration

Usage

  1. In fieldservice app go to Menu > Operations > Recurring Orders
  2. Create a new Order Recurrence model
  3. Select a template for recurrence and modify as needed.
  4. Set other fields for fsm location, etc
  5. Confirm the recurrence to create first order
  6. Future orders will be created via cron task as configured

Technical

babatoko commented 5 years ago

Proposal looks good, and I would like to add the following comment.

Once recurent orders are booked, I Wish to have a wizard to change as exemple worker in charge by an other, update instruction or any other info onto work orders. It should be possible for all work orders in a period.

We should see work orders as in agenda view as well.

babatoko commented 5 years ago

Hello, great start indeed and as you mention it's a work in progress.

I didn't figure out yet how I can set worker order frequency in my following use case.

One of my customer request me to service him every of weekdays except for even week we work 4 days (M,T,T,F).

Would be great to implement some sort of exclusion mechanism.

In my business, we rely strongly on time based on customers business hours.

As Example, a work have to be done after business hours and for each customers the closing time may be different. A constraint should be set for when creating work order template or work order a check occur on start and end time.

babatoko commented 5 years ago

A quick look at the subscription's tryton module showing the recurrence Rule

It defines combination of rules which compute the occurrence dates.

Name: The name of the rule.

Rules:

Exclusive: Define if the rule excludes the resulted dates. Frequency: Daily, Weekly, Monthly, Yearly. Interval: The interval of the frequency By Week Day: Defines the list of weekdays where the recurrence will be applied. By Month Day: Defines the list of month days to apply the recurrence to. By Year Day: Defines the list of year days to apply the recurrence to. By Week Number: Defines the list of week numbers (ISO8601) to apply the recurrence to. By Month: Defines the list of months to apply the recurrence to. By Position: Defines the list of occurrence positions. Week Start Day. The computation of occurrences is base on the python-dateutil library.

cf. http://docs.tryton.org/projects/modules-sale-subscription/en/latest/

brian10048 commented 5 years ago

Thank you for this. I understand what you are trying to accomplish. This will definitely help me develop the idea further! I hope to have completed some more fully featured improvements over the next several days

brian10048 commented 5 years ago

Closed with #179