[FIX] sale_timesheet: avoid warning on none existing SO record

This commit is avoiding the creation of the upselling
activity on the compute not yet saved,
on upselling a service product (increasing the qty_delivered)
and clicking outside of the list view containing the SOL(s)
on a SO, on a SO create before the install of sale_timesheet.

Steps to reproduce in 16.0:
1. Install sale_management,
2. Create product.template of type Service,
3. Sale & Invoice it,
4. Install sale_timesheet,
5. Come back on previous SO and modify
the qty_delivered of the SO of the product (increase it).
That will set the invoice_status of the SO to 'upselling'
and generating a next activity for the salesperson.
6. Clicking outside the SOL will pop a Warning saying:
"Activities have to be linked to records with a not null res_id"

Every SO pre-install of sale_timesheet that are in state Sale Order
allow the modification of the qty_delivered field due to the field
"qty_delivered_method" being set to "manual" instead of "timesheet".
Which is not the case in the SO created post-install of the
sale_timesheet module.

After the fix, the next activity will only be trigger when clicking
on the SAVE button of the SO.

PS: the steps and install of module make the test impossible.

opw-3293686

closes odoo/odoo#123877

X-original-commit: 448a261d21d0d8e12477d8efa2ba0dfbf29c4a56
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
This commit is contained in:
bve-odoo
2023-06-06 18:10:51 +02:00
parent 42bbe463c0
commit 6efb6eb504
@@ -56,6 +56,7 @@ class SaleOrder(models.Model):
upsellable_orders = self.filtered(lambda so:
so.state == 'sale'
and so.invoice_status != 'upselling'
and so.id
and (so.user_id or so.partner_id.user_id) # salesperson needed to assign upsell activity
)
for order in upsellable_orders: