[FIX] sale, _management: portal sale order optional products
Forward Port 0c46c8a929 from v10.0
has dome flows, namely, the new feature of grouping the taxes by tax group was not supported
Now it is supported: when modifying an optional product's quantity, every field is updated with the new values
OPW 1974708
closes odoo/odoo#32980
Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
This commit is contained in:
@@ -48,6 +48,7 @@ msgstr ""
|
||||
#. module: sale
|
||||
#: model_terms:ir.ui.view,arch_db:sale.report_saleorder_document
|
||||
#: model_terms:ir.ui.view,arch_db:sale.sale_order_portal_content
|
||||
#: model_terms:ir.ui.view,arch_db:sale.sale_order_portal_content_totals_table
|
||||
msgid "&nbsp;<span>on</span>&nbsp;"
|
||||
msgstr ""
|
||||
|
||||
@@ -220,6 +221,12 @@ msgstr ""
|
||||
msgid "<span class=\"o_stat_text\">Sold</span>"
|
||||
msgstr ""
|
||||
|
||||
#. module: sale
|
||||
#: model_terms:ir.ui.view,arch_db:sale.sale_order_portal_content
|
||||
msgid "<span groups=\"account.group_show_line_subtotals_tax_excluded\">Amount</span>\n"
|
||||
" <span groups=\"account.group_show_line_subtotals_tax_included\">Total Price</span>"
|
||||
msgstr ""
|
||||
|
||||
#. module: sale
|
||||
#: model_terms:ir.ui.view,arch_db:sale.sale_order_portal_template
|
||||
msgid "<span>Accepted on the behalf of:</span>"
|
||||
@@ -331,6 +338,7 @@ msgstr ""
|
||||
#. module: sale
|
||||
#: model_terms:ir.ui.view,arch_db:sale.report_saleorder_document
|
||||
#: model_terms:ir.ui.view,arch_db:sale.sale_order_portal_content
|
||||
#: model_terms:ir.ui.view,arch_db:sale.sale_order_portal_content_totals_table
|
||||
msgid "<strong>Subtotal</strong>"
|
||||
msgstr ""
|
||||
|
||||
@@ -362,6 +370,7 @@ msgstr ""
|
||||
#. module: sale
|
||||
#: model_terms:ir.ui.view,arch_db:sale.report_saleorder_document
|
||||
#: model_terms:ir.ui.view,arch_db:sale.sale_order_portal_content
|
||||
#: model_terms:ir.ui.view,arch_db:sale.sale_order_portal_content_totals_table
|
||||
msgid "<strong>Total</strong>"
|
||||
msgstr ""
|
||||
|
||||
@@ -3062,6 +3071,11 @@ msgstr ""
|
||||
msgid "Sell and purchase products in different units of measure"
|
||||
msgstr ""
|
||||
|
||||
#. module: sale
|
||||
#: model:ir.model.fields,field_description:sale.field_res_config_settings__module_website_sale_digital
|
||||
msgid "Sell digital products - provide downloadable content on your customer portal"
|
||||
msgstr ""
|
||||
|
||||
#. module: sale
|
||||
#: model_terms:ir.ui.view,arch_db:sale.res_config_settings_view_form
|
||||
msgid "Sell products by multiple of unit # per package"
|
||||
|
||||
@@ -127,7 +127,7 @@
|
||||
<t t-set="classes" t-value="'col-lg-auto d-print-none'"/>
|
||||
|
||||
<t t-set="title">
|
||||
<h2 class="mb-0"><b t-field="sale_order.amount_total"/> </h2>
|
||||
<h2 class="mb-0"><b t-field="sale_order.amount_total" data-id="total_amount"/> </h2>
|
||||
</t>
|
||||
<t t-set="entries">
|
||||
<ul class="list-group list-group-flush flex-wrap flex-row flex-lg-column">
|
||||
@@ -167,14 +167,15 @@
|
||||
<b t-field="sale_order.amount_undiscounted"
|
||||
t-options='{"widget": "monetary", "display_currency": sale_order.pricelist_id.currency_id}'
|
||||
style="text-decoration: line-through"
|
||||
class="d-block mt-1"/>
|
||||
class="d-block mt-1"
|
||||
data-id="amount_undiscounted" />
|
||||
</small>
|
||||
<t t-if="sale_order.amount_untaxed == sale_order.amount_total">
|
||||
<h4 t-field="sale_order.amount_total" class="text-success"/>
|
||||
<h4 t-field="sale_order.amount_total" class="text-success" data-id="total_amount"/>
|
||||
</t>
|
||||
<t t-else="">
|
||||
<h4 t-field="sale_order.amount_untaxed" class="text-success mb-0"/>
|
||||
<small>(<span t-field="sale_order.amount_total"/> Incl. tax)</small>
|
||||
<h4 t-field="sale_order.amount_untaxed" class="text-success mb-0" data-id="total_untaxed"/>
|
||||
<small>(<span t-field="sale_order.amount_total" data-id="total_amount"/> Incl. tax)</small>
|
||||
</t>
|
||||
</li>
|
||||
</t>
|
||||
@@ -519,6 +520,7 @@
|
||||
|
||||
<div id="total" class="row" name="total" style="page-break-inside: avoid;">
|
||||
<div t-attf-class="#{'col-4' if report_type != 'html' else 'col-sm-7 col-md-5'} ml-auto">
|
||||
<!-- Should be replaced in master by t-call="sale.sale_order_portal_content_totals_table" -->
|
||||
<table class="table table-sm">
|
||||
<tr class="border-black" style="border-bottom:1px solid #dddddd;">
|
||||
<td><strong>Subtotal</strong></td>
|
||||
@@ -582,4 +584,47 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template id="sale_order_portal_content_totals_table">
|
||||
<table class="table table-sm">
|
||||
<tr class="border-black">
|
||||
<td><strong>Subtotal</strong></td>
|
||||
<td class="text-right">
|
||||
<span
|
||||
data-id="total_untaxed"
|
||||
t-field="sale_order.amount_untaxed"
|
||||
t-options='{"widget": "monetary","display_currency": sale_order.pricelist_id.currency_id}'
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
<t t-foreach="sale_order.amount_by_group" t-as="amount_by_group">
|
||||
<tr>
|
||||
<t t-if="amount_by_group[3] == 1 and sale_order.amount_untaxed == amount_by_group[2]">
|
||||
<td>
|
||||
<span t-esc="amount_by_group[0]"/>
|
||||
<span>&nbsp;<span>on</span>&nbsp;<t t-esc="amount_by_group[2]" t-options='{"widget": "monetary", "display_currency": sale_order.pricelist_id.currency_id}'/></span>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<span t-esc="amount_by_group[1]"
|
||||
t-options='{"widget": "monetary", "display_currency": sale_order.pricelist_id.currency_id}'/>
|
||||
</td>
|
||||
</t>
|
||||
<t t-else ="">
|
||||
<td>
|
||||
<span t-esc="amount_by_group[0]"/>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<span t-esc="amount_by_group[1]"
|
||||
t-options='{"widget": "monetary", "display_currency": sale_order.pricelist_id.currency_id}'/>
|
||||
</td>
|
||||
</t>
|
||||
</tr>
|
||||
</t>
|
||||
<tr class="border-black">
|
||||
<td><strong>Total</strong></td>
|
||||
<td class="text-right">
|
||||
<span data-id="total_amount" t-field="sale_order.amount_total" t-options='{"widget": "monetary", "display_currency": sale_order.pricelist_id.currency_id}'/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</template>
|
||||
</odoo>
|
||||
|
||||
@@ -47,14 +47,21 @@ class CustomerPortal(CustomerPortal):
|
||||
currency = order_sudo.currency_id
|
||||
format_price = partial(formatLang, request.env, digits=currency.decimal_places)
|
||||
|
||||
return {
|
||||
results = {
|
||||
'order_line_product_uom_qty': str(quantity),
|
||||
'order_line_price_total': format_price(order_line.price_total),
|
||||
'order_line_price_subtotal': format_price(order_line.price_subtotal),
|
||||
'order_amount_total': format_price(order_sudo.amount_total),
|
||||
'order_amount_untaxed': format_price(order_sudo.amount_untaxed),
|
||||
'order_amount_tax': format_price(order_sudo.amount_tax),
|
||||
'order_amount_undiscounted': format_price(order_sudo.amount_undiscounted),
|
||||
}
|
||||
try:
|
||||
results['order_totals_table'] = request.env['ir.ui.view'].render_template('sale.sale_order_portal_content_totals_table', {'sale_order': order_sudo})
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
return results
|
||||
|
||||
@http.route(["/my/orders/<int:order_id>/add_option/<int:option_id>"], type='http', auth="public", website=True)
|
||||
def add(self, order_id, option_id, access_token=None, **post):
|
||||
|
||||
@@ -39,7 +39,7 @@ if (!$('.o_portal_sale_sidebar').length) {
|
||||
var order_id = href.match(/my\/orders\/([0-9]+)/);
|
||||
var line_id = href.match(/update_line\/([0-9]+)/);
|
||||
var params = {
|
||||
'line_id': line_id[1],
|
||||
'line_id': parseInt(line_id[1]),
|
||||
'remove': this.$el.is('[href*="remove"]'),
|
||||
'unlink': this.$el.is('[href*="unlink"]'),
|
||||
'input_quantity': quantity >= 0 ? quantity : false,
|
||||
@@ -49,6 +49,7 @@ if (!$('.o_portal_sale_sidebar').length) {
|
||||
params.access_token = token;
|
||||
}
|
||||
|
||||
order_id = parseInt(order_id[1])
|
||||
this._callUpdateLineRoute(order_id, params).then(this._updateOrderValues.bind(this));
|
||||
return false;
|
||||
},
|
||||
@@ -66,19 +67,20 @@ if (!$('.o_portal_sale_sidebar').length) {
|
||||
* when the quantity of a product has changed
|
||||
*
|
||||
* @private
|
||||
* @param {integer} order_id
|
||||
* @param {Object} params
|
||||
* @return {Deferred}
|
||||
*/
|
||||
_callUpdateLineRoute: function (order_id, params) {
|
||||
var def = new $.Deferred();
|
||||
var url = "/my/orders/" + parseInt(order_id[1]) + "/update_line_dict";
|
||||
var url = "/my/orders/" + order_id + "/update_line_dict";
|
||||
ajax.jsonRpc(url, 'call', params)
|
||||
.then(def.resolve.bind(def))
|
||||
.fail(function () {
|
||||
// Compatibility: the server may not have been restarted
|
||||
// So the real route may not exist
|
||||
delete params.input_quantity;
|
||||
ajax.jsonRpc("/quote/update_line", 'call', params)
|
||||
ajax.jsonRpc("/my/orders/" + order_id + "/update_line", 'call', params)
|
||||
.fail(def.reject.bind(def))
|
||||
.then(function (data) {
|
||||
// Data is an array, convert it to a dict
|
||||
@@ -108,6 +110,8 @@ if (!$('.o_portal_sale_sidebar').length) {
|
||||
var orderAmountTotal = data.order_amount_total;
|
||||
var orderAmountUntaxed = data.order_amount_untaxed;
|
||||
var orderAmountTax = data.order_amount_tax;
|
||||
var orderAmountUndiscounted = data.order_amount_undiscounted;
|
||||
var orderTotalsTable = $(data.order_totals_table);
|
||||
|
||||
var lineProductUomQty = data.order_line_product_uom_qty;
|
||||
var linePriceTotal = data.order_line_price_total;
|
||||
@@ -129,6 +133,13 @@ if (!$('.o_portal_sale_sidebar').length) {
|
||||
if (orderAmountTotal !== undefined) {
|
||||
this.elems.$orderAmountTotal.text(orderAmountTotal);
|
||||
}
|
||||
|
||||
if (orderAmountUndiscounted !== undefined) {
|
||||
this.elems.$orderAmountUndiscounted.text(orderAmountUndiscounted);
|
||||
}
|
||||
if (orderTotalsTable) {
|
||||
this.elems.$orderTotalsTable.find('table').replaceWith(orderTotalsTable);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Locate in the DOM the elements to update
|
||||
@@ -147,12 +158,13 @@ if (!$('.o_portal_sale_sidebar').length) {
|
||||
$linePriceTotal = $linePriceSubTotal = $parentTr.find('.oe_currency_value').last();
|
||||
}
|
||||
|
||||
var $orderAmountUntaxed = $('[data-id="total_untaxed"]>span');
|
||||
var $orderAmountTotal = $('[data-id="total_amount"]>span');
|
||||
var $orderAmountUntaxed = $('[data-id="total_untaxed"]').find('span, b');
|
||||
var $orderAmountTotal = $('[data-id="total_amount"]').find('span, b');
|
||||
var $orderAmountUndiscounted = $('[data-id="amount_undiscounted"]').find('span, b');
|
||||
|
||||
if (!$orderAmountUntaxed.length) {
|
||||
$orderAmountUntaxed = $orderAmountTotal.eq(1);
|
||||
$orderAmountTotal = $orderAmountTotal.eq(0).add($orderAmountTotal.eq(3));
|
||||
$orderAmountTotal = $orderAmountTotal.eq(0).add($orderAmountTotal.eq(2));
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -161,6 +173,8 @@ if (!$('.o_portal_sale_sidebar').length) {
|
||||
$linePriceTotal: $linePriceTotal,
|
||||
$orderAmountUntaxed: $orderAmountUntaxed,
|
||||
$orderAmountTotal: $orderAmountTotal,
|
||||
$orderTotalsTable: $('#total'),
|
||||
$orderAmountUndiscounted: $orderAmountUndiscounted,
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user