Skip to content

[ADD] survey_sign_oca: survey and sign_oca connector #99

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: 16.0
Choose a base branch
from

Conversation

kobros-tech
Copy link

@kobros-tech kobros-tech commented Apr 2, 2025

Because of the nice odoo survey interaction and organized questions and well designed format, there is a need to show the signers a survey and fill, then send them a filled sign request waiting for their approval so that we save time for them and fetch information in an interesting way not a boring one.

The commit is under development and we need to apply the idea in a professional way, and business bearing one!

description, configuration is TODO

based on PR
#91

#102

https://github.com/OCA/survey/#157

@OCA-git-bot
Copy link
Contributor

Hi @etobella,
some modules you are maintaining are being modified, check this out!

@dnplkndll
Copy link

@kobros-tech I think you want to make a new module for this connector.

I think there needs to be a complete process review too. if the fields are to map from the sign to the survey should that be able to be created from the sign template?

maybe we could use the US streamlines as a demo item since it covers the most US states and would be able to then create the exemption needed for the tex service.

https://www.streamlinedsalestax.org/docs/default-source/forms/exemption-certificateb926a7ab4a0d43e1ad4fe8eb19e79cbb.pdf?sfvrsn=857843d_5

@kobros-tech kobros-tech force-pushed the 16.0-imp-sign_oca-link-survey branch from cc24057 to 8c7d389 Compare April 2, 2025 22:51
@kobros-tech
Copy link
Author

@kobros-tech I think you want to make a new module for this connector.

I think there needs to be a complete process review too. if the fields are to map from the sign to the survey should that be able to be created from the sign template?

maybe we could use the US streamlines as a demo item since it covers the most US states and would be able to then create the exemption needed for the tex service.

https://www.streamlinedsalestax.org/docs/default-source/forms/exemption-certificateb926a7ab4a0d43e1ad4fe8eb19e79cbb.pdf?sfvrsn=857843d_5

now I improved the field item to be just one "Survey" and according to each one of them I compare the placehloder to the key of the answer, video is showing that.

I didn't want to give my suggestion of creating a new module untill you give me the suggetion on it.

I will try to apply other ones too.

Copy link
Member

@etobella etobella left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create a glue module. do not add the dependancy here

Copy link
Member

@victoralmau victoralmau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to #99 (review), I believe the module could be similar to maintenance_sign_oca. Besides, it seems that what is commented in #91 (comment) will also be necessary, right?

@kobros-tech
Copy link
Author

In addition to #99 (review), I believe the module could be similar to maintenance_sign_oca. Besides, it seems that what is commented in #91 (comment) will also be necessary, right?

yes, it's better to have it in a separate module, I wish I could as I have to patch some js methods.

@etobella
Copy link
Member

etobella commented Apr 3, 2025

We will check the hooks and add them if they have sense. Do not worry about that.

However, I think we shouldn't add unnecessary dependancies on the module.

@kobros-tech kobros-tech force-pushed the 16.0-imp-sign_oca-link-survey branch 3 times, most recently from 61e9209 to da313c8 Compare April 3, 2025 23:11
@kobros-tech
Copy link
Author

Now I add a standalone module to connect between sing_oca and survey.

@kobros-tech
Copy link
Author

@dnplkndll

@kobros-tech kobros-tech force-pushed the 16.0-imp-sign_oca-link-survey branch 2 times, most recently from 7e1e4f1 to 0296783 Compare April 4, 2025 05:23
@kobros-tech kobros-tech changed the title [16.0][IMP] sign_oca: connect sign requests with survey answers [ADD] survey_sign_oca: survey and sign_oca connector Apr 4, 2025
@kobros-tech kobros-tech force-pushed the 16.0-imp-sign_oca-link-survey branch from 0296783 to 38ad02c Compare April 4, 2025 23:55
@kobros-tech
Copy link
Author

If there is a signatur field in the request it will throw error, and it is handle in this PR #102 it is inside sign_oca module.

@kobros-tech kobros-tech force-pushed the 16.0-imp-sign_oca-link-survey branch from bdd58a7 to 41f289c Compare April 6, 2025 06:08
@kobros-tech
Copy link
Author

Screenshot from 2025-04-06 08-50-34

Screenshot from 2025-04-06 08-50-49

@kobros-tech
Copy link
Author

