-
Notifications
You must be signed in to change notification settings - Fork 58
/
product_template.py
30 lines (26 loc) · 1.57 KB
/
product_template.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
##############################################################################
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
from odoo import models, api
class ProductTemplate(models.Model):
_inherit = 'product.template'
def _compute_template_price(self):
# other approach could be to inherit the method that builds the
# action (like fields view get)
if self._context.get('portal_products'):
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)