Skip to content

Commit 71844d9

Browse files
committed
Merge PR #97 into 14.0
Signed-off-by yvaucher
2 parents 9d10ce9 + c251982 commit 71844d9

5 files changed

Lines changed: 65 additions & 30 deletions

File tree

apps_product_creator/README.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
.. image:: https://odoo-community.org/readme-banner-image
2-
:target: https://odoo-community.org/get-involved?utm_source=readme
3-
:alt: Odoo Community Association
4-
51
======================
62
Github product creator
73
======================
@@ -17,7 +13,7 @@ Github product creator
1713
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
1814
:target: https://odoo-community.org/page/development-status
1915
:alt: Beta
20-
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
2117
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
2218
:alt: License: AGPL-3
2319
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fapps--store-lightgray.png?logo=github
@@ -127,6 +123,10 @@ Contributors
127123
* Alexandre D. Díaz
128124
* Ernesto Tejeda
129125

126+
* `PyTech <https://www.pytech.it>`_:
127+
128+
* Simone Rubino <simone.rubino@pytech.it>
129+
130130
Other credits
131131
~~~~~~~~~~~~~
132132

apps_product_creator/models/odoo_module.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,20 @@ def _update_product(self):
9494
product._create_variant_ids()
9595
product.active = True
9696
product.website_published = True
97+
no_version_variants = product.product_variant_ids.filtered(
98+
lambda variant: not variant.odoo_module_version_id
99+
)
100+
for variant in no_version_variants:
101+
values = (
102+
variant.product_template_attribute_value_ids.product_attribute_value_id
103+
)
104+
for value in values:
105+
version = self.env["product.product"]._get_version_with_attribute(
106+
module.module_version_ids, value
107+
)
108+
if version:
109+
variant.odoo_module_version_id = version
110+
break
97111

98112
@api.model
99113
def _update_series_product_attribute_values(self):

apps_product_creator/readme/CONTRIBUTORS.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@
1212
* Carlos Roca
1313
* Alexandre D. Díaz
1414
* Ernesto Tejeda
15+
16+
* `PyTech <https://www.pytech.it>`_:
17+
18+
* Simone Rubino <simone.rubino@pytech.it>

apps_product_creator/static/description/index.html

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
55
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
6-
<title>README.rst</title>
6+
<title>Github product creator</title>
77
<style type="text/css">
88