@kobros-tech kobros-tech force-pushed the 16.0-imp-sign_oca-link-survey branch from ac05641 to 4a518a0 Compare April 11, 2025 14:12
@kobros-tech kobros-tech force-pushed the 16.0-imp-sign_oca-link-survey branch from 4a518a0 to 248dbea Compare April 11, 2025 14:23
class SignOcaRequest(models.Model):
_inherit = "sign.oca.request"

# This field is required for the inverse of maintenance.equipment.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# This field is required for the inverse of maintenance.equipment.
# This field is required for the inverse of survey.user.input.

Comment on lines 45 to 46
"default_maintenance_equipment_id": self.id,
"search_default_maintenance_equipment_id": self.id,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"default_maintenance_equipment_id": self.id,
"search_default_maintenance_equipment_id": self.id,
"default_maintenance_equipment_id": self.id,
"search_default_maintenance_equipment_id": self.id,

These fields are not the correct ones, you will have to change them for the corresponding ones.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a big mistake, I will fix

class Survey(models.Model):
_inherit = "survey.survey"

start_button_name = fields.Char("Survey Start Button Name", default="Start")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this field necessary for sign_oca? What use case are you trying to cover? Is this really necessary in this module?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The module is extending the concept meaning of survey module, now it can take a rool for many other functions like filling the exemption data but not in the document directly, so the case is not exactly answering a survey.

So survey module can do jobs like: survey, questionaire, filling docs and maybe evenmore.

Start Survey button name is very specific, and it can be start a survey, stary a questionaire start a foo.

Comment on lines 46 to 83
def get_related_survey_answers(self):
self.ensure_one()
# get survey answers for this sign request
model_id = self.request_id.template_id.model_id
survey_participation = self.request_id.record_ref
survey = {}
if survey_participation and model_id and model_id.model == "survey.user_input":
for line in survey_participation.user_input_line_ids:
if line.question_id.question_type == "matrix":
answer = line.suggested_answer_id.value
survey.update({line.matrix_row_id.value: answer})
elif line.question_id.question_type in ["binary", "signature"]:
answer = line.answer_binary_ids[:1].value_binary
survey.update({line.question_id.display_name: answer})
else:
answer = line.display_name
survey.update({line.question_id.display_name: answer})
return survey

def fill_survey_related_items(self, vals):
survey = self.get_related_survey_answers()
items = vals["items"]
for key in items:
item = items[key]
placeholder = item.get("placeholder")
if survey.get(placeholder) and item["role_id"] == self.role_id.id:
if survey.get(placeholder) and item["field_type"] == "text":
item["value"] = survey.get(placeholder)
elif survey.get(placeholder) and item["field_type"] == "check":
item["value"] = SurveyUtils.format_answer(survey.get(placeholder))
elif survey.get(placeholder) and item["field_type"] == "signature":
item["value"] = survey.get(placeholder)
return vals

def get_info(self, access_token=False):
vals = super().get_info(access_token)
vals = self.fill_survey_related_items(vals)
return vals
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain what this is intended to do (adding comments in the methods explaining what they do would help).
Are you trying to fill in survey data through the signature?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I will

I am just sending the same data from the server to the sign_request frontend so signers will see their answers in the corresponding field places.

"website": "https://github.com/OCA/sign",
"author": "Kencove, Odoo Community Association (OCA)",
"license": "AGPL-3",
"depends": ["sign_oca", "survey", "survey_question_type_binary"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"depends": ["sign_oca", "survey", "survey_question_type_binary"],
"depends": ["sign_oca", "survey", "survey_question_type_binary"],

IMP the survey_question_type_binary dependency should not be necessary.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is important if the survey takers will give answers of type binary or multibinary or signature.

It is very important for them to sign, and I can not ignore this field as I need it, and it is available in an OCA module.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but I will try to use get method if the field is present or not, I will try no problem.

@kobros-tech
Copy link
Author

@victoralmau
for the #91 (comment) commit if you are not going to merge, I really need the field_type to be shown in the form view and allow users to deal with. because if someone delete the data I introduce they can not create it again!.

@kobros-tech
Copy link
Author

@etobella
@victoralmau

I removed the dependency from manifest, but still having the external ones. The one related to survey is not critical here and optional, but the one related to sign_oca is important if getting merged otherwise I show the field I want here instead.

Some handy comments are added to, changes are in a separate commit for simplicity for now.

once you agree we transition to test cases.

@kobros-tech kobros-tech force-pushed the 16.0-imp-sign_oca-link-survey branch from 44c8d5f to 908ca86 Compare April 21, 2025 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants