Browse Source

[FIX] emc_wsite_portal: Explicit usage of sudo

When using sudo, write it explicitly before each query.
Prevent from showing company information if the cooperator is not a
company.
pull/1/head
Rémy Taymans 7 years ago
parent
commit
07c50e9aef
  1. 18
      easy_my_coop_website_portal/controllers/main.py
  2. 4
      easy_my_coop_website_portal/views/easy_my_coop_website_portal_templates.xml

18
easy_my_coop_website_portal/controllers/main.py

@ -41,8 +41,8 @@ class CooperatorWebsiteAccount(WebsiteAccount):
response = super(CooperatorWebsiteAccount, self).account() response = super(CooperatorWebsiteAccount, self).account()
partner = request.env.user.partner_id partner = request.env.user.partner_id
invoice_mgr = request.env['account.invoice'].sudo()
capital_request_count = invoice_mgr.search_count([
invoice_mgr = request.env['account.invoice']
capital_request_count = invoice_mgr.sudo().search_count([
('partner_id', 'in', ('partner_id', 'in',
[partner.commercial_partner_id.id]), [partner.commercial_partner_id.id]),
('state', 'in', ['open', 'paid', 'cancelled']), ('state', 'in', ['open', 'paid', 'cancelled']),
@ -67,7 +67,7 @@ class CooperatorWebsiteAccount(WebsiteAccount):
""" """
values = self._prepare_portal_layout_values() values = self._prepare_portal_layout_values()
partner = request.env.user.partner_id partner = request.env.user.partner_id
invoice_mgr = request.env['account.invoice'].sudo()
invoice_mgr = request.env['account.invoice']
domain = [ domain = [
('partner_id', 'in', ('partner_id', 'in',
@ -83,7 +83,7 @@ class CooperatorWebsiteAccount(WebsiteAccount):
('create_date', '<', date_end)] ('create_date', '<', date_end)]
# count for pager # count for pager
capital_request_count = invoice_mgr.search_count(domain)
capital_request_count = invoice_mgr.sudo().search_count(domain)
# pager # pager
pager = request.website.pager( pager = request.website.pager(
url="/my/release_capital_request", url="/my/release_capital_request",
@ -93,7 +93,7 @@ class CooperatorWebsiteAccount(WebsiteAccount):
step=self._items_per_page step=self._items_per_page
) )
# content according to pager and archive selected # content according to pager and archive selected
invoices = invoice_mgr.search(
invoices = invoice_mgr.sudo().search(
domain, limit=self._items_per_page, offset=pager['offset']) domain, limit=self._items_per_page, offset=pager['offset'])
values.update({ values.update({
'date': date_begin, 'date': date_begin,
@ -125,8 +125,8 @@ class CooperatorWebsiteAccount(WebsiteAccount):
except MissingError: except MissingError:
raise NotFound() raise NotFound()
# Get the pdf # Get the pdf
report_mgr = request.env['report'].sudo()
pdf = report_mgr.get_pdf(
report_mgr = request.env['report']
pdf = report_mgr.sudo().get_pdf(
capital_request, capital_request,
'easy_my_coop.theme_invoice_G002' 'easy_my_coop.theme_invoice_G002'
) )
@ -138,8 +138,8 @@ class CooperatorWebsiteAccount(WebsiteAccount):
def get_cooperator_certificat(self, **kw): def get_cooperator_certificat(self, **kw):
"""Render the cooperator certificate pdf of the current user""" """Render the cooperator certificate pdf of the current user"""
partner = request.env.user.partner_id partner = request.env.user.partner_id
report_mgr = request.env['report'].sudo()
pdf = report_mgr.get_pdf(
report_mgr = request.env['report']
pdf = report_mgr.sudo().get_pdf(
partner, partner,
'easy_my_coop.cooperator_certificat_G001' 'easy_my_coop.cooperator_certificat_G001'
) )

4
easy_my_coop_website_portal/views/easy_my_coop_website_portal_templates.xml

@ -77,11 +77,11 @@
<label>National Register Number: </label> <label>National Register Number: </label>
<t t-esc="coop.national_register_number"/> <t t-esc="coop.national_register_number"/>
</p> </p>
<p t-if="coop.company_register_number">
<p t-if="coop.is_company and coop.company_register_number">
<label>Company Register Number: </label> <label>Company Register Number: </label>
<t t-esc="coop.company_register_number"/> <t t-esc="coop.company_register_number"/>
</p> </p>
<p t-if="coop.representative">
<p t-if="coop.is_company and coop.representative">
<label>Legal Representative: </label> <label>Legal Representative: </label>
<t t-esc="coop.representative"/> <t t-esc="coop.representative"/>
</p> </p>

Loading…
Cancel
Save