-
-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b89e426
commit fda2eac
Showing
22 changed files
with
924 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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_link_base |
This file contains 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 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,79 @@ | ||
================ | ||
Survey Link Base | ||
================ | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:e990148f488831cfa1259013f8a7adb0d48cb5f5a1acdf75fcd8b471580ea9b3 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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%2Fsurvey-lightgray.png?logo=github | ||
:target: https://github.com/OCA/survey/tree/16.0/survey_link_base | ||
:alt: OCA/survey | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/survey-16-0/survey-16-0-survey_link_base | ||
: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/survey&target_branch=16.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This addon creates a mixin and a wizard to enable the generation of surveys from other models. | ||
Additionally, add the option to create survey responses from contacts. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/survey/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/survey/issues/new?body=module:%20survey_link_base%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 | ||
~~~~~~~ | ||
|
||
* Binhex | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* `Binhex <https://binhex.cloud>`_: | ||
|
||
* Adasat Torres de León <[email protected]> | ||
|
||
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. | ||
|
||
This module is part of the `OCA/survey <https://github.com/OCA/survey/tree/16.0/survey_link_base>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains 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 @@ | ||
# Copyright 2024 Binhex - Adasat Torres de León | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
from . import models | ||
from . import wizard |
This file contains 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,18 @@ | ||
# Copyright 2024 Binhex - Adasat Torres de León | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
{ | ||
"name": "Survey Link Base", | ||
"summary": """ | ||
This addon creates a mixin and a wizard to enable the | ||
generation of surveys from other models..""", | ||
"version": "16.0.1.0.0", | ||
"license": "AGPL-3", | ||
"author": "Binhex, Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/survey", | ||
"depends": ["survey"], | ||
"data": [ | ||
"security/ir.model.access.csv", | ||
"wizard/survey_link_wizard_views.xml", | ||
"views/res_partner_views.xml", | ||
], | ||
} |
This file contains 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 @@ | ||
# Copyright 2024 Binhex - Adasat Torres de León | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
from . import survey_survey | ||
from . import survey_user_input | ||
from . import survey_link_mixin | ||
from . import res_partner |
This file contains 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,8 @@ | ||
from odoo import models | ||
|
||
|
||
class ResPartner(models.Model): | ||
_name = "res.partner" | ||
_inherit = ["res.partner", "survey.link.mixin"] | ||
|
||
_partner_field = "id" |
This file contains 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,74 @@ | ||
# Copyright 2024 Binhex - Adasat Torres de León | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
from datetime import timedelta | ||
|
||
from odoo import _, fields, models | ||
|
||
|
||
class SurveyLinkMixin(models.AbstractModel): | ||
_name = "survey.link.mixin" | ||
|
||
survey_count = fields.Integer( | ||
compute="_compute_survey_count", | ||
) | ||
_partner_field = "partner_id" | ||
|
||
def _compute_survey_count(self): | ||
for record in self: | ||
record.survey_count = self.env["survey.user_input"].search_count( | ||
[ | ||
("origin_id", "=", record.id), | ||
("origin_model", "=", record._name), | ||
("partner_id", "=", getattr(record, record._partner_field, False)), | ||
] | ||
) | ||
|
||
def action_view_survey(self): | ||
self.ensure_one() | ||
action = self.env.ref("survey.action_survey_user_input").read()[0] | ||
action["domain"] = [ | ||
("origin_id", "=", self.id), | ||
("origin_model", "=", self._name), | ||
("partner_id", "=", getattr(self, self._partner_field, False)), | ||
] | ||
action["context"] = { | ||
"default_origin_id": self.id, | ||
"default_origin_model": self._name, | ||
"default_partner_id": getattr(self, self._partner_field, False), | ||
"default_survey_id": self.get_default_survey(), | ||
} | ||
return action | ||
|
||
# Override this method if you need to add a default survey. | ||
def get_default_survey(self): | ||
return False | ||
|
||
# This method return False if you haven't a default_survey | ||
def get_share_link(self): | ||
survey_link_wizard = self.env["survey.link.wizard"].create( | ||
{ | ||
"origin_id": self.id, | ||
"origin_model": self._name, | ||
"partner_id": getattr(self, self._partner_field, False), | ||
"date_deadline": fields.Date.today() + timedelta(days=5), | ||
"survey_id": self.get_default_survey(), | ||
} | ||
) | ||
return survey_link_wizard.share_link if survey_link_wizard else False | ||
|
||
def action_survey_link_wizard(self): | ||
self.ensure_one() | ||
return { | ||
"type": "ir.actions.act_window", | ||
"name": _("Survey Share Link"), | ||
"res_model": "survey.link.wizard", | ||
"view_mode": "form", | ||
"target": "new", | ||
"context": { | ||
"default_origin_id": self.id, | ||
"default_origin_model": self._name, | ||
"default_partner_id": getattr(self, self._partner_field, False), | ||
"default_date_deadline": fields.Date.today(), | ||
"default_survey_id": self.get_default_survey(), | ||
}, | ||
} |
This file contains 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,34 @@ | ||
# Copyright 2024 Binhex - Adasat Torres de León | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
from odoo import models | ||
|
||
|
||
class SurveySurvey(models.Model): | ||
_inherit = "survey.survey" | ||
|
||
def _create_answer( | ||
self, | ||
user=False, | ||
partner=False, | ||
email=False, | ||
test_entry=False, | ||
origin_id=False, | ||
origin_model=False, | ||
check_attempts=True, | ||
**additional_vals | ||
): | ||
user_inputs = super()._create_answer( | ||
user=user, | ||
partner=partner, | ||
email=email, | ||
test_entry=test_entry, | ||
**additional_vals | ||
) | ||
vals = {} | ||
if origin_id: | ||
vals["origin_id"] = origin_id | ||
if origin_model: | ||
vals["origin_model"] = origin_model | ||
if vals: | ||
user_inputs.write(vals) | ||
return user_inputs |
This file contains 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,10 @@ | ||
# Copyright 2024 Binhex - Adasat Torres de León | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
from odoo import fields, models | ||
|
||
|
||
class SurveyUserInput(models.Model): | ||
_inherit = "survey.user_input" | ||
|
||
origin_model = fields.Char() | ||
origin_id = fields.Integer() |
This file contains 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,3 @@ | ||
* `Binhex <https://binhex.cloud>`_: | ||
|
||
* Adasat Torres de León <[email protected]> |
This file contains 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,2 @@ | ||
This addon creates a mixin and a wizard to enable the generation of surveys from other models. | ||
Additionally, add the option to create survey responses from contacts. |
This file contains 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,2 @@ | ||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink | ||
access_full_survey_link_wizard,access.full.survey.link.wizard,model_survey_link_wizard,base.group_user,1,1,1,1 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.