Browse Source

Initial commit

pull/949/head
tarteo 8 years ago
committed by Meet
parent
commit
cdd00a18a7
  1. 59
      web_x2many_delete_all/README.rst
  2. 3
      web_x2many_delete_all/__init__.py
  3. 26
      web_x2many_delete_all/__manifest__.py
  4. 7
      web_x2many_delete_all/static/src/css/web_x2many_delete_all.css
  5. 37
      web_x2many_delete_all/static/src/js/web_x2many_delete_all.js
  6. 13
      web_x2many_delete_all/static/src/less/web_x2many_delete_all.less
  7. 11
      web_x2many_delete_all/static/src/xml/web_x2many_delete_all.xml
  8. 14
      web_x2many_delete_all/templates/assets.xml

59
web_x2many_delete_all/README.rst

@ -0,0 +1,59 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
========================
X2many Delete All Button
========================
Adds a button to Many2many and One2many fields that removes all linked records.
Configuration
=============
No configuration is needed.
Usage
=====
To use this module, you need to:
#. Go to any Many2many or One2many field;
#. click 'Edit';
#. click the top most trash can button.
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/162/10.0
Bug Tracker
===========
Bugs are tracked on `GitHub Issues
<https://github.com/OCA/162/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smashing it by providing a detailed and welcomed feedback.
Credits
=======
Contributors
------------
* Dennis Sluijk <d.sluijk@onestein.nl>
* Meet Dholakia <meetcomputer009@gmail.com>
Maintainer
----------
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
To contribute to this module, please visit https://odoo-community.org.

3
web_x2many_delete_all/__init__.py

@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
# © 2016 Onestein (<http://www.onestein.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

26
web_x2many_delete_all/__manifest__.py

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
# © 2016 Onestein (<http://www.onestein.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
'name': 'X2many Delete All Button',
'summary': """
Adds a button to x2many fields that removes all linked records
""",
'version': '10.0.1.0.0',
'category': 'Web',
'author': 'Onestein, Meet Dholakia, Odoo Community Association (OCA)',
'website': 'http://www.onestein.eu',
'license': 'AGPL-3',
'depends': [
'web',
],
'data': [
'templates/assets.xml'
],
'qweb': [
'static/src/xml/web_x2many_delete_all.xml'
],
'installable': True,
'application': False,
}

7
web_x2many_delete_all/static/src/css/web_x2many_delete_all.css

@ -0,0 +1,7 @@
/* Copyright 2016 Onestein
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
table.o_list_view th.o_list_record_delete,
table.o_list_view th.o_list_record_delete span {
cursor: pointer;
}

37
web_x2many_delete_all/static/src/js/web_x2many_delete_all.js

@ -0,0 +1,37 @@
/* Copyright 2016 Onestein
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
odoo.define('web_x2many_delete_all.Mixin', function (require) {
"use strict";
var core = require('web.core');
var _t = core._t;
var ListRenderer = require('web.ListRenderer');
ListRenderer.include({
events: _.extend({}, ListRenderer.prototype.events, {
'click thead .o_list_record_delete_all': '_onTrashAllIconClick',
}),
_renderHeader: function (isGrouped) {
var $header = this._super.apply(this, arguments);
if (this.addTrashIcon) {
$header.find('tr').append(this._renderDeleteAll('th'));
}
return $header;
},
_renderDeleteAll: function (tag) {
var $icon = $('<button>', {class: 'fa fa-trash-o o_list_record_delete_all_btn', name: 'delete all',
'aria-label': _t('Delete All ')});
return $('<th>', {class: 'o_list_record_delete_all'}).append($icon);
},
_onTrashAllIconClick: function (event) {
event.stopPropagation();
var self = this;
var resIDs = _.map(self.$('tbody tr.o_data_row'), function(rowID) {
return $(rowID).data('id')
});
_.each(resIDs, function(row_id){
self.trigger_up('list_record_delete', {id: row_id});
})
},
})
});

13
web_x2many_delete_all/static/src/less/web_x2many_delete_all.less

@ -0,0 +1,13 @@
//Delete all button in x2many list view.
.o_list_view {
.o_list_record_delete_all {
width: 1px; // to prevent the column to expand
}
.o_list_record_delete_all_btn {
padding: 0px;
background-style: none;
border-style: none;
display: table-cell;
}
}

11
web_x2many_delete_all/static/src/xml/web_x2many_delete_all.xml

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2016 Onestein
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<templates>
<t t-extend="ListView">
<t t-jquery=".o_list_record_delete" t-operation="inner">
<span class="fa fa-trash-o hidden" title="Delete all"/>
</t>
</t>
</templates>

14
web_x2many_delete_all/templates/assets.xml

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2016 Onestein
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<template id="assets_backend" inherit_id="web.assets_backend">
<xpath expr=".">
<script type="text/javascript"
src="/web_x2many_delete_all/static/src/js/web_x2many_delete_all.js"/>
<link rel="stylesheet"
href="/web_x2many_delete_all/static/src/css/web_x2many_delete_all.css"/>
</xpath>
</template>
</odoo>
Loading…
Cancel
Save