##############################################################################
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
from odoo import models, api
from odoo.tools.safe_eval import safe_eval


class ActWindowView(models.Model):
    _inherit = 'ir.actions.act_window'

    def read(self, fields=None, load='_classic_read'):
        result = super().read(fields, load=load)
        if result and result[0].get('context'):
            ctx = safe_eval(result[0].get('context', '{}'))
            if ctx.get('portal_products'):
                pricelist = self.env.user.partner_id.property_product_pricelist
                ctx.update({'pricelist': pricelist.id, 'partner': self.env.user.partner_id})
                result[0].update({'context': ctx})
        return result

##############################################################################
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
from odoo import models, api
from odoo.tools.safe_eval import safe_eval


class ActWindowView(models.Model):
    _inherit = 'ir.actions.act_window'

    def read(self, fields=None, load='_classic_read'):
        result = super().read(fields, load=load)
        for value in result:
            if value.get('context') and 'portal_products' in value.get('context'):
                eval_ctx = dict(self.env.context)
                try:
                    ctx = safe_eval(value.get('context', '{}'), eval_ctx)
                except:
                    ctx = {}
                pricelist = self.env.user.partner_id.property_product_pricelist
                ctx.update({'pricelist': pricelist.id, 'partner': self.env.user.partner_id.id})
                value.update({'context': str(ctx)})
        return result

Adjust to avoid bugs with other values in context
[FIX] portal_sale_distributor: Adjust to avoid bugs with other values in context

closes ingadhoc/sale#493

X-original-commit: 441d30af0c3fa8cbbe129893107436ea69cca740
Signed-off-by: Juan José Scarafía <1d1652a8631a1f5a0ea40ef8dcad76f737ce6379@adhoc.com.ar>
