Skip to content

[14.0][ADD] stock_picking_purchase_order_alert#1913

Closed
antoniodavid wants to merge 3 commits intoOCA:14.0from
BinhexTeam:14.0-add-stock-picking-order-alert
Closed

[14.0][ADD] stock_picking_purchase_order_alert#1913
antoniodavid wants to merge 3 commits intoOCA:14.0from
BinhexTeam:14.0-add-stock-picking-order-alert

Conversation

@antoniodavid
Copy link
Copy Markdown

@antoniodavid antoniodavid commented Apr 11, 2025

@BinhexTeam T14028

This module adds alert notifications when the quantity being received in purchase receipts
exceeds the ordered quantity by more than a configurable threshold percentage (default 30%).

Often warehouse staff receive products in different units of measure than ordered,
which can lead to input errors. For example, if 6,000 units were ordered but the
staff tries to receive 60,000 units, this module will display a warning.

The module provides:

  • A warning banner in the receipt form when quantities exceed the threshold
  • A configurable feature that can be enabled/disabled via settings
  • A configurable percentage threshold for when alerts should appear
  • Proper handling of different units of measure between order and receipt
  • Prevents validation of receipts when quantities exceed the threshold percentage
  • Forces users to review and correct quantities before validating the receipt

@rousseldenis
Copy link
Copy Markdown
Contributor

@antoniodavid Thanks for this. Seems promising.

Copy link
Copy Markdown

@christian-ramos-tecnativa christian-ramos-tecnativa left a comment

Choose a reason for hiding this comment

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

It looks pretty good, can you check my comments? Thanks

Comment thread stock_picking_order_alert/README.rst
Comment thread stock_picking_order_alert/models/res_config_settings.py Outdated
Comment thread stock_picking_order_alert/models/stock_picking.py Outdated
Comment thread stock_picking_order_alert/models/stock_picking.py Outdated
@AlvaroRM11
Copy link
Copy Markdown

Looks good, also, don't forget to run the pre-commit stuff

@antoniodavid antoniodavid changed the title [ADD] [14.0] add stock picking order alert [WIP][ADD] [14.0] add stock picking order alert Apr 11, 2025
@antoniodavid antoniodavid force-pushed the 14.0-add-stock-picking-order-alert branch from 6aa2e96 to a176084 Compare April 11, 2025 14:43
@antoniodavid antoniodavid changed the title [WIP][ADD] [14.0] add stock picking order alert [ADD] [14.0] add stock picking order alert Apr 11, 2025
@antoniodavid antoniodavid force-pushed the 14.0-add-stock-picking-order-alert branch from a176084 to e2a45a7 Compare April 11, 2025 16:11
@christian-ramos-tecnativa
Copy link
Copy Markdown

@antoniodavid Now the code LGTM just some last changes:
The PR name should be: [14.0][ADD] stock_picking_order_alert
There should be just 1 commit called: [ADD] stock_picking_order_alert
Thanks!

@antoniodavid antoniodavid changed the title [ADD] [14.0] add stock picking order alert [14.0][ADD] stock_picking_order_alert Apr 11, 2025
@antoniodavid antoniodavid force-pushed the 14.0-add-stock-picking-order-alert branch from e2a45a7 to d8f2b45 Compare April 11, 2025 17:18
@antoniodavid
Copy link
Copy Markdown
Author

@antoniodavid Now the code LGTM just some last changes: The PR name should be: [14.0][ADD] stock_picking_order_alert There should be just 1 commit called: [ADD] stock_picking_order_alert Thanks!

Ready!!!

Copy link
Copy Markdown
Contributor

@rrebollo rrebollo left a comment

Choose a reason for hiding this comment

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

Code Review: Great work! The code looks good to me (LGTM). Thank you for your contribution! I've provided a few suggestions for your consideration—feel free to address them as you see fit.

Comment thread stock_picking_order_alert/models/res_config_settings.py
Comment thread stock_picking_order_alert/models/stock_picking.py Outdated
Comment thread stock_picking_order_alert/models/stock_picking.py Outdated
Comment thread stock_picking_order_alert/models/stock_picking.py Outdated
Copy link
Copy Markdown

@sheragar sheragar left a comment

Choose a reason for hiding this comment

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

LGTM. Funtional Review 👍

Copy link
Copy Markdown
Contributor

@rrebollo rrebollo left a comment

Choose a reason for hiding this comment

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

Code Review. LGTM!

Comment thread stock_picking_order_alert/models/res_config_settings.py
@antoniodavid
Copy link
Copy Markdown
Author

ping @rousseldenis

@OCA-git-bot
Copy link
Copy Markdown
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"

display_quantity_alert_percentage = fields.Boolean(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe something on picking type level is more flexible.

default=False,
config_parameter="stock_picking_order_alert.display_quantity_alert_percentage",
)
quantity_alert_percentage = fields.Float(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same as above

# Only apply quantity check if feature is enabled
if is_enabled:
# Force compute has_quantity_alert before validation
picking._compute_has_quantity_alert()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why this ?

"""Override button_validate to prevent validation
when quantity alerts exist"""
for picking in self:
is_enabled, alert_percentage = picking._is_quantity_alert_enabled()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should be done in compute instead

Copy link
Copy Markdown
Author

@antoniodavid antoniodavid May 27, 2025

Choose a reason for hiding this comment

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

@rousseldenis thanks, for all advice. Could you review again?

@antoniodavid antoniodavid force-pushed the 14.0-add-stock-picking-order-alert branch 2 times, most recently from 229935b to c3395ba Compare May 9, 2025 22:11
@antoniodavid antoniodavid changed the title [14.0][ADD] stock_picking_order_alert [14.0][ADD] stock_picking_purchase_order_alert May 9, 2025
@antoniodavid antoniodavid force-pushed the 14.0-add-stock-picking-order-alert branch from c3395ba to f850afc Compare May 23, 2025 00:46
Copy link
Copy Markdown

@christian-ramos-tecnativa christian-ramos-tecnativa left a comment

Choose a reason for hiding this comment

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

Also check pre-commit and tests. Thanks

Comment thread stock_picking_purchase_order_alert/models/stock_picking.py Outdated
Comment thread stock_picking_purchase_order_alert/views/stock_picking_type_views.xml Outdated
Comment thread stock_picking_purchase_order_alert/models/stock_picking_type.py Outdated
Comment thread stock_picking_purchase_order_alert/models/stock_picking_type.py Outdated
Comment thread stock_picking_purchase_order_alert/readme/USAGE.rst Outdated
Comment thread stock_picking_purchase_order_alert/readme/USAGE.rst
@antoniodavid antoniodavid force-pushed the 14.0-add-stock-picking-order-alert branch 3 times, most recently from 40cb259 to 113cb70 Compare May 26, 2025 23:39
@antoniodavid
Copy link
Copy Markdown
Author

Also check pre-commit and tests. Thanks

Ready @Christian-RB

Comment thread stock_picking_purchase_order_alert/migrations/14.0.1.0.1/pre-migration.py Outdated
@antoniodavid antoniodavid force-pushed the 14.0-add-stock-picking-order-alert branch from 113cb70 to bcb7324 Compare May 27, 2025 13:19
@antoniodavid antoniodavid force-pushed the 14.0-add-stock-picking-order-alert branch from bcb7324 to 2659bd8 Compare May 27, 2025 13:22
Copy link
Copy Markdown

@christian-ramos-tecnativa christian-ramos-tecnativa left a comment

Choose a reason for hiding this comment

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

After some time working with this module I have the feeling that
we don't really need to compare de done value with the purchase. IMO using the demand field product_uom_qty should be good enough and also way more generic as that field is updated directly from the purchase/sale. WDYT @antoniodavid

Comment thread stock_picking_purchase_order_alert/models/stock_picking.py
Co-authored-by: ChristianRB <69461150+Christian-RB@users.noreply.github.com>
Copy link
Copy Markdown

@edescalona edescalona left a comment

Choose a reason for hiding this comment

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

LGTM.
Hi @antoniodavid just a question: is the warning message displayed on the receipt fixed forever, even if the user had already validated the receipt with that difference in quantities?

@antoniodavid
Copy link
Copy Markdown
Author

After some time working with this module I have the feeling that we don't really need to compare de done value with the purchase. IMO using the demand field product_uom_qty should be good enough and also way more generic as that field is updated directly from the purchase/sale. WDYT @antoniodavid

Hi @Christian-RB, all changes have been made; please confirm.

@antoniodavid
Copy link
Copy Markdown
Author

@Christian-RB, please check & approve this PR.

@antoniodavid
Copy link
Copy Markdown
Author

antoniodavid commented Aug 11, 2025

ping @rousseldenis.

@github-actions
Copy link
Copy Markdown

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions Bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Dec 14, 2025
@github-actions github-actions Bot closed this Jan 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved stale PR/Issue without recent activity, it'll be soon closed automatically.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants