odoo-addon-odoo-repository 16.0.1.3.0.13__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.
Files changed (77) hide show
  1. odoo/addons/odoo_repository/README.rst +81 -0
  2. odoo/addons/odoo_repository/__init__.py +2 -0
  3. odoo/addons/odoo_repository/__manifest__.py +58 -0
  4. odoo/addons/odoo_repository/controllers/__init__.py +1 -0
  5. odoo/addons/odoo_repository/controllers/main.py +32 -0
  6. odoo/addons/odoo_repository/data/ir_cron.xml +38 -0
  7. odoo/addons/odoo_repository/data/odoo.repository.csv +216 -0
  8. odoo/addons/odoo_repository/data/odoo_branch.xml +82 -0
  9. odoo/addons/odoo_repository/data/odoo_module.xml +16 -0
  10. odoo/addons/odoo_repository/data/odoo_repository.xml +71 -0
  11. odoo/addons/odoo_repository/data/odoo_repository_addons_path.xml +59 -0
  12. odoo/addons/odoo_repository/data/odoo_repository_org.xml +14 -0
  13. odoo/addons/odoo_repository/data/queue_job.xml +56 -0
  14. odoo/addons/odoo_repository/lib/__init__.py +0 -0
  15. odoo/addons/odoo_repository/lib/scanner.py +1302 -0
  16. odoo/addons/odoo_repository/migrations/16.0.1.1.0/post-migration.py +26 -0
  17. odoo/addons/odoo_repository/migrations/16.0.1.2.0/pre-migration.py +43 -0
  18. odoo/addons/odoo_repository/migrations/16.0.1.3.0/post-migration.py +19 -0
  19. odoo/addons/odoo_repository/models/__init__.py +18 -0
  20. odoo/addons/odoo_repository/models/authentication_token.py +12 -0
  21. odoo/addons/odoo_repository/models/odoo_author.py +16 -0
  22. odoo/addons/odoo_repository/models/odoo_branch.py +111 -0
  23. odoo/addons/odoo_repository/models/odoo_license.py +16 -0
  24. odoo/addons/odoo_repository/models/odoo_maintainer.py +31 -0
  25. odoo/addons/odoo_repository/models/odoo_module.py +24 -0
  26. odoo/addons/odoo_repository/models/odoo_module_branch.py +873 -0
  27. odoo/addons/odoo_repository/models/odoo_module_branch_version.py +123 -0
  28. odoo/addons/odoo_repository/models/odoo_module_category.py +15 -0
  29. odoo/addons/odoo_repository/models/odoo_module_dev_status.py +15 -0
  30. odoo/addons/odoo_repository/models/odoo_python_dependency.py +16 -0
  31. odoo/addons/odoo_repository/models/odoo_repository.py +664 -0
  32. odoo/addons/odoo_repository/models/odoo_repository_addons_path.py +40 -0
  33. odoo/addons/odoo_repository/models/odoo_repository_branch.py +98 -0
  34. odoo/addons/odoo_repository/models/odoo_repository_org.py +23 -0
  35. odoo/addons/odoo_repository/models/res_company.py +23 -0
  36. odoo/addons/odoo_repository/models/res_config_settings.py +23 -0
  37. odoo/addons/odoo_repository/models/ssh_key.py +12 -0
  38. odoo/addons/odoo_repository/readme/CONTRIBUTORS.rst +2 -0
  39. odoo/addons/odoo_repository/readme/DESCRIPTION.rst +1 -0
  40. odoo/addons/odoo_repository/security/ir.model.access.csv +27 -0
  41. odoo/addons/odoo_repository/security/res_groups.xml +25 -0
  42. odoo/addons/odoo_repository/static/description/README +4 -0
  43. odoo/addons/odoo_repository/static/description/icon.png +0 -0
  44. odoo/addons/odoo_repository/static/description/index.html +430 -0
  45. odoo/addons/odoo_repository/tests/__init__.py +6 -0
  46. odoo/addons/odoo_repository/tests/common.py +162 -0
  47. odoo/addons/odoo_repository/tests/test_base_scanner.py +214 -0
  48. odoo/addons/odoo_repository/tests/test_odoo_module_branch.py +97 -0
  49. odoo/addons/odoo_repository/tests/test_odoo_repository_scan.py +242 -0
  50. odoo/addons/odoo_repository/tests/test_repository_scanner.py +215 -0
  51. odoo/addons/odoo_repository/tests/test_sync_node.py +55 -0
  52. odoo/addons/odoo_repository/tests/test_utils.py +25 -0
  53. odoo/addons/odoo_repository/utils/__init__.py +0 -0
  54. odoo/addons/odoo_repository/utils/github.py +30 -0
  55. odoo/addons/odoo_repository/utils/module.py +25 -0
  56. odoo/addons/odoo_repository/utils/scanner.py +90 -0
  57. odoo/addons/odoo_repository/views/authentication_token.xml +63 -0
  58. odoo/addons/odoo_repository/views/menu.xml +38 -0
  59. odoo/addons/odoo_repository/views/odoo_author.xml +54 -0
  60. odoo/addons/odoo_repository/views/odoo_branch.xml +84 -0
  61. odoo/addons/odoo_repository/views/odoo_license.xml +40 -0
  62. odoo/addons/odoo_repository/views/odoo_maintainer.xml +69 -0
  63. odoo/addons/odoo_repository/views/odoo_module.xml +90 -0
  64. odoo/addons/odoo_repository/views/odoo_module_branch.xml +353 -0
  65. odoo/addons/odoo_repository/views/odoo_module_category.xml +40 -0
  66. odoo/addons/odoo_repository/views/odoo_module_dev_status.xml +40 -0
  67. odoo/addons/odoo_repository/views/odoo_python_dependency.xml +40 -0
  68. odoo/addons/odoo_repository/views/odoo_repository.xml +165 -0
  69. odoo/addons/odoo_repository/views/odoo_repository_addons_path.xml +49 -0
  70. odoo/addons/odoo_repository/views/odoo_repository_branch.xml +60 -0
  71. odoo/addons/odoo_repository/views/odoo_repository_org.xml +54 -0
  72. odoo/addons/odoo_repository/views/res_config_settings.xml +123 -0
  73. odoo/addons/odoo_repository/views/ssh_key.xml +63 -0
  74. odoo_addon_odoo_repository-16.0.1.3.0.13.dist-info/METADATA +100 -0
  75. odoo_addon_odoo_repository-16.0.1.3.0.13.dist-info/RECORD +77 -0
  76. odoo_addon_odoo_repository-16.0.1.3.0.13.dist-info/WHEEL +5 -0
  77. odoo_addon_odoo_repository-16.0.1.3.0.13.dist-info/top_level.txt +1 -0
