Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] fieldservice_agreement: FSM Location Agreement Bug #237

Merged
merged 2 commits into from
Jun 18, 2019

Conversation

osi-scampbell
Copy link

This PR makes a small change to FSM Agreement to ensure that even if multiple records are passed into the method it can handle them appropriately.

@max3903 max3903 changed the title [IMP] Fix FSM Location Agreement Bug [FIX] fieldservice_agreement: FSM Location Agreement Bug Jun 14, 2019
@max3903 max3903 added this to the 12.0 milestone Jun 14, 2019
@patrickrwilson
Copy link

patrickrwilson commented Jun 14, 2019

@osi-scampbell I tried testing this, after creating the service location i go to sub locations and create a sub location, once i save i get this error:
ver Error
×
An error occurred

Please use the copy button to report the error to your support service.

Odoo Server Error
Traceback (most recent call last):
File "C:\Program Files (x86)\Odoo 12.0e\server\odoo\api.py", line 1032, in get
value = self._data[field][record.id][key]
KeyError: <odoo.api.Environment object at 0x093E8090>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Program Files (x86)\Odoo 12.0e\server\odoo\fields.py", line 970, in get
value = record.env.cache.get(record, self)
File "C:\Program Files (x86)\Odoo 12.0e\server\odoo\api.py", line 1034, in get
raise CacheMiss(record, field)
odoo.exceptions.CacheMiss: ('fsm.location(2,).serviceprofile_ids', None)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Program Files (x86)\Odoo 12.0e\server\odoo\http.py", line 653, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "C:\Program Files (x86)\Odoo 12.0e\server\odoo\http.py", line 312, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "C:\Program Files (x86)\Odoo 12.0e\server\odoo\tools\pycompat.py", line 87, in reraise
raise value
File "C:\Program Files (x86)\Odoo 12.0e\server\odoo\http.py", line 695, in dispatch
result = self._call_function(**self.params)
File "C:\Program Files (x86)\Odoo 12.0e\server\odoo\http.py", line 344, in _call_function
return checked_call(self.db, *args, **kwargs)
File "C:\Program Files (x86)\Odoo 12.0e\server\odoo\service\model.py", line 97, in wrapper
return f(dbname, *args, **kwargs)
File "C:\Program Files (x86)\Odoo 12.0e\server\odoo\http.py", line 337, in checked_call
result = self.endpoint(*a, **kw)
File "C:\Program Files (x86)\Odoo 12.0e\server\odoo\http.py", line 938, in call
return self.method(*args, **kw)
File "C:\Program Files (x86)\Odoo 12.0e\server\odoo\http.py", line 517, in response_wrap
response = f(*args, **kw)
File "C:\Program Files (x86)\Odoo 12.0e\server\odoo\addons\web\controllers\main.py", line 962, in call_kw
return self._call_kw(model, method, args, kwargs)
File "C:\Program Files (x86)\Odoo 12.0e\server\odoo\addons\web\controllers\main.py", line 954, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "C:\Program Files (x86)\Odoo 12.0e\server\odoo\api.py", line 749, in call_kw
return _call_kw_multi(method, model, args, kwargs)
File "C:\Program Files (x86)\Odoo 12.0e\server\odoo\api.py", line 736, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "C:\Program Files (x86)\Odoo 12.0e\server\odoo\models.py", line 2768, in read
values[name] = field.convert_to_read(record[name], record, use_name_get)
File "C:\Program Files (x86)\Odoo 12.0e\server\odoo\models.py", line 5039, in getitem
return self._fields[key].get(self, type(self))
File "C:\Program Files (x86)\Odoo 12.0e\server\odoo\fields.py", line 974, in get
self.determine_value(record)
File "C:\Program Files (x86)\Odoo 12.0e\server\odoo\fields.py", line 1085, in determine_value
self.compute_value(recs)
File "C:\Program Files (x86)\Odoo 12.0e\server\odoo\fields.py", line 1041, in compute_value
self._compute_value(records)
File "C:\Program Files (x86)\Odoo 12.0e\server\odoo\fields.py", line 1032, in _compute_value
getattr(records, self.compute)()
File "C:\Program Files (x86)\Odoo 12.0e\server\odoo\addons\fieldservice_agreement\models\fsm_location.py", line 26, in _compute_service_ids
self.serviceprofile_ids = ids
File "C:\Program Files (x86)\Odoo 12.0e\server\odoo\fields.py", line 989, in set
record.ensure_one()
File "C:\Program Files (x86)\Odoo 12.0e\server\odoo\models.py", line 4643, in ensure_one
raise ValueError("Expected singleton: %s" % self)
ValueError: Expected singleton: fsm.location(2, 1)

@osi-scampbell
Copy link
Author

osi-scampbell commented Jun 14, 2019

@patrickrwilson just made an update, change self.serviceprofile_ids = ids on line 26 to loc.serviceprofile_ids = ids in fieldservice_agreement/models/fsm_location.py

Copy link

@patrickrwilson patrickrwilson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested with the latest change and looks to be working correctly now.

@max3903 max3903 merged commit d3ff4c4 into OCA:12.0 Jun 18, 2019
@max3903 max3903 deleted the sc_fsm_agree_typo branch June 18, 2019 13:18
patrickrwilson pushed a commit to patrickrwilson/field-service that referenced this pull request Apr 27, 2021
patrickrwilson pushed a commit to patrickrwilson/field-service that referenced this pull request Apr 27, 2021
szekawong pushed a commit to xcgd/field-service that referenced this pull request Nov 6, 2023
imlopes pushed a commit to camptocamp/field-service that referenced this pull request Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants