From d8567aa8420112bf368f25f1ee93e62fe00a0168 Mon Sep 17 00:00:00 2001 From: Mathieu Walravens <wama@odoo.com> Date: Wed, 13 Sep 2023 17:36:23 +0200 Subject: [PATCH] [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#136125 X-original-commit: dacfa84486c3251f503ef2a36b56006471961123 Signed-off-by: Tiffany Chang (tic) <tic@odoo.com> Signed-off-by: Walravens Mathieu (wama) <wama@odoo.com> --- addons/product_expiry/models/production_lot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/product_expiry/models/production_lot.py b/addons/product_expiry/models/production_lot.py index 0b8f32c03fde..65b26978ac04 100644 --- a/addons/product_expiry/models/production_lot.py +++ b/addons/product_expiry/models/production_lot.py @@ -81,7 +81,7 @@ class StockLot(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({ -- GitLab