Skip to content

[16.0][IMP][REF] stock_average_daily_sale: refactor#403

Merged
OCA-git-bot merged 2 commits intoOCA:16.0from
jbaudoux:16-stock_average_daily_sale-refactor
Apr 25, 2025
Merged

[16.0][IMP][REF] stock_average_daily_sale: refactor#403
OCA-git-bot merged 2 commits intoOCA:16.0from
jbaudoux:16-stock_average_daily_sale-refactor

Conversation

@jbaudoux
Copy link
Contributor

@jbaudoux jbaudoux commented Apr 4, 2025

  • Allow to set a location from which consumption are computed. This allows to compute consumption on a picking zone instead of the complete warehouse.
  • Properly compute the average daily quantity. The old query was lacking a time basis and not computing on daily basis.
  • Add max daily consumption metric
  • Remove stock level, this is not relevant for this report
  • Drop spike exclusion as it was counter-productive the way it was used
  • When average is computed on 5 days a week, don't loose any movement happening during weekend
  • Added multi-company rules

performance: more than 1000 lines computed per second

@jbaudoux jbaudoux force-pushed the 16-stock_average_daily_sale-refactor branch 12 times, most recently from 4b01770 to 037c974 Compare April 7, 2025 07:32
@jbaudoux jbaudoux marked this pull request as ready for review April 7, 2025 07:39
@jbaudoux
Copy link
Contributor Author

jbaudoux commented Apr 7, 2025

Tests are red due to network issue

@jbaudoux
Copy link
Contributor Author

jbaudoux commented Apr 7, 2025

For review @rousseldenis @twalter-c2c @lmignon

<field name="standard_deviation_exclude_factor">3</field>
<field name="safety_factor">0.3</field>
<field name="number_days_qty_in_stock">2</field>
<field name="exclude_weekends">1</field>

Choose a reason for hiding this comment

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

Suggested change
<field name="exclude_weekends">1</field>
<field name="exclude_weekends">0</field>

Maybe we can include weekends in demo data to be consistent with the change merged in v14 #355.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't rely much on demo data anymore in the tests. So doesn't really matter

Comment on lines +73 to +102
<field name="warehouse_id" />
<field name="location_id" />
<field name="product_id" />
<field name="abc_classification_level" />
<field name="sale_ok" />
<field name="date_from" />
<field name="date_to" />
</group>
<group>
<field name="nbr_sales" />
<field name="average_qty_by_sale" />
<field name="average_daily_sales_count" />
<field name="max_daily_qty" />
<field name="average_daily_qty" />
<field name="daily_standard_deviation" />
<field name="safety" />
<field name="recommended_qty" />

Choose a reason for hiding this comment

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

I suggested a different order of columns in #401 . Hard to say which one is better. To be discussed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah thanks for pointing out. I'll add the optional here. Seems a nice addition.
For the order of columns, it's a matter of taste... I tried to be logical. Anyway it's a detail

Copy link
Contributor Author

@jbaudoux jbaudoux Apr 7, 2025

Choose a reason for hiding this comment

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

I did this
d5add51
based on your suggestion

SElECT * FROM cfg
WHERE cfg.abc_classification_level = COALESCE(pt.abc_storage, 'c')
AND sl_src.parent_path ilike concat(cfg.location_parent_path, '%%')
AND sl_dest.parent_path not ilike concat(cfg.location_parent_path, '%%')

Choose a reason for hiding this comment

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

I wonder if we want to take internal transfers into account. Which we do now, am I right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it's on purpose to be able to monitor a picking zone instead of stock to customer

Copy link

@twalter-c2c twalter-c2c left a comment

Choose a reason for hiding this comment

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

Great job! I dropped few minor comments.

- Allow to set a location from which consumption are computed
- Properly compute the average daily quantity
- Add max daily consumption metric
- Remove stock level, this is not relevant for this report
- Drop spike exclusion as it was counter-productive the way it was used
- Moved safety and recommended quantity as computed field so that it can
  be extended
- Added multi-company rules
@jbaudoux jbaudoux force-pushed the 16-stock_average_daily_sale-refactor branch from 037c974 to d5add51 Compare April 7, 2025 16:06
@jbaudoux jbaudoux force-pushed the 16-stock_average_daily_sale-refactor branch from d5add51 to 08e8abe Compare April 7, 2025 16:08
Copy link

@lmignon lmignon left a comment

Choose a reason for hiding this comment

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

The readability is highly improved in addition to all the improvements. Thank you @jbaudoux . LGTM (Code review).

As a side note, I'm a little alarmed by the deletion of the exclusion of peaks, which was intended to ensure that the average does not take into account “exceptional events”, which should not be taken into account when talking about averages. (we'll see..)

@OCA-git-bot
Copy link
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). 🤖

@rousseldenis
Copy link
Contributor

/ocabot merge major

@OCA-git-bot
Copy link
Contributor

Hey, thanks for contributing! Proceeding to merge this for you.
Prepared branch 16.0-ocabot-merge-pr-403-by-rousseldenis-bump-major, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 2881723 into OCA:16.0 Apr 25, 2025
7 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 709c973. Thanks a lot for contributing to OCA. ❤️

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