Skip to content

Commit

Permalink
[FIX] portal_sale_distributor: Fix price compute calculation for Port…
Browse files Browse the repository at this point in the history
…al's
  • Loading branch information
nicomacr committed Jan 11, 2022
1 parent 504efec commit 37f986b
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions portal_sale_distributor/models/product_template.py
Expand Up @@ -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):
Expand All @@ -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)

0 comments on commit 37f986b

Please sign in to comment.