Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions apps_product_creator/README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

======================
Github product creator
======================
Expand All @@ -17,7 +13,7 @@ Github product creator
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fapps--store-lightgray.png?logo=github
Expand Down Expand Up @@ -127,6 +123,10 @@ Contributors
* Alexandre D. Díaz
* Ernesto Tejeda

* `PyTech <https://www.pytech.it>`_:

* Simone Rubino <simone.rubino@pytech.it>

Other credits
~~~~~~~~~~~~~

Expand Down
14 changes: 14 additions & 0 deletions apps_product_creator/models/odoo_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,20 @@ def _update_product(self):
product._create_variant_ids()
product.active = True
product.website_published = True
no_version_variants = product.product_variant_ids.filtered(
lambda variant: not variant.odoo_module_version_id
)
for variant in no_version_variants:
values = (
variant.product_template_attribute_value_ids.product_attribute_value_id
)
for value in values:
version = self.env["product.product"]._get_version_with_attribute(
module.module_version_ids, value
)
if version:
variant.odoo_module_version_id = version
break

@api.model
def _update_series_product_attribute_values(self):
Expand Down
4 changes: 4 additions & 0 deletions apps_product_creator/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@
* Carlos Roca
* Alexandre D. Díaz
* Ernesto Tejeda

* `PyTech <https://www.pytech.it>`_:

* Simone Rubino <simone.rubino@pytech.it>
48 changes: 23 additions & 25 deletions apps_product_creator/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>README.rst</title>
<title>Github product creator</title>
<style type="text/css">

