Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][ADD] shopinvader_optional_products : export optional products #1562

Open
wants to merge 1 commit into
base: 14.0
Choose a base branch
from
Open
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
72 changes: 72 additions & 0 deletions shopinvader_optional_products/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
============================
Shopinvader Optional Product
============================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:bea320a72013088dbe13e7b885990c3ec23093811ff8beef6bf70a88205e1d2e
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/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-shopinvader%2Fodoo--shopinvader-lightgray.png?logo=github
:target: https://github.com/shopinvader/odoo-shopinvader/tree/14.0/shopinvader_optional_products
:alt: shopinvader/odoo-shopinvader

|badge1| |badge2| |badge3|

Exports the optional products that one can define when the Sale Product Configurator module is installed.

The optional products must be binded to the corresponding shopinvader backend.

The JSON block exported is a list of dict that gives, for each shopinvader variant of the optional products :

* id
* name
* description
* url_key
* images

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/shopinvader/odoo-shopinvader/issues>`_.
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
`feedback <https://github.com/shopinvader/odoo-shopinvader/issues/new?body=module:%20shopinvader_optional_products%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Akretion

Contributors
~~~~~~~~~~~~

* `Akretion <https://www.akretion.com>`_:

* Olivier Nibart

Maintainers
~~~~~~~~~~~

This module is part of the `shopinvader/odoo-shopinvader <https://github.com/shopinvader/odoo-shopinvader/tree/14.0/shopinvader_optional_products>`_ project on GitHub.

You are welcome to contribute.
1 change: 1 addition & 0 deletions shopinvader_optional_products/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
23 changes: 23 additions & 0 deletions shopinvader_optional_products/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2024 Akretion (http://www.akretion.com)
# Olivier Nibart <olivier.nibart@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
"name": "Shopinvader Optional Product",
"summary": "Export optional products",
"version": "14.0.0.0.1",
"category": "e-commerce",
"website": "https://github.com/shopinvader/odoo-shopinvader",
"author": "Akretion",
"license": "AGPL-3",
"depends": [
"shopinvader",
"sale_product_configurator",
"shopinvader_image",
"base_sparse_field",
],
"data": [
"data/ir_export_product.xml",
],
"installable": True,
}
9 changes: 9 additions & 0 deletions shopinvader_optional_products/data/ir_export_product.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>

<record id="ir_exp_shopinvader_variant_optional_products" model="ir.exports.line">
<field name="name">optional_products</field>
<field name="export_id" ref="shopinvader.ir_exp_shopinvader_variant" />
</record>

</odoo>
1 change: 1 addition & 0 deletions shopinvader_optional_products/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import shopinvader_variant
33 changes: 33 additions & 0 deletions shopinvader_optional_products/models/shopinvader_variant.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2024 Akretion (http://www.akretion.com)
# Olivier Nibart <olivier.nibart@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import fields, models


class ShopinvaderVariant(models.Model):
_inherit = "shopinvader.variant"

optional_products = fields.Serialized(
compute="_compute_optional_products", string="Shopinvader Optional Products"
)

def _compute_optional_products(self):
for record in self:
optional_products = []
for pt in record.optional_product_ids:
variants = pt.shopinvader_bind_ids.filtered(
lambda x, rec=record: x.backend_id == rec.backend_id
and x.lang_id == rec.lang_id
).shopinvader_variant_ids
for variant in variants:
optional_products.append(
{
"name": variant.name,
"id": variant.id,
"description": variant.description or "",
"url_key": variant.url_key,
"images": variant.images,
}
)
record.optional_products = optional_products
3 changes: 3 additions & 0 deletions shopinvader_optional_products/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* `Akretion <https://www.akretion.com>`_:

* Olivier Nibart
11 changes: 11 additions & 0 deletions shopinvader_optional_products/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Exports the optional products that one can define when the Sale Product Configurator module is installed.

The optional products must be binded to the corresponding shopinvader backend.

The JSON block exported is a list of dict that gives, for each shopinvader variant of the optional products :

* id
* name
* description
* url_key
* images
Loading