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

[16.0][MIG] website_sale_stock_list_preview: Migration to version 16.0 #832

Merged
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
6 changes: 6 additions & 0 deletions setup/website_sale_stock_list_preview/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
85 changes: 85 additions & 0 deletions website_sale_stock_list_preview/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
===============================
Website Sale Stock List Preview
===============================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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-OCA%2Fe--commerce-lightgray.png?logo=github
:target: https://github.com/OCA/e-commerce/tree/15.0/website_sale_stock_list_preview
:alt: OCA/e-commerce
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/e-commerce-15-0/e-commerce-15-0-website_sale_stock_list_preview
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/113/15.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

This module extends the functionality of e-Commerce to give
the buyer the information about the stock on the preview of the products.

**Table of contents**

.. contents::
:local:

Usage
=====

To use this module, you need to:

* Edit some products on the option Availability of e-commerce
* Go to the shop on the website and active Add to Cart view on Customize menu.
* You can see on your products the results of the options that you had choose.

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/e-commerce/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/e-commerce/issues/new?body=module:%20website_sale_stock_list_preview%0Aversion:%2015.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
~~~~~~~

* Tecnativa

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

* Carlos Roca <[email protected]>
* Sergio Teruel <[email protected]>
* Carlos Dauden <[email protected]>

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

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/e-commerce <https://github.com/OCA/e-commerce/tree/15.0/website_sale_stock_list_preview>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions website_sale_stock_list_preview/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import controllers
25 changes: 25 additions & 0 deletions website_sale_stock_list_preview/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2020 Tecnativa - Carlos Roca
# Copyright 2020 Tecnativa - Sergio Teruel
# Copyright 2020 Tecnativa - Carlos Dauden
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Website Sale Stock List Preview",
"summary": "Show the stock of products on the product previews",
"version": "16.0.1.0.0",
"category": "Website",
"website": "https://github.com/OCA/e-commerce",
"author": "Tecnativa, Odoo Community Association (OCA)",
"license": "AGPL-3",
"installable": True,
"depends": ["website_sale_stock"],
"data": ["views/templates.xml"],
"assets": {
"web.assets_frontend": [
"/website_sale_stock_list_preview/static/src/js/*",
"/website_sale_stock_list_preview/static/src/scss/*",
],
"web.assets_tests": [
"/website_sale_stock_list_preview/static/src/tests/*.js",
],
},
}
3 changes: 3 additions & 0 deletions website_sale_stock_list_preview/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import main
50 changes: 50 additions & 0 deletions website_sale_stock_list_preview/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Copyright 2020 Tecnativa - Carlos Roca
# Copyright 2020 Tecnativa - Carlos Dauden
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import http
from odoo.http import request

from odoo.addons.sale.controllers.variant import VariantController


class WebsiteSaleVariantController(VariantController):
@http.route(
["/sale/get_combination_info_stock_preview"],
type="json",
auth="public",
website=True,
)
def get_combination_info_stock_preview(self, product_template_ids, **kw):
"""Special route to use website logic in get_combination_info override.
This route is called in JS by appending _website to the base route.
"""
current_website = request.env["website"].get_current_website()
res = []
templates = (
request.env["product.template"]
.sudo()
.with_context(
warehouse=current_website.sudo().warehouse_id.id,
website_sale_stock_available=True,
)
.browse(product_template_ids)
)
for template in templates.filtered(lambda t: t.is_published):
variants = template.product_variant_ids
res.append(
{
"product_template": template.id,
"product_type": template.type,
"free_qty": sum(variants.mapped("free_qty")),
"cart_qty": sum(
[product._get_cart_qty(current_website) for product in variants]
),
"out_of_stock_message": template.out_of_stock_message,
"allow_out_of_stock_order": template.allow_out_of_stock_order,
"show_availability": template.show_availability,
"available_threshold": template.available_threshold,
"uom_name": template.uom_name,
}
)
return res
14 changes: 14 additions & 0 deletions website_sale_stock_list_preview/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
3 changes: 3 additions & 0 deletions website_sale_stock_list_preview/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* Carlos Roca <[email protected]>
* Sergio Teruel <[email protected]>
* Carlos Dauden <[email protected]>
2 changes: 2 additions & 0 deletions website_sale_stock_list_preview/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module extends the functionality of e-Commerce to give
the buyer the information about the stock on the preview of the products.
5 changes: 5 additions & 0 deletions website_sale_stock_list_preview/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
To use this module, you need to:

* Edit some products on the option Availability of e-commerce
* Go to the shop on the website and active Add to Cart view on Customize menu.
* You can see on your products the results of the options that you had choose.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading