19.0 vanilla

This commit is contained in:
Ernad Husremovic 2026-03-09 09:32:12 +01:00
parent 79f83631d5
commit 73afc09215
6267 changed files with 1534193 additions and 1130106 deletions

View file

@ -1,12 +1,11 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from werkzeug.exceptions import NotFound
from odoo import http, _
from odoo.exceptions import AccessError, MissingError
from odoo.fields import Domain
from odoo.http import request
from odoo.osv import expression
from odoo.addons.account.controllers.portal import PortalAccount
from odoo.addons.hr_timesheet.controllers.portal import TimesheetCustomerPortal
@ -19,7 +18,7 @@ class PortalProjectAccount(PortalAccount, ProjectCustomerPortal):
def _invoice_get_page_view_values(self, invoice, access_token, **kwargs):
values = super()._invoice_get_page_view_values(invoice, access_token, **kwargs)
domain = request.env['account.analytic.line']._timesheet_get_portal_domain()
domain = expression.AND([
domain = Domain.AND([
domain,
request.env['account.analytic.line']._timesheet_get_sale_domain(
invoice.mapped('line_ids.sale_line_ids'),
@ -47,7 +46,7 @@ class PortalProjectAccount(PortalAccount, ProjectCustomerPortal):
# content according to pager and archive selected
invoices = values['invoices'](pager['offset'])
request.session['my_invoices_history'] = invoices.ids[:100]
request.session['my_invoices_history'] = [i['invoice'].id for i in invoices[:100]]
values.update({
'invoices': invoices,
@ -60,46 +59,31 @@ class PortalProjectAccount(PortalAccount, ProjectCustomerPortal):
class SaleTimesheetCustomerPortal(TimesheetCustomerPortal):
def _get_searchbar_inputs(self):
searchbar_inputs = super()._get_searchbar_inputs()
searchbar_inputs.update(
so={'input': 'so', 'label': _('Search in Sales Order')},
sol={'input': 'sol', 'label': _('Search in Sales Order Item')},
invoice={'input': 'invoice', 'label': _('Search in Invoice')})
return searchbar_inputs
return super()._get_searchbar_inputs() | {
'so': {'input': 'so', 'label': _('Search in Sales Order Item'), 'sequence': 50},
'invoice': {'input': 'invoice', 'label': _('Search in Invoice'), 'sequence': 80},
}
def _get_searchbar_groupby(self):
searchbar_groupby = super()._get_searchbar_groupby()
searchbar_groupby.update(
so={'input': 'so', 'label': _('Sales Order')},
sol={'input': 'sol', 'label': _('Sales Order Item')},
invoice={'input': 'invoice', 'label': _('Invoice')})
return searchbar_groupby
return super()._get_searchbar_groupby() | {
'so_line': {'label': _('Sales Order Item'), 'sequence': 80},
'timesheet_invoice_id': {'label': _('Invoice'), 'sequence': 90},
}
def _get_search_domain(self, search_in, search):
search_domain = super()._get_search_domain(search_in, search)
if search_in in ('sol', 'all'):
search_domain = expression.OR([search_domain, [('so_line', 'ilike', search)]])
if search_in in ('so', 'all'):
search_domain = expression.OR([search_domain, [('so_line.order_id.name', 'ilike', search)]])
if search_in in ('invoice', 'all'):
invoices = request.env['account.move'].sudo().search([('name', 'ilike', search)])
domain = request.env['account.analytic.line']._timesheet_get_sale_domain(invoices.mapped('invoice_line_ids.sale_line_ids'), invoices)
search_domain = expression.OR([search_domain, domain])
return search_domain
def _get_groupby_mapping(self):
groupby_mapping = super()._get_groupby_mapping()
groupby_mapping.update(
sol='so_line',
so='order_id',
invoice='timesheet_invoice_id')
return groupby_mapping
if search_in == 'so':
return Domain('so_line', 'ilike', search) | Domain('so_line.order_id.name', 'ilike', search)
elif search_in == 'invoice':
invoices = request.env['account.move'].sudo().search(['|', ('name', 'ilike', search), ('id', 'ilike', search)])
return Domain(request.env['account.analytic.line']._timesheet_get_sale_domain(invoices.mapped('invoice_line_ids.sale_line_ids'), invoices))
else:
return super()._get_search_domain(search_in, search)
def _get_searchbar_sortings(self):
searchbar_sortings = super()._get_searchbar_sortings()
searchbar_sortings.update(
sol={'label': _('Sales Order Item'), 'order': 'so_line'})
return searchbar_sortings
return super()._get_searchbar_sortings() | {
'so_line': {'label': _('Sales Order Item')},
'timesheet_invoice_id': {'label': _('Invoice')},
}
def _task_get_page_view_values(self, task, access_token, **kwargs):
values = super()._task_get_page_view_values(task, access_token, **kwargs)
@ -117,7 +101,7 @@ class SaleTimesheetCustomerPortal(TimesheetCustomerPortal):
moves = request.env['account.move']
invoice_ids = task.sale_order_id.invoice_ids
if invoice_ids and request.env['account.move'].check_access_rights('read', raise_exception=False):
if invoice_ids and request.env['account.move'].has_access('read'):
moves = request.env['account.move'].search([('id', 'in', invoice_ids.ids)])
values['invoices_accessible'] = moves.ids
if moves:
@ -133,6 +117,6 @@ class SaleTimesheetCustomerPortal(TimesheetCustomerPortal):
})
return values
@http.route(['/my/timesheets', '/my/timesheets/page/<int:page>'], type='http', auth="user", website=True)
def portal_my_timesheets(self, page=1, sortby=None, filterby=None, search=None, search_in='all', groupby='sol', **kw):
return super().portal_my_timesheets(page, sortby, filterby, search, search_in, groupby, **kw)
@http.route()
def portal_my_timesheets(self, *args, groupby='so_line', **kw):
return super().portal_my_timesheets(*args, groupby=groupby, **kw)