コード例 #1
0
ファイル: product.py プロジェクト: adeel982010/eagle13.02
 def _get_partner_pricelist_multi_search_domain_hook(self):
     domain = super(ProductPricelist,
                    self)._get_partner_pricelist_multi_search_domain_hook()
     website = ir_http.get_request_website()
     if website:
         domain += self._get_website_pricelists_domain(website.id)
     return domain
コード例 #2
0
    def _post_processing_att(self, tagName, atts, options):
        if atts.get('data-no-post-process'):
            return atts

        atts = super(QWeb, self)._post_processing_att(tagName, atts, options)

        if options.get('inherit_branding') or options.get('rendering_bundle') or \
           options.get('edit_translations') or options.get('debug') or (request and request.session.debug):
            return atts

        website = ir_http.get_request_website()
        if not website and options.get('website_id'):
            website = self.env['website'].browse(options['website_id'])

        if not website:
            return atts

        name = self.URL_ATTRS.get(tagName)
        if request and name and name in atts:
            atts[name] = url_for(atts[name])

        if not website.cdn_activated:
            return atts

        if name and name in atts:
            atts = OrderedDict(atts)
            atts[name] = website.get_cdn_url(atts[name])
        if isinstance(atts.get('style'), str) and 'background-image' in atts['style']:
            atts = OrderedDict(atts)
            atts['style'] = re_background_image.sub(lambda m: '%s%s' % (m.group(1), website.get_cdn_url(m.group(2))), atts['style'])

        return atts
コード例 #3
0
ファイル: res_lang.py プロジェクト: adeel982010/eagle13.02
 def get_available(self):
     """ Return the available languages as a list of (code, name) sorted by name. """
     website = ir_http.get_request_website()
     if website:
         return sorted([(lang.code, lang.url_code, lang.name)
                        for lang in request.website.language_ids])
     return super(Lang, self).get_available()
コード例 #4
0
ファイル: product.py プロジェクト: adeel982010/eagle13.02
 def _get_partner_pricelist_multi_filter_hook(self):
     res = super(ProductPricelist,
                 self)._get_partner_pricelist_multi_filter_hook()
     website = ir_http.get_request_website()
     if website:
         res = res.filtered(
             lambda pl: pl._is_available_on_website(website.id))
     return res
コード例 #5
0
 def _compute_cart_qty(self):
     website = ir_http.get_request_website()
     if not website:
         self.cart_qty = 0
         return
     cart = website.sale_get_order()
     for product in self:
         product.cart_qty = sum(
             cart.order_line.filtered(
                 lambda p: p.product_id.id == product.id).mapped(
                     'product_uom_qty')) if cart else 0
コード例 #6
0
ファイル: product.py プロジェクト: adeel982010/eagle13.02
 def _get_partner_pricelist_multi(self, partner_ids, company_id=None):
     ''' If `property_product_pricelist` is read from website, we should use
         the website's company and not the user's one.
         Passing a `company_id` to super will avoid using the current user's
         company.
     '''
     website = ir_http.get_request_website()
     if not company_id and website:
         company_id = website.company_id.id
     return super(ProductPricelist, self)._get_partner_pricelist_multi(
         partner_ids, company_id)
コード例 #7
0
ファイル: ir_rule.py プロジェクト: adeel982010/eagle13.02
    def _eval_context(self):
        res = super(IrRule, self)._eval_context()

        # We need is_frontend to avoid showing website's company items in backend
        # (that could be different than current company). We can't use
        # `get_current_website(falback=False)` as it could also return a website
        # in backend (if domain set & match)..
        is_frontend = ir_http.get_request_website()
        Website = self.env['website']
        res['website'] = is_frontend and Website.get_current_website(
        ) or Website
        return res
コード例 #8
0
 def _compute_last_website_so_id(self):
     SaleOrder = self.env['sale.order']
     for partner in self:
         is_public = any([u._is_public()
                          for u in partner.with_context(active_test=False).user_ids])
         website = ir_http.get_request_website()
         if website and not is_public:
             partner.last_website_so_id = SaleOrder.search([
                 ('partner_id', '=', partner.id),
                 ('website_id', '=', website.id),
                 ('state', '=', 'draft'),
             ], order='write_date desc', limit=1)
         else:
             partner.last_website_so_id = SaleOrder  # Not in a website context or public User
コード例 #9
0
ファイル: website.py プロジェクト: rapidgrps/eagle-12.3
 def _get_pricelist_available(self, req, show_visible=False):
     """ Return the list of pricelists that can be used on website for the current user.
     Country restrictions will be detected with GeoIP (if installed).
     :param bool show_visible: if True, we don't display pricelist where selectable is False (Eg: Code promo)
     :returns: pricelist recordset
     """
     website = ir_http.get_request_website()
     if not website:
         if self.env.context.get('website_id'):
             website = self.browse(self.env.context['website_id'])
         else:
             # In the weird case we are coming from the backend (https://github.com/eagle/eagle/issues/20245)
             website = len(self) == 1 and self or self.search([], limit=1)
     isocountry = req and req.session.geoip and req.session.geoip.get('country_code') or False
     partner = self.env.user.partner_id
     last_order_pl = partner.last_website_so_id.pricelist_id
     partner_pl = partner.sudo(user=self.env.user).property_product_pricelist
     pricelists = website._get_pl_partner_order(isocountry, show_visible,
                                                website.user_id.sudo().partner_id.property_product_pricelist.id,
                                                req and req.session.get('website_sale_current_pl') or None,
                                                website.pricelist_ids,
                                                partner_pl=partner_pl and partner_pl.id or None,
                                                order_pl=last_order_pl and last_order_pl.id or None)
     return self.env['product.pricelist'].browse(pricelists)