forked from OCA/e-commerce
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request OCA#174 from Tecnativa/9.0-website_sale_vat_requir…
…ed-mig [MIG][9.0][website_sale_vat_required] Migrate
- Loading branch information
Showing
8 changed files
with
152 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
|
||
======================= | ||
e-commerce required VAT | ||
======================= | ||
|
||
This module extends checkout e-commerce form in order to force user to fill | ||
'VAT number' field. | ||
|
||
Usage | ||
===== | ||
|
||
To use this module, you need to: | ||
|
||
#. Buy something from your e-commerce | ||
#. Go to checkout page. | ||
#. Try to checkout without specifying a VAT, or using a wrong one. | ||
#. You will get an error. | ||
|
||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas | ||
:alt: Try me on Runbot | ||
:target: https://runbot.odoo-community.org/runbot/113/9.0 | ||
|
||
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 smash it by providing detailed and welcomed feedback. | ||
|
||
Credits | ||
======= | ||
|
||
Contributors | ||
------------ | ||
|
||
* Lorenzo Battistini <lorenzo.battistini@agilebg.com> | ||
* Jairo Llopis <jairo.llopis@tecnativa.com> | ||
|
||
Maintainer | ||
---------- | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
This module is maintained by the OCA. | ||
|
||
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. | ||
|
||
To contribute to this module, please visit https://odoo-community.org. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2015 Agile Business Group sagl (<http://www.agilebg.com>) | ||
# Copyright 2017 Jairo Llopis <jairo.llopis@tecnativa.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from . import controllers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2015 Agile Business Group sagl (<http://www.agilebg.com>) | ||
# Copyright 2017 Jairo Llopis <jairo.llopis@tecnativa.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
'name': 'e-commerce required VAT', | ||
'summary': 'VAT number required in checkout form', | ||
'version': '9.0.1.0.0', | ||
'category': 'Website', | ||
'author': "Agile Business Group, " | ||
"Tecnativa, " | ||
"Odoo Community Association (OCA)", | ||
'website': 'http://www.agilebg.com', | ||
'license': 'AGPL-3', | ||
'depends': [ | ||
'website_sale', | ||
'base_vat', | ||
], | ||
'demo': [ | ||
'demo/assets.xml', | ||
], | ||
'installable': True, | ||
'auto_install': False, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2015 Lorenzo Battistini <lorenzo.battistini@agilebg.com> | ||
# Copyright 2017 Jairo Llopis <jairo.llopis@tecnativa.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from . import main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2015 Agile Business Group sagl (<http://www.agilebg.com>) | ||
# Copyright 2017 Jairo Llopis <jairo.llopis@tecnativa.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from openerp.addons.website_sale.controllers.main import website_sale | ||
|
||
|
||
class WebsiteSale(website_sale): | ||
def _get_mandatory_billing_fields(self): | ||
result = super(WebsiteSale, self)._get_mandatory_billing_fields() | ||
result.append("vat") | ||
return result | ||
|
||
def _get_optional_billing_fields(self): | ||
result = super(WebsiteSale, self)._get_optional_billing_fields() | ||
try: | ||
result.remove("vat") | ||
except ValueError: # pragma: no-cover | ||
# If any other addon removed it already, do not die | ||
pass | ||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- Copyright 2017 Jairo Llopis <jairo.llopis@tecnativa.com> | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> | ||
|
||
<odoo> | ||
|
||
<template id="assets_frontend_demo" inherit_id="website.assets_frontend"> | ||
<xpath expr="."> | ||
<script type="text/javascript" | ||
src="/website_sale_vat_required/static/src/js/website_sale.tour.js"/> | ||
</xpath> | ||
</template> | ||
|
||
</odoo> |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions
23
website_sale_vat_required/static/src/js/website_sale.tour.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* Copyright 2017 Jairo Llopis <jairo.llopis@tecnativa.com> | ||
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */ | ||
|
||
odoo.define('website_sale_vat_required.tour', function (require) { | ||
"use strict"; | ||
|
||
require("website_sale.tour"); | ||
var buy_tour = require('web.Tour').tours["shop_buy_product"]; | ||
|
||
buy_tour.steps.forEach(function (value, index) { | ||
// Search upstream tour step that would fail with this addon installed | ||
if (value.title === "test without input error") { | ||
// Patch step's `onload` method | ||
var oldonload = value.onload; | ||
value.onload = function () { | ||
// Fill VAT field with a good value | ||
$('.has-error > input[name="vat"]').val("BE0477472701") | ||
return oldonload.apply(this, arguments); | ||
}; | ||
return false; | ||
} | ||
}); | ||
}); |