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

I'm currently working on a automation and this is my code


First the automation will be triggered via webhook and will receive this

template_id = int(payload.get('template_id'))
partner_id = int(payload.get('partner_id'))


Then it will create 2 records in sign.item model so client can input their signature and date of signing

item_signature = {
    "template_id" : template_id,
    "type_id": 1, # 1 = signature item
    "required" : True,
    "responsible_id" : 1, # 1 = customer role
    "page": 9,
    "posX": 0.344,
    "posY": 0.156,
    "width" : 0.189,
    "height" : 0.024,
    "name": "Signature"
}

env['sign.item'].create(item_signature)

item_sign_date = {
    "template_id" : template_id,
    "type_id": 12, # 12 = date item
    "required" : True,
    "responsible_id" : 1, # 1 = customer role
    "page": 9,
    "posX": 0.302,
    "posY": 0.228,
    "width" : 0.150,
    "height" : 0.015,
    "name" : "Date"
}

env['sign.item'].create(item_sign_date)


Now I wanted to send a sign request to client by creating a record in sign.send.request

send_request_data = {
    "template_id": template_id,
    "subject": "Test Subject",
    "filename": "test.pdf",
}
   
send_request = env["sign.send.request"].create(send_request_data)


Then i have to add a record in model sign.send.request.signer in which i can append it to the "send_request" above

signer_data = [{
    "role_id": 1,  # 1 = customer role
    "partner_id": partner_id,
    "sign_send_request_id": send_request.id
}]

signer = env["sign.send.request.signer"].create(signer_data)


To send the request i have to run this

send_request.send_request()


But odoo will throw an error to me everytime 

"odoo.exceptions.ValidationError: You must specify one signer for each role of your sign template"


I don't understand why I'm getting this error. I have already ensure the the signature item and date item will be filled by customer. Then I have added a signer with role of "customer". 


When I check in sign module, a record was actually create, but the signer was set to "Public User" even though it should not.


Please help me know the reason why I'm getting this error and possible solutions. Thanks in advance

아바타
취소
작성자 베스트 답변

I solve the issue by adding something in here

 send_request_data = {
        "template_id": template_id,
        "subject": "Test Subject",
        "filename": "test.pdf",
        "signers_count": 1,
        "signer_id": partner_id # add this line, tells odoo this sign request is for this contact
    }


send_request = env["sign.send.request"].create(send_request_data)


So after creating a record in model sign.send.request continue adding a record for model sign.send.request.signer. Then add this line


send_request.write({
        "signer_ids" : [signer_id.id]
})


This will tell odoo that the sign request about to be sent should be sent to this people.

아바타
취소

Hello Johnny Solas,
I was searching for a solution as well, and I’m glad to see you’ve already found one. This will definitely be helpful.
Thanks!

베스트 답변

Hello Johnny Solas,

You can try the following code:

# Create signature item
item_signature = {
    "template_id": 1,
    "type_id": 1,  # 1 = signature item
    "required": True,
    "responsible_id": 1,  # 1 = customer role
    "page": 9,
    "posX": 0.344,
    "posY": 0.156,
    "width": 0.189,
    "height": 0.024,
    "name": "Signature"
}

env['sign.item'].sudo().create(item_signature)

# Create date item
item_sign_date = {
    "template_id": 1,
    "type_id": 12,  # 12 = date item
    "required": True,
    "responsible_id": 1,  # 1 = customer role
    "page": 9,
    "posX": 0.302,
    "posY": 0.228,
    "width": 0.150,
    "height": 0.015,
    "name": "Date"
}

env['sign.item'].sudo().create(item_sign_date)

# Create the sign send request
send_request_data = {
    "template_id": 1,
    "subject": "Test Subject",
    "filename": "test.pdf",
    "signers_count": 1,
}

send_request = env["sign.send.request"].create(send_request_data)

# Create signer
signer_data = [{
    "role_id": 1,  # Assuming this is the required role ID
    "partner_id": 3,
    "mail_sent_order": 1,
    "sign_send_request_id": send_request.id
}]

env["sign.send.request.signer"].create(signer_data)

# Send the request
send_request.send_request()

Make sure to replace template_id, partner_id, and role_id with values from your payload. This should work without any errors. Let me know if you face any issues.

Thanks!

아바타
취소
작성자

Thank you for your help!

I tried this code, the error "You must specify one signer for each role of your sign template" is now gone. However there are new issues.

1. Whenever I tried to open the document generated by "send_request.send_request()". It shows this error message

"UncaughtClientError > TypeError Uncaught Javascript Error > Cannot set properties of undefined (setting '106') Occured on yourcompany.com on 2025-02-10 11:08:16 GMT

TypeError: Cannot set properties of undefined (setting '106')
at PDFIframe.getSignItems (https://yourcompany.com/web/assets/280e2ad/web.assets_web_dark.min.js:22716:82)
at PDFIframe.start (https://yourcompany.com/web/assets/280e2ad/web.assets_web_dark.min.js:22682:29)
at PDFIframe.waitForPagesToLoad (https://yourcompany.com/web/assets/280e2ad/web.assets_web_dark.min.js:22681:85)
at https://yourcompany.com/web/assets/280e2ad/web.assets_web_dark.min.js:22681:119
"

2. It used the wrong template. I tried changing the template_id in the payload, but it still use the same wrong template. I also suspect that this the same issue, is the reason why the Signature and Date item was not added in the template.

I would appreciate your guidance on resolving these issues!

작성자

I restart my odoo and then Issue #2 was gone, but #1 is still their

관련 게시물 답글 화면 활동
1
4월 23
2763
0
2월 25
1345
0
2월 25
1245
0
9월 24
1009
0
8월 25
1748