Last active
March 13, 2022 09:32
-
-
Save tong-odoo/271b8f4d28b9a0f34814695155d19739 to your computer and use it in GitHub Desktop.
Create js button and call odoo actions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
odoo.define("manila_healthtek_stock_quant_report.InventoryReportListController", function (require) { | |
"use strict"; | |
var core = require("web.core"); | |
const InventoryReportListController = require("stock.InventoryReportListController"); | |
var qweb = core.qweb; | |
const InventoryBookReportListController = InventoryReportListController.include({ | |
renderButtons: function ($node) { | |
this._super.apply(this, arguments); | |
var $buttonPrint = $(qweb.render("InventoryReport.PrintButtons")); | |
$buttonPrint.css("margin-right", "3px"); | |
$buttonPrint.on("click", this._onPrintInventoryBook.bind(this)); | |
this.$buttons.prepend($buttonPrint); | |
}, | |
_onPrintInventoryBook: function () { | |
const self = this; | |
this._rpc({ | |
model: "stock.quant", | |
method: "print_pdf", | |
args: [[]], | |
}).then(function (res) { | |
const reportname = `${res.report_name}?docids=${res.data.join( | |
"," | |
)}&report_type=qweb-pdf&model_name=stock.quant`; | |
const action = { | |
type: "ir.actions.report", | |
report_type: "qweb-pdf", | |
report_name: reportname, | |
report_file: res.report_file, | |
}; | |
self.do_action(action); | |
}); | |
}, | |
}); | |
return InventoryBookReportListController; | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8" ?> | |
<templates id="template" xml:space="preserve"> | |
<button t-name="InventoryReport.PrintButtons" class="btn btn-primary" type="button">Print Inventory Book</button> | |
</templates> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment