odoo-addon-l10n-it-riba-oca 18.0.1.0.0.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- odoo/addons/l10n_it_riba_oca/README.rst +175 -0
- odoo/addons/l10n_it_riba_oca/__init__.py +9 -0
- odoo/addons/l10n_it_riba_oca/__manifest__.py +59 -0
- odoo/addons/l10n_it_riba_oca/data/riba_sequence.xml +14 -0
- odoo/addons/l10n_it_riba_oca/demo/riba_demo.xml +39 -0
- odoo/addons/l10n_it_riba_oca/hooks.py +17 -0
- odoo/addons/l10n_it_riba_oca/i18n/it.po +1686 -0
- odoo/addons/l10n_it_riba_oca/i18n/l10n_it_riba.pot +1573 -0
- odoo/addons/l10n_it_riba_oca/i18n/l10n_it_riba_oca.pot +1554 -0
- odoo/addons/l10n_it_riba_oca/migrations/18.0.1.0.0/pre-migrate.py +16 -0
- odoo/addons/l10n_it_riba_oca/models/__init__.py +14 -0
- odoo/addons/l10n_it_riba_oca/models/account.py +563 -0
- odoo/addons/l10n_it_riba_oca/models/account_config.py +35 -0
- odoo/addons/l10n_it_riba_oca/models/ir_ui_menu.py +27 -0
- odoo/addons/l10n_it_riba_oca/models/partner.py +35 -0
- odoo/addons/l10n_it_riba_oca/models/riba.py +560 -0
- odoo/addons/l10n_it_riba_oca/models/riba_config.py +120 -0
- odoo/addons/l10n_it_riba_oca/readme/CONFIGURE.md +33 -0
- odoo/addons/l10n_it_riba_oca/readme/CONTRIBUTORS.md +17 -0
- odoo/addons/l10n_it_riba_oca/readme/DESCRIPTION.md +3 -0
- odoo/addons/l10n_it_riba_oca/readme/USAGE.md +35 -0
- odoo/addons/l10n_it_riba_oca/report/__init__.py +4 -0
- odoo/addons/l10n_it_riba_oca/report/report.xml +16 -0
- odoo/addons/l10n_it_riba_oca/report/slip_qweb.py +18 -0
- odoo/addons/l10n_it_riba_oca/security/ir.model.access.csv +23 -0
- odoo/addons/l10n_it_riba_oca/security/riba_security.xml +34 -0
- odoo/addons/l10n_it_riba_oca/static/description/icon.png +0 -0
- odoo/addons/l10n_it_riba_oca/static/description/index.html +512 -0
- odoo/addons/l10n_it_riba_oca/tests/__init__.py +10 -0
- odoo/addons/l10n_it_riba_oca/tests/riba_common.py +339 -0
- odoo/addons/l10n_it_riba_oca/tests/test_account_move.py +54 -0
- odoo/addons/l10n_it_riba_oca/tests/test_menu.py +51 -0
- odoo/addons/l10n_it_riba_oca/tests/test_riba.py +905 -0
- odoo/addons/l10n_it_riba_oca/views/account_config_view.xml +46 -0
- odoo/addons/l10n_it_riba_oca/views/account_view.xml +205 -0
- odoo/addons/l10n_it_riba_oca/views/configuration_view.xml +94 -0
- odoo/addons/l10n_it_riba_oca/views/partner_view.xml +29 -0
- odoo/addons/l10n_it_riba_oca/views/riba_detail_view.xml +97 -0
- odoo/addons/l10n_it_riba_oca/views/riba_view.xml +296 -0
- odoo/addons/l10n_it_riba_oca/views/slip_report.xml +149 -0
- odoo/addons/l10n_it_riba_oca/views/wizard_credit.xml +46 -0
- odoo/addons/l10n_it_riba_oca/views/wizard_due_date_settlement.xml +37 -0
- odoo/addons/l10n_it_riba_oca/views/wizard_past_due.xml +67 -0
- odoo/addons/l10n_it_riba_oca/views/wizard_presentation.xml +48 -0
- odoo/addons/l10n_it_riba_oca/views/wizard_riba_file_export.xml +33 -0
- odoo/addons/l10n_it_riba_oca/views/wizard_riba_issue.xml +46 -0
- odoo/addons/l10n_it_riba_oca/views/wizard_riba_payment_date.xml +45 -0
- odoo/addons/l10n_it_riba_oca/wizard/__init__.py +16 -0
- odoo/addons/l10n_it_riba_oca/wizard/wizard_credit.py +280 -0
- odoo/addons/l10n_it_riba_oca/wizard/wizard_due_date_settlement.py +24 -0
- odoo/addons/l10n_it_riba_oca/wizard/wizard_past_due.py +319 -0
- odoo/addons/l10n_it_riba_oca/wizard/wizard_presentation_riba.py +47 -0
- odoo/addons/l10n_it_riba_oca/wizard/wizard_riba_file_export.py +429 -0
- odoo/addons/l10n_it_riba_oca/wizard/wizard_riba_issue.py +143 -0
- odoo/addons/l10n_it_riba_oca/wizard/wizard_riba_multiple_payment.py +107 -0
- odoo/addons/l10n_it_riba_oca/wizard/wizard_riba_multiple_payment_views.xml +46 -0
- odoo/addons/l10n_it_riba_oca/wizard/wizard_riba_payment_date.py +31 -0
- odoo_addon_l10n_it_riba_oca-18.0.1.0.0.8.dist-info/METADATA +197 -0
- odoo_addon_l10n_it_riba_oca-18.0.1.0.0.8.dist-info/RECORD +61 -0
- odoo_addon_l10n_it_riba_oca-18.0.1.0.0.8.dist-info/WHEEL +5 -0
- odoo_addon_l10n_it_riba_oca-18.0.1.0.0.8.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
# Copyright 2023 Simone Rubino - Aion Tech
|
|
2
|
+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
|
3
|
+
|
|
4
|
+
from odoo import fields
|
|
5
|
+
from odoo.tests import common
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class TestRibaCommon(common.TransactionCase):
|
|
9
|
+
def setUp(self):
|
|
10
|
+
super().setUp()
|
|
11
|
+
tax_model = self.env["account.tax"]
|
|
12
|
+
self.account_tax = (
|
|
13
|
+
self.env.ref("l10n_it.2601", raise_if_not_found=False)
|
|
14
|
+
or self.env.ref("l10n_generic_coa.tax_payable", raise_if_not_found=False)
|
|
15
|
+
or self.env["account.account"].search(
|
|
16
|
+
[("account_type", "=", "liability_current")], limit=1
|
|
17
|
+
)
|
|
18
|
+
)
|
|
19
|
+
self.tax_22 = tax_model.create(
|
|
20
|
+
{
|
|
21
|
+
"name": "IVA 22 Sale",
|
|
22
|
+
"description": "22",
|
|
23
|
+
"amount": 22.00,
|
|
24
|
+
"type_tax_use": "sale",
|
|
25
|
+
"invoice_repartition_line_ids": [
|
|
26
|
+
(5, 0, 0),
|
|
27
|
+
(
|
|
28
|
+
0,
|
|
29
|
+
0,
|
|
30
|
+
{
|
|
31
|
+
"factor_percent": 100,
|
|
32
|
+
"repartition_type": "base",
|
|
33
|
+
},
|
|
34
|
+
),
|
|
35
|
+
(
|
|
36
|
+
0,
|
|
37
|
+
0,
|
|
38
|
+
{
|
|
39
|
+
"factor_percent": 100,
|
|
40
|
+
"repartition_type": "tax",
|
|
41
|
+
"account_id": self.account_tax.id,
|
|
42
|
+
},
|
|
43
|
+
),
|
|
44
|
+
],
|
|
45
|
+
"refund_repartition_line_ids": [
|
|
46
|
+
(5, 0, 0),
|
|
47
|
+
(
|
|
48
|
+
0,
|
|
49
|
+
0,
|
|
50
|
+
{
|
|
51
|
+
"factor_percent": 100,
|
|
52
|
+
"repartition_type": "base",
|
|
53
|
+
},
|
|
54
|
+
),
|
|
55
|
+
(
|
|
56
|
+
0,
|
|
57
|
+
0,
|
|
58
|
+
{
|
|
59
|
+
"factor_percent": 100,
|
|
60
|
+
"repartition_type": "tax",
|
|
61
|
+
"account_id": self.account_tax.id,
|
|
62
|
+
},
|
|
63
|
+
),
|
|
64
|
+
],
|
|
65
|
+
}
|
|
66
|
+
)
|
|
67
|
+
self.env.company.vat = "IT12345670017"
|
|
68
|
+
self.company2 = self.env["res.company"].create(
|
|
69
|
+
{
|
|
70
|
+
"name": "company 2",
|
|
71
|
+
}
|
|
72
|
+
)
|
|
73
|
+
self.service_due_cost = self._create_service_due_cost()
|
|
74
|
+
self.account_model = self.env["account.account"]
|
|
75
|
+
self.move_line_model = self.env["account.move.line"]
|
|
76
|
+
self.move_model = self.env["account.move"]
|
|
77
|
+
self.slip_model = self.env["riba.slip"]
|
|
78
|
+
self.partner = self.env.ref("base.res_partner_3")
|
|
79
|
+
self.partner.vat = "IT01234567890"
|
|
80
|
+
self.product1 = self.env.ref("product.product_product_5")
|
|
81
|
+
self.sale_journal = self.env["account.journal"].search([("type", "=", "sale")])[
|
|
82
|
+
0
|
|
83
|
+
]
|
|
84
|
+
self.bank_journal = self.env["account.journal"].search(
|
|
85
|
+
[("type", "=", "bank")], limit=1
|
|
86
|
+
)
|
|
87
|
+
self.payment_term1 = self._create_pterm()
|
|
88
|
+
self.payment_term2 = self._create_pterm2()
|
|
89
|
+
self.account_rec1_id = self.account_model.create(
|
|
90
|
+
dict(
|
|
91
|
+
code="custacc",
|
|
92
|
+
name="customer account",
|
|
93
|
+
account_type="asset_receivable",
|
|
94
|
+
reconcile=True,
|
|
95
|
+
)
|
|
96
|
+
)
|
|
97
|
+
self.sale_account = self.env["account.account"].search(
|
|
98
|
+
[
|
|
99
|
+
(
|
|
100
|
+
"account_type",
|
|
101
|
+
"=",
|
|
102
|
+
"income_other",
|
|
103
|
+
)
|
|
104
|
+
],
|
|
105
|
+
limit=1,
|
|
106
|
+
)
|
|
107
|
+
self.expenses_account = self.env["account.account"].search(
|
|
108
|
+
[
|
|
109
|
+
(
|
|
110
|
+
"account_type",
|
|
111
|
+
"=",
|
|
112
|
+
"expense",
|
|
113
|
+
)
|
|
114
|
+
],
|
|
115
|
+
limit=1,
|
|
116
|
+
)
|
|
117
|
+
self.bank_account = self.env["account.account"].search(
|
|
118
|
+
[
|
|
119
|
+
(
|
|
120
|
+
"account_type",
|
|
121
|
+
"=",
|
|
122
|
+
"asset_cash",
|
|
123
|
+
)
|
|
124
|
+
],
|
|
125
|
+
limit=1,
|
|
126
|
+
)
|
|
127
|
+
self.account_payment_term_riba = self.env.ref(
|
|
128
|
+
"l10n_it_riba_oca.account_payment_term_riba"
|
|
129
|
+
)
|
|
130
|
+
self.invoice = self._create_invoice()
|
|
131
|
+
self.invoice2 = self._create_invoice()
|
|
132
|
+
self.invoice_sbf = self._create_sbf_invoice()
|
|
133
|
+
self.acceptance_account = self.env["account.account"].create(
|
|
134
|
+
{
|
|
135
|
+
"code": "STC",
|
|
136
|
+
"name": "STC Bills (test)",
|
|
137
|
+
"reconcile": True,
|
|
138
|
+
"account_type": "asset_receivable",
|
|
139
|
+
}
|
|
140
|
+
)
|
|
141
|
+
self.riba_account = self.env["account.account"].create(
|
|
142
|
+
{
|
|
143
|
+
"code": "RiBa",
|
|
144
|
+
"name": "RiBa Account (test)",
|
|
145
|
+
"reconcile": True,
|
|
146
|
+
"account_type": "asset_fixed",
|
|
147
|
+
}
|
|
148
|
+
)
|
|
149
|
+
self.past_due_account = self.env["account.account"].create(
|
|
150
|
+
{
|
|
151
|
+
"code": "PastDue",
|
|
152
|
+
"name": "Past Due Bills Account (test)",
|
|
153
|
+
"reconcile": True,
|
|
154
|
+
"account_type": "asset_receivable",
|
|
155
|
+
}
|
|
156
|
+
)
|
|
157
|
+
self.company_bank = self.env.ref("l10n_it_riba_oca.company_bank")
|
|
158
|
+
self.company2_bank = self.env["res.partner.bank"].create(
|
|
159
|
+
{
|
|
160
|
+
"acc_number": "IT000000000000000000",
|
|
161
|
+
"partner_id": self.company2.partner_id.id,
|
|
162
|
+
"company_id": self.company2.id,
|
|
163
|
+
}
|
|
164
|
+
)
|
|
165
|
+
self.riba_config_incasso = self.create_config_incasso()
|
|
166
|
+
self.riba_config_sbf = self.create_config_sbf()
|
|
167
|
+
self.company_bank.codice_sia = "AA555"
|
|
168
|
+
|
|
169
|
+
def _create_service_due_cost(self):
|
|
170
|
+
return self.env["product.product"].create(
|
|
171
|
+
{
|
|
172
|
+
"name": "Collection Fees",
|
|
173
|
+
"type": "service",
|
|
174
|
+
"taxes_id": [[6, 0, self.tax_22.ids]],
|
|
175
|
+
"property_account_income_id": self._account_expense().id,
|
|
176
|
+
}
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
def _account_expense(self):
|
|
180
|
+
return self.env["account.account"].create(
|
|
181
|
+
{
|
|
182
|
+
"code": "demoduecost",
|
|
183
|
+
"name": "cashing fees",
|
|
184
|
+
"account_type": "expense",
|
|
185
|
+
}
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
def _create_invoice(self):
|
|
189
|
+
# ----- Set invoice date to recent date in the system
|
|
190
|
+
# ----- This solves problems with account_invoice_sequential_dates
|
|
191
|
+
self.partner.property_account_receivable_id = self.account_rec1_id.id
|
|
192
|
+
recent_date = (
|
|
193
|
+
self.env["account.move"]
|
|
194
|
+
.search([("invoice_date", "!=", False)], order="invoice_date desc", limit=1)
|
|
195
|
+
.invoice_date
|
|
196
|
+
)
|
|
197
|
+
return self.env["account.move"].create(
|
|
198
|
+
{
|
|
199
|
+
"invoice_date": recent_date or fields.Date.today(),
|
|
200
|
+
"move_type": "out_invoice",
|
|
201
|
+
"journal_id": self.sale_journal.id,
|
|
202
|
+
"partner_id": self.partner.id,
|
|
203
|
+
"invoice_payment_term_id": self.payment_term1.id,
|
|
204
|
+
"riba_partner_bank_id": self.partner.bank_ids[0].id,
|
|
205
|
+
"invoice_line_ids": [
|
|
206
|
+
(
|
|
207
|
+
0,
|
|
208
|
+
0,
|
|
209
|
+
{
|
|
210
|
+
"name": self.product1.name,
|
|
211
|
+
"product_id": self.product1.id,
|
|
212
|
+
"quantity": 1.0,
|
|
213
|
+
"price_unit": 100.00,
|
|
214
|
+
"account_id": self.sale_account.id,
|
|
215
|
+
"tax_ids": [[6, 0, self.tax_22.ids]],
|
|
216
|
+
},
|
|
217
|
+
)
|
|
218
|
+
],
|
|
219
|
+
}
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
def _create_sbf_invoice(self):
|
|
223
|
+
self.partner.property_account_receivable_id = self.account_rec1_id.id
|
|
224
|
+
recent_date = (
|
|
225
|
+
self.env["account.move"]
|
|
226
|
+
.search([("invoice_date", "!=", False)], order="invoice_date desc", limit=1)
|
|
227
|
+
.invoice_date
|
|
228
|
+
)
|
|
229
|
+
return self.env["account.move"].create(
|
|
230
|
+
{
|
|
231
|
+
"invoice_date": recent_date,
|
|
232
|
+
"move_type": "out_invoice",
|
|
233
|
+
"journal_id": self.sale_journal.id,
|
|
234
|
+
"partner_id": self.partner.id,
|
|
235
|
+
"invoice_payment_term_id": self.account_payment_term_riba.id,
|
|
236
|
+
"invoice_line_ids": [
|
|
237
|
+
(
|
|
238
|
+
0,
|
|
239
|
+
0,
|
|
240
|
+
{
|
|
241
|
+
"name": "product1",
|
|
242
|
+
"product_id": self.product1.id,
|
|
243
|
+
"quantity": 1.0,
|
|
244
|
+
"price_unit": 450.00,
|
|
245
|
+
"account_id": self.sale_account.id,
|
|
246
|
+
"tax_ids": [[6, 0, []]],
|
|
247
|
+
},
|
|
248
|
+
)
|
|
249
|
+
],
|
|
250
|
+
}
|
|
251
|
+
)
|
|
252
|
+
|
|
253
|
+
def _create_pterm(self):
|
|
254
|
+
return self.env["account.payment.term"].create(
|
|
255
|
+
{
|
|
256
|
+
"name": "RiBa 30/60",
|
|
257
|
+
"riba": True,
|
|
258
|
+
"riba_payment_cost": 5.00,
|
|
259
|
+
"line_ids": [
|
|
260
|
+
(
|
|
261
|
+
0,
|
|
262
|
+
0,
|
|
263
|
+
{
|
|
264
|
+
"value": "percent",
|
|
265
|
+
"delay_type": "days_after",
|
|
266
|
+
"nb_days": 30,
|
|
267
|
+
"days_next_month": "0",
|
|
268
|
+
"value_amount": 0.50,
|
|
269
|
+
},
|
|
270
|
+
),
|
|
271
|
+
(
|
|
272
|
+
0,
|
|
273
|
+
0,
|
|
274
|
+
{
|
|
275
|
+
"value": "percent",
|
|
276
|
+
"delay_type": "days_after",
|
|
277
|
+
"nb_days": 60,
|
|
278
|
+
"days_next_month": "0",
|
|
279
|
+
},
|
|
280
|
+
),
|
|
281
|
+
],
|
|
282
|
+
}
|
|
283
|
+
)
|
|
284
|
+
|
|
285
|
+
def _create_pterm2(self):
|
|
286
|
+
return self.env["account.payment.term"].create(
|
|
287
|
+
{
|
|
288
|
+
"name": "RiBa 30",
|
|
289
|
+
"riba": True,
|
|
290
|
+
"riba_payment_cost": 5.00,
|
|
291
|
+
"line_ids": [
|
|
292
|
+
(
|
|
293
|
+
0,
|
|
294
|
+
0,
|
|
295
|
+
{
|
|
296
|
+
"value": "percent",
|
|
297
|
+
"delay_type": "days_after_end_of_month",
|
|
298
|
+
"nb_days": 1,
|
|
299
|
+
"days_next_month": "0",
|
|
300
|
+
},
|
|
301
|
+
)
|
|
302
|
+
],
|
|
303
|
+
}
|
|
304
|
+
)
|
|
305
|
+
|
|
306
|
+
def create_config_sbf(self):
|
|
307
|
+
return self.env["riba.configuration"].create(
|
|
308
|
+
{
|
|
309
|
+
"name": "Subject To Collection",
|
|
310
|
+
"type": "sbf",
|
|
311
|
+
"bank_id": self.company_bank.id,
|
|
312
|
+
"acceptance_journal_id": self.bank_journal.id,
|
|
313
|
+
"credit_journal_id": self.bank_journal.id,
|
|
314
|
+
"acceptance_account_id": self.acceptance_account.id,
|
|
315
|
+
"credit_account_id": self.riba_account.id,
|
|
316
|
+
"bank_account_id": self.bank_account.id,
|
|
317
|
+
"bank_expense_account_id": self.expenses_account.id,
|
|
318
|
+
"past_due_journal_id": self.bank_journal.id,
|
|
319
|
+
"overdue_credit_account_id": self.past_due_account.id,
|
|
320
|
+
"protest_charge_account_id": self.expenses_account.id,
|
|
321
|
+
"settlement_journal_id": self.bank_journal.id,
|
|
322
|
+
}
|
|
323
|
+
)
|
|
324
|
+
|
|
325
|
+
def create_config_incasso(self):
|
|
326
|
+
return self.env["riba.configuration"].create(
|
|
327
|
+
{
|
|
328
|
+
"name": "After Collection",
|
|
329
|
+
"type": "incasso",
|
|
330
|
+
"bank_id": self.company_bank.id,
|
|
331
|
+
"acceptance_journal_id": self.bank_journal.id,
|
|
332
|
+
"acceptance_account_id": self.acceptance_account.id,
|
|
333
|
+
"credit_account_id": self.riba_account.id,
|
|
334
|
+
"past_due_journal_id": self.bank_journal.id,
|
|
335
|
+
"overdue_credit_account_id": self.past_due_account.id,
|
|
336
|
+
"protest_charge_account_id": self.expenses_account.id,
|
|
337
|
+
"settlement_journal_id": self.bank_journal.id,
|
|
338
|
+
}
|
|
339
|
+
)
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Copyright 2024 Simone Rubino - Aion Tech
|
|
2
|
+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
|
3
|
+
|
|
4
|
+
from odoo import Command
|
|
5
|
+
from odoo.tests import Form
|
|
6
|
+
|
|
7
|
+
from .riba_common import TestRibaCommon
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class TestAccountMove(TestRibaCommon):
|
|
11
|
+
def test_select_commercial_partner_bank(self):
|
|
12
|
+
"""The bank is only in the commercial partner,
|
|
13
|
+
and we are invoicing one of its contacts:
|
|
14
|
+
the commercial partner's bank is set in the invoice.
|
|
15
|
+
"""
|
|
16
|
+
# Arrange
|
|
17
|
+
payment_term = self.payment_term1
|
|
18
|
+
commercial_partner = self.env["res.partner"].create(
|
|
19
|
+
{
|
|
20
|
+
"name": "Test commercial partner",
|
|
21
|
+
"bank_ids": [
|
|
22
|
+
Command.create(
|
|
23
|
+
{
|
|
24
|
+
"acc_number": "test account number",
|
|
25
|
+
}
|
|
26
|
+
),
|
|
27
|
+
],
|
|
28
|
+
}
|
|
29
|
+
)
|
|
30
|
+
bank = commercial_partner.bank_ids
|
|
31
|
+
invoice_partner = self.env["res.partner"].create(
|
|
32
|
+
{
|
|
33
|
+
"name": "Test invoice partner",
|
|
34
|
+
"parent_id": commercial_partner.id,
|
|
35
|
+
}
|
|
36
|
+
)
|
|
37
|
+
# pre-condition
|
|
38
|
+
self.assertFalse(invoice_partner.bank_ids)
|
|
39
|
+
self.assertEqual(invoice_partner.parent_id, commercial_partner)
|
|
40
|
+
self.assertTrue(bank)
|
|
41
|
+
|
|
42
|
+
# Act
|
|
43
|
+
move_form = Form(
|
|
44
|
+
self.env["account.move"].with_context(
|
|
45
|
+
default_move_type="out_invoice",
|
|
46
|
+
default_name="Test invoice",
|
|
47
|
+
)
|
|
48
|
+
)
|
|
49
|
+
move_form.partner_id = invoice_partner
|
|
50
|
+
move_form.invoice_payment_term_id = payment_term
|
|
51
|
+
move = move_form.save()
|
|
52
|
+
|
|
53
|
+
# Assert
|
|
54
|
+
self.assertEqual(move.riba_partner_bank_id, bank)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Copyright 2022 Simone Rubino - Agile Business Group
|
|
2
|
+
# Copyright 2023 Simone Rubino - Aion Tech
|
|
3
|
+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
|
4
|
+
|
|
5
|
+
from odoo.tests import common
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class TestRiBaMenu(common.TransactionCase):
|
|
9
|
+
def setUp(self):
|
|
10
|
+
super().setUp()
|
|
11
|
+
self.menu_model = self.env["ir.ui.menu"]
|
|
12
|
+
self.root_riba_menu = self.browse_ref("l10n_it_riba_oca.menu_riba")
|
|
13
|
+
self.new_parent = self.browse_ref("base.menu_custom")
|
|
14
|
+
|
|
15
|
+
def test_sibling_moved(self):
|
|
16
|
+
"""Check that RiBa menu is moved when a sibling changes parent."""
|
|
17
|
+
root_riba_parent_menu = self.root_riba_menu.parent_id
|
|
18
|
+
sibling_menu = self.menu_model.search(
|
|
19
|
+
[
|
|
20
|
+
("parent_id", "=", root_riba_parent_menu.id),
|
|
21
|
+
],
|
|
22
|
+
limit=1,
|
|
23
|
+
)
|
|
24
|
+
# pre-condition: menus have same parent
|
|
25
|
+
self.assertEqual(root_riba_parent_menu, sibling_menu.parent_id)
|
|
26
|
+
|
|
27
|
+
# Change sibling's parent
|
|
28
|
+
sibling_menu.parent_id = self.new_parent
|
|
29
|
+
|
|
30
|
+
# Check that RiBa menu's parent has changed according to its sibling
|
|
31
|
+
self.assertEqual(self.root_riba_menu.parent_id, sibling_menu.parent_id)
|
|
32
|
+
self.assertNotEqual(self.root_riba_menu.parent_id, root_riba_parent_menu)
|
|
33
|
+
|
|
34
|
+
def test_not_sibling_not_moved(self):
|
|
35
|
+
"""Check that RiBa menu is not moved when a menu
|
|
36
|
+
that is not a sibling changes parent."""
|
|
37
|
+
root_riba_parent_menu = self.root_riba_menu.parent_id
|
|
38
|
+
not_sibling_menu = self.menu_model.search(
|
|
39
|
+
[
|
|
40
|
+
("parent_id", "!=", root_riba_parent_menu.id),
|
|
41
|
+
],
|
|
42
|
+
limit=1,
|
|
43
|
+
)
|
|
44
|
+
# pre-condition: menus have different parent
|
|
45
|
+
self.assertNotEqual(root_riba_parent_menu, not_sibling_menu.parent_id)
|
|
46
|
+
|
|
47
|
+
# Change not-sibling menu's parent
|
|
48
|
+
not_sibling_menu.parent_id = self.new_parent
|
|
49
|
+
|
|
50
|
+
# Check RiBa menu's parent is not changed
|
|
51
|
+
self.assertEqual(self.root_riba_menu.parent_id, root_riba_parent_menu)
|