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

[16.0][MIG] shift_worker_status #537

Merged
merged 33 commits into from
Dec 23, 2024
Merged

Conversation

remytms
Copy link
Collaborator

@remytms remytms commented Dec 4, 2024

Description

Migration of module shift_worker_status

Odoo task (if applicable)

task

Checklist before approval

  • Tests are present (or not needed).
  • Credits/copyright have been changed correctly.
  • Change log snippet is present.
  • (If a new module) Moving this to OCA has been considered.

carmenbianca and others added 28 commits December 4, 2024 11:08
Signed-off-by: Carmen Bianca BAKKER <[email protected]>
* rename many2many tables and their columns.
* rename constraints and indexes.
Signed-off-by: Carmen Bianca BAKKER <[email protected]>
Signed-off-by: Carmen Bianca BAKKER <[email protected]>
There are two fixes in this commit:

- Use .search() instead of .get_param() for a more robust search of the
  old value.
- Rename all XMLIDs. When they XMLIDs aren't renamed, the values get
  overridden during init, even though the config_parameter keys were
  renamed.

Signed-off-by: Carmen Bianca BAKKER <[email protected]>
Signed-off-by: Carmen Bianca BAKKER <[email protected]>
Signed-off-by: Carmen Bianca BAKKER <[email protected]>
Signed-off-by: Carmen Bianca BAKKER <[email protected]>
Signed-off-by: Carmen Bianca BAKKER <[email protected]>
Signed-off-by: Carmen Bianca BAKKER <[email protected]>
fix shift_worker_status.irregular_penalty config parameter resetting to
true when updating the module.
Copy link
Collaborator

@polchampion polchampion left a comment

Choose a reason for hiding this comment

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

functional test on 16-test-shift
@remytms can you add the features listed below in the DESCRIPTION file?
see also my comments below fyi

features

  • add "irregular penalty" config in shift settings
  • compute next countdown date for irregular workers, taking into account holidays and exemption status
  • compute the future alert date for irregular workers but without taking holidays into account (to add to roadmap)
  • compute regular and irregular statuses according to alert start day, alert delay, grace delay and time extensions, taking into account holidays and exemption status
  • recompute status and counters when a shift undergoes a state change
  • postpone alert start time based on holidays and extension status
  • handle is_regular and is_compensation consistency on shifts, on worker change and by raising a validation error if the fields are not properly set

some remarks¨

  • contrary to v12, it's not possible to change the attendance state of a shift by clicking on the state names on the top right in form view.
  • "Future Alert Date" and "Next Countdown Date" are computed according to a hardcoded 28-day period instead of depending on "shift.shift_period"
  • The next countdown date takes into account holidays and exemptions, but sadly the future alert date does not...
  • when shift_worker_status isn't installed, there is an error (see below) preventing to subscribe a worker to a working mode
