2
2
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3
3
4
4
5
- from odoo import fields , models
5
+ from psycopg2 .extensions import AsIs
6
+
7
+ from odoo import api , fields , models , tools
6
8
7
9
8
10
class AccountMoveLineCashBasisReport (models .Model ):
@@ -126,7 +128,6 @@ class AccountMoveLineCashBasisReport(models.Model):
126
128
account_internal_group = fields .Selection (
127
129
selection = "_selection_account_internal_group" , readonly = True
128
130
)
129
- account_root_id = fields .Many2one ("account.root" , readonly = True )
130
131
state = fields .Selection (
131
132
selection = "_selection_parent_state" ,
132
133
)
@@ -164,17 +165,15 @@ def _selection_account_internal_group(self):
164
165
allfields = ["internal_group" ]
165
166
)["internal_group" ]["selection" ]
166
167
167
- @property
168
- def _table_query (self ):
169
- return """
170
- WITH moves AS (
168
+ @api . model_cr
169
+ def init (self ):
170
+ query = """
171
+ WITH moves AS (
171
172
SELECT
172
173
"account_move_line".id as id,
173
174
"account_move_line".move_id as move_id,
174
175
"account_move_line".name as name,
175
176
"account_move_line".ref as ref,
176
- "account_move_line".parent_state as parent_state,
177
- "account_move_line".parent_state as state,
178
177
"account_move_line".company_id as company_id,
179
178
"account_move_line".currency_id as currency_id,
180
179
"account_move_line".journal_id as journal_id,
@@ -192,12 +191,10 @@ def _table_query(self):
192
191
"account_move_line".reconciled as reconciled,
193
192
"account_move_line".full_reconcile_id as full_reconcile_id,
194
193
"account_move_line".statement_id as statement_id,
195
- "account_move_line".account_root_id as account_root_id,
196
194
"account".user_type_id as user_type_id,
197
195
"account".group_id as account_group_id,
198
196
"account_type".type as account_internal_type,
199
- "account_type".internal_group as account_internal_group,
200
- "account_move_line".exclude_from_invoice_tab
197
+ "account_type".internal_group as account_internal_group
201
198
FROM ONLY account_move_line
202
199
JOIN ONLY account_account account ON
203
200
"account_move_line".account_id = account.id
@@ -245,8 +242,6 @@ def _table_query(self):
245
242
"account_move_line".move_id as move_id,
246
243
"account_move_line".name as name,
247
244
"account_move_line".ref as ref,
248
- "account_move_line".parent_state as parent_state,
249
- "account_move_line".parent_state as state,
250
245
"account_move_line".company_id as company_id,
251
246
"account_move_line".currency_id as currency_id,
252
247
"account_move_line".journal_id as journal_id,
@@ -266,12 +261,10 @@ def _table_query(self):
266
261
"account_move_line".reconciled as reconciled,
267
262
"account_move_line".full_reconcile_id as full_reconcile_id,
268
263
"account_move_line".statement_id as statement_id,
269
- "account_move_line".account_root_id as account_root_id,
270
264
"account".user_type_id as user_type_id,
271
265
"account".group_id as account_group_id,
272
266
"account_type".type as account_internal_type,
273
- "account_type".internal_group as account_internal_group,
274
- "account_move_line".exclude_from_invoice_tab
267
+ "account_type".internal_group as account_internal_group
275
268
FROM payment_table ref
276
269
JOIN ONLY account_move_line ON
277
270
"account_move_line".move_id = ref.move_id
@@ -289,4 +282,8 @@ def _table_query(self):
289
282
WHERE account.internal_type IN ('receivable', 'payable')
290
283
)
291
284
)
292
- """
285
+ """
286
+ tools .drop_view_if_exists (self .env .cr , self ._table )
287
+ self ._cr .execute (
288
+ "CREATE OR REPLACE VIEW %s AS %s" , (AsIs (self ._table ), AsIs (query ))
289
+ )
0 commit comments