When receiving OODO POS, you need to add the address from res.partner city in the receipt
I don't know how to add the res.partner
object belowscreen.js
print_xml: function() {
var env = {
widget: this,
pos: this.pos,
order: this.pos.get_order(),
receipt: this.pos.get_order().export_for_printing(),
paymentlines: this.pos.get_order().get_paymentlines()
};
render_receipt: function() {
var order = this.pos.get_order();
this.$('.pos-receipt-container').html(QWeb.render('PosTicket',{
widget:this,
order: order,
partner:partner,
receipt: order.export_for_printing(),
orderlines: order.get_orderlines(),
paymentlines: order.get_paymentlines(),
}));
};
};
I tried to add a partner object in the above javascript but it doesn't work. I am new to odoo and I also lack JavaScript knowledge, so PLS help me solve this problem. If I can add an object res.partner
to this javascript file and then only I am available to access the objcet res.partner
in my file pos.xml
.
I will not provide the address information of the company and it is not in res_company, so how can I get the street and other address from res_partner for the company?
source to share
You can get it using the get_client () method.
You will get the complete current order partner object, then you can use it as a py file eg. partner.city
etc. in the receipt template.
render_receipt: function() {
var order = this.pos.get_order();
this.$('.pos-receipt-container').html(QWeb.render('PosTicket',{
widget:this,
order: order,
partner:this.pos.get_order().get_client(),
receipt: order.export_for_printing(),
orderlines: order.get_orderlines(),
paymentlines: order.get_paymentlines(),
}));
};
Update:
To add address fields to res.company models in js.
var module = require('point_of_sale.models');
var models = module.PosModel.prototype.models;
for(var i=0; i<models.length; i++){
var model=models[i];
if(model.model === 'res.company'){
model.fields.push('street');
model.fields.push('city');
model.fields.push('state_id');
model.fields.push('country_id');
// other field you want to pull from the res.company table.
}
}
Then you get it in company:this.pos.company
.
Now you can use it in your template for example. company.street, company.city
etc.
For country and state, use company.state_id [1] and company.country_id [1] in the template.
source to share