[MERGE] forward port branch 9.0 up to 0a4db3c0d7
This commit is contained in:
@@ -278,13 +278,19 @@ var DebugWidget = PosBaseWidget.extend({
|
||||
});
|
||||
|
||||
this.$('.button.export_unpaid_orders').click(function(){
|
||||
self.gui.download_file(self.pos.export_unpaid_orders(),
|
||||
"unpaid_orders_" + (new Date()).toUTCString().replace(/\ /g,'_') + '.json');
|
||||
self.gui.prepare_download_link(
|
||||
self.pos.export_unpaid_orders(),
|
||||
_t("unpaid orders") + ' ' + moment().format('YYYY-MM-DD-HH-mm-ss') + '.json',
|
||||
".export_unpaid_orders", ".download_unpaid_orders"
|
||||
);
|
||||
});
|
||||
|
||||
this.$('.button.export_paid_orders').click(function() {
|
||||
self.gui.download_file(self.pos.export_paid_orders(),
|
||||
"paid_orders_" + (new Date()).toUTCString().replace(/\ /g,'_') + '.json');
|
||||
self.gui.prepare_download_link(
|
||||
self.pos.export_paid_orders(),
|
||||
_t("paid orders") + ' ' + moment().format('YYYY-MM-DD-HH-mm-ss') + '.json',
|
||||
".export_paid_orders", ".download_paid_orders"
|
||||
);
|
||||
});
|
||||
|
||||
this.$('.button.import_orders input').on('change', function(event) {
|
||||
|
||||
@@ -362,7 +362,34 @@ var Gui = core.Class.extend({
|
||||
// if 'contents' is not a string, it is converted into
|
||||
// a JSON representation of the contents.
|
||||
|
||||
|
||||
// TODO: remove me in master: deprecated in favor of prepare_download_link
|
||||
// this method is kept for backward compatibility but is likely not going
|
||||
// to work as many browsers do to not accept fake click events on links
|
||||
download_file: function(contents, name) {
|
||||
href_params = this.prepare_file_blob(contents,name);
|
||||
var evt = document.createEvent("HTMLEvents");
|
||||
evt.initEvent("click");
|
||||
|
||||
$("<a>",href_params).get(0).dispatchEvent(evt);
|
||||
|
||||
},
|
||||
|
||||
prepare_download_link: function(contents, filename, src, target) {
|
||||
var href_params = this.prepare_file_blob(contents, filename);
|
||||
|
||||
$(target).parent().attr(href_params);
|
||||
$(src).addClass('oe_hidden');
|
||||
$(target).removeClass('oe_hidden');
|
||||
|
||||
// hide again after click
|
||||
$(target).click(function() {
|
||||
$(src).removeClass('oe_hidden');
|
||||
$(this).addClass('oe_hidden');
|
||||
});
|
||||
},
|
||||
|
||||
prepare_file_blob: function(contents, name) {
|
||||
var URL = window.URL || window.webkitURL;
|
||||
|
||||
if (typeof contents !== 'string') {
|
||||
@@ -371,13 +398,8 @@ var Gui = core.Class.extend({
|
||||
|
||||
var blob = new Blob([contents]);
|
||||
|
||||
var evt = document.createEvent("HTMLEvents");
|
||||
evt.initEvent("click");
|
||||
|
||||
$("<a>",{
|
||||
download: name || 'document.txt',
|
||||
href: URL.createObjectURL(blob),
|
||||
}).get(0).dispatchEvent(evt);
|
||||
return {download: name || 'document.txt',
|
||||
href: URL.createObjectURL(blob),}
|
||||
},
|
||||
|
||||
/* ---- Gui: EMAILS ---- */
|
||||
|
||||
@@ -105,7 +105,9 @@ var ErrorTracebackPopupWidget = ErrorPopupWidget.extend({
|
||||
this._super(opts);
|
||||
|
||||
this.$('.download').off('click').click(function(){
|
||||
self.gui.download_file(self.options.body,'traceback.txt');
|
||||
self.gui.prepare_download_link(self.options.body,
|
||||
_t('error') + ' ' + moment().format('YYYY-MM-DD-HH-mm-ss') + '.txt',
|
||||
'.download', '.download_error_file');
|
||||
});
|
||||
|
||||
this.$('.email').off('click').click(function(){
|
||||
|
||||
@@ -992,6 +992,9 @@
|
||||
<div class="button cancel">
|
||||
Ok
|
||||
</div>
|
||||
<a><div class="button icon download_error_file oe_hidden">
|
||||
<i class="fa fa-arrow-down"></i>
|
||||
</div></a>
|
||||
<div class="button icon download">
|
||||
<i class="fa fa-download"></i>
|
||||
</div>
|
||||
@@ -1293,7 +1296,9 @@
|
||||
<li class="button delete_orders">Delete Paid Orders</li>
|
||||
<li class="button delete_unpaid_orders">Delete Unpaid Orders</li>
|
||||
<li class="button export_paid_orders">Export Paid Orders</li>
|
||||
<a><li class="button download_paid_orders oe_hidden">Download Paid Orders</li></a>
|
||||
<li class="button export_unpaid_orders">Export Unpaid Orders</li>
|
||||
<a><li class="button download_unpaid_orders oe_hidden">Download Unpaid Orders</li></a>
|
||||
<li class="button import_orders" style="position:relative">
|
||||
Import Orders
|
||||
<input type="file" style="opacity:0;position:absolute;top:0;left:0;right:0;bottom:0;margin:0;cursor:pointer"/>
|
||||
|
||||
@@ -435,6 +435,7 @@ class PurchaseOrder(models.Model):
|
||||
result = action.read()[0]
|
||||
|
||||
#override the context to get rid of the default filtering on picking type
|
||||
result.pop('id', None)
|
||||
result['context'] = {}
|
||||
pick_ids = sum([order.picking_ids.ids for order in self], [])
|
||||
#choose the view_mode accordingly
|
||||
|
||||
Reference in New Issue
Block a user