base_partner_one2many_phone: improve mig script, add form view for res.partner.phone
This commit is contained in:
@@ -35,20 +35,24 @@ def migrate(cr, version):
|
||||
mig_phone_entries(cr, xdict, '3_phone_primary', '4_phone_secondary', ['1_home', '6_phone_fax_home', '3_office', '7_other'])
|
||||
mig_phone_entries(cr, xdict, '5_mobile_primary', '6_mobile_secondary', ['2_mobile'])
|
||||
mig_phone_entries(cr, xdict, '7_fax_primary', '8_fax_secondary', ['4_home_fax', '5_office_fax'])
|
||||
cr.execute('select id, email from res_partner where email is not null')
|
||||
cr.execute('select id, email from res_partner where email is not null order by id')
|
||||
for partner in cr.dictfetchall():
|
||||
email = partner['email'].strip()
|
||||
if email:
|
||||
email_split = email.split(',')
|
||||
print('partner_id=', partner['id'])
|
||||
old_email = partner['email'].strip()
|
||||
if old_email:
|
||||
email_split = old_email.split(',')
|
||||
clean_email_split = [x.strip() for x in email_split if x.strip()]
|
||||
# primary:
|
||||
email_primary = email_split.pop(0).strip()
|
||||
email_primary = clean_email_split.pop(0)
|
||||
rppo.create({
|
||||
'type': '1_email_primary',
|
||||
'partner_id': partner['id'],
|
||||
'email': email_primary,
|
||||
})
|
||||
cr.execute('UPDATE res_partner set email=%s where id=%s', (email_primary, partner['id']))
|
||||
for email_sec in email_split:
|
||||
for email_sec in clean_email_split:
|
||||
email_sec = email_sec.strip()
|
||||
if email_sec:
|
||||
rppo.create({
|
||||
'type': '2_email_secondary',
|
||||
'partner_id': partner['id'],
|
||||
|
||||
@@ -24,6 +24,22 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="res_partner_phone_form" model="ir.ui.view">
|
||||
<field name="name">res.partner.phone.form</field>
|
||||
<field name="model">res.partner.phone</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Phone and E-mail">
|
||||
<group name="main">
|
||||
<field name="partner_id" invisible="not context.get('partner_phone_main_view')"/>
|
||||
<field name="type"/>
|
||||
<field name="phone" widget="phone" attrs="{'required': [('type', 'not in', ('1_email_primary', '2_email_secondary'))], 'invisible': [('type', 'in', ('1_email_primary', '2_email_secondary'))]}"/>
|
||||
<field name="email" widget="email" attrs="{'invisible': [('type', 'not in', ('1_email_primary', '2_email_secondary'))], 'required': [('type', 'in', ('1_email_primary', '2_email_secondary'))]}"/>
|
||||
<field name="note"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="res_partner_phone_search" model="ir.ui.view">
|
||||
<field name="name">res.partner.phone.search</field>
|
||||
<field name="model">res.partner.phone</field>
|
||||
|
||||
Reference in New Issue
Block a user