[REF] event: merge phone and mobile fields on registration

RATIONALE

Merge two phone-related field on registration as they overlap. Having only
one is sufficient for contact-oriented model like registration.

SPECIFICATIONS

Registration model currently holds two phone field, phone and mobile. This
leads to having records with sometimes phone, sometimes mobile being filled.
This makes phone flows not easy: we have to define fallbacks (use phone or
mobile), data is not always synchronized, ... in the end what event users
need is one phone field to be able to communicate with attendees. Having
only one field is sufficient and simplifies the model.

Keep only one phone field, instead of two. Merge phone and mobile into a single
one, keeping phone as first value when having both available e.g. when
synchronizing with the partner.

Task-3366899

Part-of: odoo/odoo#128232
Co-authored-by: "Jeremy Hennecart" <jeh@odoo.com>
This commit is contained in:
Thibault Delavallée
2023-09-27 17:40:55 +00:00
co-authored by Jeremy Hennecart
parent 69e2d08d4e
commit 643df62f12
30 changed files with 116 additions and 188 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
{
'name': 'Events Organization',
'version': '1.7',
'version': '1.8',
'website': 'https://www.odoo.com/app/events',
'category': 'Marketing/Events',
'summary': 'Trainings, Conferences, Meetings, Exhibitions, Registrations',
+15 -33
View File
@@ -28,12 +28,11 @@ class EventRegistration(models.Model):
partner_id = fields.Many2one('res.partner', string='Booked by', tracking=1)
name = fields.Char(
string='Attendee Name', index='trigram',
compute='_compute_name', readonly=False, store=True, tracking=10)
email = fields.Char(string='Email', compute='_compute_email', readonly=False, store=True, tracking=11)
phone = fields.Char(string='Phone', compute='_compute_phone', readonly=False, store=True, tracking=12)
mobile = fields.Char(string='Mobile', compute='_compute_mobile', readonly=False, store=True, tracking=13)
compute='_compute_name', readonly=False, store=True, tracking=2)
email = fields.Char(string='Email', compute='_compute_email', readonly=False, store=True, tracking=3)
phone = fields.Char(string='Phone', compute='_compute_phone', readonly=False, store=True, tracking=4)
company_name = fields.Char(
string='Company Name', compute='_compute_company_name', readonly=False, store=True, tracking=14)
string='Company Name', compute='_compute_company_name', readonly=False, store=True, tracking=5)
# organization
date_closed = fields.Datetime(
string='Attended Date', compute='_compute_date_closed',
@@ -48,7 +47,7 @@ class EventRegistration(models.Model):
state = fields.Selection([
('draft', 'Unconfirmed'), ('cancel', 'Cancelled'),
('open', 'Confirmed'), ('done', 'Attended')],
string='Status', default='draft', readonly=True, copy=False, tracking=True)
string='Status', default='draft', readonly=True, copy=False, tracking=6)
@api.depends('partner_id')
def _compute_name(self):
@@ -56,7 +55,7 @@ class EventRegistration(models.Model):
if not registration.name and registration.partner_id:
registration.name = registration._synchronize_partner_values(
registration.partner_id,
fnames=['name']
fnames={'name'},
).get('name') or False
@api.depends('partner_id')
@@ -65,26 +64,18 @@ class EventRegistration(models.Model):
if not registration.email and registration.partner_id:
registration.email = registration._synchronize_partner_values(
registration.partner_id,
fnames=['email']
fnames={'email'},
).get('email') or False
@api.depends('partner_id')
def _compute_phone(self):
for registration in self:
if not registration.phone and registration.partner_id:
registration.phone = registration._synchronize_partner_values(
partner_values = registration._synchronize_partner_values(
registration.partner_id,
fnames=['phone']
).get('phone') or False
@api.depends('partner_id')
def _compute_mobile(self):
for registration in self:
if not registration.mobile and registration.partner_id:
registration.mobile = registration._synchronize_partner_values(
registration.partner_id,
fnames=['mobile']
).get('mobile') or False
fnames={'phone', 'mobile'},
)
registration.phone = partner_values.get('phone') or partner_values.get('mobile') or False
@api.depends('partner_id')
def _compute_company_name(self):
@@ -92,7 +83,7 @@ class EventRegistration(models.Model):
if not registration.company_name and registration.partner_id:
registration.company_name = registration._synchronize_partner_values(
registration.partner_id,
fnames=['company_name']
fnames={'company_name'},
).get('company_name') or False
@api.depends('state')
@@ -111,7 +102,7 @@ class EventRegistration(models.Model):
def _synchronize_partner_values(self, partner, fnames=None):
if fnames is None:
fnames = ['name', 'email', 'phone', 'mobile']
fnames = {'name', 'email', 'phone', 'mobile'}
if partner:
contact_id = partner.address_get().get('contact', False)
if contact_id:
@@ -125,12 +116,6 @@ class EventRegistration(models.Model):
country = self.partner_id.country_id or self.event_id.country_id or self.env.company.country_id
self.phone = self._phone_format(fname='phone', country=country) or self.phone
@api.onchange('mobile', 'event_id', 'partner_id')
def _onchange_mobile_validation(self):
if self.mobile:
country = self.partner_id.country_id or self.event_id.country_id or self.env.company.country_id
self.mobile = self._phone_format(fname='mobile', country=country)
# ------------------------------------------------------------
# CRUD
# ------------------------------------------------------------
@@ -141,7 +126,7 @@ class EventRegistration(models.Model):
all_partner_ids = set(values['partner_id'] for values in vals_list if values.get('partner_id'))
all_event_ids = set(values['event_id'] for values in vals_list if values.get('event_id'))
for values in vals_list:
if not values.get('phone') and not values.get('mobile'):
if not values.get('phone'):
continue
related_country = self.env['res.country']
@@ -151,10 +136,7 @@ class EventRegistration(models.Model):
related_country = self.env['event.event'].with_prefetch(all_event_ids).browse(values['event_id']).country_id
if not related_country:
related_country = self.env.company.country_id
for fname in {'mobile', 'phone'}:
if values.get(fname):
values[fname] = self._phone_format(number=values[fname], country=related_country) or values[fname]
values['phone'] = self._phone_format(number=values['phone'], country=related_country) or values['phone']
registrations = super(EventRegistration, self).create(vals_list)
+4 -4
View File
@@ -99,8 +99,8 @@ class EventCase(common.TransactionCase):
registrations = cls.env['event.registration'].create([{
'create_date': create_date,
'event_id': event.id,
'name': 'Test Registration %s' % x,
'email': '_test_reg_%s@example.com' % x,
'phone': '04560000%s%s' % (x, x),
} for x in range(0, reg_count)])
'name': f'Test Registration {idx}',
'email': f'_test_reg_{idx}@example.com',
'phone': f'04560000{idx}{idx}',
} for idx in range(0, reg_count)])
return registrations
+38 -42
View File
@@ -710,79 +710,75 @@ class TestEventRegistrationPhone(EventCase):
""" Test onchange on phone / mobile, should try to format number """
event = self.test_event.with_user(self.env.user)
lead_form = Form(self.env['event.registration'])
lead_form.event_id = event
lead_form.mobile = '7200000011'
lead_form.phone = '7200000000'
self.assertEqual(lead_form.mobile, '+917200000011')
self.assertEqual(lead_form.phone, '+917200000000')
reg_form = Form(self.env['event.registration'])
reg_form.event_id = event
reg_form.phone = '7200000000'
self.assertEqual(reg_form.phone, '+917200000000')
@users('user_eventregistrationdesk')
def test_registration_phone_format(self):
""" Test phone formatting: based on partner (BE numbers) or event
(IN numbers) or company (BE numbers). """
partner_mobileonly = self.env['res.partner'].sudo().create({
'name': 'Constantin Customer 3 Mobile',
'email': 'constantin3test.example.com',
'country_id': self.env.ref('base.be').id,
'phone': False,
'mobile': '0456987654',
})
event = self.test_event.with_user(self.env.user)
# customer_id, mobile, phone -> based on partner or event country
# customer_id, phone -> based on partner or event country
sources = [
(self.event_customer.id, None, None), # BE local on partner
(self.event_customer2.id, None, None), # BE local on partner
(self.event_customer2.id, '0456001122', None), # BE local + on partner
(False, '0456778899', '+32456778899'), # BE local + BE global
(False, '7200000000', False), # IN local
(False, False, '7200000011'), # IN local
(False, '7200000000', '7200000011'), # IN local
(False, '+917200000088', '+917200000099'), # IN global
(self.event_customer.id, None), # BE local on partner
(self.event_customer2.id, None), # BE local on partner
(partner_mobileonly.id, None), # BE local on partner
(self.event_customer2.id, '0456001122'), # BE local + on partner
(False, '0456778899'), # BE local
(False, '7200000000'), # IN local
(False, '+917200000088'), # IN global
]
# mobile, phone
# expected phone
expected = [
(False, '0485112233'), # partner values, no format
('0456654321', '0456987654'), # partner values, no format
('+32456001122', '0456987654'), # BE on partner / partner value, no format
('0456778899', '+32456778899'), # IN on event -> cannot format BE
('+917200000000', False), # IN on event
(False, '+917200000011'), # IN on event
('+917200000000', '+917200000011'), # IN on event
('+917200000088', '+917200000099'), # already formatted
'0485112233', # partner values, no format (phone only)
'0456987654', # partner values, no format (both: phone wins)
'0456987654', # partner values, no format (mobile only)
'+32456001122', # BE on partner
'0456778899', # IN on event -> cannot format BE
'+917200000000', # IN on event
'+917200000088', # already formatted
]
for (partner_id, mobile, phone), (exp_mobile, exp_phone) in zip(sources, expected):
with self.subTest(partner_id=partner_id, mobile=mobile, phone=phone):
for (partner_id, phone), exp_phone in zip(sources, expected):
with self.subTest(partner_id=partner_id, phone=phone):
create_vals = {
'event_id': event.id,
'partner_id': partner_id,
}
if mobile is not None:
create_vals['mobile'] = mobile
if phone is not None:
create_vals['phone'] = phone
reg = self.env['event.registration'].create(create_vals)
self.assertEqual(reg.mobile, exp_mobile)
self.assertEqual(reg.phone, exp_phone)
# no country on event -> based on partner or event company country
self.test_event.write({'address_id': False})
expected = [
(False, '0485112233'), # partner values, no format
('0456654321', '0456987654'), # partner values, no format
('+32456001122', '0456987654'), # BE on partner / partner value, no format
('+32456778899', '+32456778899'), # BE on company
('7200000000', False), # BE on company -> cannot format IN
(False, '7200000011'), # BE on company -> cannot format IN
('7200000000', '7200000011'), # BE on company -> cannot format IN
('+917200000088', '+917200000099'), # already formatted
'0485112233', # partner values, no format (phone only)
'0456987654', # partner values, no format (both: phone wins)
'0456987654', # partner values, no format (mobile only)
'+32456001122', # BE on company
'+32456778899', # BE on company
'7200000000', # BE on company -> cannot format IN
'+917200000088', # already formatted
]
for (partner_id, mobile, phone), (exp_mobile, exp_phone) in zip(sources, expected):
with self.subTest(partner_id=partner_id, mobile=mobile, phone=phone):
for (partner_id, phone), exp_phone in zip(sources, expected):
with self.subTest(partner_id=partner_id, phone=phone):
create_vals = {
'event_id': event.id,
'partner_id': partner_id,
}
if mobile is not None:
create_vals['mobile'] = mobile
if phone is not None:
create_vals['phone'] = phone
reg = self.env['event.registration'].create(create_vals)
self.assertEqual(reg.mobile, exp_mobile)
self.assertEqual(reg.phone, exp_phone)
@@ -15,7 +15,6 @@
<field name="partner_id" optional="hide"/>
<field name="email" optional="show"/>
<field name="phone" optional="show"/>
<field name="mobile" optional="hide"/>
<field name="company_name" optional="hide"/>
<field name="event_id" column_invisible="context.get('default_event_id')" readonly="state != 'draft'"/>
<field name="event_ticket_id" domain="[('event_id', '=', event_id)]" readonly="state != 'draft'"/>
@@ -64,8 +63,7 @@
<group string="Attendee" name="attendee">
<field class="o_text_overflow" name="name"/>
<field name="email"/>
<field name="phone" class="o_force_ltr" widget="phone" options="{'enable_sms': false}"/>
<field name="mobile" class="o_force_ltr" widget="phone"/>
<field name="phone" class="o_force_ltr" widget="phone" options="{'enable_sms': true}"/>
<field name="company_name" placeholder='e.g. "Azure Interior"'/>
</group>
<group string="Event Information" name="event">
+1 -1
View File
@@ -4,7 +4,7 @@
{
'name': "Events Booths",
'category': 'Marketing/Events',
'version': '1.0',
'version': '1.1',
'summary': "Manage event booths",
'description': """
Create booths for your favorite event.
@@ -25,10 +25,6 @@
<li t-if="contact_email">
<b>Renter Email</b>: <span t-out="contact_email"/>
</li>
<t t-set="contact_mobile" t-value="booth.contact_mobile"/>
<li t-if="contact_mobile">
<b>Renter Mobile</b>: <span t-out="contact_mobile"/>
</li>
<t t-set="contact_phone" t-value="booth.contact_phone"/>
<li t-if="contact_phone">
<b>Renter Phone</b>: <span t-out="contact_phone"/>
+1 -8
View File
@@ -21,7 +21,6 @@ class EventBooth(models.Model):
partner_id = fields.Many2one('res.partner', string='Renter', tracking=True, copy=False)
contact_name = fields.Char('Renter Name', compute='_compute_contact_name', readonly=False, store=True, copy=False)
contact_email = fields.Char('Renter Email', compute='_compute_contact_email', readonly=False, store=True, copy=False)
contact_mobile = fields.Char('Renter Mobile', compute='_compute_contact_mobile', readonly=False, store=True, copy=False)
contact_phone = fields.Char('Renter Phone', compute='_compute_contact_phone', readonly=False, store=True, copy=False)
# state
state = fields.Selection(
@@ -42,17 +41,11 @@ class EventBooth(models.Model):
if not booth.contact_email:
booth.contact_email = booth.partner_id.email or False
@api.depends('partner_id')
def _compute_contact_mobile(self):
for booth in self:
if not booth.contact_mobile:
booth.contact_mobile = booth.partner_id.mobile or False
@api.depends('partner_id')
def _compute_contact_phone(self):
for booth in self:
if not booth.contact_phone:
booth.contact_phone = booth.partner_id.phone or False
booth.contact_phone = booth.partner_id.phone or booth.partner_id.mobile or False
@api.depends('state')
def _compute_is_available(self):
@@ -40,7 +40,6 @@ class TestEventData(TestEventBoothCommon):
self.assertEqual(booth.contact_name, customer.name)
self.assertEqual(booth.contact_email, customer_email)
self.assertEqual(booth.contact_phone, customer.phone)
self.assertFalse(booth.contact_mobile, 'Data has no mobile')
booth.write({
'contact_email': '"New Emails" <new.email@test.example.com',
@@ -25,7 +25,6 @@
<field name="contact_name"/>
<field name="contact_email" widget="email"/>
<field name="contact_phone" widget="phone"/>
<field name="contact_mobile" widget="phone"/>
</group>
</group>
</sheet>
@@ -75,7 +74,6 @@
<field name="contact_name" optional="hide"/>
<field name="contact_email" optional="hide"/>
<field name="contact_phone" optional="hide"/>
<field name="contact_mobile" optional="hide"/>
<field name="state" widget="badge"
decoration-info="state == 'available'"
decoration-success="state == 'unavailable'"/>
+1 -1
View File
@@ -4,7 +4,7 @@
{
'name': "Events Booths Sales",
'category': 'Marketing/Events',
'version': '1.1',
'version': '1.2',
'summary': "Manage event booths sale",
'description': """
Sell your event booths and track payments on sale orders.
@@ -19,7 +19,6 @@ class EventBoothRegistration(models.Model):
contact_name = fields.Char(string='Contact Name', compute='_compute_contact_name', readonly=False, store=True)
contact_email = fields.Char(string='Contact Email', compute='_compute_contact_email', readonly=False, store=True)
contact_phone = fields.Char(string='Contact Phone', compute='_compute_contact_phone', readonly=False, store=True)
contact_mobile = fields.Char(string='Contact Mobile', compute='_compute_contact_mobile', readonly=False, store=True)
_sql_constraints = [('unique_registration', 'unique(sale_order_line_id, event_booth_id)',
'There can be only one registration for a booth by sale order line')]
@@ -40,17 +39,11 @@ class EventBoothRegistration(models.Model):
def _compute_contact_phone(self):
for registration in self:
if not registration.contact_phone:
registration.contact_phone = registration.partner_id.phone or False
@api.depends('partner_id')
def _compute_contact_mobile(self):
for registration in self:
if not registration.contact_mobile:
registration.contact_mobile = registration.partner_id.mobile or False
registration.contact_phone = registration.partner_id.phone or registration.partner_id.mobile or False
@api.model
def _get_fields_for_booth_confirmation(self):
return ['sale_order_line_id', 'partner_id', 'contact_name', 'contact_email', 'contact_phone', 'contact_mobile']
return ['sale_order_line_id', 'partner_id', 'contact_name', 'contact_email', 'contact_phone']
def action_confirm(self):
for registration in self:
@@ -106,9 +106,6 @@ class TestEventBoothSale(TestEventBoothSaleWData):
self.assertEqual(
booth.contact_name, self.event_customer.name,
"Booth contact name should be the same as sale order customer name.")
self.assertEqual(
booth.contact_mobile, self.event_customer.mobile,
"Booth contact mobile should be the same as sale order customer mobile.")
self.assertEqual(
booth.contact_phone, self.event_customer.phone,
"Booth contact phone should be the same as sale order customer phone.")
@@ -19,7 +19,6 @@
<field name="contact_name"/>
<field name="contact_email"/>
<field name="contact_phone"/>
<field name="contact_mobile"/>
</group>
</group>
</sheet>
@@ -38,7 +37,6 @@
<field name="contact_name" optional="hide"/>
<field name="contact_email" optional="hide"/>
<field name="contact_phone" optional="hide"/>
<field name="contact_mobile" optional="hide"/>
</tree>
</field>
</record>
+1 -1
View File
@@ -55,7 +55,7 @@ class EventLeadRule(models.Model):
If conditions are met, leads are created with pre-filled informations defined
on the rule (type, user_id, team_id). Contact information coming from the
registrations are computed (customer, name, email, phone, mobile, contact_name).
registrations are computed (customer, name, email, phone, contact_name).
SPECIFICATIONS: OTHER POINTS
+11 -5
View File
@@ -215,26 +215,32 @@ class EventRegistration(models.Model):
if (not phone_formatted or not partner_phone_formatted) and self.phone != valid_partner.phone:
valid_partner = self.env['res.partner']
registration_phone = self._find_first_notnull('phone')
if valid_partner:
contact_vals = self.env['crm.lead']._prepare_values_from_partner(valid_partner)
# force email_from / phone only if not set on partner because those fields are now synchronized automatically
if not valid_partner.email:
contact_vals['email_from'] = self._find_first_notnull('email')
if not valid_partner.phone:
contact_vals['phone'] = self._find_first_notnull('phone')
contact_vals['phone'] = registration_phone
else:
# don't force email_from + partner_id because those fields are now synchronized automatically
contact_vals = {
'contact_name': self._find_first_notnull('name'),
'email_from': self._find_first_notnull('email'),
'phone': self._find_first_notnull('phone'),
'phone': registration_phone,
'lang_id': False,
}
contact_vals.update({
'name': "%s - %s" % (self.event_id.name, valid_partner.name or self._find_first_notnull('name') or self._find_first_notnull('email')),
'partner_id': valid_partner.id,
'mobile': valid_partner.mobile or self._find_first_notnull('mobile'),
})
# try to avoid copying registration_phone on both phone and mobile fields
# as would be noise; pay attention partner.hone is propagated through compute
mobile = valid_partner.mobile or registration_phone
if mobile != contact_vals.get('phone', valid_partner.phone):
contact_vals['mobile'] = valid_partner.mobile or registration_phone
return contact_vals
def _get_lead_description(self, prefix='', line_counter=True, line_suffix=''):
@@ -328,12 +334,12 @@ class EventRegistration(models.Model):
""" Get registration fields linked to lead contact. Those are used notably
to see if an update of lead is necessary or to fill contact values
in ``_get_lead_contact_values())`` """
return ['name', 'email', 'phone', 'mobile', 'partner_id']
return ['name', 'email', 'phone', 'partner_id']
@api.model
def _get_lead_description_fields(self):
""" Get registration fields linked to lead description. Those are used
notablyto see if an update of lead is necessary or to fill description
notably to see if an update of lead is necessary or to fill description
in ``_get_lead_description())`` """
return ['name', 'email', 'phone']
+3 -2
View File
@@ -94,14 +94,15 @@ class EventCrmCase(TestCrmCommon, EventCase):
self.assertEqual(lead.referred, event.name)
# registration information
registration_phone = registrations._find_first_notnull('phone')
self.assertEqual(lead.partner_id, partner)
self.assertEqual(lead.name, '%s - %s' % (event.name, expected_reg_name))
self.assertNotIn('False', lead.name) # avoid a "Dear False" like construct ^^ (this assert is serious and intended)
self.assertEqual(lead.contact_name, expected_contact_name)
self.assertEqual(lead.partner_name, expected_partner_name)
self.assertEqual(lead.email_from, partner.email if partner and partner.email else registrations._find_first_notnull('email'))
self.assertEqual(lead.phone, partner.phone if partner and partner.phone else registrations._find_first_notnull('phone'))
self.assertEqual(lead.mobile, partner.mobile if partner and partner.mobile else registrations._find_first_notnull('mobile'))
self.assertEqual(lead.phone, partner.phone if partner and partner.phone else registration_phone)
self.assertEqual(lead.mobile, partner.mobile if partner and partner.mobile else ((registration_phone != lead.phone) and registration_phone))
# description: to improve
self.assertNotIn('False', lead.description) # avoid a "Dear False" like construct ^^ (this assert is serious and intended)
+9 -11
View File
@@ -2,10 +2,12 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.event_crm.tests.common import TestEventCrmCommon
from odoo.tests import tagged
from odoo.tests.common import users
from odoo.tools import mute_logger
@tagged('event_flow')
class TestEventCrmFlow(TestEventCrmCommon):
@classmethod
@@ -103,17 +105,16 @@ class TestEventCrmFlow(TestEventCrmCommon):
def test_event_crm_flow_per_attendee_single_wo_partner(self):
""" Single registration, attendee based, no partner involved, check
contact info propagation """
for name, email, mobile, phone in [
('My Name', 'super.email@test.example.com', '0456442211', '0456332211'),
(False, 'super.email@test.example.com', False, '0456442211'),
('"My Name"', '"My Name" <my.name@test.example.com>', False, False),
for name, email, phone in [
('My Name', 'super.email@test.example.com', '0456442211'),
(False, 'super.email@test.example.com', False),
('"My Name"', '"My Name" <my.name@test.example.com>', False),
]:
with self.subTest(name=name, email=email, mobile=mobile, phone=phone):
with self.subTest(name=name, email=email, phone=phone):
registration = self.env['event.registration'].create({
'name': name,
'partner_id': False,
'email': email,
'mobile': mobile,
'phone': phone,
'event_id': self.event_0.id,
})
@@ -123,8 +124,7 @@ class TestEventCrmFlow(TestEventCrmCommon):
registration = self.env['event.registration'].create({
'partner_id': self.event_customer.id,
'email': 'other.email@test.example.com',
'phone': False,
'mobile': '0456112233',
'phone': '0456112233',
'event_id': self.event_0.id,
})
self.assertLeadConvertion(self.test_rule_attendee, registration, partner=None)
@@ -164,8 +164,7 @@ class TestEventCrmFlow(TestEventCrmCommon):
registration = self.env['event.registration'].create({
'partner_id': self.event_customer.id,
'email': 'trigger.test@not.test.example.com',
'phone': False,
'mobile': '0456112233',
'phone': '0456112233',
'event_id': self.event_0.id,
})
@@ -192,7 +191,6 @@ class TestEventCrmFlow(TestEventCrmCommon):
'partner_id': False,
'email': 'super.email@test.example.com',
'phone': False,
'mobile': '0456332211',
'event_id': self.event_0.id,
})
self.assertEqual(len(self.test_rule_order.lead_ids), 1)
+1 -1
View File
@@ -2,7 +2,7 @@
{
'name': 'Events Sales',
'version': '1.2',
'version': '1.3',
'category': 'Marketing/Events',
'website': 'https://www.odoo.com/app/events',
'description': """
+3 -9
View File
@@ -110,7 +110,7 @@ class TestEventSale(TestEventSaleCommon):
'sale_order_line_id': ticket1_line.id,
})
self.assertEqual(ticket1_reg1.partner_id, self.event_customer)
for field in ['name', 'email', 'phone', 'mobile']:
for field in ['name', 'email', 'phone']:
self.assertEqual(ticket1_reg1[field], self.event_customer[field])
# EVENT REGISTRATION EDITOR
@@ -126,7 +126,7 @@ class TestEventSale(TestEventSaleCommon):
# check line linked to existing registration (ticket1_reg1)
ticket1_editor_reg1 = editor.event_registration_ids.filtered(lambda line: line.registration_id)
for field in ['name', 'email', 'phone', 'mobile']:
for field in ['name', 'email', 'phone']:
self.assertEqual(ticket1_editor_reg1[field], ticket1_reg1[field])
# check new lines
@@ -144,7 +144,6 @@ class TestEventSale(TestEventSaleCommon):
ticket1_editor_other[1].write({
'name': 'ManualEntry2',
'email': 'manual.email.2@test.example.com',
'mobile': '+32456222222',
})
self.assertFalse(editor.seats_available_insufficient)
@@ -170,14 +169,9 @@ class TestEventSale(TestEventSaleCommon):
set(ticket1_new_reg.mapped('phone')),
set(['+32456111111', self.event_customer._phone_format(fname='phone')])
)
self.assertEqual(
set(ticket1_new_reg.mapped('mobile')),
set(['+32456222222', self.event_customer._phone_format(fname='mobile')])
)
for field in ['name', 'email']:
self.assertEqual(ticket2_new_reg[field], self.event_customer[field])
for field in ['phone', 'mobile']:
self.assertEqual(ticket2_new_reg[field], self.event_customer._phone_format(fname=field))
self.assertEqual(ticket2_new_reg['phone'], self.event_customer._phone_format(fname='phone'))
# ADDING MANUAL LINES ON SO
# ------------------------------------------------------------
@@ -67,7 +67,6 @@ class RegistrationEditor(models.TransientModel):
'name': reg.name,
'email': reg.email,
'phone': reg.phone,
'mobile': reg.mobile,
'sale_order_line_id': so_line.id,
}])
for count in range(int(so_line.product_uom_qty) - len(existing_registrations)):
@@ -78,7 +77,6 @@ class RegistrationEditor(models.TransientModel):
'name': so_line.order_partner_id.name,
'email': so_line.order_partner_id.email,
'phone': so_line.order_partner_id.phone,
'mobile': so_line.order_partner_id.mobile,
}])
res['event_registration_ids'] = attendee_list
res = self._convert_to_write(res)
@@ -114,7 +112,6 @@ class RegistrationEditorLine(models.TransientModel):
event_ticket_id = fields.Many2one('event.event.ticket', string='Event Ticket')
email = fields.Char(string='Email')
phone = fields.Char(string='Phone')
mobile = fields.Char(string='Mobile')
name = fields.Char(string='Name')
def get_registration_data(self):
@@ -124,8 +121,7 @@ class RegistrationEditorLine(models.TransientModel):
'event_ticket_id': self.event_ticket_id.id,
'partner_id': self.editor_id.sale_order_id.partner_id.id,
'name': self.name or self.editor_id.sale_order_id.partner_id.name,
'phone': self.phone or self.editor_id.sale_order_id.partner_id.phone,
'mobile': self.mobile or self.editor_id.sale_order_id.partner_id.mobile,
'phone': self.phone or self.editor_id.sale_order_id.partner_id.phone or self.editor_id.sale_order_id.partner_id.mobile,
'email': self.email or self.editor_id.sale_order_id.partner_id.email,
'sale_order_id': self.editor_id.sale_order_id.id,
'sale_order_line_id': self.sale_order_line_id.id,
@@ -22,7 +22,6 @@
<field name="event_ticket_id" domain="[('event_id', '=', event_id)]" readonly='1' force_save="1"/>
<field name="name"/>
<field name="email"/>
<field name="mobile" class="o_force_ltr"/>
<field name="phone" class="o_force_ltr"/>
<field name="sale_order_line_id" column_invisible="True"/>
</tree>
+16 -18
View File
@@ -250,39 +250,37 @@ class TestEventFullCommon(EventCrmCase, TestSalesCommon, MockVisitor):
], limit=1)
cls.customer_data = [
{'email': 'customer.email.%02d@test.example.com' % x,
'name': 'My Customer %02d' % x,
'mobile': '04569999%02d' % x,
{'email': f'customer.email.{idx:02d}@test.example.com',
'name': f'My Customer {idx:02d}',
'partner_id': False,
'phone': '04560000%02d' % x,
} for x in range(0, 10)
'phone': f'04560000{idx:02d}',
} for idx in range(0, 10)
]
cls.website_customer_data = [
{'email': 'website.email.%02d@test.example.com' % x,
'name': 'My Customer %02d' % x,
'mobile': '04569999%02d' % x,
{'email': f'website.email.{idx:02d}@test.example.com',
'name': f'My Customer {idx:02d}',
'partner_id': cls.env.ref('base.public_partner').id,
'phone': '04560000%02d' % x,
'phone': f'04560000{idx:02d}',
'registration_answer_ids': [
(0, 0, {
'question_id': cls.test_event.question_ids[0].id,
'value_answer_id': cls.test_event.question_ids[0].answer_ids[(x % 2)].id,
'value_answer_id': cls.test_event.question_ids[0].answer_ids[(idx % 2)].id,
}), (0, 0, {
'question_id': cls.test_event.question_ids[1].id,
'value_answer_id': cls.test_event.question_ids[1].answer_ids[(x % 2)].id,
'value_answer_id': cls.test_event.question_ids[1].answer_ids[(idx % 2)].id,
}), (0, 0, {
'question_id': cls.test_event.question_ids[2].id,
'value_text_box': 'CustomerAnswer%s' % x,
'value_text_box': f'CustomerAnswer{idx}',
})
],
} for x in range(0, 10)
} for idx in range(0, 10)
]
cls.partners = cls.env['res.partner'].create([
{'email': 'partner.email.%02d@test.example.com' % x,
'name': 'PartnerCustomer',
'mobile': '04569999%02d' % x,
'phone': '04560000%02d' % x,
} for x in range(0, 10)
{'email': f'partner.email.{idx:02d}@test.example.com',
'name': f'PartnerCustomer {idx:02d}',
'mobile': f'04569999{idx:02d}',
'phone': f'04560000{idx:02d}',
} for idx in range(0, 10)
])
def assertLeadConvertion(self, rule, registrations, partner=None, **expected):
@@ -306,7 +306,6 @@ class TestRegistrationPerformance(EventPerformanceCase):
with Form(self.env['event.registration']) as reg_form:
reg_form.event_id = event
reg_form.email = 'email.00@test.example.com'
reg_form.mobile = '0456999999'
reg_form.name = 'My Customer'
reg_form.phone = '0456000000'
_registration = reg_form.save()
@@ -14,7 +14,7 @@ class EventRegistration(models.Model):
domain=[('question_type', '=', 'simple_choice')])
def _get_website_registration_allowed_fields(self):
return {'name', 'phone', 'email', 'mobile', 'company_name', 'event_id', 'partner_id', 'event_ticket_id'}
return {'name', 'phone', 'email', 'company_name', 'event_id', 'partner_id', 'event_ticket_id'}
def _get_registration_summary(self):
res = super()._get_registration_summary()
@@ -39,7 +39,7 @@ class WebsiteVisitor(models.Model):
for visitor in self:
visitor.event_registration_count = visitor_mapping.get(visitor.id, 0)
@api.depends('event_registration_ids.email', 'event_registration_ids.mobile', 'event_registration_ids.phone')
@api.depends('event_registration_ids.email', 'event_registration_ids.phone')
def _compute_email_phone(self):
super(WebsiteVisitor, self)._compute_email_phone()
@@ -48,7 +48,7 @@ class WebsiteVisitor(models.Model):
if not visitor.email:
visitor.email = next((reg.email for reg in linked_registrations if reg.email), False)
if not visitor.mobile:
visitor.mobile = next((reg.mobile or reg.phone for reg in linked_registrations if reg.mobile or reg.phone), False)
visitor.mobile = next((reg.phone for reg in linked_registrations if reg.phone), False)
@api.depends('event_registration_ids')
def _compute_event_registered_ids(self):
@@ -17,7 +17,7 @@
<field name="model">event.registration</field>
<field name="inherit_id" ref="event.view_event_registration_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='mobile']" position="after">
<xpath expr="//field[@name='phone']" position="after">
<field name="visitor_id" groups="base.group_no_one"/>
</xpath>
<sheet position="inside">
@@ -58,7 +58,7 @@ class WebsiteEventBoothController(WebsiteEventController):
default_contact = {
'name': request.env.user.partner_id.name,
'email': request.env.user.partner_id.email,
'phone': request.env.user.partner_id.phone,
'phone': request.env.user.partner_id.phone or request.env.user.partner_id.mobile,
'mobile': request.env.user.partner_id.mobile,
}
else:
@@ -128,16 +128,13 @@ class WebsiteEventBoothController(WebsiteEventController):
partner.name = kwargs['contact_name']
if not partner.phone and kwargs.get('contact_phone'):
partner.phone = kwargs['contact_phone']
if not partner.mobile and kwargs.get('contact_mobile'):
partner.mobile = kwargs['contact_mobile']
else:
partner = request.env.user.partner_id
return {
'partner_id': partner.id,
'contact_name': kwargs.get('contact_name') or partner.name,
'contact_email': kwargs.get('contact_email') or partner.email,
'contact_mobile': kwargs.get('contact_mobile') or partner.mobile,
'contact_phone': kwargs.get('contact_phone') or partner.phone,
'contact_phone': kwargs.get('contact_phone') or partner.phone or partner.mobile,
}
def _prepare_booth_registration_success_values(self, event_name, booth_values):
@@ -148,7 +145,6 @@ class WebsiteEventBoothController(WebsiteEventController):
'name': booth_values.get('contact_name'),
'email': booth_values.get('contact_email'),
'phone': booth_values.get('contact_phone'),
'mobile': booth_values.get('contact_mobile'),
},
})
@@ -44,13 +44,6 @@
t-att-value="default_contact.get('phone', '')"/>
</div>
</div>
<div class="row mb-3">
<label class="col-form-label col-sm-auto">Mobile</label>
<div class="col-sm">
<input type="tel" class="form-control" name="contact_mobile"
t-att-value="default_contact.get('mobile', '')"/>
</div>
</div>
</div>
<div class="o_wbooth_registration_error_section alert alert-danger d-none mt-4" role="alert">
<i class="fa fa-exclamation-triangle me-2" role="img" aria-label="Error" title="Error"/>
@@ -15,8 +15,6 @@ class WebsiteEventBoothController(WebsiteEventController):
booth_values['contact_email'] = kwargs.get('sponsor_email')
if not booth_values.get('contact_name'):
booth_values['contact_name'] = kwargs.get('sponsor_name')
if not booth_values.get('contact_mobile'):
booth_values['contact_mobile'] = kwargs.get('sponsor_mobile')
if not booth_values.get('contact_phone'):
booth_values['contact_phone'] = kwargs.get('sponsor_phone')
@@ -36,7 +34,7 @@ class WebsiteEventBoothController(WebsiteEventController):
sponsor_values = {
'sponsor_name': kwargs.get('sponsor_name') or booth_values.get('contact_name'),
'sponsor_email': kwargs.get('sponsor_email') or booth_values.get('contact_email'),
'sponsor_mobile': kwargs.get('sponsor_mobile') or booth_values.get('contact_mobile'),
'sponsor_mobile': kwargs.get('sponsor_mobile') or booth_values.get('contact_phone'),
'sponsor_phone': kwargs.get('sponsor_phone') or booth_values.get('contact_phone'),
'sponsor_subtitle': kwargs.get('sponsor_slogan'),
'sponsor_website_description': plaintext2html(kwargs.get('sponsor_description')) if kwargs.get('sponsor_description') else '',