Skip to content

Commit

Permalink
[IMP] Bug OCA#266 False ETA Error
Browse files Browse the repository at this point in the history
[IMP] Bug OCA#265 Linked Location Search Error

[IMP] Bug OCA#272 Rate Not Declared

[IMP] Bug OCA#263 equipment_count Wrong

[IMP] Bug OCA#277 Worker Pricelists Computed Wrong

[IMP] Flake8 + Remove Debug
  • Loading branch information
osi-scampbell authored and Ammar-OSI committed Jan 7, 2022
1 parent bbce4f1 commit 27a2779
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 19 deletions.
13 changes: 1 addition & 12 deletions fieldservice/models/fsm_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,7 @@ def comp_count(self, contact, equipment, loc):
child_locs = self.env['fsm.location'].\
search([('fsm_parent_id', '=', child.id)])
equip = self.env['fsm.equipment'].\
search_count([('location_id',
'=', child.id)])
search_count([('location_id', '=', child.id)])
if child_locs:
for loc in child_locs:
equip += loc.comp_count(0, 1, loc)
Expand Down Expand Up @@ -336,16 +335,6 @@ def _compute_equipment_ids(self):
for loc in self:
equipment = self.comp_count(0, 1, loc)
loc.equipment_count = equipment
for location in self:
child_locs = self.env['fsm.location']. \
search([('fsm_parent_id', '=', location.id)])
equipment = (self.env['fsm.equipment'].
search_count([('location_id',
'in', child_locs.ids)]) +
self.env['fsm.equipment'].
search_count([('location_id',
'=', location.id)]))
location.equipment_count = equipment or 0

@api.constrains('fsm_parent_id')
def _check_location_recursion(self):
Expand Down
9 changes: 5 additions & 4 deletions fieldservice/models/fsm_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,11 @@ def write(self, vals):
+ timedelta(hours=vals.get('scheduled_duration'))
vals['scheduled_date_end'] = str(date_to_with_delta)
if 'scheduled_date_end' not in vals and 'scheduled_date_start' in vals:
date_to_with_delta = fields.Datetime.from_string(
vals.get('scheduled_date_start')) + \
timedelta(hours=self.scheduled_duration)
vals['scheduled_date_end'] = str(date_to_with_delta)
if vals['scheduled_date_start']:
date_to_with_delta = fields.Datetime.from_string(
vals.get('scheduled_date_start')) + \
timedelta(hours=self.scheduled_duration)
vals['scheduled_date_end'] = str(date_to_with_delta)
res = super(FSMOrder, self).write(vals)
for order in self:
if 'customer_id' not in vals and order.customer_id is False:
Expand Down
22 changes: 19 additions & 3 deletions fieldservice/models/fsm_person.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,25 @@ def _search(self, args, offset=0, limit=None, order=None, count=False,
for arg in args:
if isinstance(arg, (list)):
if arg[0] == 'location_ids':
self.env.cr.execute("SELECT person_id "
"FROM fsm_location_person "
"WHERE location_id=%s", (arg[2],))
# If given int search ID, else search name
if isinstance(arg[2], int):
self.env.cr.execute("SELECT person_id "
"FROM fsm_location_person "
"WHERE location_id=%s", (arg[2],))
else:
arg[2] = '%' + arg[2] + '%'
self.env.cr.execute("SELECT id "
"FROM fsm_location "
"WHERE complete_name like %s",
(arg[2],))
location_ids = self.env.cr.fetchall()
if location_ids:
location_ids = \
[location[0] for location in location_ids]
self.env.cr.execute("SELECT DISTINCT person_id "
"FROM fsm_location_person "
"WHERE location_id in %s",
[tuple(location_ids)])
workers_ids = self.env.cr.fetchall()
if workers_ids:
preferred_workers_list = \
Expand Down

0 comments on commit 27a2779

Please sign in to comment.