Skip to content

Commit 35b0714

Browse files
committed
[MIG] account_move_line_cash_basis_report: Migration to 12.0
1 parent 66accdc commit 35b0714

File tree

4 files changed

+33
-36
lines changed

4 files changed

+33
-36
lines changed

account_move_line_cash_basis_report/__manifest__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"name": "Account Move Line Cash Basis Report",
66
"summary": """
77
Account Move Line Cash Basis Report""",
8-
"version": "14.0.1.0.0",
8+
"version": "12.0.1.0.0",
99
"license": "AGPL-3",
1010
"author": "Escodoo",
1111
"website": "https://github.com/Escodoo/account-addons",

account_move_line_cash_basis_report/models/account_move_line_cash_basis_report.py

+14-17
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
33

44

5-
from odoo import fields, models
5+
from psycopg2.extensions import AsIs
6+
7+
from odoo import api, fields, models, tools
68

79

810
class AccountMoveLineCashBasisReport(models.Model):
@@ -126,7 +128,6 @@ class AccountMoveLineCashBasisReport(models.Model):
126128
account_internal_group = fields.Selection(
127129
selection="_selection_account_internal_group", readonly=True
128130
)
129-
account_root_id = fields.Many2one("account.root", readonly=True)
130131
state = fields.Selection(
131132
selection="_selection_parent_state",
132133
)
@@ -164,17 +165,15 @@ def _selection_account_internal_group(self):
164165
allfields=["internal_group"]
165166
)["internal_group"]["selection"]
166167

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 (
171172
SELECT
172173
"account_move_line".id as id,
173174
"account_move_line".move_id as move_id,
174175
"account_move_line".name as name,
175176
"account_move_line".ref as ref,
176-
"account_move_line".parent_state as parent_state,
177-
"account_move_line".parent_state as state,
178177
"account_move_line".company_id as company_id,
179178
"account_move_line".currency_id as currency_id,
180179
"account_move_line".journal_id as journal_id,
@@ -192,12 +191,10 @@ def _table_query(self):
192191
"account_move_line".reconciled as reconciled,
193192
"account_move_line".full_reconcile_id as full_reconcile_id,
194193
"account_move_line".statement_id as statement_id,
195-
"account_move_line".account_root_id as account_root_id,
196194
"account".user_type_id as user_type_id,
197195
"account".group_id as account_group_id,
198196
"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
201198
FROM ONLY account_move_line
202199
JOIN ONLY account_account account ON
203200
"account_move_line".account_id = account.id
@@ -245,8 +242,6 @@ def _table_query(self):
245242
"account_move_line".move_id as move_id,
246243
"account_move_line".name as name,
247244
"account_move_line".ref as ref,
248-
"account_move_line".parent_state as parent_state,
249-
"account_move_line".parent_state as state,
250245
"account_move_line".company_id as company_id,
251246
"account_move_line".currency_id as currency_id,
252247
"account_move_line".journal_id as journal_id,
@@ -266,12 +261,10 @@ def _table_query(self):
266261
"account_move_line".reconciled as reconciled,
267262
"account_move_line".full_reconcile_id as full_reconcile_id,
268263
"account_move_line".statement_id as statement_id,
269-
"account_move_line".account_root_id as account_root_id,
270264
"account".user_type_id as user_type_id,
271265
"account".group_id as account_group_id,
272266
"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
275268
FROM payment_table ref
276269
JOIN ONLY account_move_line ON
277270
"account_move_line".move_id = ref.move_id
@@ -289,4 +282,8 @@ def _table_query(self):
289282
WHERE account.internal_type IN ('receivable', 'payable')
290283
)
291284
)
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+
)

account_move_line_cash_basis_report/security/account_move_line_cash_basis_report.xml

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<field name="model_id" ref="model_account_move_line_cash_basis_report" />
99
<field
1010
name="domain_force"
11-
>['|',('company_id','=',False),('company_id', 'in', company_ids)]</field>
11+
>['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
1212
</record>
1313

1414
<record
@@ -34,13 +34,14 @@
3434
name="name"
3535
>account.move.line.cash.basis.report access group_account_readonly</field>
3636
<field name="model_id" ref="model_account_move_line_cash_basis_report" />
37-
<field name="group_id" ref="account.group_account_readonly" />
37+
<field name="group_id" ref="account.group_account_user" />
3838
<field name="perm_read" eval="1" />
3939
<field name="perm_create" eval="0" />
4040
<field name="perm_write" eval="0" />
4141
<field name="perm_unlink" eval="0" />
4242
</record>
4343

44+
4445
<record
4546
model="ir.model.access"
4647
id="account_move_line_cash_basis_report_access_group_account_manager"

account_move_line_cash_basis_report/views/account_move_line_cash_basis_report.xml

+15-16
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<form string="Journal Item" create="false">
1313
<sheet>
1414
<field name="company_id" invisible="1" />
15-
<field name="parent_state" invisible="1" />
15+
<!-- <field name="parent_state" invisible="1" /> -->
1616
<group>
1717
<field name="name" />
1818
<field
@@ -46,7 +46,7 @@
4646
<group string="Dates">
4747
<field
4848
name="date"
49-
groups="account.group_account_readonly"
49+
groups="account.group_account_user"
5050
/>
5151
<!-- <field name="date_maturity"/>-->
5252
</group>
@@ -114,7 +114,6 @@
114114
/>
115115
<field name="date" />
116116
<field name="account_id" />
117-
<field name="account_root_id" />
118117
<field name="account_internal_type" />
119118
<field name="partner_id" />
120119
<field name="journal_id" />
@@ -254,18 +253,18 @@
254253
<field name="arch" type="xml">
255254
<tree>
256255
<field name="date" />
257-
<field name="journal_id" optional="show" />
258-
<field name="name" optional="show" />
259-
<field name="ref" optional="hidden" />
260-
<field name="account_id" optional="show" />
261-
<field name="partner_id" optional="show" />
262-
<field name="analytic_account_id" optional="hidden" />
263-
<field name="debit" optional="show" />
264-
<field name="credit" optional="show" />
265-
<field name="balance" optional="hidden" />
266-
<field name="user_type_id" optional="hidden" />
267-
<field name="account_internal_type" optional="hidden" />
268-
<field name="account_internal_group" optional="hidden" />
256+
<field name="journal_id" />
257+
<field name="name" />
258+
<field name="ref" invisible="1" />
259+
<field name="account_id" />
260+
<field name="partner_id" />
261+
<field name="analytic_account_id" invisible="1" />
262+
<field name="debit" />
263+
<field name="credit" />
264+
<field name="balance" invisible="1" />
265+
<field name="user_type_id" invisible="1" />
266+
<field name="account_internal_type" invisible="1" />
267+
<field name="account_internal_group" invisible="1" />
269268
</tree>
270269
</field>
271270
</record>
@@ -276,7 +275,7 @@
276275
>account.move.line.cash.basis.report.pivot (in account_move_line_cash_basis_report)</field>
277276
<field name="model">account.move.line.cash.basis.report</field>
278277
<field name="arch" type="xml">
279-
<pivot string="Account Move Line Cash Basis Report" sample="1">
278+
<pivot string="Account Move Line Cash Basis Report">
280279
<field name="user_type_id" type="row" />
281280
<field name="account_id" type="row" />
282281
<field name="date" interval="month" type="col" />

0 commit comments

Comments
 (0)