Skip to content

Instantly share code, notes, and snippets.

@findsomeoneyys
Last active April 9, 2020 13:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save findsomeoneyys/c387c2cb936ccb422e8a780806b8ab80 to your computer and use it in GitHub Desktop.
Save findsomeoneyys/c387c2cb936ccb422e8a780806b8ab80 to your computer and use it in GitHub Desktop.
在树视图中添加禁止print打印,引入js后在tree view 增加print="false"
<?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>
<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>
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