From 4ff88bc7be0077fee0a4127f3fc5e758dbd9befa Mon Sep 17 00:00:00 2001 From: Djamel Touati Date: Tue, 26 Mar 2024 14:38:11 +0000 Subject: [PATCH] [FIX] sale_crm: avoid displaying archived records in quotation Before this commit, when the user created a new quotation from Contact->Opportunity-> ("New Quotation" or "Quotations/orders widget button", archived records could be added to the quotation (e.g. ,product, taxes...) because the context was set to active_test = false. After this commit, the context is configured back to active_test = true when creating a quotation from opportunity. opw-3802796 closes odoo/odoo#161087 X-original-commit: 3085c3b24bef719c3cf63ec9d3b5a7d7b2a34037 Signed-off-by: Djamel Touati (otd) Signed-off-by: Thibault Delavallee (tde) --- addons/crm/models/res_partner.py | 5 ++++- addons/sale_crm/models/crm_lead.py | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/crm/models/res_partner.py b/addons/crm/models/res_partner.py index a6df4c7ba51..423aeeffb16 100644 --- a/addons/crm/models/res_partner.py +++ b/addons/crm/models/res_partner.py @@ -2,6 +2,8 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. from odoo import api, fields, models +from odoo.osv import expression + class Partner(models.Model): @@ -67,9 +69,10 @@ class Partner(models.Model): This function returns an action that displays the opportunities from partner. ''' action = self.env['ir.actions.act_window']._for_xml_id('crm.crm_lead_opportunities') - action['context'] = {'active_test': False} + action['context'] = {} if self.is_company: action['domain'] = [('partner_id.commercial_partner_id', '=', self.id)] else: action['domain'] = [('partner_id', '=', self.id)] + action['domain'] = expression.AND([action['domain'], [('active', 'in', [True, False])]]) return action diff --git a/addons/sale_crm/models/crm_lead.py b/addons/sale_crm/models/crm_lead.py index 8d95e4b3b73..e4272d1aaab 100644 --- a/addons/sale_crm/models/crm_lead.py +++ b/addons/sale_crm/models/crm_lead.py @@ -39,7 +39,6 @@ class CrmLead(models.Model): action = self.env["ir.actions.actions"]._for_xml_id("sale_crm.sale_action_quotations_new") action['context'] = self._prepare_opportunity_quotation_context() action['context']['search_default_opportunity_id'] = self.id - action['context']['active_test'] = True return action def action_view_sale_quotation(self):