I want to add new fields to POS Receipt.I want to do it by inheriting the js file in my custom module.I don't know js so I don't know how to inherit it.In odoo's file point of sale > static > src > js > pos.js
model: 'res.company',
fields: [ 'currency_id', 'email', 'website', 'company_registry', 'vat', 'name', 'phone', 'partner_id' , 'country_id', 'tax_calculation_rounding_method'],
ids: function(self){ return [self.user.company_id[0]]; },
loaded: function(self,companies){ self.company = companies[0]; },
I edited fields and added my required field say street2
and it is coming in Pos Receipt
I tried inheriting the js file but it is not working.
This is my code
var _super = module.PosModel.prototype;
module.PosModel = module.PosModel.extend({
initialize: function (session, attributes) {
_super.initialize.apply(this, arguments);
this.models.push({
model: 'res.company',
fields: ['street2'],
})
return this;
},
});
I also create an xml file to show the path of js file.
xml
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<template id="assets" inherit_id="point_of_sale.assets">
<xpath expr="." position="inside">
<script type="text/javascript" src="/xn_pos_vat_enhancement_v11/static/src/js/pos_receipt_fields.js"></script>
</xpath>
</template>
</data>
</odoo>
Odoo Version : 11 (Community)
I have done this by:
odoo.define('xn_pos_vat_enhancement_v11.pos_receipt_fields', function (require) {
var models = require('point_of_sale.models');
var core = require('web.core');
var _t = core._t;
var session = require('web.session');
var rpc = require('web.rpc');
var _super_PosModel = models.PosModel.prototype;
models.PosModel = models.PosModel.extend({
get_model: function (_name) {
var _index = this.models.map(function (e) {
return e.model;
}).indexOf(_name);
if (_index > -1) {
return this.models[_index];
}
return false;
},
initialize: function (session, attributes) {
var self = this;
var company_model = this.get_model('res.company');
company_model.fields.push('street','street2','state_id');
_super_PosModel.initialize.apply(this, arguments);
},
get_config: function () {
return this.config;
},
});
});
Where xn_pos_vat_enhancement_v11
is my module name and pos_receipt_fields
is my file name.
I don't know to explain the whole code,if anyone can I will accept their answer.