-
-
Notifications
You must be signed in to change notification settings - Fork 66
[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
kobros-tech
wants to merge
9
commits into
OCA:16.0
Choose a base branch
from
kencove:16.0-imp-sign_oca-link-survey
base: 16.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f3f6597
[ADD] survey_sign_oca: survey and sign_oca connector
kobros-tech ae6fcee
[IMP] survey_sign_oca: populate check fields from survey answers
kobros-tech 2d44b6d
[IMP] survey_sign_oca: populate fields in backend
kobros-tech a34e1d3
[IMP] survey_sign_oca: depend on new survey signature type
kobros-tech af9ea9f
[IMP] survey_sign_oca: make start button text editable
kobros-tech 5484dcd
[IMP] survey_sign_oca: review changes
kobros-tech b3670c7
[IMP] survey_sign_oca: fill items with default values
kobros-tech 15cc682
[IMP] survey_sign_oca: add end heading
kobros-tech c4479a4
[IMP] survey_sign_oca: add multiple choice feature
kobros-tech File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../../../../survey_sign_oca |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import setuptools | ||
|
|
||
| setuptools.setup( | ||
| setup_requires=['setuptools-odoo'], | ||
| odoo_addon=True, | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,169 @@ | ||
| =============== | ||
| Survey Sign Oca | ||
| =============== | ||
|
|
||
| .. | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
| !! This file is generated by oca-gen-addon-readme !! | ||
| !! changes will be overwritten. !! | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
| !! source digest: sha256:c6ec61a6c8661f9097946736d2cd67efc929e1531803516fa6d82728aab2c98a | ||
| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
|
||
| .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
| :target: https://odoo-community.org/page/development-status | ||
| :alt: Beta | ||
| .. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
| :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
| :alt: License: AGPL-3 | ||
| .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsign-lightgray.png?logo=github | ||
| :target: https://github.com/OCA/sign/tree/16.0/survey_sign_oca | ||
| :alt: OCA/sign | ||
| .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
| :target: https://translation.odoo-community.org/projects/sign-16-0/sign-16-0-survey_sign_oca | ||
| :alt: Translate me on Weblate | ||
| .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
| :target: https://runboat.odoo-community.org/builds?repo=OCA/sign&target_branch=16.0 | ||
| :alt: Try me on Runboat | ||
|
|
||
| |badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
|
||
| This module allows you to make survey signature requests manually or | ||
| automatically. | ||
|
|
||
| **Table of contents** | ||
|
|
||
| .. contents:: | ||
| :local: | ||
|
|
||
| Configuration | ||
| ============= | ||
|
|
||
| 1. Go to Sign > Settings > Roles and create a new one with the following | ||
| data if not there: | ||
|
|
||
| - For the survey participant | ||
|
|
||
| - Partner type: Expression | ||
| - Expression: {{object.partner_id.id}} | ||
|
|
||
| - For the survey responsible if you want | ||
|
|
||
| - Partner type: Expression | ||
| - Expression: {{object.survey_id.user_id.partner_id.id}} | ||
|
|
||
| 2. Go to Sign > Settings > Fields and create a new one with the | ||
| following data if not there: | ||
|
|
||
| - Text Survey Field | ||
|
|
||
| - Field Type: text | ||
| - Default Value: survey | ||
|
|
||
| - Check Survey Field | ||
|
|
||
| - Field Type: check | ||
| - Default Value: survey | ||
|
|
||
| - Signature Survey Field | ||
|
|
||
| - Field Type: signature | ||
| - Default Value: survey | ||
|
|
||
| 3. Go to Sign > Templates and create a template with the following data: | ||
|
|
||
| - Model: Survey User Input | ||
| - In some of the elements you will have to set the previously created | ||
| role[s]. | ||
|
|
||
| 4. Go to Settings > Survey Sign OCA: | ||
|
|
||
| 5. Defines the template previously created (optional, only for automatic | ||
| creation of signature requests). | ||
|
|
||
| Usage | ||
| ===== | ||
|
|
||
| A smart-button will be displayed on the participations form view of the | ||
| linked sign requests. | ||
|
|
||
| Manual Sign Request creation process: | ||
|
|
||
| :: | ||
|
|
||
| - Go to Surveys \> Participations and change to list view. | ||
| - Select the records that you want. | ||
| - Click on the "Sign from template" action. | ||
| - Select a template. | ||
| - Click on Generate. | ||
| - Sign Requests will have been generated (and sent) for the selected items. | ||
|
|
||
| Automatic Sign Request creation process: | ||
|
|
||
| :: | ||
|
|
||
| - When a partner takes a survey, a sign request will be created automatically. | ||
|
|
||
| For generated sign requests scoping survey, input values are populated | ||
| automatically with the survey answered values. | ||
|
|
||
| Answers of yes/no type are shown in text fields as Yes/No and in check | ||
| fields as checked/unchecked. | ||
|
|
||
| Answers of type binary can be trated as signature fields if the survey | ||
| question is the same as the signature placeholder in sign request. | ||
|
|
||
| In that case make sure to have this module: | ||
| ``survey_question_type_binary`` from OCA installed. | ||
|
|
||
| Signers can still update the input values if they want. | ||
|
|
||
| Bug Tracker | ||
| =========== | ||
|
|
||
| Bugs are tracked on `GitHub Issues <https://github.com/OCA/sign/issues>`_. | ||
| In case of trouble, please check there if your issue has already been reported. | ||
| If you spotted it first, help us to smash it by providing a detailed and welcomed | ||
| `feedback <https://github.com/OCA/sign/issues/new?body=module:%20survey_sign_oca%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
|
||
| Do not contact contributors directly about support or help with technical issues. | ||
|
|
||
| Credits | ||
| ======= | ||
|
|
||
| Authors | ||
| ------- | ||
|
|
||
| * Kencove | ||
|
|
||
| Contributors | ||
| ------------ | ||
|
|
||
| - `Kencove <https://kencove.com>`__ | ||
|
|
||
| - Mohamed Alkobrosli | ||
|
|
||
| Maintainers | ||
| ----------- | ||
|
|
||
| This module is maintained by the OCA. | ||
|
|
||
| .. image:: https://odoo-community.org/logo.png | ||
| :alt: Odoo Community Association | ||
| :target: https://odoo-community.org | ||
|
|
||
| OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
| mission is to support the collaborative development of Odoo features and | ||
| promote its widespread use. | ||
|
|
||
| .. |maintainer-Kencove| image:: https://github.com/Kencove.png?size=40px | ||
| :target: https://github.com/Kencove | ||
| :alt: Kencove | ||
|
|
||
| Current `maintainer <https://odoo-community.org/page/maintainer-role>`__: | ||
|
|
||
| |maintainer-Kencove| | ||
|
|
||
| This module is part of the `OCA/sign <https://github.com/OCA/sign/tree/16.0/survey_sign_oca>`_ project on GitHub. | ||
|
|
||
| You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from . import models |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # Copyright 2025 Kencove - Mohamed Alkobrosli | ||
| # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
| { | ||
| "name": "Survey Sign Oca", | ||
| "version": "16.0.1.0.0", | ||
| "category": "Surveys", | ||
| "website": "https://github.com/OCA/sign", | ||
| "author": "Kencove, Odoo Community Association (OCA)", | ||
| "license": "AGPL-3", | ||
| "depends": ["sign_oca", "survey"], | ||
| "data": [ | ||
| "views/survey_user_views.xml", | ||
| "views/res_config_settings_view.xml", | ||
| "views/sign_oca_request_views.xml", | ||
| "data/sign_oca_role.xml", | ||
| ], | ||
| "installable": True, | ||
| "maintainers": ["Kencove"], | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| <odoo> | ||
| <record id="sign_field_survey_text" model="sign.oca.field"> | ||
| <field name="name">Survey Text</field> | ||
| <field name="field_type">text</field> | ||
| <field name="default_value">survey</field> | ||
| </record> | ||
|
|
||
| <record id="sign_field_survey_check" model="sign.oca.field"> | ||
| <field name="name">Survey Check</field> | ||
| <field name="field_type">check</field> | ||
| <field name="default_value">survey</field> | ||
| </record> | ||
|
|
||
| <record id="sign_field_survey_signature" model="sign.oca.field"> | ||
| <field name="name">Survey Signature</field> | ||
| <field name="field_type">signature</field> | ||
| <field name="default_value">survey</field> | ||
| </record> | ||
|
|
||
| <record id="role_survey_user_input" model="sign.oca.role"> | ||
| <field name="name">Survey Participant</field> | ||
| <field name="partner_selection_policy">expression</field> | ||
| <field name="expression_partner">{{object.partner_id.id}}</field> | ||
| </record> | ||
|
|
||
| <record id="role_survey_responsible_input" model="sign.oca.role"> | ||
| <field name="name">Survey Responsible</field> | ||
| <field name="partner_selection_policy">expression</field> | ||
| <field | ||
| name="expression_partner" | ||
| >{{object.survey_id.user_id.partner_id.id}}</field> | ||
| </record> | ||
| </odoo> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| from . import survey_invite | ||
| from . import res_company | ||
| from . import res_config_settings | ||
| from . import sign_oca_request |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # Copyright 2025 Kencove - Mohamed Alkobrosli | ||
| # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
|
||
| from odoo import fields, models | ||
|
|
||
|
|
||
| class ResCompany(models.Model): | ||
| _inherit = "res.company" | ||
|
|
||
| survey_user_input_sign_oca_template_id = fields.Many2one( | ||
| comodel_name="sign.oca.template", | ||
| domain="[('model_id.model', '=', 'survey.user_input')]", | ||
| string="Sign Oca Template", | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # Copyright 2025 Kencove - Mohamed Alkobrosli | ||
| # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
|
||
| from odoo import fields, models | ||
|
|
||
|
|
||
| class ResConfigSettings(models.TransientModel): | ||
| _inherit = "res.config.settings" | ||
|
|
||
| survey_user_input_sign_oca_template_id = fields.Many2one( | ||
| comodel_name="sign.oca.template", | ||
| related="company_id.survey_user_input_sign_oca_template_id", | ||
| string="Sign Oca Template", | ||
| readonly=False, | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| # Copyright 2025 Kencove - Mohamed Alkobrosli | ||
| # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
| from odoo import api, fields, models | ||
|
|
||
|
|
||
| # This class is to format questions of type (yes, no) | ||
| # in case we need the answer as (True, False) in case of filling checkboxes | ||
| class SurveyUtils: | ||
| @staticmethod | ||
| def is_yes_no_answer(value): | ||
| return str(value).strip().lower() in ["yes", "no"] | ||
|
|
||
| @staticmethod | ||
| def answer_is_yes(value): | ||
| return str(value).strip().lower() == "yes" | ||
|
|
||
| @staticmethod | ||
| def format_answer(answer): | ||
| if SurveyUtils.is_yes_no_answer(answer): | ||
| answer = SurveyUtils.answer_is_yes(answer) | ||
| return answer | ||
|
|
||
|
|
||
| class SignOcaRequest(models.Model): | ||
| _inherit = "sign.oca.request" | ||
|
|
||
| # This field is required for the inverse of survey.user.input. | ||
| survey_user_input_id = fields.Many2one( | ||
| comodel_name="survey.user_input", | ||
| compute="_compute_survey_user_input_id", | ||
| string="Survey Participation", | ||
| readonly=True, | ||
| store=True, | ||
| ondelete="cascade", | ||
| ) | ||
|
|
||
| @api.depends("record_ref") | ||
| def _compute_survey_user_input_id(self): | ||
| for item in self.filtered( | ||
| lambda x: x.record_ref and x.record_ref._name == "survey.user_input" | ||
| ): | ||
| item.survey_user_input_id = item.record_ref.id | ||
|
|
||
|
|
||
| class SignOcaRequestSigner(models.Model): | ||
|
|
||
| _inherit = "sign.oca.request.signer" | ||
|
|
||
| def get_related_survey_answers(self): | ||
| self.ensure_one() | ||
| survey_participation = self.request_id.record_ref | ||
| survey = {} | ||
| if survey_participation: | ||
| for line in survey_participation.user_input_line_ids: | ||
| # Questions of type matrix have questions and suggested answers like a matrix | ||
| # We map the answeres to the questions for each matrix type | ||
| 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") | ||
| # According to placeholder we target the answer of a question | ||
| # having same text as the placeholder | ||
| # and we choose the answer format based on the item field_typ | ||
| 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) | ||
| if item.get("default_value") and item.get("default_value") != "survey": | ||
| item["value"] = vals.get("partner").get(item["default_value"]) | ||
| return vals | ||
|
|
||
| def get_info(self, access_token=False): | ||
| vals = super().get_info(access_token) | ||
| # get survey answers for this sign request | ||
| # and fill items with answers / default values | ||
| model_id = self.request_id.template_id.model_id | ||
| if model_id and model_id.model == "survey.user_input": | ||
| vals = self.fill_survey_related_items(vals) | ||
| return vals | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.