Skip to content

Commit

Permalink
[MIG] website_sale_secondary_unit: Migration to v12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sergio-teruel committed Oct 24, 2019
1 parent 02e4c72 commit 026b440
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 72 deletions.
10 changes: 5 additions & 5 deletions website_sale_secondary_unit/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ Website Sale Secondary Unit
: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_secondary_unit
:target: https://github.com/OCA/e-commerce/tree/12.0/website_sale_secondary_unit
: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_secondary_unit
:target: https://translation.odoo-community.org/projects/e-commerce-12-0/e-commerce-12-0-website_sale_secondary_unit
: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 @@ -52,7 +52,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_secondary_unit%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_secondary_unit%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 @@ -82,6 +82,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_secondary_unit>`_ project on GitHub.
This module is part of the `OCA/e-commerce <https://github.com/OCA/e-commerce/tree/12.0/website_sale_secondary_unit>`_ 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_secondary_unit/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
'name': 'Website Sale Secondary Unit',
'summary': 'Allow manage secondary units in website shop',
'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 @@ -23,8 +23,5 @@
'views/product_secondary_unit_views.xml',
'views/templates.xml',
],
'demo': [
'data/demo.xml',
],
'post_init_hook': 'post_init_hook',
}
2 changes: 1 addition & 1 deletion website_sale_secondary_unit/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def create(self, vals):
SecondaryUom = self.env['product.secondary.unit']
secondary_uom = SecondaryUom.browse(
vals.get('secondary_uom_id', False))
product_uom = self.env['product.uom'].browse(
product_uom = self.env['uom.uom'].browse(
vals.get('product_uom', False))
if secondary_uom:
factor = (secondary_uom.factor * (product_uom and
Expand Down
4 changes: 2 additions & 2 deletions website_sale_secondary_unit/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_product_secondary_unit_public,access_product_second_unit_public,product_secondary_unit.model_product_secondary_unit,base.group_public,1,0,0,0
access_product_secondary_unit_portal,access_product_second_unit_portal,product_secondary_unit.model_product_secondary_unit,base.group_portal,1,0,0,0
access_product_uom_public,access_product_uom_public,product.model_product_uom,base.group_public,1,0,0,0
access_product_uom_portal,access_product_uom_portal,product.model_product_uom,base.group_portal,1,0,0,0
access_product_uom_public,access_product_uom_public,uom.model_uom_uom,base.group_public,1,0,0,0
access_product_uom_portal,access_product_uom_portal,uom.model_uom_uom,base.group_portal,1,0,0,0
6 changes: 3 additions & 3 deletions website_sale_secondary_unit/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Website Sale Secondary Unit</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_secondary_unit"><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_secondary_unit"><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_secondary_unit"><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_secondary_unit"><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 sale_order_secondary_unit module to
allow sell products in online store in secondary units defined.</p>
<p><strong>Table of contents</strong></p>
Expand Down Expand Up @@ -401,7 +401,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_secondary_unit%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_secondary_unit%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 All @@ -425,7 +425,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_secondary_unit">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_secondary_unit">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 @@ -20,7 +20,7 @@ odoo.define("website_sale_secondary_unit.tour", function (require) {

var steps = [
{
trigger: "a:contains('iPod')",
trigger: "a:contains('Customizable Desk')",
},
{
trigger: "#secondary_uom",
Expand All @@ -35,19 +35,16 @@ odoo.define("website_sale_secondary_unit.tour", function (require) {
extra_trigger: "span:contains(Box 5 Unit(s))"
},
{
trigger: "a:contains('iPod')",
trigger: "a:contains('Customizable Desk')",
},
{
trigger: "#add_to_cart",
extra_trigger: ".js_product:has(input[name='add_qty']:propValueContains(1))",
},
{
trigger: "a[href='/shop/checkout']",
trigger: "a[href='/shop/checkout?express=1']",
extra_trigger: "span:containsExact(Unit(s))"
},
{
trigger: "a[href='/shop/confirm_order']",
},
{
trigger: "#o_payment_form_pay",
extra_trigger: "table:has(span:contains(Box 5 Unit(s)):has(span:contains(Unit(s)))"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,38 @@


class WebsiteSaleSecondaryUnitHttpCase(HttpCase):
def setUp(self):
super().setUp()
# Models
ProductSecondaryUnit = self.env['product.secondary.unit']
product_uom_unit = self.env.ref('uom.product_uom_unit')
self.product_template = self.env.ref(
'product.product_product_4_product_template')
vals = {
'name': 'Box',
'uom_id': product_uom_unit.id,
'factor': 5.0,
'product_tmpl_id': self.product_template.id,
'website_published': True,
}
self.secondary_unit_box_5 = ProductSecondaryUnit.create(vals)
self.secondary_unit_box_10 = ProductSecondaryUnit.create(
dict(vals, factor=10.0))
self.product_template.write({
'secondary_uom_ids': [
(6, 0, [self.secondary_unit_box_5.id,
self.secondary_unit_box_10.id,]),
],
'optional_product_ids': [(6, 0, [])]
})

def test_ui_website(self):
"""Test frontend tour."""
tour = (
"odoo.__DEBUG__.services['web_tour.tour']",
"website_sale_secondary_unit",
)
self.phantom_js(
self.browser_js(
url_path="/",
code="%s.run('%s')" % tour,
ready="%s.tours['%s'].ready" % tour,
Expand Down
4 changes: 2 additions & 2 deletions website_sale_secondary_unit/views/assets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
src="/website_sale_secondary_unit/static/src/js/website_sale_secondary_unit.js"/>
<script type="text/javascript"
src="/website_sale_secondary_unit/static/src/js/website_sale_secondary_unit_tour.js"/>
<link type="text/less" rel="stylesheet"
href="/website_sale_secondary_unit/static/src/less/website_sale_secondary_unit.less"/>
<link type="text/scss" rel="stylesheet"
href="/website_sale_secondary_unit/static/src/scss/website_sale_secondary_unit.scss"/>
</xpath>
</template>
</odoo>
81 changes: 33 additions & 48 deletions website_sale_secondary_unit/views/templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@

<template id="secondary_qty">
<div class="css_quantity input-group oe_website_spinner" contenteditable="false">
<a t-attf-href="#" class="mb8 input-group-addon js_add_cart_json">
<i class="fa fa-minus"></i>
</a>
<div class="input-group-prepend">
<a t-attf-href="#" class="btn btn-secondary js_add_cart_json" aria-label="Remove one" title="Remove one">
<i class="fa fa-minus"></i>
</a>
</div>
<input type="text" class="form-control secondary-quantity" data-min="1" name="add_secondary_qty" value="1"/>
<a t-attf-href="#" class="mb8 input-group-addon float_left js_add_cart_json">
<i class="fa fa-plus"></i>
</a>
<div class="input-group-append">
<a t-attf-href="#" class="btn btn-secondary float_left js_add_cart_json" aria-label="Add one" title="Add one">
<i class="fa fa-plus"></i>
</a>
</div>
</div>
</template>

Expand Down Expand Up @@ -48,7 +52,7 @@
</template>

<template id="product_price" inherit_id="website_sale.product_price">
<xpath expr="//b[@t-esc='product.website_price']" position="after">
<xpath expr="//b[hasclass('oe_price')]" position="after">
<t t-if="product.secondary_uom_ids">
/ <span class="css_editable_mode_hidden price_uom" t-field="product.uom_id"/>
</t>
Expand All @@ -57,28 +61,32 @@

<template id="product_quantity" inherit_id="website_sale.product_quantity">
<xpath expr="//input[@name='add_qty']/.." position="attributes">
<attribute name="t-attf-class">css_quantity input-group oe_website_spinner #{'hide' if product.secondary_uom_ids else None}</attribute>
<attribute name="t-attf-class">css_quantity input-group oe_website_spinner #{'d-none' if product.secondary_uom_ids else None}</attribute>
</xpath>
</template>

<template id="cart_lines" inherit_id="website_sale.cart_lines">
<xpath expr="//td[hasclass('td-qty')]/div" position="before">
<t t-if="line.secondary_uom_id">
<span class="css_secondary_quantity input-group oe_website_spinner">
<a t-attf-href="#" class="mb8 input-group-addon js_add_cart_json hidden-xs">
<i class="fa fa-minus"></i>
</a>
<div class="css_secondary_quantity input-group mx-auto oe_website_spinner">
<div class="input-group-prepend">
<a t-attf-href="#" class="btn btn-link js_add_cart_json d-xs d-md-inline-block" aria-label="Remove one" title="Remove one">
<i class="fa fa-minus"></i>
</a>
</div>
<input type="text" class="js_secondary_quantity form-control secondary-quantity"
t-att-data-line-id="line.id"
t-att-data-product-id="line.product_id.id"
t-att-data-secondary-uom-id="line.secondary_uom_id.id"
t-att-data-secondary-uom-factor="line.secondary_uom_id.factor"
t-att-data-product-uom-factor="line.product_uom.factor"
t-att-value="int(line.secondary_uom_qty) == line.secondary_uom_qty and int(line.secondary_uom_qty) or line.secondary_uom_qty" />
<a t-attf-href="#" class="mb8 input-group-addon float_left js_add_cart_json hidden-xs">
<i class="fa fa-plus"></i>
</a>
</span>
<div class="input-group-append">
<a t-attf-href="#" class="btn btn-link float_left js_add_cart_json d-xs d-md-inline-block" aria-label="Add one" title="Add one">
<i class="fa fa-plus"></i>
</a>
</div>
</div>
<div>
<t t-call="website_sale_secondary_unit.second_qty_description">
<t t-set="secondary_uom" t-value="line.secondary_uom_id"/>
Expand All @@ -87,7 +95,7 @@
</t>
</xpath>
<xpath expr="//td[hasclass('td-qty')]/div[hasclass('css_quantity')]" position="attributes">
<attribute name="t-attf-class">css_quantity input-group oe_website_spinner #{'hide' if line.secondary_uom_id else None}</attribute>
<attribute name="t-attf-class">css_quantity input-group oe_website_spinner #{'d-none' if line.secondary_uom_id else None}</attribute>
</xpath>
<xpath expr="//td[hasclass('td-qty')]/div[hasclass('css_quantity')]" position="after">
<t t-if="not line.secondary_uom_id">
Expand All @@ -111,7 +119,7 @@
</xpath>
</template>

<template id="payment" inherit_id="website_sale.payment">
<template id="cart_summary" inherit_id="website_sale.cart_summary">
<xpath expr="//td[hasclass('td-qty')]" position="inside">
<t t-if="line.secondary_uom_id">
<div t-esc="int(line.secondary_uom_qty) == line.secondary_uom_qty and int(line.secondary_uom_qty) or line.secondary_uom_qty"/>
Expand All @@ -121,7 +129,7 @@
</t>
</xpath>
<xpath expr="//td[hasclass('td-qty')]/div" position="attributes">
<attribute name="t-attf-class">#{'hide' if line.secondary_uom_id else None}</attribute>
<attribute name="t-attf-class">#{'d-none' if line.secondary_uom_id else None}</attribute>
</xpath>
<xpath expr="//td[hasclass('td-qty')]/div" position="after">
<t t-if="not line.secondary_uom_id">
Expand All @@ -145,41 +153,18 @@
</xpath>
</template>

<template id="confirmation" inherit_id="website_sale.confirmation">
<xpath expr="//td[hasclass('td-qty')]" position="inside">
<t t-if="line.secondary_uom_id">
<span t-esc="int(line.secondary_uom_qty) == line.secondary_uom_qty and int(line.secondary_uom_qty) or line.secondary_uom_qty"/>
<t t-call="website_sale_secondary_unit.second_qty_description">
<t t-set="secondary_uom" t-value="line.secondary_uom_id"/>
</t>
</t>
</xpath>
<xpath expr="//td[hasclass('td-qty')]/div" position="attributes">
<attribute name="t-attf-class">#{'hide' if line.secondary_uom_id else None}</attribute>
</xpath>
<!-- Display product uom to price column to clarify that price is per product unit -->
<xpath expr="//td[hasclass('td-price')]/span/div" position="attributes">
<attribute name="class" separator=" " add="pull-left"/>
</xpath>
<xpath expr="//td[hasclass('td-price')]/span" position="inside">
<t t-if="line.product_id.secondary_uom_ids">
/ <span class="css_editable_mode_hidden price_uom" t-field="line.product_id.uom_id"/>
</t>
</xpath>
</template>

<template id="cart_popover" inherit_id="website_sale.cart_popover">
<xpath expr="//small" position="after">
<small t-if="line.secondary_uom_id">
<xpath expr="//div[hasclass('col-9')]" position="inside">
<div t-if="line.secondary_uom_id">
Qty: <t t-esc="int(line.secondary_uom_qty) == line.secondary_uom_qty and int(line.secondary_uom_qty) or line.secondary_uom_qty" />
<t t-call="website_sale_secondary_unit.second_qty_description">
<t t-set="secondary_uom" t-value="line.secondary_uom_id"/>
</t>
</small>
</xpath>
<xpath expr="//small" position="attributes">
<attribute name="t-attf-class">#{'hide' if line.secondary_uom_id else None}</attribute>
</div>
</xpath>
<!-- <xpath expr="//small" position="attributes">-->
<!-- <attribute name="t-attf-class">#{'d-none' if line.secondary_uom_id else None}</attribute>-->
<!-- </xpath>-->
</template>

</odoo>

0 comments on commit 026b440

Please sign in to comment.