-
-
Notifications
You must be signed in to change notification settings - Fork 489
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
11.0 mig website_sale_vat_required #236
Merged
pedrobaeza
merged 5 commits into
OCA:11.0
from
ernestotejeda:11.0-mig-website_sale_vat_required
Jun 22, 2018
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c484d26
[ADD] website_sale_vat_required
eLBati 082c5ab
[FIX] Vat label selector
StefanRijnhart 673c03b
[FIX] Compatibility with website_sale Phantomjs tests
pedrobaeza c175623
[MIG][9.0][website_sale_vat_required] Migrate
yajo b844d8e
[MIG] website_sale_vat_required: Migration to 11.0
ernestotejeda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ | ||
**This file is going to be generated by oca-gen-addon-readme.** |
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,5 @@ | ||
# 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,27 @@ | ||
# 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': '11.0.1.0.0', | ||
'category': 'Website', | ||
'author': "Agile Business Group, " | ||
"Tecnativa, " | ||
"Odoo Community Association (OCA)", | ||
'website': 'https://github.com/OCA/e-commerce', | ||
'license': 'AGPL-3', | ||
'depends': [ | ||
'website_sale', | ||
'base_vat', | ||
], | ||
'data': [ | ||
'views/templates.xml', | ||
], | ||
'demo': [ | ||
'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,5 @@ | ||
# 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,12 @@ | ||
# 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 odoo.addons.website_sale.controllers.main import WebsiteSale | ||
|
||
|
||
class WebsiteSale(WebsiteSale): | ||
def _get_mandatory_billing_fields(self): | ||
result = super(WebsiteSale, self)._get_mandatory_billing_fields() | ||
result.append("vat") | ||
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,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- License AGPL-3.0 (http://www.gnu.org/licenses/agpl.html). --> | ||
|
||
<odoo> | ||
|
||
<template id="website_sale_vat_required_assets_frontend_demo" inherit_id="website_sale.assets_frontend"> | ||
<xpath expr="//script[last()]" position="after"> | ||
<script type="text/javascript" | ||
src="/website_sale_vat_required/static/src/js/website_sale_vat_required.tour.js"/> | ||
</xpath> | ||
</template> | ||
|
||
</odoo> |
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,5 @@ | ||
* Lorenzo Battistini <lorenzo.battistini@agilebg.com> | ||
* `Tecnativa <https://www.tecnativa.com>`_: | ||
|
||
* Jairo Llopis | ||
* Ernesto Tejeda |
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,2 @@ | ||
This module extends checkout e-commerce form in order to force user to fill | ||
'VAT number' field. |
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 @@ | ||
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. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions
40
website_sale_vat_required/static/src/js/website_sale_vat_required.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,40 @@ | ||
/* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
*/ | ||
|
||
odoo.define('website_sale_vat_required.tour', function(require) { | ||
|
||
"use strict"; | ||
|
||
require("website_sale.tour"); | ||
var base = require("web_editor.base"); | ||
var tour = require("web_tour.tour"); | ||
var steps = tour.tours.shop_buy_product.steps; | ||
|
||
steps.splice( | ||
_.findIndex(steps, { 'content': "Confirm checkout"}), | ||
0, | ||
{ | ||
content: 'Next', | ||
trigger: ".btn-primary:contains('Next')", | ||
}, | ||
{ | ||
content: 'Set VAT', | ||
trigger: "div.has-error input[name='vat']", | ||
extra_trigger: "div.has-error input[name='vat']", | ||
run: function (actions) { | ||
$('div.has-error input[name="vat"]').val("BE0477472701"); | ||
if ($('#div_phone').hasClass('has-error')){ | ||
$('#div_phone input').val('11111111'); | ||
} | ||
var input_accept_legal_terms = $('div.has-error input[name="accepted_legal_terms"]'); | ||
if (!_.isUndefined(input_accept_legal_terms && !input_accept_legal_terms== false)){ | ||
$('div.has-error input[name="accepted_legal_terms"]').prop( "checked", true ); | ||
} | ||
} | ||
}, | ||
{ | ||
content: 'Next', | ||
trigger: ".btn-primary:contains('Next')", | ||
} | ||
); | ||
}); |
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,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
|
||
<template id="address" inherit_id="website_sale.address" name="Address Management"> | ||
<xpath expr="//input[@name='vat']/.." position="replace"/> | ||
<xpath expr="//input[@name='company_name']/../.." position="after"> | ||
<t t-if="mode[1] == 'billing'"> | ||
<div t-attf-class="form-group #{error.get('vat') and 'has-error' or ''} col-md-6 div_vat"> | ||
<label class="control-label font-weight-normal" for="vat">TIN / VAT </label> | ||
<input type="text" name="vat" class="form-control" t-att-value="'vat' in checkout and checkout['vat']" /> | ||
</div> | ||
</t> | ||
</xpath> | ||
</template> | ||
|
||
</odoo> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. It seems included upstream already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This migration has been made from v9 directly . In v9 the only thing you need to do is set 'vat' as mandatory field using _get_mandatory_billing_fields method. In v10 and v11, if you only do that and you don't modify the template 'address', then, when an user is logged in, odoo will not permit to complete the form until this field is filled, but this field will be hide and the user will wonder what happened. This is, because now, odoo only show this field if there is no user logged in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's interesting. So, Odoo doesn't let a user modify his VAT number. IMHO that makes sense; if you need to change such field, you're probably better creating a new customer.
Then maybe you should only require
vat
when he's adding a new address. I think you can check that by making sure there's norequest.params["partner_id"]
.