99
/*
@@ -360,21 +360,16 @@
360360
</style>
361361
</head>
362362
<body>
363-
<div class="document">
363+
<div class="document" id="github-product-creator">
364+
<h1 class="title">Github product creator</h1>
364365

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="github-product-creator">
370-
<h1>Github product creator</h1>
371366
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
372367
!! This file is generated by oca-gen-addon-readme !!
373368
!! changes will be overwritten. !!
374369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
375370
!! source digest: sha256:023c64ae59318af28d85b38b9a6ba4fca975553d380fae15261eb0032531f7c5
376371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
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/apps-store/tree/14.0/apps_product_creator"><img alt="OCA/apps-store" src="https://img.shields.io/badge/github-OCA%2Fapps--store-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/apps-store-14-0/apps-store-14-0-apps_product_creator"><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/apps-store&amp;target_branch=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
372+
<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/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/apps-store/tree/14.0/apps_product_creator"><img alt="OCA/apps-store" src="https://img.shields.io/badge/github-OCA%2Fapps--store-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/apps-store-14-0/apps-store-14-0-apps_product_creator"><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/apps-store&amp;target_branch=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
378373
<p>This module extends the functionality of the module Github connector to create a product for every module found.
379374
A variant is also created for every version of the module.</p>
380375
<p><strong>Table of contents</strong></p>
@@ -404,15 +399,15 @@ <h1>Github product creator</h1>
404399
</ul>
405400
</div>
406401
<div class="section" id="configuration">
407-
<h2><a class="toc-backref" href="#toc-entry-1">Configuration</a></h2>
402+
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
408403
<p>There’s an scheduled action that creates the product, disabled by default. For enabling it:</p>
409404
<ol class="arabic simple">
410405
<li>Go to <em>Settings &gt; Technical &gt; Automation &gt; Scheduled Actions</em>.</li>
411406
<li>Locate “Create/Update product variants for each module version” and access its form.</li>
412407
</ol>
413408
</div>
414409
<div class="section" id="usage">
415-
<h2><a class="toc-backref" href="#toc-entry-2">Usage</a></h2>
410+
<h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
416411
<p>To see the module working</p>
417412
<blockquote>
418413
<ul class="simple">
@@ -429,57 +424,57 @@ <h2><a class="toc-backref" href="#toc-entry-2">Usage</a></h2>
429424
Now you can see the products created.</blockquote>
430425
</div>
431426
<div class="section" id="changelog">
432-
<h2><a class="toc-backref" href="#toc-entry-3">Changelog</a></h2>
427+
<h1><a class="toc-backref" href="#toc-entry-3">Changelog</a></h1>
433428
<div class="section" id="section-1">
434-
<h3><a class="toc-backref" href="#toc-entry-4">14.0.1.0.0 (2021-08-02)</a></h3>
429+
<h2><a class="toc-backref" href="#toc-entry-4">14.0.1.0.0 (2021-08-02)</a></h2>
435430
<ul class="simple">
436431
<li>Migration to 14.0</li>
437432
</ul>
438433
</div>
439434
<div class="section" id="section-2">
440-
<h3><a class="toc-backref" href="#toc-entry-5">13.0.1.0.0 (2020-07-10)</a></h3>
435+
<h2><a class="toc-backref" href="#toc-entry-5">13.0.1.0.0 (2020-07-10)</a></h2>
441436
<ul class="simple">
442437
<li>Migration to 13.0</li>
443438
</ul>
444439
</div>
445440
<div class="section" id="section-3">
446-
<h3><a class="toc-backref" href="#toc-entry-6">12.0.1.0.0 (2019-04-10)</a></h3>
441+
<h2><a class="toc-backref" href="#toc-entry-6">12.0.1.0.0 (2019-04-10)</a></h2>
447442
<ul class="simple">
448443
<li>Migration to 12.0</li>
449444
</ul>
450445
</div>
451446
<div class="section" id="section-4">
452-
<h3><a class="toc-backref" href="#toc-entry-7">11.0.1.1.2 (2018-10-02)</a></h3>
447+
<h2><a class="toc-backref" href="#toc-entry-7">11.0.1.1.2 (2018-10-02)</a></h2>
453448
<ul class="simple">
454449
<li>Publish the modules automatically on the website</li>
455450
</ul>
456451
</div>
457452
<div class="section" id="section-5">
458-
<h3><a class="toc-backref" href="#toc-entry-8">11.0.1.1.0 (2018-10-02)</a></h3>
453+
<h2><a class="toc-backref" href="#toc-entry-8">11.0.1.1.0 (2018-10-02)</a></h2>
459454
<ul class="simple">
460455
<li>[ADD] Added dependency on github_connector_oca to display development_status
461456
(<a class="reference external" href="https://github.com/OCA/apps-store/pull/19">#19</a>)</li>
462457
</ul>
463458
</div>
464459
</div>
465460
<div class="section" id="bug-tracker">
466-
<h2><a class="toc-backref" href="#toc-entry-9">Bug Tracker</a></h2>
461+
<h1><a class="toc-backref" href="#toc-entry-9">Bug Tracker</a></h1>
467462
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/apps-store/issues">GitHub Issues</a>.
468463
In case of trouble, please check there if your issue has already been reported.
469464
If you spotted it first, help us to smash it by providing a detailed and welcomed
470465
<a class="reference external" href="https://github.com/OCA/apps-store/issues/new?body=module:%20apps_product_creator%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
471466
<p>Do not contact contributors directly about support or help with technical issues.</p>
472467
</div>
473468
<div class="section" id="credits">
474-
<h2><a class="toc-backref" href="#toc-entry-10">Credits</a></h2>
469+
<h1><a class="toc-backref" href="#toc-entry-10">Credits</a></h1>
475470
<div class="section" id="authors">
476-
<h3><a class="toc-backref" href="#toc-entry-11">Authors</a></h3>
471+
<h2><a class="toc-backref" href="#toc-entry-11">Authors</a></h2>
477472
<ul class="simple">
478473
<li>BizzAppDev</li>
479474
</ul>
480475
</div>
481476
<div class="section" id="contributors">
482-
<h3><a class="toc-backref" href="#toc-entry-12">Contributors</a></h3>
477+
<h2><a class="toc-backref" href="#toc-entry-12">Contributors</a></h2>
483478
<ul class="simple">
484479
<li>Alex Comba &lt;<a class="reference external" href="mailto:alex.comba&#64;agilebg.com">alex.comba&#64;agilebg.com</a>&gt;</li>
485480
<li>Antonio Esposito &lt;<a class="reference external" href="mailto:a.esposito&#64;onestein.nl">a.esposito&#64;onestein.nl</a>&gt;</li>
@@ -495,19 +490,23 @@ <h3><a class="toc-backref" href="#toc-entry-12">Contributors</a></h3>
495490
<li>Ernesto Tejeda</li>
496491
</ul>
497492
</li>
493+
<li><a class="reference external" href="https://www.pytech.it">PyTech</a>:<ul>
494+
<li>Simone Rubino &lt;<a class="reference external" href="mailto:simone.rubino&#64;pytech.it">simone.rubino&#64;pytech.it</a>&gt;</li>
495+
</ul>
496+
</li>
498497
</ul>
499498
</div>
500499
<div class="section" id="other-credits">
501-
<h3><a class="toc-backref" href="#toc-entry-13">Other credits</a></h3>
500+
<h2><a class="toc-backref" href="#toc-entry-13">Other credits</a></h2>
502501
<div class="section" id="images">
503-
<h4><a class="toc-backref" href="#toc-entry-14">Images</a></h4>
502+
<h3><a class="toc-backref" href="#toc-entry-14">Images</a></h3>
504503
<ul class="simple">
505504
<li>Odoo Community Association: <a class="reference external" href="https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg">Icon</a>.</li>
506505
</ul>
507506
</div>
508507
</div>
509508
<div class="section" id="maintainers">
510-
<h3><a class="toc-backref" href="#toc-entry-15">Maintainers</a></h3>
509+
<h2><a class="toc-backref" href="#toc-entry-15">Maintainers</a></h2>
511510
<p>This module is maintained by the OCA.</p>
512511
<a class="reference external image-reference" href="https://odoo-community.org">
513512
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
@@ -520,6 +519,5 @@ <h3><a class="toc-backref" href="#toc-entry-15">Maintainers</a></h3>
520519
</div>
521520
</div>
522521
</div>
523-
</div>
524522
</body>
525523
</html>

apps_product_creator/tests/test_apps_product_creator.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,22 @@ def test_odoo_module_update_product(self):
3232
self.odoo_module2._update_product()
3333
self.assertTrue(self.odoo_module2.product_template_id.active)
3434
self.assertTrue(self.odoo_module2.product_template_id.website_published)
35+
36+
def test_restore_variant_module_version(self):
37+
# Arrange
38+
module = self.odoo_module2
39+
module.action_create_product()
40+
template = module.product_template_id
41+
variant = template.product_variant_ids
42+
module_version = variant.odoo_module_version_id
43+
variant.odoo_module_version_id = False
44+
# pre-condition
45+
self.assertEqual(len(variant), 1)
46+
self.assertFalse(variant.odoo_module_version_id)
47+
self.assertTrue(module_version)
48+
49+
# Act
50+
module._update_product()
51+
52+
# Assert
53+
self.assertEqual(variant.odoo_module_version_id, module_version)

0 commit comments

Comments
 (0)