Skip to content

Commit

Permalink
Merge pull request #9 from apuestaya/12.0
Browse files Browse the repository at this point in the history
fields adjusts
  • Loading branch information
dkrimmer84 committed May 2, 2020
2 parents 9aa0aed + d4eb177 commit a82dae6
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 4 deletions.
12 changes: 11 additions & 1 deletion controllers/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,21 @@ class controller(http.Controller):
def get_partner_state_city(self, **kw):
_response = {}
partner_id = kw.get('partner_id')
query = "select xcity from res_partner where id = " + str(partner_id)
query = "select xcity, state_id from res_partner where id = " + str(partner_id)
request.cr.execute(query)
partner_city = request.cr.dictfetchone()
_response['xcity_id_'] = partner_city
return _response

@http.route('/l10n_co_res_partner/get_partner_state/', methods=['POST'], type='json', auth="public", website=True)
def get_partner_state(self, **kw):
_response = {}
partner_id = kw.get('partner_id')
query = "select state_id from res_partner where id = " + str(partner_id)
request.cr.execute(query)
state_id = request.cr.dictfetchone()
_response['state_id'] = state_id
return _response

@http.route('/l10n_co_res_partner/get_state_city/', methods=['POST'], type='json', auth="public", website=True)
def get_state_city(self, **kw):
Expand Down
44 changes: 41 additions & 3 deletions static/src/js/frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ odoo.define('module.DianInvoice', function(require) {
if($("form.checkout_autoformat").length>0)
{
$(".div_zip").remove()
$('#country_id option[value="Colombia"]');
var country_id = $('#country_id option:contains(Colombia)').val();
$("#country_id").val(country_id);

$('input[name="city"]').val("not_needed")
init_xcity_selection()

Expand Down Expand Up @@ -56,10 +58,24 @@ odoo.define('module.DianInvoice', function(require) {

function init_xcity_selection()
{

populate_states(country_id);
if($("select[name='xcity']").find('option').length == 0)
{
populate_xcity_field(true);


}
var companyBrandName = $("input[name='companyBrandName']").val()
if(String(companyBrandName).length>0)
{
$("select[name='doctype']").val(31);
}
else
{
$("select[name='doctype']").val(13);
}
$("input[name='company_name']").val(companyBrandName);
}

function update_nit_cod_verification()
Expand Down Expand Up @@ -129,7 +145,8 @@ odoo.define('module.DianInvoice', function(require) {

$("select[name='xcity']").html('');
$("select[name='xcity']").append(xcities_options);

var code = $("select[name='xcity'] option:selected").attr("code")
$("input[name='zip']").val(code)
if(set_partner_city)
{

Expand All @@ -149,7 +166,9 @@ odoo.define('module.DianInvoice', function(require) {
{
if (response.result.xcity_id_!=null)
{
$("select[name='xcity']").val(response.result.xcity_id_.xcity)
$("select[name='xcity']").val(response.result.xcity_id_.xcity)
var code = $("select[name='xcity'] option:selected").attr("code")
$("input[name='zip']").val(code)
}
}
});
Expand All @@ -165,6 +184,25 @@ odoo.define('module.DianInvoice', function(require) {

}

function populate_states(country_id)
{
var data = { "params": { "mode": "shipping" } }
var country_id = $('#country_id option:contains(Colombia)').val();
$.ajax({
type: "POST",
url: '/shop/country_infos/' + String(country_id),
data: JSON.stringify(data),
dataType: 'json',
contentType: "application/json",
async: false,
success: function(response)
{
console.log(response)
}
});

}

function dian_nit_codigo_verificacion(myNit)
{
var vpri,
Expand Down

0 comments on commit a82dae6

Please sign in to comment.