I want to add a button in the tree view of sale order module, next to create and import buttons. That button will execute a python method.I have created a custom module, extending sale order module.But its not showing the button in saleorder.
My model is:-# -*- coding: utf-8 -*-
from odoo import models, fields, api
#Model of sale-order
class SaleOrder(models.Model):
_inherit = 'sale.order'
@api.multi
def update_sales_button(self):
pass
Button in my sale_filters/static/src/xml/qweb.xml is:
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-extend="ListView.buttons">
<t t-jquery="button.o_list_button_add" t-operation="after">
<t t-if="widget.model=='sale.order'">
<button class="btn btn-sm btn-primary update_sales_button" type="button">Run my stuff</button>
</t>
</t>
</t>
</templates>
My javascript is:-
odoo.define('sale_filters.sync.tree', function (require) {
"use strict";
console.log("fgfgfgfhghghghghfgdfgfgfgfgfgfgfgfgfg")
ListView = require('web.ListView')
ListView.include({
render_buttons: function() {
// GET BUTTON REFERENCE
this._super.apply(this, arguments)
if (this.$buttons) {
var btn = this.$buttons.find('.update_sales_button')
}
// PERFORM THE ACTION
btn.on('click', this.proxy('do_new_button'))
},
do_new_button: function() {
instance.web.Model('sale.order')
.call('update_sales_button', [[]])
}
})
});
My view is:-
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<template id="assets_backend" name="x_export_view assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/sale_filters/static/src/js/sale_dashboard.js">
</script>
</xpath>
</template>
</data>
</odoo>
Please help..
Thanks in Advance
Now I can see the button...
But my javascript is not working..