[IMP] point_of_sale: download/print saleDetailsReport from closePosPopup
In this commit we make it possible for a user to download/print the Sales Report of the current session by clicking at the "download"/"printer" icon at the lower right corner of the closing pos popup. This is a commonly used feature. Thus, we make the UI more usable. In general, the sales report can be generated by two different ways: - either by providing a start and end time (products within that time span will be included). - or by providing a session_id (products that are sold during this specific pos_session will be included) which is used in some localisation modules (e.g. pos_l10n_se). To achieve this, we generalized the `_get_report_values` function to consider both possibilities. As a result, the inherited version of the function at the pos_l10n_se module was made reduntant, so we deleted it. NOTE: the "Printer" button will be displayed only when a printer is connected to the IoT box. task-2755384 Part-of: odoo/odoo#88006
This commit is contained in:
@@ -1245,6 +1245,8 @@ class ReportSaleDetails(models.AbstractModel):
|
||||
payments = []
|
||||
|
||||
return {
|
||||
'date_start': date_start,
|
||||
'date_stop': date_stop,
|
||||
'currency_precision': user_currency.decimal_places,
|
||||
'total_paid': user_currency.round(total),
|
||||
'payments': payments,
|
||||
@@ -1264,8 +1266,15 @@ class ReportSaleDetails(models.AbstractModel):
|
||||
@api.model
|
||||
def _get_report_values(self, docids, data=None):
|
||||
data = dict(data or {})
|
||||
# initialize data keys with their value if provided, else None
|
||||
data.update({
|
||||
'session_ids': data.get('session_ids') or docids,
|
||||
'config_ids': data.get('config_ids'),
|
||||
'date_start': data.get('date_start'),
|
||||
'date_stop': data.get('date_stop')
|
||||
})
|
||||
configs = self.env['pos.config'].browse(data['config_ids'])
|
||||
data.update(self.get_sale_details(data['date_start'], data['date_stop'], configs.ids))
|
||||
data.update(self.get_sale_details(data['date_start'], data['date_stop'], configs.ids, data['session_ids']))
|
||||
return data
|
||||
|
||||
class AccountCashRounding(models.Model):
|
||||
|
||||
@@ -138,6 +138,7 @@
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: unset;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.pos .close-pos-popup .footer .button {
|
||||
|
||||
@@ -73,6 +73,13 @@ odoo.define('point_of_sale.ClosePosPopup', function(require) {
|
||||
closeDetailsPopup() {
|
||||
this.state.displayMoneyDetailsPopup = false;
|
||||
}
|
||||
async downloadSalesReport() {
|
||||
await this.env.legacyActionManager.do_action('point_of_sale.sale_details_report', {
|
||||
additional_context: {
|
||||
active_ids: [this.env.pos.pos_session.id],
|
||||
},
|
||||
});
|
||||
}
|
||||
handleInputChange(paymentId) {
|
||||
let expectedAmount;
|
||||
if (paymentId === this.defaultCashDetails.id) {
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<div class="search-bar-portal search-bar-container sb-product" />
|
||||
<div class="status-buttons" t-if="state.uiState === 'READY'" t-att-class="{ oe_hidden: state.mobileSearchBarIsShown }">
|
||||
<CashierName />
|
||||
<SaleDetailsButton t-if="env.proxy.printer" />
|
||||
<SaleDetailsButton t-if="env.proxy.printer" isHeaderButton="true"/>
|
||||
<ProxyStatus t-if="env.pos.config.use_proxy" />
|
||||
<CustomerFacingDisplayButton t-if="customerFacingDisplayButtonIsShown" />
|
||||
<SyncNotification />
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
<templates id="template" xml:space="preserve">
|
||||
|
||||
<t t-name="SaleDetailsButton" owl="1">
|
||||
<div class="oe_status">
|
||||
<div class="js_connected oe_icon">
|
||||
<i class="fa fa-fw fa-print" role="img" aria-label="Print" t-on-click="onClick"
|
||||
title="Print a report with all the sales of the current PoS Session"></i>
|
||||
<div t-att-class="{'oe_status': props.isHeaderButton }" t-on-click="onClick">
|
||||
<div class="js_connected oe_icon"
|
||||
title="Print a report with all the sales of the current PoS Session">
|
||||
<i class="fa fa-fw fa-print" role="img" aria-label="Print"></i>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
@@ -80,8 +80,16 @@
|
||||
<div class="button highlight" t-on-click="onCloseSession">Close Session</div>
|
||||
<div class="button" t-on-click="closePos" title="Visit the Backend but keep session open">Backend</div>
|
||||
<div class="button" t-att-class="{'disabled': !canCancel()}" t-on-click="cancelPopup">Discard</div>
|
||||
<div class="small button icon"><i class="fa fa-print" role="img" title="Print the report"/></div>
|
||||
<div class="small button icon"><i class="fa fa-file-pdf-o" role="img" title="Download the report as PDF"/></div>
|
||||
<!-- Download Sale Details -->
|
||||
<div class="small button icon"
|
||||
t-on-click="downloadSalesReport"
|
||||
title="Download a report with all the sales of the current PoS Session">
|
||||
<i class="fa fa-download" role="img"/>
|
||||
</div>
|
||||
<!-- Print Sale Details -->
|
||||
<div t-if="env.proxy.printer" class="small button icon">
|
||||
<SaleDetailsButton/>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
<MoneyDetailsPopup
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
<record id="sale_details_report" model="ir.actions.report">
|
||||
<field name="name">Sales Details</field>
|
||||
<field name="model">report.point_of_sale.report_saledetails</field>
|
||||
<field name="model">pos.session</field>
|
||||
<field name="report_type">qweb-pdf</field>
|
||||
<field name="report_name">point_of_sale.report_saledetails</field>
|
||||
</record>
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
<div class="text-center">
|
||||
<h2>Sales Details</h2>
|
||||
|
||||
<strong><t t-esc="date_start" t-options="{'widget': 'datetime'}"/> - <t t-esc="date_stop" t-options="{'widget': 'datetime'}"/></strong>
|
||||
<t t-if="date_start and date_stop">
|
||||
<strong><t t-esc="date_start" t-options="{'widget': 'datetime'}"/> - <t t-esc="date_stop" t-options="{'widget': 'datetime'}"/></strong>
|
||||
</t>
|
||||
</div>
|
||||
|
||||
<!-- Orderlines -->
|
||||
|
||||
Reference in New Issue
Block a user