-
-
Notifications
You must be signed in to change notification settings - Fork 209
[16.0][IMP] shopfloor_reception*: allow over receiving #1090
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
base: 16.0
Are you sure you want to change the base?
[16.0][IMP] shopfloor_reception*: allow over receiving #1090
Conversation
Adds a new hook allowing custom logic, such as creating a helpdesk ticket or sending a notification, to be executed when a user confirms an over-reception on a picking line.
|
Hi @simahawk, @JuMiSanAr, @guewen, @mmequignon, @sebalix, |
8e064b8 to
462d83d
Compare
| if compare == 1 and not is_over_reception_confirmed: | ||
| line.write(previous_vals) | ||
| message = self._response_for_confirm_over_reception( | ||
| picking, | ||
| line, | ||
| quantity, | ||
| action, | ||
| message=self.msg_store.line_scanned_qty_done_higher_than_allowed(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid the useless write,
if compare == 1:
return self._response_for_confirm_over_reception()
line.qty_done = quantityThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This write is not useless, this is used to rollback the value before user confirms.
I need to do this because the function _set_quantity__check_quantity_done is checking all the qty_done on the move so I need to update the move before this check but then I need to rollback before user confirms. I agree this is not beautiful since, in the case of a user confirming, we will have a useless double write. However, I suspect this is necessary to follow this pattern to avoid problems in the case of many workers working on the same move.
I copied this pattern from the function _set_quantity__by_product
shopfloor/actions/message.py
Outdated
| # def over_reception_ask_confirm(self): | ||
| # return { | ||
| # "message_type": "warning", | ||
| # "body": _( | ||
| # "You confirmed you wanted to receive more goods " | ||
| # "than expected. Click again to continue." | ||
| # ), | ||
| # } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # def over_reception_ask_confirm(self): | |
| # return { | |
| # "message_type": "warning", | |
| # "body": _( | |
| # "You confirmed you wanted to receive more goods " | |
| # "than expected. Click again to continue." | |
| # ), | |
| # } |
shopfloor/actions/message.py
Outdated
| "message_type": "warning", | ||
| "body": _( | ||
| "Confirm location change from %(location_from)s to " "%(location_to)s?" | ||
| "Confirm location change from %(location_from)s to %(location_to)s?" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid this changes
| } | ||
| if (this.qty > this.qtyTodo) { | ||
| return "background-color: orangered"; | ||
| return "background-color: rgb(229, 171, 0)"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid this changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea was to make the color a "warning" color instead of a "danger" one since now it is possible to over-receive. Thus, it is no more an error.
| """ | ||
|
|
||
| def _set_quantity__process__set_qty_and_split( | ||
| self, picking, line, quantity, action, is_over_reception_confirmed=False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| self, picking, line, quantity, action, is_over_reception_confirmed=False | |
| self, picking, line, quantity, action=None, is_over_reception_confirmed=False |
…estions. - Add docstrings to important functions - Revert color change when qty > expected qty - Remove leftover commented lines - Add defaults to new args of modified function `_set_quantity__process__set_qty_and_split`
7ffe855 to
6704bf5
Compare
…n over reception scenario.
| return response | ||
| compare = self._set_quantity__check_quantity_done(selected_line) | ||
| compare = self._set_quantity__check_quantity_done( | ||
| selected_line, selected_line.qty_done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| selected_line, selected_line.qty_done | |
| selected_line, sum(move.move_line_ids.mapped("qty_done")) |
- Make new args of `_set_quantity__check_quantity_done` function optional so as to keep previous signature in already existing calls to that function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review + functional test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have separated commits per module? The rest can be squashed.
| @@ -1,7 +1,3 @@ | |||
| .. image:: https://odoo-community.org/readme-banner-image | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please rollback these README changes?
TIP: run export SKIP=oca-gen-addon-readme to avoid updating readme files on each commit ;)
| savepoint.rollback() | ||
| return self._response_for_set_quantity( | ||
| picking, line, message=self.msg_store.unable_to_pick_qty() | ||
| def _after_over_recepetion_confirmed_hook(self, picking, line): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| def _after_over_recepetion_confirmed_hook(self, picking, line): | |
| def _after_over_reception_confirmed_hook(self, picking, line): |
| "process_with_new_pack", | ||
| is_over_reception_confirmed, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| "process_with_new_pack", | |
| is_over_reception_confirmed, | |
| action="process_with_new_pack", | |
| is_over_reception_confirmed=is_over_reception_confirmed, |
I'm not a fan of "hiding" kw args w/ positional args just because python allows to do so :)
| <div class="button-list button-vertical-list full"> | ||
| <v-row align="center"> | ||
| <v-col class="text-center" cols="12"> | ||
| <div>{{ state.display_info.message }}</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
display_info messages are normally visible on the top of the page automatically. Is this really needed?
This PR adds the possibility to receive more goods than ordered (in case of an error from the supplier for example)