Skip to content

Commit

Permalink
[MIG] website_sale_stock_available_display: Migration to v12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sergio-teruel committed Oct 29, 2019
1 parent 3c850e3 commit db320df
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 52 deletions.
10 changes: 5 additions & 5 deletions website_sale_stock_available_display/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ Website Sale Stock Available Display
: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/11.0/website_sale_stock_available_display
:target: https://github.com/OCA/e-commerce/tree/12.0/website_sale_stock_available_display
: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-11-0/e-commerce-11-0-website_sale_stock_available_display
:target: https://translation.odoo-community.org/projects/e-commerce-12-0/e-commerce-12-0-website_sale_stock_available_display
: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/11.0
:target: https://runbot.odoo-community.org/runbot/113/12.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -54,7 +54,7 @@ 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_available_display%0Aversion:%2011.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/e-commerce/issues/new?body=module:%20website_sale_stock_available_display%0Aversion:%2012.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.

Expand Down Expand Up @@ -86,6 +86,6 @@ 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/11.0/website_sale_stock_available_display>`_ project on GitHub.
This module is part of the `OCA/e-commerce <https://github.com/OCA/e-commerce/tree/12.0/website_sale_stock_available_display>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
5 changes: 1 addition & 4 deletions website_sale_stock_available_display/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
'name': 'Website Sale Stock Available Display',
'summary': 'Display stock in shop online and allow to sell with no stock '
'available',
'version': '11.0.1.0.0',
'version': '12.0.1.0.0',
'development_status': 'Beta',
'category': 'Website',
'website': 'https://github.com/OCA/e-commerce',
Expand All @@ -20,7 +20,4 @@
'views/product_template_views.xml',
'views/templates.xml',
],
'demo': [
'data/demo.xml',
],
}
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Website Sale Stock Available Display</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" 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" 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" href="https://github.com/OCA/e-commerce/tree/11.0/website_sale_stock_available_display"><img alt="OCA/e-commerce" src="https://img.shields.io/badge/github-OCA%2Fe--commerce-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/e-commerce-11-0/e-commerce-11-0-website_sale_stock_available_display"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/113/11.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" 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" 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" href="https://github.com/OCA/e-commerce/tree/12.0/website_sale_stock_available_display"><img alt="OCA/e-commerce" src="https://img.shields.io/badge/github-OCA%2Fe--commerce-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/e-commerce-12-0/e-commerce-12-0-website_sale_stock_available_display"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/113/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module extends the functionality of website sale stock module to allow to
display available stock in website products and allow to buy if not enough
stock.
Expand Down Expand Up @@ -404,7 +404,7 @@ <h1><a class="toc-backref" href="#id2">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/e-commerce/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 smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/e-commerce/issues/new?body=module:%20website_sale_stock_available_display%0Aversion:%2011.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/e-commerce/issues/new?body=module:%20website_sale_stock_available_display%0Aversion:%2012.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">
Expand Down Expand Up @@ -434,7 +434,7 @@ <h2><a class="toc-backref" href="#id6">Maintainers</a></h2>
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/e-commerce/tree/11.0/website_sale_stock_available_display">OCA/e-commerce</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/e-commerce/tree/12.0/website_sale_stock_available_display">OCA/e-commerce</a> project on GitHub.</p>
<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>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ odoo.define('website_sale_stock_available_display.load', function (require) {
'use strict';
var ajax = require('web.ajax');
var core = require('web.core');
var website_sale_stock = require('website_sale_stock.website_sale');
var ProductConfiguratorMixin = require(
'website_sale_stock.ProductConfiguratorMixin');
var QWeb = core.qweb;

var load_xml = ajax.loadXML('/website_sale_stock_available_display/static/src/xml/website_sale_stock_product_availability.xml', QWeb);
var load_xml = ajax.loadXML(
'/website_sale_stock_available_display/static/src/xml/website_sale_stock_product_availability.xml',
QWeb
);
load_xml.then(function() {
$('.oe_website_sale').find('input[name="add_qty"]').trigger('change');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,21 @@ odoo.define("website_sale_stock_available_display.tour", function (require) {

var tour = require("web_tour.tour");
var base = require("web_editor.base");
var rpc = require("web.rpc");

var steps = [
{
trigger: "a:contains('Computer Motherboard')",
run: function(actions){
rpc.query({
model: 'res.partner',
method: 'write',
args: [[3], {'vat': false}]})
.then(function(data){
actions.auto();
})
}
},
{
trigger: "a#add_to_cart",
extra_trigger: ".availability_messages:has(span:contains('0 Unit(s) in stock')):has(div:contains('Available in 10 days'))",
},
{
trigger: "a[href='/shop/checkout']",
trigger: "span:contains('Process Checkout')",
extra_trigger: ".availability_messages:has(span:contains('0 Unit(s) in stock'))",
},
// To compatibility with website_sale_vat_required
{
trigger: "div.div_vat input[name='vat']",
run: function(actions){
$('div.div_vat input[name="vat"]').val("BE0477472701");
$('#div_phone input').val('11111111');
$('div input[name="accepted_legal_terms"]').prop( "checked", true );
},
},
{
trigger: ".btn-primary:contains('Next')",
},
{
trigger: "a[href='/shop/confirm_order']",
trigger: ".btn-primary:contains('Confirm Order')",
},
{
trigger: "a[href='/shop']",
Expand All @@ -56,11 +34,11 @@ odoo.define("website_sale_stock_available_display.tour", function (require) {
extra_trigger: ".availability_messages:has(span:contains('10 Unit(s) in stock'))",
},
{
trigger: "a[href='/shop/checkout']",
trigger: "span:contains('Process Checkout')",
extra_trigger: ".availability_messages:has(span:contains('10.0 Unit(s) in stock'))",
},
{
trigger: "a[href='/shop/confirm_order']",
trigger: ".btn-primary:contains('Confirm Order')",
},
{
trigger: "a[href='/shop']",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,52 @@

class websiteSaleStockNoQtyAllowed(HttpCase):

def setUp(self):
super().setUp()
# For testing with website_sale_vat_required module, I avoid
# address step to fill partner vat
self.env.ref('base.user_admin').partner_id.write({
'vat': 'BE0477472701',
'phone': '9999999999',
})
self.ProductTemplate = self.env['product.template']
# The website_sequence is set quite high to display this products in
# first page.
# Set list price to 0.0 to avoid payment step because this step has an
# asynchronous call
common_vals = {
'type': 'product',
'website_published': True,
'inventory_availability': 'always_no_lock',
'website_sequence': 5000,
'list_price': 0.0,
}
vals = common_vals.copy()
vals.update({
'name': 'Computer Motherboard',
'custom_message': 'Available in 10 days',
})
self.product_template_wo_qty = self.ProductTemplate.create(vals)
vals = common_vals.copy()
vals.update({
'name': 'Special Mouse',
})
self.product_product_w_qty = self.ProductTemplate.create(vals)
self.env['stock.quant'].create({
'product_id': self.product_product_w_qty.product_variant_ids.id,
'product_uom_id': self.product_product_w_qty.uom_id.id,
'location_id': self.env.ref('stock.stock_location_stock').id,
'quantity': 10.0,
})

def test_ui_website(self):
"""Test frontend tour."""
tour = (
"odoo.__DEBUG__.services['web_tour.tour']",
"website_sale_stock_available_display",
)
self.phantom_js(
url_path="/",
self.browser_js(
url_path="/shop",
code="%s.run('%s')" % tour,
ready="%s.tours['%s'].ready" % tour,
login="admin"
Expand Down
11 changes: 2 additions & 9 deletions website_sale_stock_available_display/views/templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,11 @@
</xpath>
</template>

<!-- Payment -->
<template id="payment" inherit_id="website_sale.payment">
<!-- Cart Summary -->
<template id="cart_summary" inherit_id="website_sale.cart_summary">
<xpath expr="//table[@id='cart_products']//td[hasclass('td-qty')]" position="inside">
<t t-call="website_sale_stock_available_display.stock_info"/>
</xpath>
</template>

<!-- Confirmation aditinal info -->
<template id="confirmation" inherit_id="website_sale.confirmation">
<xpath expr="//td[hasclass('td-qty')]" position="inside">
<t t-call="website_sale_stock_available_display.stock_info"/>
</xpath>
</template>

</odoo>

0 comments on commit db320df

Please sign in to comment.