Skip to content

[18.0][IMP] sale_order_product_recommendation_product_sold_by_delivery_week: show live per-customer weekly sales in catalog - #379

Open
CarlosRoca13 wants to merge 1 commit into
OCA:18.0from
Tecnativa:18.0-IMP-sale_order_product_recommendation_product_sold_by_delivery_week
Open

[18.0][IMP] sale_order_product_recommendation_product_sold_by_delivery_week: show live per-customer weekly sales in catalog#379
CarlosRoca13 wants to merge 1 commit into
OCA:18.0from
Tecnativa:18.0-IMP-sale_order_product_recommendation_product_sold_by_delivery_week

Conversation

@CarlosRoca13

Copy link
Copy Markdown
Contributor

The product catalog showed the globally stored (and cron-refreshed) weekly sales hint from product_sold_by_delivery_week, which did not match the recommendation wizard: the wizard computes the hint live and filtered by the order's customer.

When the catalog is opened from a sale order it now displays a new field, weekly_sold_delivered_catalog_shown, computed on the fly and filtered by the order's commercial partner, hiding the base global hint. Outside of a sale order catalog the product lists keep showing the original stored field, and the base module is left untouched.

The computation shared by the wizard and the catalog is extracted into a single helper, product.product._weekly_sold_delivered_shown_map(), so the hint is produced in one place and both computes just map their records.

cc @Tecnativa TT63163

ping @sergio-teruel @carlosdauden

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hi @chienandalu,
some modules you are maintaining are being modified, check this out!

@OCA-git-bot OCA-git-bot added series:18.0 mod:sale_order_product_recommendation_produc f7d00 Module sale_order_product_recommendation_product_sold_by_delivery_week labels Jun 17, 2026
@CarlosRoca13
CarlosRoca13 force-pushed the 18.0-IMP-sale_order_product_recommendation_product_sold_by_delivery_week branch from bf33257 to 4e7afbb Compare June 17, 2026 11:46
…: show live per-customer weekly sales in catalog

The product catalog showed the globally stored (and cron-refreshed) weekly sales hint from product_sold_by_delivery_week, which did not match the recommendation wizard: the wizard computes the hint live and filtered by the order's customer.

When the catalog is opened from a sale order it now displays a new field, weekly_sold_delivered_catalog_shown, computed on the fly and filtered by the order's commercial partner, hiding the base global hint. Outside of a sale order catalog the product lists keep showing the original stored field, and the base module is left untouched.

The computation shared by the wizard and the catalog is extracted into a single helper, product.product._weekly_sold_delivered_shown_map(), so the hint is produced in one place and both computes just map their records.
@CarlosRoca13
CarlosRoca13 force-pushed the 18.0-IMP-sale_order_product_recommendation_product_sold_by_delivery_week branch from 4e7afbb to 0d25fe7 Compare June 17, 2026 11:48
Comment on lines +9 to +13
weekly_sold_delivered_catalog_shown = fields.Char(
string="Weekly Sold for Catalog",
compute="_compute_weekly_sold_delivered_catalog_shown",
groups="sales_team.group_sale_salesman",
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Doesn't this fit in the base module?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You're right that there's no hard technical dependency: the catalog field doesn't use anything from sale_order_product_recommendation and the base module already has the catalog view and the weekly_partner_id filtering, so it could live there.

I kept it in the glue module on purpose, though. Its only reason to exist is to make the catalog match the recommendation wizard. And the base field is intentionally stored + cron-refreshed for performance, showing a global hint; moving this in would force a live, per-customer recompute on every catalog open for everyone using only the base module, changing its behavior and performance. So the field belongs where the "match the wizard" intent lives.

If you'd still prefer the global catalog hint to be live/per-customer for base users too, I can move the field + view there instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:sale_order_product_recommendation_produc f7d00 Module sale_order_product_recommendation_product_sold_by_delivery_week series:18.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants