Initial commit: Sale packages
|
After Width: | Height: | Size: 6 KiB |
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="70" height="70" viewBox="0 0 70 70"><defs><path id="a" d="M4 0h61c4 0 5 1 5 5v60c0 4-1 5-5 5H4c-3 0-4-1-4-5V5c0-4 1-5 4-5z"/><linearGradient id="c" x1="100%" x2="0%" y1="0%" y2="100%"><stop offset="0%" stop-color="#DA956B"/><stop offset="100%" stop-color="#CC7039"/></linearGradient><path id="d" d="M56.243 52.279c.578 0 1.05.537 1.05 1.193v.978c0 .656-.472 1.194-1.05 1.194H13.532c-.578 0-1.05-.538-1.05-1.194v-35.8c0-.657.472-1.194 1.05-1.194h1.5c.578 0 1.05.537 1.05 1.194v33.629h40.161zM39 23.025l4.981 4.963-6.302 7.25-4.866-5.53c-.411-.467-1.068-.467-1.48 0L20.92 41.423a1.31 1.31 0 0 0-.018 1.68l2.494 2.924c.412.477 1.086.487 1.497.01l7.186-8.165 4.857 5.52a.965.965 0 0 0 1.488 0l9.558-10.86L53 37.664 55 20l-16 3.025z"/><path id="e" d="M56.243 50.279c.578 0 1.05.537 1.05 1.193v.978c0 .656-.472 1.194-1.05 1.194H13.532c-.578 0-1.05-.538-1.05-1.194v-35.8c0-.657.472-1.194 1.05-1.194h1.5c.578 0 1.05.537 1.05 1.194v33.629h40.161zM39 21.025l4.981 4.963-6.302 7.25-4.866-5.53c-.411-.467-1.068-.467-1.48 0L20.92 39.423a1.31 1.31 0 0 0-.018 1.68l2.494 2.924c.412.477 1.086.487 1.497.01l7.186-8.165 4.857 5.52a.965.965 0 0 0 1.488 0l9.558-10.86L53 35.664 55 18l-16 3.025z"/></defs><g fill="none" fill-rule="evenodd"><mask id="b" fill="#fff"><use xlink:href="#a"/></mask><g mask="url(#b)"><path fill="url(#c)" d="M0 0H70V70H0z"/><path fill="#FFF" fill-opacity=".383" d="M4 1h61c2.667 0 4.333.667 5 2V0H0v3c.667-1.333 2-2 4-2z"/><path fill="#393939" d="M45.243 69H4c-2 0-4-.146-4-4.077V35.315L13 16h3v26.5l15-14.27.974.024L40 21.096l13 14.27-18 18.346h22L45.243 69z" opacity=".324"/><path fill="#000" fill-opacity=".383" d="M4 69h61c2.667 0 4.333-1 5-3v4H0v-4c.667 2 2 3 4 3z"/><use fill="#000" fill-rule="nonzero" opacity=".3" xlink:href="#d"/><use fill="#FFF" fill-rule="nonzero" xlink:href="#e"/></g></g></svg>
|
||||
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 54 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 50 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
|
@ -0,0 +1,111 @@
|
|||
odoo.define('sale_management.sale_management', function (require) {
|
||||
'use strict';
|
||||
|
||||
var publicWidget = require('web.public.widget');
|
||||
|
||||
publicWidget.registry.SaleUpdateLineButton = publicWidget.Widget.extend({
|
||||
selector: '.o_portal_sale_sidebar',
|
||||
events: {
|
||||
'click a.js_update_line_json': '_onClickOptionQuantityButton',
|
||||
'click a.js_add_optional_products': '_onClickAddOptionalProduct',
|
||||
'change .js_quantity': '_onChangeOptionQuantity',
|
||||
},
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
async start() {
|
||||
await this._super(...arguments);
|
||||
this.orderDetail = this.$el.find('table#sales_order_table').data();
|
||||
},
|
||||
|
||||
/**
|
||||
* Calls the route to get updated values of the line and order
|
||||
* when the quantity of a product has changed
|
||||
*
|
||||
* @private
|
||||
* @param {integer} order_id
|
||||
* @param {Object} params
|
||||
* @return {Deferred}
|
||||
*/
|
||||
_callUpdateLineRoute(order_id, params) {
|
||||
return this._rpc({
|
||||
route: "/my/orders/" + order_id + "/update_line_dict",
|
||||
params: params,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Refresh the UI of the order details
|
||||
*
|
||||
* @private
|
||||
* @param {Object} data: contains order html details
|
||||
*/
|
||||
_refreshOrderUI(data){
|
||||
window.location.reload();
|
||||
},
|
||||
|
||||
/**
|
||||
* Process the change in line quantity
|
||||
*
|
||||
* @private
|
||||
* @param {Event} ev
|
||||
*/
|
||||
async _onChangeOptionQuantity(ev) {
|
||||
ev.preventDefault();
|
||||
let self = this,
|
||||
$target = $(ev.currentTarget),
|
||||
quantity = parseInt($target.val());
|
||||
|
||||
const result = await this._callUpdateLineRoute(self.orderDetail.orderId, {
|
||||
'line_id': $target.data('lineId'),
|
||||
'input_quantity': quantity >= 0 ? quantity : false,
|
||||
'access_token': self.orderDetail.token
|
||||
});
|
||||
this._refreshOrderUI(result);
|
||||
},
|
||||
|
||||
/**
|
||||
* Reacts to the click on the -/+ buttons
|
||||
*
|
||||
* @private
|
||||
* @param {Event} ev
|
||||
*/
|
||||
async _onClickOptionQuantityButton(ev) {
|
||||
ev.preventDefault();
|
||||
let self = this,
|
||||
$target = $(ev.currentTarget);
|
||||
|
||||
const result = await this._callUpdateLineRoute(self.orderDetail.orderId, {
|
||||
'line_id': $target.data('lineId'),
|
||||
'remove': $target.data('remove'),
|
||||
'unlink': $target.data('unlink'),
|
||||
'access_token': self.orderDetail.token
|
||||
});
|
||||
this._refreshOrderUI(result);
|
||||
},
|
||||
|
||||
/**
|
||||
* Triggered when optional product added to order from portal.
|
||||
*
|
||||
* @private
|
||||
* @param {Event} ev
|
||||
*/
|
||||
_onClickAddOptionalProduct(ev) {
|
||||
ev.preventDefault();
|
||||
let self = this,
|
||||
$target = $(ev.currentTarget);
|
||||
|
||||
// to avoid double click on link with href.
|
||||
$target.css('pointer-events', 'none');
|
||||
|
||||
this._rpc({
|
||||
route: "/my/orders/" + self.orderDetail.orderId + "/add_option/" + $target.data('optionId'),
|
||||
params: {access_token: self.orderDetail.token}
|
||||
}).then((data) => {
|
||||
this._refreshOrderUI(data);
|
||||
});
|
||||
},
|
||||
|
||||
});
|
||||
});
|
||||