Skip to content

Commit

Permalink
[FIX] travis
Browse files Browse the repository at this point in the history
  • Loading branch information
oihane committed Jun 1, 2021
1 parent fa25796 commit b695d09
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
1 change: 0 additions & 1 deletion res_country_state_usability/models/res_country_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ def write(self, vals):
self.with_context(active_test=False).mapped("country_id").write(
{"active": vals["active"]})
return res

32 changes: 19 additions & 13 deletions website_portal_filter/controllers/portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from odoo.http import request
from odoo.addons.portal.controllers.portal import pager as portal_pager
from datetime import date, datetime, timedelta
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT
from odoo.addons.portal.controllers.portal import CustomerPortal
from odoo.addons.website.controllers.main import QueryURL

Expand All @@ -18,7 +18,6 @@ def portal_my_orders(self, page=1, date_begin=None, date_end=None,
SaleOrder = request.env['sale.order']
default_url = '/my/orders'

user = request.env.user
domain = self.get_base_sale_domain()

all_orders = SaleOrder.sudo().search(domain)
Expand Down Expand Up @@ -76,7 +75,7 @@ def portal_my_orders(self, page=1, date_begin=None, date_end=None,
'date': _date,
'customer': args['customer'],
'searchbar_inputs': searchbar_inputs,
# 'searchbar_filters': [],
# 'searchbar_filters': [],
'partner_ids': order_partner_ids,
'filterby': args['filterby'],
'date_filters': date_filters,
Expand Down Expand Up @@ -155,7 +154,7 @@ def portal_my_purchase_orders(self, page=1, date_begin=None, date_end=None,
'date': _date,
'customer': args['customer'],
'searchbar_inputs': searchbar_inputs,
# 'searchbar_filters': [],
# 'searchbar_filters': [],
'partner_ids': order_partner_ids,
'filterby': args['filterby'],
'date_filters': date_filters,
Expand All @@ -173,7 +172,7 @@ def get_base_purchase_domain(self):

@http.route()
def portal_my_invoices(self, page=1, date_begin=None, date_end=None,
sortby=None, search_in='all', **kw):
sortby=None, search_in='all', **kw):
res = super(CustomerPortal, self).portal_my_invoices(
page, date_begin, date_end, sortby, **kw)
AccountInvoice = request.env['account.invoice']
Expand Down Expand Up @@ -206,9 +205,12 @@ def portal_my_invoices(self, page=1, date_begin=None, date_end=None,
step=self._items_per_page
)
# content according to pager and archive selected
invoices = AccountInvoice.search(domain, order=order, limit=self._items_per_page, offset=pager['offset'])
invoices = AccountInvoice.search(
domain, order=order, limit=self._items_per_page,
offset=pager['offset'])
request.session['my_invoices_history'] = invoices.ids[:100]
invoice_partner_ids = all_invoices.mapped('partner_id').sorted(key=lambda r: str(r.name)) if invoices else None
invoice_partner_ids = all_invoices.mapped('partner_id').sorted(
key=lambda r: str(r.name)) if invoices else None
res.qcontext.update({
'invoices': invoices,
'keep': keep,
Expand Down Expand Up @@ -266,21 +268,22 @@ def filter_data(self, args, model):
domain += ['|', ('name', 'ilike', search),
('partner_id.name', 'ilike', search)]


if 'date' in args and args.get('date') not in ['all', '']:
_date = args.get('date')
date_filters = self._get_date_filters()
domain += date_filters[_date]['domain']

if 'date_from' in args and args.get('date_from') != '':
date_from = datetime.strptime(args.get('date_from'), DEFAULT_SERVER_DATE_FORMAT)
date_from = datetime.strptime(
args.get('date_from'), DEFAULT_SERVER_DATE_FORMAT)
if model == 'invoices':
domain += [("date_invoice", '>=', date_from)]
if model == 'orders':
domain += [("date_order", '>=', date_from)]

if 'date_to' in args and args.get('date_to') != '':
date_to = datetime.strptime(args.get('date_to'), DEFAULT_SERVER_DATE_FORMAT)
date_to = datetime.strptime(
args.get('date_to'), DEFAULT_SERVER_DATE_FORMAT)
if model == 'invoices':
domain += [("date_invoice", '<=', date_to)]
if model == 'orders':
Expand All @@ -293,15 +296,18 @@ def _prepare_portal_layout_values(self):

values['purchase_count'] = request.env['purchase.order'].search_count(
self.get_base_purchase_domain()
) if request.env['purchase.order'].check_access_rights('read', raise_exception=False) else 0
) if request.env['purchase.order'].check_access_rights(
'read', raise_exception=False) else 0

values['order_count'] = request.env['sale.order'].search_count(
self.get_base_sale_domain()
) if request.env['sale.order'].check_access_rights('read', raise_exception=False) else 0
) if request.env['sale.order'].check_access_rights(
'read', raise_exception=False) else 0

values['invoice_count'] = request.env['account.invoice'].search_count(
self.get_base_invoice_domain()
) if request.env['account.invoice'].check_access_rights('read', raise_exception=False) else 0
) if request.env['account.invoice'].check_access_rights(
'read', raise_exception=False) else 0

return values

Expand Down
3 changes: 2 additions & 1 deletion website_stock/controllers/website_stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ def _prepare_portal_layout_values(self):
values = super(PortalStock, self)._prepare_portal_layout_values()
stock_picking_count = request.env['stock.picking'].search_count(
[('partner_id', '=', request.env.user.partner_id.id)]
) if request.env['stock.picking'].check_access_rights('write', raise_exception=False) else 0
) if request.env['stock.picking'].check_access_rights(
'write', raise_exception=False) else 0
values.update({
'stock_count': stock_picking_count,
})
Expand Down

0 comments on commit b695d09

Please sign in to comment.