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

Hi can anyone tell me how i can inherit the js document signable is there in
enterprise/sign/static/src/js/common/document_signable
becasuse I want to modify the function 
registerCreatedSignItemEvents
with this
registerCreatedSignItemEvents = function ($signatureItem, type, isSignItemEditable) { if (type.name === _t("Date")) { $signatureItem.on("focus", (e) => this.fillTextSignItem( $(e.currentTarget), moment().format(time.getLangDateFormat()) ) ); } if (type.item_type === "signature" || type.item_type === "initial") { $signatureItem.on( "click", (e) => { // when signing for the first time in edit mode, clicking in .o_sign_item_display should cause the sign. // (because both edit and sign are possible) However if you want to change the signature after another // one is set, .o_sign_item_display is not there anymore. if ( this.isDialogOpen || isSignItemEditable && $(e.currentTarget).find('.o_sign_item_display').length && !$(e.target).hasClass('o_sign_item_display') ) { return; } this.handleSignatureDialogClick($(e.currentTarget), type) } ); } if (type.item_type === "sequential") { $signatureItem.on("focus", (e) => { $signatureItem.val('dsadasd') // getSequentialNumberForElementType(type.name) // .then(data => { // const numberFormatted = String(data.sequentialNumber).padStart(data.padding, '0'); // var sequentialNumberComplete // if (typeof data.prefix === 'string' && typeof data.suffix === 'string') { // sequentialNumberComplete = `${data.prefix}${numberFormatted}${data.suffix}`; // } // if (typeof data.prefix === 'string') { // sequentialNumberComplete = `${data.prefix}${numberFormatted}`; // } else if(typeof data.suffix === 'string') { // sequentialNumberComplete = `${numberFormatted}${data.suffix}`; // } // $signatureItem.val(sequentialNumberComplete); // }); }); }
if (type.auto_value && ['text', 'textarea'].includes(type.item_type)) { $signatureItem.on("focus", (e) => this.fillTextSignItem($signatureItem, type.auto_value) ); } if ( config.device.isMobile && ["text", "textarea"].includes(type.item_type) ) { const inputBottomSheet = new InputBottomSheet(this, { type: type.item_type, value: $signatureItem.val(), label: `${type.tip}: ${type.placeholder}`, placeholder: $signatureItem.attr("placeholder"), onTextChange: (value) => { $signatureItem.val(value); }, onValidate: (value) => { $signatureItem.val(value); $signatureItem.trigger("input"); inputBottomSheet.hide(); this.signatureItemNav.goToNextSignItem(); }, }); inputBottomSheet.appendTo(document.body); $signatureItem.on("focus", () => { inputBottomSheet.updateInputText($signatureItem.val()); inputBottomSheet.show(); }); } $signatureItem.on("input", (e) => { this.checkSignItemsCompletion(this.role); this.signatureItemNav.setTip(_t("next")); }); };

but i dont undestand how to inherit and access to that function

아바타
취소
베스트 답변

Hi,
You can refer to the below steps.To inherit and override this function in Odoo 16 OWL, you can use the following steps:
Create a new module, for example, my_module.
In your new module, create a file static/src/js/my_module.js and put the following code in it:
import {formatFloat as originalFormatFloat} from 'web/static/src/views/fields/formatters.js';

export function formatFloat(value, options = {}) { //Your custom code is here // You can call the original function using originalFormatFloat() }

In your new module, create a file called views/assets.xml and put the following code in it:

Install your new module in Odoo.
This will override the formatFloat function in your Odoo instance and use your custom implementation instead. You can modify the code in the my_module.js file to customize the behavior of the function as needed


Hope it helps

아바타
취소
관련 게시물 답글 화면 활동
2
7월 25
4225
1
5월 24
4509
0
10월 24
1186
3
12월 23
19970
2
3월 15
4420