콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
2207 화면

I need to modify this patch to modify button function of the dialog... any help???:

patch(SaleOrderLineProductField.prototype, 'sale_product_matrix', {


/**
* Triggers Matrix Dialog opening
*
* @param {String} jsonInfo matrix dialog content
* @param {integer} productTemplateId product.template id
* @param {editedCellAttributes} list of product.template.attribute.value ids
* used to focus on the matrix cell representing the edited line.
*
* @private
*/
_openMatrixConfigurator: function (jsonInfo, productTemplateId, editedCellAttributes) {
const infos = JSON.parse(jsonInfo);
const saleOrderRecord = this.props.record.model.root;
const MatrixDialog = new Dialog(this, {
title: this.env._t('Choose Product Variants'),
size: 'extra-large', // adapt size depending on matrix size?
$content: $(qweb.render(
'product_matrix.matrix', {
header: infos.header,
rows: infos.matrix,
format({price, currency_id}) {
if (!price) { return ""; }
const sign = price < 0 ? '-' : '+';
const formatted = formatMonetary(
Math.abs(price),
{
currencyId: currency_id,
},
);
return markup(`${sign} ${formatted}`);
}
}
)),
buttons: [
{text: this.env._t('Confirm'), classes: 'btn-primary', close: true, click: function (result) {
const $inputs = this.$('.o_matrix_input');
var matrixChanges = [];
_.each($inputs, function (matrixInput) {
if (matrixInput.value && matrixInput.value !== matrixInput.attributes.value.nodeValue) {
matrixChanges.push({
qty: parseFloat(matrixInput.value),
ptav_ids: matrixInput.attributes.ptav_ids.nodeValue.split(",").map(function (id) {
return parseInt(id);
}),
});
}
});
if (matrixChanges.length > 0) {
// NB: server also removes current line opening the matrix
saleOrderRecord.update({
grid: JSON.stringify({changes: matrixChanges, product_template_id: productTemplateId}),
grid_update: true // to say that the changes to grid have to be applied to the SO.
});
}
}},
{text: this.env._t('Close'), close: true},
],
}).open();

MatrixDialog.opened(function () {
MatrixDialog.$content.closest('.o_dialog_container').removeClass('d-none');
if (editedCellAttributes.length > 0) {
const str = editedCellAttributes.toString();
MatrixDialog.$content.find('.o_matrix_input').filter((k, v) => v.attributes.ptav_ids.nodeValue === str)[0].focus();
} else {
MatrixDialog.$content.find('.o_matrix_input:first()').focus();
}
});
},
});


아바타
취소
베스트 답변

you can make the following changes:

patch(SaleOrderLineProductField.prototype, 'sale_product_matrix', {
// ...

/**
* Triggers Matrix Dialog opening
*
* @param {String} jsonInfo matrix dialog content
* @param {integer} productTemplateId product.template id
* @param {editedCellAttributes} list of product.template.attribute.value ids
* used to focus on the matrix cell representing the edited line.
*
* @private
*/
_openMatrixConfigurator: function (jsonInfo, productTemplateId, editedCellAttributes) {
const infos = JSON.parse(jsonInfo);
const saleOrderRecord = this.props.record.model.root;
const MatrixDialog = new Dialog(this, {
title: this.env._t('Choose Product Variants'),
size: 'extra-large', // adapt size depending on matrix size?
$content: $(qweb.render(
'product_matrix.matrix', {
header: infos.header,
rows: infos.matrix,
format({price, currency_id}) {
if (!price) { return ""; }
const sign = price < 0 ? '-' : '+';
const formatted = formatMonetary(
Math.abs(price),
{
currencyId: currency_id,
},
);
return markup(`${sign} ${formatted}`);
}
}
)),
buttons: [
{
text: this.env._t('Custom Button'), // Modify the button text
classes: 'btn-primary',
close: true,
click: function (result) {
// Modify the button functionality here
console.log('Custom button clicked!');
}
},
{text: this.env._t('Close'), close: true},
],
}).open();

// ...
},
});

In the above code, the changes have been made to the button section of the MatrixDialog object. You can modify the button text by changing the text property to your desired label. Additionally, you can customize the button's functionality by modifying the click function inside the button object.

아바타
취소
베스트 답변

Hey , 

 You can add the same  code with different patch name and only add your required code , so indirectly you will be writing code to extend SaleOrderLineProductField only .


hope this helps :)

아바타
취소
관련 게시물 답글 화면 활동
3
8월 25
330
2
8월 25
338
0
8월 25
153
1
8월 25
509
1
7월 25
830