Skip to content
Snippets Groups Projects
Commit dacfa844 authored by Mathieu Walravens's avatar Mathieu Walravens
Browse files

[FIX] product_expiry: send alert activity to the correct user


Steps to reproduce:
1. Have 2 companies, and select the one w/ the highest ID
2. Create a new product tracked by lot + expiration date
3. Receive product
4. Set the received lot's expiration and alert dates in the past
5. Inventory > Operations > Run scheduler

Before this commit:
An activity is created on the lot for OdooBot,
despite the product's responsible set to the current user.
It happens because the default value for `responsible_id` is the current
user, but the value is only set for the current company. When the
scheduler runs, it doesn't set the company; therefore, it takes the
product's responsible user for the company with the lowest ID, which is
not set.

After this commit:
The activity is created for the product's responsible user using
the lot's company.

opw-3489340

closes odoo/odoo#135361

Signed-off-by: default avatarTiffany Chang (tic) <tic@odoo.com>
parent 1cad85f7
No related branches found
No related tags found
No related merge requests found
......@@ -95,7 +95,7 @@ class StockProductionLot(models.Model):
for lot in alert_lots:
lot.activity_schedule(
'product_expiry.mail_activity_type_alert_date_reached',
user_id=lot.product_id.responsible_id.id or SUPERUSER_ID,
user_id=lot.product_id.with_company(lot.company_id).responsible_id.id or lot.product_id.responsible_id.id or SUPERUSER_ID,
note=_("The alert date has been reached for this lot/serial number")
)
alert_lots.write({
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment