From c3acf2065e24d7c51593eee753f59b95045b7756 Mon Sep 17 00:00:00 2001 From: clementthomas Date: Tue, 9 Jan 2024 11:55:20 +0100 Subject: [PATCH] [IMP] big refactoring : use event_type instead of product_product --- .../__manifest__.py | 2 +- survey_crm_generation_training/i18n/fr.po | 6 +----- .../models/crm_lead.py | 2 +- .../models/survey_user_input.py | 4 ++-- .../views/crm_lead_views.xml | 12 +++++------ survey_event_base/models/survey_user_input.py | 20 +++++++++---------- .../models/survey_user_input.py | 2 +- 7 files changed, 22 insertions(+), 26 deletions(-) diff --git a/survey_crm_generation_training/__manifest__.py b/survey_crm_generation_training/__manifest__.py index 5d403f4..22cdd93 100644 --- a/survey_crm_generation_training/__manifest__.py +++ b/survey_crm_generation_training/__manifest__.py @@ -19,7 +19,7 @@ Customize lead creation from survey according to trainings "category": "", "depends": ["event","survey_crm_generation","survey_event_registration_generation","survey_event_base"], "data": [ - "views/crm_lead_views.xml" + "views/crm_lead_views.xml", ], "installable": True, "auto_install":True diff --git a/survey_crm_generation_training/i18n/fr.po b/survey_crm_generation_training/i18n/fr.po index 650cee7..f14241b 100644 --- a/survey_crm_generation_training/i18n/fr.po +++ b/survey_crm_generation_training/i18n/fr.po @@ -26,11 +26,7 @@ msgstr "" " Réponses\n" " " -#. module: survey_crm_generation_training -#: model:ir.model.fields,field_description:survey_crm_generation_training.field_crm_lead__event_products_ids -#: model_terms:ir.ui.view,arch_db:survey_crm_generation_training.view_crm_case_opportunities_filter_survey_crm_generation_training -msgid "Event product" -msgstr "Produit de formation" + #. module: survey_crm_generation_training #: model:ir.model,name:survey_crm_generation_training.model_crm_lead diff --git a/survey_crm_generation_training/models/crm_lead.py b/survey_crm_generation_training/models/crm_lead.py index 10c645d..fa29479 100644 --- a/survey_crm_generation_training/models/crm_lead.py +++ b/survey_crm_generation_training/models/crm_lead.py @@ -6,7 +6,7 @@ from odoo import fields, models class CrmLead(models.Model): _inherit = "crm.lead" - event_products_ids = fields.Many2many('product.product', string='Event product') + event_type_ids = fields.Many2many('event.type', string='Formation') def action_view_survey_user_input_id(self): diff --git a/survey_crm_generation_training/models/survey_user_input.py b/survey_crm_generation_training/models/survey_user_input.py index ad83ffc..a83f84d 100644 --- a/survey_crm_generation_training/models/survey_user_input.py +++ b/survey_crm_generation_training/models/survey_user_input.py @@ -8,8 +8,8 @@ class SurveyUserInput(models.Model): 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. + if answer (survey_user_input) contains event_type_ids, copy it in lead. """ - self.opportunity_id.event_products_ids = self.event_products_ids.ids + self.opportunity_id.event_type_ids = self.event_type_ids.ids return super(SurveyUserInput, self)._create_opportunity_post_process() diff --git a/survey_crm_generation_training/views/crm_lead_views.xml b/survey_crm_generation_training/views/crm_lead_views.xml index c7bf7f7..7137bce 100644 --- a/survey_crm_generation_training/views/crm_lead_views.xml +++ b/survey_crm_generation_training/views/crm_lead_views.xml @@ -6,10 +6,10 @@ crm.lead - + - + @@ -37,9 +37,7 @@ @@ -54,8 +52,10 @@ - + + + diff --git a/survey_event_base/models/survey_user_input.py b/survey_event_base/models/survey_user_input.py index 3ab4e18..f3963ce 100644 --- a/survey_event_base/models/survey_user_input.py +++ b/survey_event_base/models/survey_user_input.py @@ -16,7 +16,7 @@ class SurveyUserInput(models.Model): _inherit = 'survey.user_input' events_ids = fields.Many2many('event.event', string='Events', compute="compute_events_ids", search="search_events_ids") #related events - event_products_ids = fields.Many2many('product.product', string='Event products', compute="compute_event_products_ids", search="search_event_products_ids") #related event products + event_type_ids = fields.Many2many('event.type', string='Formations', compute="compute_event_type_ids", search="search_event_type_ids") #related event products def search_events_ids(self, operator, value): user_input_ids = set() @@ -27,7 +27,7 @@ class SurveyUserInput(models.Model): @api.depends('user_input_line_ids') def compute_events_ids(self): - """set events_ids as answer of "event" question + """get all answers of type "event.event" """ for user_input in self: event_ids = [] @@ -38,9 +38,9 @@ class SurveyUserInput(models.Model): user_input.events_ids = event_ids - def search_event_products_ids(self, operator, value): + def search_event_type_ids(self, operator, value): user_input_ids = set() - user_input_lines = self.env['survey.user_input.line'].search([('record_reference_model','=','product.product'),('record_reference','=', value)]) + user_input_lines = self.env['survey.user_input.line'].search([('record_reference_model','=','event.type'),('record_reference','=', value)]) for user_input_line in user_input_lines: user_input_ids.add(user_input_line.user_input_id.id) return [('id',operator,list(user_input_ids))] @@ -48,14 +48,14 @@ class SurveyUserInput(models.Model): @api.depends('user_input_line_ids') - def compute_event_products_ids(self): - """set event_products_ids as answer of "event product" or "multiple event products" question + def compute_event_type_ids(self): + """get all answers of type "event.type" """ for user_input in self: - event_products_ids = [] + event_type_ids = [] for user_input in self: for user_input_line in user_input.user_input_line_ids: - if user_input_line.record_reference_model == 'product.product': - event_products_ids.append(user_input_line.record_reference) - user_input.event_products_ids = event_products_ids + if user_input_line.record_reference_model == 'event.type': + event_type_ids.append(user_input_line.record_reference) + user_input.event_type_ids = event_type_ids diff --git a/survey_event_speaker_generation/models/survey_user_input.py b/survey_event_speaker_generation/models/survey_user_input.py index aa41c97..a8138c4 100644 --- a/survey_event_speaker_generation/models/survey_user_input.py +++ b/survey_event_speaker_generation/models/survey_user_input.py @@ -33,7 +33,7 @@ class SurveyUserInput(models.Model): for user_input in self.filtered(lambda r: r.survey_id.generate_speaker and not r.speaker_id and r.partner_id): user_input.update({"speaker_id": user_input.partner_id.id}) for event in user_input.events_ids: - event.speakers = [Command.link(user_input.speaker_id.id)] + event.speaker_ids = [Command.link(user_input.speaker_id.id)] user_input._create_speaker_post_process(user_input.speaker_id)