Files
odoo_source/addons/event_booth/tests/test_event_booth_internals.py
Thibault DelavalléeandJeremy Hennecart 643df62f12 [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>
2023-09-27 17:40:55 +00:00

57 lines
2.4 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from datetime import datetime, timedelta
from odoo.addons.event_booth.tests.common import TestEventBoothCommon
from odoo.fields import Datetime as FieldsDatetime
from odoo.tests.common import users, tagged
@tagged('post_install', '-at_install', 'event_booth')
class TestEventData(TestEventBoothCommon):
@users('user_eventmanager')
def test_event_booth_contact(self):
""" Test contact details computation """
customer = self.env['res.partner'].browse(self.event_customer.ids)
category = self.env['event.booth.category'].browse(self.event_booth_category_1.ids)
self.assertTrue(all(
bool(customer[fname])
for fname in ['name', 'email', 'country_id', 'phone']
)
)
customer_email = customer.email
event = self.env['event.event'].create({
'name': 'Event',
'date_begin': FieldsDatetime.to_string(datetime.today() + timedelta(days=1)),
'date_end': FieldsDatetime.to_string(datetime.today() + timedelta(days=15)),
'event_type_id': False,
})
self.assertEqual(event.event_booth_ids, self.env['event.booth'])
booth = self.env['event.booth'].create({
'name': 'Test Booth',
'booth_category_id': category.id,
'event_id': event.id,
'partner_id': customer.id,
})
self.assertEqual(booth.contact_name, customer.name)
self.assertEqual(booth.contact_email, customer_email)
self.assertEqual(booth.contact_phone, customer.phone)
booth.write({
'contact_email': '"New Emails" <new.email@test.example.com',
'contact_phone': False,
})
self.assertEqual(booth.contact_email, '"New Emails" <new.email@test.example.com')
self.assertEqual(booth.contact_phone, False)
self.assertEqual(customer.email, customer_email, 'No sync from booth to partner')
# partial update of contact fields: we may end up with mixed contact information, is it a good idea ?
booth.write({'partner_id': self.event_customer2.id})
self.assertEqual(booth.contact_name, customer.name)
self.assertEqual(booth.contact_email, '"New Emails" <new.email@test.example.com')
self.assertEqual(booth.contact_phone, self.event_customer2.phone)