Odoo Server Error
Traceback (most recent call last):
  File "/home/odoo16/src/odoo/odoo/http.py", line 1652, in _serve_db
    return service_model.retrying(self._serve_ir_http, self.env)
  File "/home/odoo16/src/odoo/odoo/service/model.py", line 133, in retrying
    result = func()
  File "/home/odoo16/src/odoo/odoo/http.py", line 1679, in _serve_ir_http
    response = self.dispatcher.dispatch(rule.endpoint, args)
  File "/home/odoo16/src/odoo/odoo/http.py", line 1883, in dispatch
    result = self.request.registry['ir.http']._dispatch(endpoint)
  File "/home/odoo16/src/odoo/odoo/addons/base/models/ir_http.py", line 154, in _dispatch
    result = endpoint(**request.params)
  File "/home/odoo16/src/odoo/odoo/http.py", line 734, in route_wrapper
    result = endpoint(self, *args, **params_ok)
  File "/home/odoo16/src/odoo/addons/web/controllers/dataset.py", line 46, in call_button
    action = self._call_kw(model, method, args, kwargs)
  File "/home/odoo16/src/odoo/addons/web/controllers/dataset.py", line 33, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "/home/odoo16/src/odoo/odoo/api.py", line 469, in call_kw
    model.env.flush_all()
  File "/home/odoo16/src/odoo/odoo/api.py", line 755, in flush_all
    self._recompute_all()
  File "/home/odoo16/src/odoo/odoo/api.py", line 751, in _recompute_all
    self[field.model_name]._recompute_field(field)
  File "/home/odoo16/src/odoo/odoo/models.py", line 6283, in _recompute_field
    field.recompute(records)
  File "/home/odoo16/src/odoo/odoo/fields.py", line 1370, in recompute
    apply_except_missing(self.compute_value, recs)
  File "/home/odoo16/src/odoo/odoo/fields.py", line 1343, in apply_except_missing
    func(records)
  File "/home/odoo16/src/odoo/odoo/fields.py", line 1392, in compute_value
    records._compute_field_value(self)
  File "/home/odoo16/src/odoo/addons/mail/models/mail_thread.py", line 403, in _compute_field_value
    return super()._compute_field_value(field)
  File "/home/odoo16/src/odoo/odoo/models.py", line 4241, in _compute_field_value
    fields.determine(field.compute, self)
  File "/home/odoo16/src/odoo/odoo/fields.py", line 101, in determine
    return needle(records, *args)
  File "/home/odoo16/src/odoo/odoo/fields.py", line 702, in _compute_related
    record[self.name] = self._process_related(value[self.related_field.name])
  File "/home/odoo16/src/odoo/odoo/models.py", line 5957, in __getitem__
    return self._fields[key].__get__(self, self.env.registry[self._name])
  File "/home/odoo16/src/odoo/odoo/fields.py", line 1158, in __get__
    self.recompute(record)
  File "/home/odoo16/src/odoo/odoo/fields.py", line 1370, in recompute
    apply_except_missing(self.compute_value, recs)
  File "/home/odoo16/src/odoo/odoo/fields.py", line 1343, in apply_except_missing
    func(records)
  File "/home/odoo16/src/odoo/odoo/fields.py", line 1392, in compute_value
    records._compute_field_value(self)
  File "/home/odoo16/src/odoo/odoo/models.py", line 4241, in _compute_field_value
    fields.determine(field.compute, self)
  File "/home/odoo16/src/odoo/odoo/fields.py", line 98, in determine
    return needle(*args)
  File "/home/odoo16/src/coopiteasy/obeesdoo/shift/models/cooperative_status.py", line 183, in _compute_status
    rec._state_change(previous_status, new_status)
TypeError: CooperativeStatus._state_change() takes 2 positional arguments but 3 were given

The above server error caused the following client error:
RPC_ERROR: Odoo Server Error
    RPCError@https://odoo16.main.test.srv.coopiteasy.be/web/assets/227-3c0999b/web.assets_backend.min.js:993:274
    makeErrorFromResponse@https://odoo16.main.test.srv.coopiteasy.be/web/assets/227-3c0999b/web.assets_backend.min.js:997:163
    jsonrpc/promise</<@https://odoo16.main.test.srv.coopiteasy.be/web/assets/227-3c0999b/web.assets_backend.min.js:1005:34
    ```

_write function is not called the same way than in 12.0.

The _state_change() hook is therefore not triggered correctly.

_state_change() is now added to the _compute_state function as for the
log in status.history.
next_countdown_date and future_alert_date were not computed the same
way, leading to differences for an irregular worker, with a counter (sr)
equal to zero and an exemption set during the next countdown date.
@remytms remytms force-pushed the 16.0-mig-shift_worker_status branch from 4fc9d48 to 21ef06f Compare December 16, 2024 14:59
@polchampion
Copy link
Collaborator

all good

features

  • add "irregular penalty" config in shift settings
  • compute next countdown date and future alert date for irregular workers, taking into account holidays and exemption status
  • compute the future alert date for irregular workers but without taking holidays into account (to add to roadmap)
  • compute regular and irregular statuses according to alert start day, alert delay, grace delay and time extensions, taking into account holidays and exemption status
  • recompute status and counters when a shift undergoes a state change
  • postpone alert start time based on holidays and extension status
  • handle is_regular and is_compensation consistency on shifts, on worker change and by raising a validation error if the fields are not properly set

@polchampion
Copy link
Collaborator

@remytms Good work! can you add the above features list to the module description and then merge?

@remytms
Copy link
Collaborator Author

remytms commented Dec 23, 2024

/ocabot merge nobump

@github-grap-bot
Copy link
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 16.0-ocabot-merge-pr-537-by-remytms-bump-nobump, awaiting test results.

@github-grap-bot github-grap-bot merged commit 6ce9884 into 16.0 Dec 23, 2024
2 checks passed
@github-grap-bot github-grap-bot deleted the 16.0-mig-shift_worker_status branch December 23, 2024 10:04
@github-grap-bot
Copy link
Contributor

Congratulations, your PR was merged at 4f1153d. Thanks a lot for contributing to beescoop. ❤️

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.

5 participants