From cffcee614797c608037718494e28af691da7bf03 Mon Sep 17 00:00:00 2001 From: Adrien Widart Date: Tue, 15 Jun 2021 07:57:31 +0000 Subject: [PATCH] [FIX] stock: display lot on delivery slip When consulting a delivery slip, a portal user won't see the lots/serial numbers used. To reproduce the error: (Need demo data) 1. Create a product P - Product Type: Storable - Tracking: By Lots 2. Update its quantity 3. In Settings, enable "Display Lots & Serial Numbers on Delivery Slips" 4. Create + Validate a SO: - Customer: Joel Willis - Lines: 1 x P 5. Validate the delivery 6. Log in DB with 'portal' (Joel Willis) 7. On SO, open the Delivery Slip Error: The product's lot is not mentioned Here is the condition to display the lot: https://github.com/odoo/odoo/blob/c61db20204700a375f7005f50f95b44a60c3bb70/addons/stock/report/report_deliveryslip.xml#L77-L79 Problem is that portal users are not part of `group_lot_on_delivery_slip` When enabling the option, the groups are updated here https://github.com/odoo/odoo/blob/adccb562209c2431a49438d36794f0765f1bc86d/odoo/addons/base/models/res_config.py#L570-L576 `implied_group` (which is `stock.group_lot_on_delivery_slip` in our case) is added to `groups.implied_group` The variable `groups` comes from `classified`, which is defined thanks to method `_get_classified_fields` (see L553 in above code block) And here is an extract of how this method works: https://github.com/odoo/odoo/blob/adccb562209c2431a49438d36794f0765f1bc86d/odoo/addons/base/models/res_config.py#L460-L462 At some point, it checks if the field `group_lot_on_delivery_slip` has an attribute `group`. In case `group` is not defined, the group `base.group_user` is used. This is the reason why, by default, the option is enabled for internal users only instead of all users. Therefore, we just need to define the attribute `group` to the field `group_lot_on_delivery_slip` OPW-2558761 closes odoo/odoo#72656 X-original-commit: 475b35397b7254012a082a1206c478084c069857 Signed-off-by: William Henrotin Signed-off-by: Adrien Widart --- addons/stock/models/res_config_settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/stock/models/res_config_settings.py b/addons/stock/models/res_config_settings.py index 11971f4f0b2..08f5cfa489a 100644 --- a/addons/stock/models/res_config_settings.py +++ b/addons/stock/models/res_config_settings.py @@ -13,7 +13,7 @@ class ResConfigSettings(models.TransientModel): group_stock_production_lot = fields.Boolean("Lots & Serial Numbers", implied_group='stock.group_production_lot') group_lot_on_delivery_slip = fields.Boolean("Display Lots & Serial Numbers on Delivery Slips", - implied_group='stock.group_lot_on_delivery_slip') + implied_group='stock.group_lot_on_delivery_slip', group="base.group_user,base.group_portal") group_stock_tracking_lot = fields.Boolean("Packages", implied_group='stock.group_tracking_lot') group_stock_tracking_owner = fields.Boolean("Consignment",