/*
Expand Down Expand Up @@ -360,21 +360,16 @@
</style>
</head>
<body>
<div class="document">
<div class="document" id="github-product-creator">
<h1 class="title">Github product creator</h1>


<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
</a>
<div class="section" id="github-product-creator">
<h1>Github product creator</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:7eb7c768e99a47aec4d80572c3f409d5f1e42bdde03caf778f05fc649775832d
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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>
<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>
<p>This module extends the functionality of the module Github connector to create a product for every module found.
A variant is also created for every version of the module.</p>
<p><strong>Table of contents</strong></p>
Expand Down Expand Up @@ -404,15 +399,15 @@ <h1>Github product creator</h1>
</ul>
</div>
<div class="section" id="configuration">
<h2><a class="toc-backref" href="#toc-entry-1">Configuration</a></h2>
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
<p>There’s an scheduled action that creates the product, disabled by default. For enabling it:</p>
<ol class="arabic simple">
<li>Go to <em>Settings &gt; Technical &gt; Automation &gt; Scheduled Actions</em>.</li>
<li>Locate “Create/Update product variants for each module version” and access its form.</li>
</ol>
</div>
<div class="section" id="usage">
<h2><a class="toc-backref" href="#toc-entry-2">Usage</a></h2>
<h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
<p>To see the module working</p>
<blockquote>
<ul class="simple">
Expand All @@ -429,57 +424,57 @@ <h2><a class="toc-backref" href="#toc-entry-2">Usage</a></h2>
Now you can see the products created.</blockquote>
</div>
<div class="section" id="changelog">
<h2><a class="toc-backref" href="#toc-entry-3">Changelog</a></h2>
<h1><a class="toc-backref" href="#toc-entry-3">Changelog</a></h1>
<div class="section" id="section-1">
<h3><a class="toc-backref" href="#toc-entry-4">14.0.1.0.0 (2021-08-02)</a></h3>
<h2><a class="toc-backref" href="#toc-entry-4">14.0.1.0.0 (2021-08-02)</a></h2>
<ul class="simple">
<li>Migration to 14.0</li>
</ul>
</div>
<div class="section" id="section-2">
<h3><a class="toc-backref" href="#toc-entry-5">13.0.1.0.0 (2020-07-10)</a></h3>
<h2><a class="toc-backref" href="#toc-entry-5">13.0.1.0.0 (2020-07-10)</a></h2>
<ul class="simple">
<li>Migration to 13.0</li>
</ul>
</div>
<div class="section" id="section-3">
<h3><a class="toc-backref" href="#toc-entry-6">12.0.1.0.0 (2019-04-10)</a></h3>
<h2><a class="toc-backref" href="#toc-entry-6">12.0.1.0.0 (2019-04-10)</a></h2>
<ul class="simple">
<li>Migration to 12.0</li>
</ul>
</div>
<div class="section" id="section-4">
<h3><a class="toc-backref" href="#toc-entry-7">11.0.1.1.2 (2018-10-02)</a></h3>
<h2><a class="toc-backref" href="#toc-entry-7">11.0.1.1.2 (2018-10-02)</a></h2>
<ul class="simple">
<li>Publish the modules automatically on the website</li>
</ul>
</div>
<div class="section" id="section-5">
<h3><a class="toc-backref" href="#toc-entry-8">11.0.1.1.0 (2018-10-02)</a></h3>
<h2><a class="toc-backref" href="#toc-entry-8">11.0.1.1.0 (2018-10-02)</a></h2>
<ul class="simple">
<li>[ADD] Added dependency on github_connector_oca to display development_status
(<a class="reference external" href="https://github.com/OCA/apps-store/pull/19">#19</a>)</li>
</ul>
</div>
</div>
<div class="section" id="bug-tracker">
<h2><a class="toc-backref" href="#toc-entry-9">Bug Tracker</a></h2>
<h1><a class="toc-backref" href="#toc-entry-9">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/apps-store/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<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>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h2><a class="toc-backref" href="#toc-entry-10">Credits</a></h2>
<h1><a class="toc-backref" href="#toc-entry-10">Credits</a></h1>
<div class="section" id="authors">
<h3><a class="toc-backref" href="#toc-entry-11">Authors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-11">Authors</a></h2>
<ul class="simple">
<li>BizzAppDev</li>
</ul>
</div>
<div class="section" id="contributors">
<h3><a class="toc-backref" href="#toc-entry-12">Contributors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-12">Contributors</a></h2>
<ul class="simple">
<li>Alex Comba &lt;<a class="reference external" href="mailto:alex.comba&#64;agilebg.com">alex.comba&#64;agilebg.com</a>&gt;</li>
<li>Antonio Esposito &lt;<a class="reference external" href="mailto:a.esposito&#64;onestein.nl">a.esposito&#64;onestein.nl</a>&gt;</li>
Expand All @@ -495,19 +490,23 @@ <h3><a class="toc-backref" href="#toc-entry-12">Contributors</a></h3>
<li>Ernesto Tejeda</li>
</ul>
</li>
<li><a class="reference external" href="https://www.pytech.it">PyTech</a>:<ul>
<li>Simone Rubino &lt;<a class="reference external" href="mailto:simone.rubino&#64;pytech.it">simone.rubino&#64;pytech.it</a>&gt;</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="other-credits">
<h3><a class="toc-backref" href="#toc-entry-13">Other credits</a></h3>
<h2><a class="toc-backref" href="#toc-entry-13">Other credits</a></h2>
<div class="section" id="images">
<h4><a class="toc-backref" href="#toc-entry-14">Images</a></h4>
<h3><a class="toc-backref" href="#toc-entry-14">Images</a></h3>
<ul class="simple">
<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>
</ul>
</div>
</div>
<div class="section" id="maintainers">
<h3><a class="toc-backref" href="#toc-entry-15">Maintainers</a></h3>
<h2><a class="toc-backref" href="#toc-entry-15">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
Expand All @@ -520,6 +519,5 @@ <h3><a class="toc-backref" href="#toc-entry-15">Maintainers</a></h3>
</div>
</div>
</div>
</div>
</body>
</html>
19 changes: 19 additions & 0 deletions apps_product_creator/tests/test_apps_product_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,22 @@ def test_odoo_module_update_product(self):
self.odoo_module2._update_product()
self.assertTrue(self.odoo_module2.product_template_id.active)
self.assertTrue(self.odoo_module2.product_template_id.website_published)

def test_restore_variant_module_version(self):
# Arrange
module = self.odoo_module2
module.action_create_product()
template = module.product_template_id
variant = template.product_variant_ids
module_version = variant.odoo_module_version_id
variant.odoo_module_version_id = False
# pre-condition
self.assertEqual(len(variant), 1)
self.assertFalse(variant.odoo_module_version_id)
self.assertTrue(module_version)

# Act
module._update_product()

# Assert
self.assertEqual(variant.odoo_module_version_id, module_version)