[IMP] point_of_sale: allow to chose the state on customer screen

When you are creating some customers inside the point of sale, it is
impossible to set a state on the customer address and to see the one set
if it has been created in backend.

So we've added a selction field for the state, set it's default value to
the one set on the company.

Task-1978312
Closes #33484

Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
This commit is contained in:
mgh-odoo
2019-06-04 08:55:17 +00:00
committed by Pierre Masereel
parent 02abe4ca20
commit 5cf88125f8
4 changed files with 43 additions and 5 deletions
+5 -4
View File
@@ -277,10 +277,11 @@ var PosDB = core.Class.extend({
if(partner.barcode){
this.partner_by_barcode[partner.barcode] = partner;
}
partner.address = (partner.street || '') +', '+
(partner.zip || '') +' '+
(partner.city || '') +', '+
(partner.country_id[1] || '');
partner.address = (partner.street ? partner.street + ', ': '') +
(partner.zip ? partner.zip + ', ': '') +
(partner.city ? partner.city + ', ': '') +
(partner.state_id ? partner.state_id[1] + ', ': '') +
(partner.country_id ? partner.country_id[1]: '');
this.partner_search_string += this._partner_search_string(partner);
}
}
+7 -1
View File
@@ -181,7 +181,7 @@ exports.PosModel = Backbone.Model.extend({
},
},{
model: 'res.company',
fields: [ 'currency_id', 'email', 'website', 'company_registry', 'vat', 'name', 'phone', 'partner_id' , 'country_id', 'tax_calculation_rounding_method'],
fields: [ 'currency_id', 'email', 'website', 'company_registry', 'vat', 'name', 'phone', 'partner_id' , 'country_id', 'state_id', 'tax_calculation_rounding_method'],
ids: function(self){ return [self.user.company_id[0]]; },
loaded: function(self,companies){ self.company = companies[0]; },
},{
@@ -215,6 +215,12 @@ exports.PosModel = Backbone.Model.extend({
self.partners = partners;
self.db.add_partners(partners);
},
},{
model: 'res.country.state',
fields: ['name', 'country_id'],
loaded: function(self,states){
self.states = states;
},
},{
model: 'res.country',
fields: ['name', 'vat_label'],
@@ -1150,6 +1150,7 @@ var ClientListScreenWidget = ScreenWidget.extend({
this.$('.new-customer').click(function(){
self.display_client_details('edit',{
'country_id': self.pos.company.country_id,
'state_id': self.pos.company.state_id,
});
});
@@ -1535,6 +1536,24 @@ var ClientListScreenWidget = ScreenWidget.extend({
}, 0);
});
contents.find('.client-address-country').on('change', function (ev) {
var $stateSelection = contents.find('.client-address-states');
var value = this.value;
$stateSelection.empty()
$stateSelection.append($("<option/>", {
value: '',
text: 'None',
}));
self.pos.states.forEach(function (state) {
if (state.country_id[0] == value) {
$stateSelection.append($("<option/>", {
value: state.id,
text: state.name
}));
}
});
});
contents.find('.image-uploader').on('change',function(event){
self.load_image_file(event.target.files[0],function(res){
if (res) {
@@ -362,6 +362,18 @@
<span class='label'>Postcode</span>
<input class='detail client-address-zip' name='zip' t-att-value='partner.zip || ""' placeholder='ZIP'></input>
</div>
<div class='client-detail'>
<span class='label'>State</span>
<select class='detail client-address-states needsclick' name='state_id'>
<option value=''>None</option>
<t t-foreach='widget.pos.states' t-as='state'>
<option t-if="partner.country_id[0] == state.country_id[0]" t-att-value='state.id'
t-att-selected="partner.state_id ? ((state.id === partner.state_id[0]) ? true : undefined) : undefined">
<t t-esc='state.name'/>
</option>
</t>
</select>
</div>
<div class='client-detail'>
<span class='label'>Country</span>
<select class='detail client-address-country needsclick' name='country_id'>