[NEW] first commit for all modules coming from training-tools
This commit is contained in:
2
survey_crm_generation_training/models/__init__.py
Normal file
2
survey_crm_generation_training/models/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from . import crm_lead
|
||||
from . import survey_user_input
|
23
survey_crm_generation_training/models/crm_lead.py
Normal file
23
survey_crm_generation_training/models/crm_lead.py
Normal file
@@ -0,0 +1,23 @@
|
||||
# Copyright 2023 Tecnativa - David Vidal
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class CrmLead(models.Model):
|
||||
_inherit = "crm.lead"
|
||||
|
||||
event_products_ids = fields.Many2many('product.product', string='Event product')
|
||||
|
||||
|
||||
def action_view_survey_user_input_id(self):
|
||||
form_view_id = self.env.ref('survey.survey_user_input_view_form').id
|
||||
if self.survey_user_input_id:
|
||||
action = self.env["ir.actions.actions"]._for_xml_id("survey.action_survey_user_input")
|
||||
action['res_id'] = self.survey_user_input_id.id
|
||||
action['domain'] = [('id', '=', self.survey_user_input_id.id)]
|
||||
action['view_type'] = 'form'
|
||||
action['view_mode'] = 'form'
|
||||
action['binding_view_types'] = 'form'
|
||||
action['view_id'] = form_view_id
|
||||
action['views'] = [(form_view_id, 'form')]
|
||||
return action
|
15
survey_crm_generation_training/models/survey_user_input.py
Normal file
15
survey_crm_generation_training/models/survey_user_input.py
Normal file
@@ -0,0 +1,15 @@
|
||||
# Copyright 2022 Tecnativa - David Vidal
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
from odoo import fields, models, _
|
||||
|
||||
|
||||
class SurveyUserInput(models.Model):
|
||||
_inherit = "survey.user_input"
|
||||
|
||||
def _create_opportunity_post_process(self):
|
||||
"""After lead creation from survey answer (module survey_crm_generation),
|
||||
if answer (survey_user_input) contains event_products_ids, copy it in lead.
|
||||
"""
|
||||
self.opportunity_id.event_products_ids = self.event_products_ids.ids
|
||||
|
||||
return super(SurveyUserInput, self)._create_opportunity_post_process()
|
Reference in New Issue
Block a user