@@ -0,0 +1,430 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
+ <meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
6
+ <title>README.rst</title>
7
+ <style type="text/css">
8
+
9
+ /*
10
+ :Author: David Goodger (goodger@python.org)
11
+ :Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
12
+ :Copyright: This stylesheet has been placed in the public domain.
13
+
14
+ Default cascading style sheet for the HTML output of Docutils.
15
+ Despite the name, some widely supported CSS2 features are used.
16
+
17
+ See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
18
+ customize this style sheet.
19
+ */
20
+
21
+ /* used to remove borders from tables and images */
22
+ .borderless, table.borderless td, table.borderless th {
23
+ border: 0 }
24
+
25
+ table.borderless td, table.borderless th {
26
+ /* Override padding for "table.docutils td" with "! important".
27
+ The right padding separates the table cells. */
28
+ padding: 0 0.5em 0 0 ! important }
29
+
30
+ .first {
31
+ /* Override more specific margin styles with "! important". */
32
+ margin-top: 0 ! important }
33
+
34
+ .last, .with-subtitle {
35
+ margin-bottom: 0 ! important }
36
+
37
+ .hidden {
38
+ display: none }
39
+
40
+ .subscript {
41
+ vertical-align: sub;
42
+ font-size: smaller }
43
+
44
+ .superscript {
45
+ vertical-align: super;
46
+ font-size: smaller }
47
+
48
+ a.toc-backref {
49
+ text-decoration: none ;
50
+ color: black }
51
+
52
+ blockquote.epigraph {
53
+ margin: 2em 5em ; }
54
+
55
+ dl.docutils dd {
56
+ margin-bottom: 0.5em }
57
+
58
+ object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
59
+ overflow: hidden;
60
+ }
61
+
62
+ /* Uncomment (and remove this text!) to get bold-faced definition list terms
63
+ dl.docutils dt {
64
+ font-weight: bold }
65
+ */
66
+
67
+ div.abstract {
68
+ margin: 2em 5em }
69
+
70
+ div.abstract p.topic-title {
71
+ font-weight: bold ;
72
+ text-align: center }
73
+
74
+ div.admonition, div.attention, div.caution, div.danger, div.error,
75
+ div.hint, div.important, div.note, div.tip, div.warning {
76
+ margin: 2em ;
77
+ border: medium outset ;
78
+ padding: 1em }
79
+
80
+ div.admonition p.admonition-title, div.hint p.admonition-title,
81
+ div.important p.admonition-title, div.note p.admonition-title,
82
+ div.tip p.admonition-title {
83
+ font-weight: bold ;
84
+ font-family: sans-serif }
85
+
86
+ div.attention p.admonition-title, div.caution p.admonition-title,
87
+ div.danger p.admonition-title, div.error p.admonition-title,
88
+ div.warning p.admonition-title, .code .error {
89
+ color: red ;
90
+ font-weight: bold ;
91
+ font-family: sans-serif }
92
+
93
+ /* Uncomment (and remove this text!) to get reduced vertical space in
94
+ compound paragraphs.
95
+ div.compound .compound-first, div.compound .compound-middle {
96
+ margin-bottom: 0.5em }
97
+
98
+ div.compound .compound-last, div.compound .compound-middle {
99
+ margin-top: 0.5em }
100
+ */
101
+
102
+ div.dedication {
103
+ margin: 2em 5em ;
104
+ text-align: center ;
105
+ font-style: italic }
106
+
107
+ div.dedication p.topic-title {
108
+ font-weight: bold ;
109
+ font-style: normal }
110
+
111
+ div.figure {
112
+ margin-left: 2em ;
113
+ margin-right: 2em }
114
+
115
+ div.footer, div.header {
116
+ clear: both;
117
+ font-size: smaller }
118
+
119
+ div.line-block {
120
+ display: block ;
121
+ margin-top: 1em ;
122
+ margin-bottom: 1em }
123
+
124
+ div.line-block div.line-block {
125
+ margin-top: 0 ;
126
+ margin-bottom: 0 ;
127
+ margin-left: 1.5em }
128
+
129
+ div.sidebar {
130
+ margin: 0 0 0.5em 1em ;
131
+ border: medium outset ;
132
+ padding: 1em ;
133
+ background-color: #ffffee ;
134
+ width: 40% ;
135
+ float: right ;
136
+ clear: right }
137
+
138
+ div.sidebar p.rubric {
139
+ font-family: sans-serif ;
140
+ font-size: medium }
141
+
142
+ div.system-messages {
143
+ margin: 5em }
144
+
145
+ div.system-messages h1 {
146
+ color: red }
147
+
148
+ div.system-message {
149
+ border: medium outset ;
150
+ padding: 1em }
151
+
152
+ div.system-message p.system-message-title {
153
+ color: red ;
154
+ font-weight: bold }
155
+
156
+ div.topic {
157
+ margin: 2em }
158
+
159
+ h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
160
+ h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
161
+ margin-top: 0.4em }
162
+
163
+ h1.title {
164
+ text-align: center }
165
+
166
+ h2.subtitle {
167
+ text-align: center }
168
+
169
+ hr.docutils {
170
+ width: 75% }
171
+
172
+ img.align-left, .figure.align-left, object.align-left, table.align-left {
173
+ clear: left ;
174
+ float: left ;
175
+ margin-right: 1em }
176
+
177
+ img.align-right, .figure.align-right, object.align-right, table.align-right {
178
+ clear: right ;
179
+ float: right ;
180
+ margin-left: 1em }
181
+
182
+ img.align-center, .figure.align-center, object.align-center {
183
+ display: block;
184
+ margin-left: auto;
185
+ margin-right: auto;
186
+ }
187
+
188
+ table.align-center {
189
+ margin-left: auto;
190
+ margin-right: auto;
191
+ }
192
+
193
+ .align-left {
194
+ text-align: left }
195
+
196
+ .align-center {
197
+ clear: both ;
198
+ text-align: center }
199
+
200
+ .align-right {
201
+ text-align: right }
202
+
203
+ /* reset inner alignment in figures */
204
+ div.align-right {
205
+ text-align: inherit }
206
+
207
+ /* div.align-center * { */
208
+ /* text-align: left } */
209
+
210
+ .align-top {
211
+ vertical-align: top }
212
+
213
+ .align-middle {
214
+ vertical-align: middle }
215
+
216
+ .align-bottom {
217
+ vertical-align: bottom }
218
+
219
+ ol.simple, ul.simple {
220
+ margin-bottom: 1em }
221
+
222
+ ol.arabic {
223
+ list-style: decimal }
224
+
225
+ ol.loweralpha {
226
+ list-style: lower-alpha }
227
+
228
+ ol.upperalpha {
229
+ list-style: upper-alpha }
230
+
231
+ ol.lowerroman {
232
+ list-style: lower-roman }
233
+
234
+ ol.upperroman {
235
+ list-style: upper-roman }
236
+
237
+ p.attribution {
238
+ text-align: right ;
239
+ margin-left: 50% }
240
+
241
+ p.caption {
242
+ font-style: italic }
243
+
244
+ p.credits {
245
+ font-style: italic ;
246
+ font-size: smaller }
247
+
248
+ p.label {
249
+ white-space: nowrap }
250
+
251
+ p.rubric {
252
+ font-weight: bold ;
253
+ font-size: larger ;
254
+ color: maroon ;
255
+ text-align: center }
256
+
257
+ p.sidebar-title {
258
+ font-family: sans-serif ;
259
+ font-weight: bold ;
260
+ font-size: larger }
261
+
262
+ p.sidebar-subtitle {
263
+ font-family: sans-serif ;
264
+ font-weight: bold }
265
+
266
+ p.topic-title {
267
+ font-weight: bold }
268
+
269
+ pre.address {
270
+ margin-bottom: 0 ;
271
+ margin-top: 0 ;
272
+ font: inherit }
273
+
274
+ pre.literal-block, pre.doctest-block, pre.math, pre.code {
275
+ margin-left: 2em ;
276
+ margin-right: 2em }
277
+
278
+ pre.code .ln { color: gray; } /* line numbers */
279
+ pre.code, code { background-color: #eeeeee }
280
+ pre.code .comment, code .comment { color: #5C6576 }
281
+ pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
282
+ pre.code .literal.string, code .literal.string { color: #0C5404 }
283
+ pre.code .name.builtin, code .name.builtin { color: #352B84 }
284
+ pre.code .deleted, code .deleted { background-color: #DEB0A1}
285
+ pre.code .inserted, code .inserted { background-color: #A3D289}
286
+
287
+ span.classifier {
288
+ font-family: sans-serif ;
289
+ font-style: oblique }
290
+
291
+ span.classifier-delimiter {
292
+ font-family: sans-serif ;
293
+ font-weight: bold }
294
+
295
+ span.interpreted {
296
+ font-family: sans-serif }
297
+
298
+ span.option {
299
+ white-space: nowrap }
300
+
301
+ span.pre {
302
+ white-space: pre }
303
+
304
+ span.problematic, pre.problematic {
305
+ color: red }
306
+
307
+ span.section-subtitle {
308
+ /* font-size relative to parent (h1..h6 element) */
309
+ font-size: 80% }
310
+
311
+ table.citation {
312
+ border-left: solid 1px gray;
313
+ margin-left: 1px }
314
+
315
+ table.docinfo {
316
+ margin: 2em 4em }
317
+
318
+ table.docutils {
319
+ margin-top: 0.5em ;
320
+ margin-bottom: 0.5em }
321
+
322
+ table.footnote {
323
+ border-left: solid 1px black;
324
+ margin-left: 1px }
325
+
326
+ table.docutils td, table.docutils th,
327
+ table.docinfo td, table.docinfo th {
328
+ padding-left: 0.5em ;
329
+ padding-right: 0.5em ;
330
+ vertical-align: top }
331
+
332
+ table.docutils th.field-name, table.docinfo th.docinfo-name {
333
+ font-weight: bold ;
334
+ text-align: left ;
335
+ white-space: nowrap ;
336
+ padding-left: 0 }
337
+
338
+ /* "booktabs" style (no vertical lines) */
339
+ table.docutils.booktabs {
340
+ border: 0px;
341
+ border-top: 2px solid;
342
+ border-bottom: 2px solid;
343
+ border-collapse: collapse;
344
+ }
345
+ table.docutils.booktabs * {
346
+ border: 0px;
347
+ }
348
+ table.docutils.booktabs th {
349
+ border-bottom: thin solid;
350
+ text-align: left;
351
+ }
352
+
353
+ h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
354
+ h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
355
+ font-size: 100% }
356
+
357
+ ul.auto-toc {
358
+ list-style-type: none }
359
+
360
+ </style>
361
+ </head>
362
+ <body>
363
+ <div class="document">
364
+
365
+
366
+ <a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
367
+ <img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
368
+ </a>
369
+ <div class="section" id="odoo-repositories-data">
370
+ <h1>Odoo Repositories Data</h1>
371
+ <!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
372
+ !! This file is generated by oca-gen-addon-readme !!
373
+ !! changes will be overwritten. !!
374
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
375
+ !! source digest: sha256:4104a55f42cc9182dfb114f697afd9ad7e46e074d91a9fe373ee555411c96b9c
376
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
377
+ <p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/odoo-repository/tree/16.0/odoo_repository"><img alt="OCA/odoo-repository" src="https://img.shields.io/badge/github-OCA%2Fodoo--repository-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/odoo-repository-16-0/odoo-repository-16-0-odoo_repository"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/odoo-repository&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
378
+ <p>Base module to host data collected from Odoo repositories.</p>
379
+ <p><strong>Table of contents</strong></p>
380
+ <div class="contents local topic" id="contents">
381
+ <ul class="simple">
382
+ <li><a class="reference internal" href="#bug-tracker" id="toc-entry-1">Bug Tracker</a></li>
383
+ <li><a class="reference internal" href="#credits" id="toc-entry-2">Credits</a><ul>
384
+ <li><a class="reference internal" href="#authors" id="toc-entry-3">Authors</a></li>
385
+ <li><a class="reference internal" href="#contributors" id="toc-entry-4">Contributors</a></li>
386
+ <li><a class="reference internal" href="#maintainers" id="toc-entry-5">Maintainers</a></li>
387
+ </ul>
388
+ </li>
389
+ </ul>
390
+ </div>
391
+ <div class="section" id="bug-tracker">
392
+ <h2><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h2>
393
+ <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/odoo-repository/issues">GitHub Issues</a>.
394
+ In case of trouble, please check there if your issue has already been reported.
395
+ If you spotted it first, help us to smash it by providing a detailed and welcomed
396
+ <a class="reference external" href="https://github.com/OCA/odoo-repository/issues/new?body=module:%20odoo_repository%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
397
+ <p>Do not contact contributors directly about support or help with technical issues.</p>
398
+ </div>
399
+ <div class="section" id="credits">
400
+ <h2><a class="toc-backref" href="#toc-entry-2">Credits</a></h2>
401
+ <div class="section" id="authors">
402
+ <h3><a class="toc-backref" href="#toc-entry-3">Authors</a></h3>
403
+ <ul class="simple">
404
+ <li>Camptocamp</li>
405
+ </ul>
406
+ </div>
407
+ <div class="section" id="contributors">
408
+ <h3><a class="toc-backref" href="#toc-entry-4">Contributors</a></h3>
409
+ <ul class="simple">
410
+ <li>Camptocamp
411
+ * Sébastien Alix &lt;<a class="reference external" href="mailto:sebastien.alix&#64;camptocamp.com">sebastien.alix&#64;camptocamp.com</a>&gt;</li>
412
+ </ul>
413
+ </div>
414
+ <div class="section" id="maintainers">
415
+ <h3><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h3>
416
+ <p>This module is maintained by the OCA.</p>
417
+ <a class="reference external image-reference" href="https://odoo-community.org">
418
+ <img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
419
+ </a>
420
+ <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
421
+ mission is to support the collaborative development of Odoo features and
422
+ promote its widespread use.</p>
423
+ <p>This module is part of the <a class="reference external" href="https://github.com/OCA/odoo-repository/tree/16.0/odoo_repository">OCA/odoo-repository</a> project on GitHub.</p>
424
+ <p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
425
+ </div>
426
+ </div>
427
+ </div>
428
+ </div>
429
+ </body>
430
+ </html>
@@ -0,0 +1,6 @@
1
+ from . import test_utils
2
+ from . import test_base_scanner
3
+ from . import test_repository_scanner
4
+ from . import test_odoo_repository_scan
5
+ from . import test_sync_node
6
+ from . import test_odoo_module_branch
@@ -0,0 +1,162 @@
1
+ # Copyright 2024 Camptocamp SA
2
+ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
3
+
4
+ import os
5
+ import pathlib
6
+ import re
7
+ import tempfile
8
+ from unittest.mock import patch
9
+
10
+ import git
11
+ from oca_port.tests.common import CommonCase
12
+
13
+ from odoo.tests.common import TransactionCase
14
+
15
+
16
+ class Common(TransactionCase, CommonCase):
17
+ @classmethod
18
+ def setUpClass(cls):
19
+ super().setUpClass()
20
+ CommonCase.setUpClass()
21
+ cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True))
22
+ cls.repositories_path = tempfile.mkdtemp()
23
+ cls.env["ir.config_parameter"].set_param(
24
+ "odoo_repository_storage_path", cls.repositories_path
25
+ )
26
+ cls._apply_git_config()
27
+
28
+ def setUp(self):
29
+ super().setUp()
30
+ # Leverage the existing test class from 'oca_port' to bootstrap
31
+ # temporary git repositories to run tests
32
+ CommonCase.setUp(self)
33
+ self.repo_name = pathlib.Path(self.repo_upstream_path).parts[-1]
34
+ self.org = self.env["odoo.repository.org"].create({"name": self.fork_org})
35
+ self.odoo_repository = self.env["odoo.repository"].create(
36
+ {
37
+ "org_id": self.org.id,
38
+ "name": self.repo_name,
39
+ "repo_url": self.repo_upstream_path,
40
+ "clone_url": self.repo_upstream_path,
41
+ "repo_type": "github",
42
+ }
43
+ )
44
+ # branch1
45
+ self.branch1_name = self.source1.split("/")[1]
46
+ self.branch = (
47
+ self.env["odoo.branch"]
48
+ .with_context(active_test=False)
49
+ .search([("name", "=", self.branch1_name)])
50
+ )
51
+ if not self.branch:
52
+ self.branch = self.env["odoo.branch"].create(
53
+ {
54
+ "name": self.branch1_name,
55
+ }
56
+ )
57
+ self.branch.active = True
58
+ # branch2
59
+ self.branch2_name = self.source2.split("/")[1]
60
+ self.branch2 = (
61
+ self.env["odoo.branch"]
62
+ .with_context(active_test=False)
63
+ .search([("name", "=", self.branch2_name)])
64
+ )
65
+ if not self.branch2:
66
+ self.branch2 = self.env["odoo.branch"].create(
67
+ {
68
+ "name": self.branch2_name,
69
+ }
70
+ )
71
+ self.branch2.active = True
72
+ # branch3
73
+ self.branch3_name = self.target2.split("/")[1]
74
+ # technical module
75
+ self.module_name = self.addon
76
+ self.module_branch_model = self.env["odoo.module.branch"]
77
+
78
+ @classmethod
79
+ def _apply_git_config(cls):
80
+ """Configure git (~/.gitconfig) if no config file exists."""
81
+ git_cfg = pathlib.Path(os.path.expanduser("~/.gitconfig"))
82
+ if git_cfg.exists():
83
+ return
84
+ os.system("git config --global user.email 'test@example.com'")
85
+ os.system("git config --global user.name 'test'")
86
+
87
+ def _patch_github_class(self):
88
+ res = super()._patch_github_class()
89
+ # Patch helper method part of 'odoo_repository' module as well
90
+ self.patcher2 = patch("odoo.addons.odoo_repository.utils.github.request")
91
+ github_request = self.patcher2.start()
92
+ github_request.return_value = {}
93
+ self.addCleanup(self.patcher2.stop)
94
+ return res
95
+
96
+ def _update_module_version_on_branch(self, branch, version):
97
+ """Change module version on a given branch, and commit the change."""
98
+ repo = git.Repo(self.repo_upstream_path)
99
+ repo.git.checkout(branch)
100
+ # Update version in manifest file
101
+ lines = []
102
+ with open(self.manifest_path, "r+") as manifest:
103
+ for line in manifest:
104
+ pattern = r".*version['\"]:\s['\"]([\d.]+).*"
105
+ match = re.search(pattern, line)
106
+ if match:
107
+ current_version = match.group(1)
108
+ line = line.replace(current_version, version)
109
+ lines.append(line)
110
+ with open(self.manifest_path, "r+") as manifest:
111
+ manifest.writelines(lines)
112
+ # Commit
113
+ repo.index.add(self.manifest_path)
114
+ commit = repo.index.commit(f"[IMP] {self.addon}: bump version to {version}")
115
+ return commit.hexsha
116
+
117
+ def _update_module_installable_on_branch(self, branch, installable=True):
118
+ repo = git.Repo(self.repo_upstream_path)
119
+ repo.git.checkout(branch)
120
+ # Update installable key in manifest file
121
+ lines = []
122
+ with open(self.manifest_path, "r+") as manifest:
123
+ for line in manifest:
124
+ pattern = r".*installable[`\"]:\s(\b[A-Z,a-z]+),.*"
125
+ match = re.search(pattern, line)
126
+ if match:
127
+ current_value = match.group(1)
128
+ line = line.replace(current_value, str(installable))
129
+ lines.append(line)
130
+ with open(self.manifest_path, "r+") as manifest:
131
+ manifest.writelines(lines)
132
+ # Commit
133
+ repo.index.add(self.manifest_path)
134
+ commit = repo.index.commit(
135
+ f"[IMP] {self.addon}: make installable={installable}"
136
+ )
137
+ return commit.hexsha
138
+
139
+ def _run_odoo_repository_action_scan(self, branch_id, force=False):
140
+ """Run `action_scan` for given `branch_id` on the Odoo repository."""
141
+ self.odoo_repository.with_context(queue_job__no_delay=True).action_scan(
142
+ branch_ids=[branch_id], force=force
143
+ )
144
+
145
+ def _create_odoo_module(self, name):
146
+ return self.env["odoo.module"].create({"name": name})
147
+
148
+ def _create_odoo_repository_branch(self, repo, branch, **values):
149
+ vals = {
150
+ "repository_id": repo.id,
151
+ "branch_id": branch.id,
152
+ }
153
+ vals.update(values)
154
+ return self.env["odoo.repository.branch"].create(vals)
155
+
156
+ def _create_odoo_module_branch(self, module, branch, **values):
157
+ vals = {
158
+ "module_id": module.id,
159
+ "branch_id": branch.id,
160
+ }
161
+ vals.update(values)
162
+ return self.env["odoo.module.branch"].create(vals)