Skip to content

Commit 34f57c2

Browse files
authored
Merge pull request OCA#174 from Tecnativa/9.0-website_sale_vat_required-mig
[MIG][9.0][website_sale_vat_required] Migrate
2 parents 04bfe3f + 9e76821 commit 34f57c2

File tree

8 files changed

+152
-0
lines changed

8 files changed

+152
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
2+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
3+
:alt: License: AGPL-3
4+
5+
=======================
6+
e-commerce required VAT
7+
=======================
8+
9+
This module extends checkout e-commerce form in order to force user to fill
10+
'VAT number' field.
11+
12+
Usage
13+
=====
14+
15+
To use this module, you need to:
16+
17+
#. Buy something from your e-commerce
18+
#. Go to checkout page.
19+
#. Try to checkout without specifying a VAT, or using a wrong one.
20+
#. You will get an error.
21+
22+
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
23+
:alt: Try me on Runbot
24+
:target: https://runbot.odoo-community.org/runbot/113/9.0
25+
26+
Bug Tracker
27+
===========
28+
29+
Bugs are tracked on `GitHub Issues
30+
<https://github.com/OCA/e-commerce/issues>`_. In case of trouble, please
31+
check there if your issue has already been reported. If you spotted it first,
32+
help us smash it by providing detailed and welcomed feedback.
33+
34+
Credits
35+
=======
36+
37+
Contributors
38+
------------
39+
40+
* Lorenzo Battistini <lorenzo.battistini@agilebg.com>
41+
* Jairo Llopis <jairo.llopis@tecnativa.com>
42+
43+
Maintainer
44+
----------
45+
46+
.. image:: https://odoo-community.org/logo.png
47+
:alt: Odoo Community Association
48+
:target: https://odoo-community.org
49+
50+
This module is maintained by the OCA.
51+
52+
OCA, or the Odoo Community Association, is a nonprofit organization whose
53+
mission is to support the collaborative development of Odoo features and
54+
promote its widespread use.
55+
56+
To contribute to this module, please visit https://odoo-community.org.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2015 Agile Business Group sagl (<http://www.agilebg.com>)
3+
# Copyright 2017 Jairo Llopis <jairo.llopis@tecnativa.com>
4+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
5+
6+
from . import controllers
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2015 Agile Business Group sagl (<http://www.agilebg.com>)
3+
# Copyright 2017 Jairo Llopis <jairo.llopis@tecnativa.com>
4+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
5+
6+
{
7+
'name': 'e-commerce required VAT',
8+
'summary': 'VAT number required in checkout form',
9+
'version': '9.0.1.0.0',
10+
'category': 'Website',
11+
'author': "Agile Business Group, "
12+
"Tecnativa, "
13+
"Odoo Community Association (OCA)",
14+
'website': 'http://www.agilebg.com',
15+
'license': 'AGPL-3',
16+
'depends': [
17+
'website_sale',
18+
'base_vat',
19+
],
20+
'demo': [
21+
'demo/assets.xml',
22+
],
23+
'installable': True,
24+
'auto_install': False,
25+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2015 Lorenzo Battistini <lorenzo.battistini@agilebg.com>
3+
# Copyright 2017 Jairo Llopis <jairo.llopis@tecnativa.com>
4+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
5+
6+
from . import main
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2015 Agile Business Group sagl (<http://www.agilebg.com>)
3+
# Copyright 2017 Jairo Llopis <jairo.llopis@tecnativa.com>
4+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
5+
6+
from openerp.addons.website_sale.controllers.main import website_sale
7+
8+
9+
class WebsiteSale(website_sale):
10+
def _get_mandatory_billing_fields(self):
11+
result = super(WebsiteSale, self)._get_mandatory_billing_fields()
12+
result.append("vat")
13+
return result
14+
15+
def _get_optional_billing_fields(self):
16+
result = super(WebsiteSale, self)._get_optional_billing_fields()
17+
try:
18+
result.remove("vat")
19+
except ValueError: # pragma: no-cover
20+
# If any other addon removed it already, do not die
21+
pass
22+
return result
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Copyright 2017 Jairo Llopis <jairo.llopis@tecnativa.com>
3+
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
4+
5+
<odoo>
6+
7+
<template id="assets_frontend_demo" inherit_id="website.assets_frontend">
8+
<xpath expr=".">
9+
<script type="text/javascript"
10+
src="/website_sale_vat_required/static/src/js/website_sale.tour.js"/>
11+
</xpath>
12+
</template>
13+
14+
</odoo>
1.9 KB
Loading
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* Copyright 2017 Jairo Llopis <jairo.llopis@tecnativa.com>
2+
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
3+
4+
odoo.define('website_sale_vat_required.tour', function (require) {
5+
"use strict";
6+
7+
require("website_sale.tour");
8+
var buy_tour = require('web.Tour').tours["shop_buy_product"];
9+
10+
buy_tour.steps.forEach(function (value, index) {
11+
// Search upstream tour step that would fail with this addon installed
12+
if (value.title === "test without input error") {
13+
// Patch step's `onload` method
14+
var oldonload = value.onload;
15+
value.onload = function () {
16+
// Fill VAT field with a good value
17+
$('.has-error > input[name="vat"]').val("BE0477472701")
18+
return oldonload.apply(this, arguments);
19+
};
20+
return false;
21+
}
22+
});
23+
});

0 commit comments

Comments
 (0)