Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 4 additions & 17 deletions addons/event_sale/report/event_sale_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,11 @@ def init(self):
tools.drop_view_if_exists(self._cr, self._table)
self._cr.execute('CREATE OR REPLACE VIEW %s AS (%s);' % (self._table, self._query()))

def _query(self, with_=None, select=None, join=None, group_by=None, where=None):
def _query(self, with_=None, select=None, join=None, group_by=None):
return "\n".join([
self._with_clause(*(with_ or [])),
self._select_clause(*(select or [])),
self._from_clause(*(join or [])),
self._where_clause(*(where or [])),
self._group_by_clause(*(group_by or []))
])

Expand All @@ -65,9 +64,9 @@ def _with_clause(self, *with_):
WITH
""" + ',\n '.join(with_) if with_ else ''

def _select_clause(self):
def _select_clause(self, *select):
# Extra clauses formatted as `cte1.column1 AS new_column1`, `table1.column2 AS new_column2`...
select_query = """
return """
SELECT
ROW_NUMBER() OVER (ORDER BY event_registration.id) AS id,

Expand Down Expand Up @@ -109,11 +108,7 @@ def _select_clause(self):
sale_order_line.price_subtotal
/ CASE COALESCE(sale_order.currency_rate, 0) WHEN 0 THEN 1.0 ELSE sale_order.currency_rate END
/ sale_order_line.product_uom_qty
END AS sale_price_untaxed"""
additional_fields = self._select_additional_fields()
if additional_fields:
select_query += ",\n " + ",\n ".join(f"{v} AS {k}" for k, v in additional_fields.items())
return select_query
END AS sale_price_untaxed""" + (',\n ' + ',\n '.join(select) if select else '')

def _from_clause(self, *join_):
# Extra clauses formatted as `column1`, `column2`...
Expand All @@ -130,11 +125,3 @@ def _group_by_clause(self, *group_by):
return """
GROUP BY
""" + ',\n '.join(group_by) if group_by else ''

def _where_clause(self, *where):
return """
WHERE """ + ',\n '.join(where) if where else ''

def _select_additional_fields(self):
# To be overridden in other modules
return {}
1 change: 0 additions & 1 deletion addons/pos_event_sale/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import models
from . import report
3 changes: 0 additions & 3 deletions addons/pos_event_sale/report/__init__.py

This file was deleted.

73 changes: 0 additions & 73 deletions addons/pos_event_sale/report/event_sale_report.py

This file was deleted.

1 change: 0 additions & 1 deletion addons/pos_event_sale/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import test_frontend
from . import test_sale_report
72 changes: 0 additions & 72 deletions addons/pos_event_sale/tests/test_sale_report.py

This file was deleted.

6 changes: 2 additions & 4 deletions addons/website_event_sale/report/event_sale_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,5 @@ class EventSaleReport(models.Model):

is_published = fields.Boolean('Published Events', readonly=True)

def _select_additional_fields(self):
res = super()._select_additional_fields()
res['is_published'] = 'event_event.is_published'
return res
def _select_clause(self, *select):
return super()._select_clause('event_event.is_published as is_published', *select)