diff --git a/portal_sale_distributor/models/product_template.py b/portal_sale_distributor/models/product_template.py index d7b13c737..b598cf1d0 100644 --- a/portal_sale_distributor/models/product_template.py +++ b/portal_sale_distributor/models/product_template.py @@ -2,7 +2,7 @@ # For copyright and license notices, see __manifest__.py file in module root # directory ############################################################################## -from odoo import models +from odoo import models, api class ProductTemplate(models.Model): @@ -11,11 +11,20 @@ class ProductTemplate(models.Model): def _compute_template_price(self): # other approach could be to inherit the method that builds the # action (like fields view get) - super()._compute_template_price() if self._context.get('portal_products'): - pricelist = self.env.user.partner_id.property_product_pricelist - context = dict(self._context, pricelist=pricelist.id, - partner=self.env.user.partner_id) - self2 = self.with_context(context) if self._context != context else self - for rec, rec2 in zip(self, self2): - rec.price = rec2.price + self = self.with_context(prefetch_fields=False, pricelist=self.env.user.partner_id.property_product_pricelist.id) + super()._compute_template_price() + # if self._context.get('portal_products'): + # pricelist = self.env.user.partner_id.property_product_pricelist + # context = dict(self._context, pricelist=pricelist.id, + # partner=self.env.user.partner_id,) + # self2 = self.with_context(context) if self._context != context else self + # for rec, rec2 in zip(self, self2): + # rec.price = rec2.price + + # @api.model + # def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False): + # if self._context.get('portal_products'): + # pricelist = self.env.user.partner_id.property_product_pricelist + # self = self.with_context(pricelist=pricelist.id, partner=self.env.user.partner_id) + # return super().fields_view_get(view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu)