Last active
April 9, 2020 13:16
-
-
Save findsomeoneyys/c387c2cb936ccb422e8a780806b8ab80 to your computer and use it in GitHub Desktop.
在树视图中添加禁止print打印,引入js后在tree view 增加print="false"
This file contains 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"?> | |
<odoo> | |
<data> | |
<template id="assets_backend_base" name="base assets" inherit_id="web.assets_backend"> | |
<xpath expr="." position="inside"> | |
<script type="text/javascript" src="/module/path/to/static/src/js/web_disable_print.js"/> | |
</xpath> | |
</template> | |
</data> | |
</odoo> |
This file contains 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
<record id="view_order_line_tree" model="ir.ui.view"> | |
<field name="name">sale.order.line.tree</field> | |
<field name="model">sale.order.line</field> | |
<field name="arch" type="xml"> | |
<tree string="Sales Order Lines" create="false" print="false"> //just add print="false" in tree view like this | |
<field name="order_id"/> | |
<field name="order_partner_id"/> | |
</tree> | |
</field> | |
</record> |
This file contains 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("web_disable_print", function(require) { | |
"use strict"; | |
var ListView = require('web.ListView'); | |
ListView.include({ | |
init: function (viewInfo, params) { | |
this._super.apply(this, arguments); | |
var print = this.arch.attrs.print ? JSON.parse(this.arch.attrs.print) : true; | |
if (print === false) { | |
delete this.controllerParams.toolbarActions['print']; | |
} | |
}, | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment