|
|
@ -17,9 +17,11 @@ odoo.define('pos_invoice_automate.PaymentScreen', function(require) { |
|
|
|
} |
|
|
|
} |
|
|
|
async validateOrder(isForceValidate) { |
|
|
|
try { |
|
|
|
this.env.services.ui.block(); |
|
|
|
const value = await this.env.pos.push_single_order(this.currentOrder); |
|
|
|
const config_id = this.env.pos.config.id |
|
|
|
const order_id = value[0].id |
|
|
|
const config_id = this.env.pos.config.id; |
|
|
|
const order_id = value[0].id; |
|
|
|
if (this.env.pos.config.is_started) { |
|
|
|
await this.rpc({ |
|
|
|
model: 'pos.config', |
|
|
@ -28,14 +30,13 @@ odoo.define('pos_invoice_automate.PaymentScreen', function(require) { |
|
|
|
}); |
|
|
|
} else { |
|
|
|
if (this.env.pos.config.button_operation == 'download') { |
|
|
|
var self = this; |
|
|
|
await this.rpc({ |
|
|
|
model: 'pos.order', |
|
|
|
method: 'download_invoice', |
|
|
|
args: [order_id], |
|
|
|
}).then(function(result) { |
|
|
|
self.env.legacyActionManager.do_action(result) |
|
|
|
}) |
|
|
|
}).then((result) => { |
|
|
|
this.env.legacyActionManager.do_action(result); |
|
|
|
}); |
|
|
|
} else if (this.env.pos.config.button_operation == 'send') { |
|
|
|
await this.rpc({ |
|
|
|
model: 'pos.order', |
|
|
@ -43,17 +44,25 @@ odoo.define('pos_invoice_automate.PaymentScreen', function(require) { |
|
|
|
args: [order_id], |
|
|
|
}); |
|
|
|
} else if (this.env.pos.config.button_operation == 'download_send_mail') { |
|
|
|
var self = this; |
|
|
|
await this.rpc({ |
|
|
|
model: 'pos.order', |
|
|
|
method: 'send_mail_invoice', |
|
|
|
args: [order_id], |
|
|
|
}).then(function(result) { |
|
|
|
self.env.legacyActionManager.do_action(result) |
|
|
|
}) |
|
|
|
}).then((result) => { |
|
|
|
this.env.legacyActionManager.do_action(result); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
await super.validateOrder(isForceValidate); |
|
|
|
} catch (error) { |
|
|
|
console.error("Error during validation:", error); |
|
|
|
this.showPopup('ErrorPopup', { |
|
|
|
title: this.env._t('Validation Error'), |
|
|
|
body: this.env._t('An error occurred while validating the order.'), |
|
|
|
}); |
|
|
|
} finally { |
|
|
|
this.env.services.ui.unblock(); |
|
|
|
} |
|
|
|
} |
|
|
|
async _finalizeValidation() { |
|
|
|
if ((this.currentOrder.is_paid_with_cash() || this.currentOrder.get_change()) && this.env.pos.config.iface_cashdrawer && this.env.proxy && this.env.proxy.printer) { |
|
|
@ -71,9 +80,9 @@ odoo.define('pos_invoice_automate.PaymentScreen', function(require) { |
|
|
|
// 1. Save order to server.
|
|
|
|
syncOrderResult = await this.env.pos.push_single_order(this.currentOrder); |
|
|
|
// 2. Invoice.
|
|
|
|
if (this.currentOrder.is_to_invoice()) { |
|
|
|
if (this.shouldDownloadInvoice() && this.currentOrder.is_to_invoice()) { |
|
|
|
if (syncOrderResult.length) { |
|
|
|
await this.env.legacyActionManager.do_action('account.account_invoices', { |
|
|
|
await this.env.legacyActionManager.do_action(this.env.pos.invoiceReportAction, { |
|
|
|
additional_context: { |
|
|
|
active_ids: [syncOrderResult[0].account_move], |
|
|
|
}, |
|
|
@ -102,6 +111,7 @@ odoo.define('pos_invoice_automate.PaymentScreen', function(require) { |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
this.env.services.ui.unblock(); |
|
|
|
if (error.code == 700 || error.code == 701) |
|
|
|
this.error = true; |
|
|
|
|
|
|
@ -127,6 +137,7 @@ odoo.define('pos_invoice_automate.PaymentScreen', function(require) { |
|
|
|
} finally { |
|
|
|
// Always show the next screen regardless of error since pos has to
|
|
|
|
// continue working even offline.
|
|
|
|
this.env.services.ui.unblock() |
|
|
|
this.showScreen(this.nextScreen); |
|
|
|
// Remove the order from the local storage so that when we refresh the page, the order
|
|
|
|
// won't be there
|
|
|
|