-
-
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 df4d7f9
Showing
21 changed files
with
941 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_purchase |
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,80 @@ | ||
=============== | ||
Survey Purchase | ||
=============== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! 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_purchase | ||
: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_purchase | ||
: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 link to a survey in the purchase order, | ||
using a template configured in the settings. | ||
The link can be found in the "Other Information" section of the purchase order. | ||
|
||
**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_purchase%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_purchase>`_ 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,3 @@ | ||
# Copyright 2024 Binhex - Adasat Torres de León | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
from . import models |
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,16 @@ | ||
# Copyright 2024 Binhex - Adasat Torres de León | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
{ | ||
"name": "Survey Purchase", | ||
"summary": """ | ||
This addon allows to create surveys from purchase orders""", | ||
"version": "16.0.1.0.0", | ||
"license": "AGPL-3", | ||
"author": "Binhex, Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/survey", | ||
"depends": ["survey", "purchase"], | ||
"data": [ | ||
"views/res_config_settings_views.xml", | ||
"views/purchase_order_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,63 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * survey_purchase | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 16.0-20240104\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-12-26 14:12+0000\n" | ||
"PO-Revision-Date: 2024-12-26 14:13+0000\n" | ||
"Last-Translator: \n" | ||
"Language-Team: \n" | ||
"Language: es\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Plural-Forms: nplurals=2; plural=(n != 1);\n" | ||
"X-Generator: Poedit 3.5\n" | ||
|
||
#. module: survey_purchase | ||
#: model:ir.model,name:survey_purchase.model_res_company | ||
msgid "Companies" | ||
msgstr "Compañías" | ||
|
||
#. module: survey_purchase | ||
#: model:ir.model,name:survey_purchase.model_res_config_settings | ||
msgid "Config Settings" | ||
msgstr "Opciones de Configuración" | ||
|
||
#. module: survey_purchase | ||
#: model:ir.model.fields,field_description:survey_purchase.field_res_company__survey_purchase_id | ||
#: model:ir.model.fields,field_description:survey_purchase.field_res_config_settings__survey_purchase_id | ||
msgid "Default Purchase Survey" | ||
msgstr "Encuesta de compra por defecto" | ||
|
||
#. module: survey_purchase | ||
#: model:ir.model,name:survey_purchase.model_purchase_order | ||
#: model:ir.model.fields,field_description:survey_purchase.field_survey_user_input__purchase_order_id | ||
msgid "Purchase Order" | ||
msgstr "Orden de compra" | ||
|
||
#. module: survey_purchase | ||
#: model:ir.model,name:survey_purchase.model_survey_survey | ||
#: model:ir.model.fields,field_description:survey_purchase.field_purchase_order__survey_id | ||
#: model_terms:ir.ui.view,arch_db:survey_purchase.purchase_order_form_inherit | ||
#: model_terms:ir.ui.view,arch_db:survey_purchase.res_config_settings_form_inherit | ||
msgid "Survey" | ||
msgstr "Encuesta" | ||
|
||
#. module: survey_purchase | ||
#: model:ir.model.fields,field_description:survey_purchase.field_purchase_order__survey_count | ||
msgid "Survey Count" | ||
msgstr "Recuento de encuestas" | ||
|
||
#. module: survey_purchase | ||
#: model:ir.model.fields,field_description:survey_purchase.field_purchase_order__survey_share_link | ||
msgid "Survey Share Link" | ||
msgstr "Enlace para compartir encuestas" | ||
|
||
#. module: survey_purchase | ||
#: model:ir.model,name:survey_purchase.model_survey_user_input | ||
msgid "Survey User Input" | ||
msgstr "Datos de Entrada del usuario" |
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,63 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * survey_purchase | ||
# | ||
#, fuzzy | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 16.0-20240104\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-12-26 14:12+0000\n" | ||
"PO-Revision-Date: 2024-12-26 14:12+0000\n" | ||
"Last-Translator: \n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Plural-Forms: \n" | ||
"X-Generator: Poedit 3.5\n" | ||
|
||
#. module: survey_purchase | ||
#: model:ir.model,name:survey_purchase.model_res_company | ||
msgid "Companies" | ||
msgstr "" | ||
|
||
#. module: survey_purchase | ||
#: model:ir.model,name:survey_purchase.model_res_config_settings | ||
msgid "Config Settings" | ||
msgstr "" | ||
|
||
#. module: survey_purchase | ||
#: model:ir.model.fields,field_description:survey_purchase.field_res_company__survey_purchase_id | ||
#: model:ir.model.fields,field_description:survey_purchase.field_res_config_settings__survey_purchase_id | ||
msgid "Default Purchase Survey" | ||
msgstr "" | ||
|
||
#. module: survey_purchase | ||
#: model:ir.model,name:survey_purchase.model_purchase_order | ||
#: model:ir.model.fields,field_description:survey_purchase.field_survey_user_input__purchase_order_id | ||
msgid "Purchase Order" | ||
msgstr "" | ||
|
||
#. module: survey_purchase | ||
#: model:ir.model,name:survey_purchase.model_survey_survey | ||
#: model:ir.model.fields,field_description:survey_purchase.field_purchase_order__survey_id | ||
#: model_terms:ir.ui.view,arch_db:survey_purchase.purchase_order_form_inherit | ||
#: model_terms:ir.ui.view,arch_db:survey_purchase.res_config_settings_form_inherit | ||
msgid "Survey" | ||
msgstr "" | ||
|
||
#. module: survey_purchase | ||
#: model:ir.model.fields,field_description:survey_purchase.field_purchase_order__survey_count | ||
msgid "Survey Count" | ||
msgstr "" | ||
|
||
#. module: survey_purchase | ||
#: model:ir.model.fields,field_description:survey_purchase.field_purchase_order__survey_share_link | ||
msgid "Survey Share Link" | ||
msgstr "" | ||
|
||
#. module: survey_purchase | ||
#: model:ir.model,name:survey_purchase.model_survey_user_input | ||
msgid "Survey User Input" | ||
msgstr "" |
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,7 @@ | ||
# Copyright 2024 Binhex - Adasat Torres de León | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
from . import res_company | ||
from . import res_config_settings | ||
from . import survey_survey | ||
from . import survey_user_input | ||
from . import purchase_order |
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,73 @@ | ||
# Copyright 2024 Binhex - Adasat Torres de León | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
import werkzeug | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class PurchaseOrder(models.Model): | ||
_inherit = "purchase.order" | ||
|
||
survey_count = fields.Integer( | ||
compute="_compute_survey_count", | ||
) | ||
|
||
survey_id = fields.Many2one( | ||
comodel_name="survey.survey", | ||
string="Survey", | ||
related="company_id.survey_purchase_id", | ||
) | ||
|
||
survey_share_link = fields.Char(compute="_compute_survey_share_link", store=True) | ||
|
||
def _compute_survey_count(self): | ||
for order in self: | ||
order.survey_count = self.env["survey.user_input"].search_count( | ||
[("purchase_order_id", "in", self.ids)] | ||
) | ||
|
||
def action_view_survey(self): | ||
self.ensure_one() | ||
action = self.env.ref("survey.action_survey_user_input").read()[0] | ||
action["domain"] = [("purchase_order_id", "=", self.id)] | ||
action["context"] = { | ||
"default_purchase_order_id": self.id, | ||
"default_partner_id": self.partner_id.id, | ||
"default_survey_id": self.survey_id.id, | ||
} | ||
return action | ||
|
||
def _create_survey_token(self): | ||
SurveyUserInput = self.env["survey.user_input"] | ||
|
||
survey_user_input = SurveyUserInput.search( | ||
[ | ||
("purchase_order_id", "=", self.id), | ||
("state", "in", ["new", "in_progress"]), | ||
("partner_id", "=", self.partner_id.id), | ||
("survey_id", "=", self.survey_id.id), | ||
], | ||
limit=1, | ||
) | ||
|
||
if not survey_user_input: | ||
survey_user_input = self.survey_id._create_answer( | ||
email=self.partner_id.email, | ||
purchase=self, | ||
) | ||
return survey_user_input.access_token | ||
|
||
@api.depends("survey_id") | ||
def _compute_survey_share_link(self): | ||
for record in self: | ||
if record.survey_id: | ||
token = record._create_survey_token() | ||
link = "/survey/%s/%s" % ( | ||
record.survey_id.access_token, | ||
token, | ||
) | ||
record.survey_share_link = werkzeug.urls.url_join( | ||
record.survey_id.get_base_url(), link | ||
) | ||
else: | ||
record.survey_share_link = False |
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,11 @@ | ||
# 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 ResCompany(models.Model): | ||
_inherit = "res.company" | ||
|
||
survey_purchase_id = fields.Many2one( | ||
comodel_name="survey.survey", string="Default Purchase 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,14 @@ | ||
# 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 ResConfigSettings(models.TransientModel): | ||
_inherit = "res.config.settings" | ||
|
||
survey_purchase_id = fields.Many2one( | ||
comodel_name="survey.survey", | ||
string="Default Purchase Survey", | ||
related="company_id.survey_purchase_id", | ||
readonly=False, | ||
) |
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,31 @@ | ||
# 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, | ||
purchase=False, | ||
check_attempts=True, | ||
**additional_vals | ||
): | ||
user_inputs = super()._create_answer( | ||
user=user, | ||
partner=partner, | ||
email=email, | ||
test_entry=test_entry, | ||
**additional_vals | ||
) | ||
|
||
if purchase: | ||
for user_input in user_inputs: | ||
user_input.purchase_order_id = purchase | ||
|
||
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,12 @@ | ||
# 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" | ||
|
||
purchase_order_id = fields.Many2one( | ||
comodel_name="purchase.order", | ||
string="Purchase Order", | ||
) |
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]> |
Oops, something went wrong.