module : mail. Problem in the structure database (mail.mail, mail.message)

Asked by Sylvain LE GAL (GRAP)

Hi everybody,

working on 'mail' module migration, I have some problem. (again...)
It seem like the class in 6.1 "mail.message" is not the same class that 7.0 "mail.message".

*** In 6.1, there is only
- mail.message.common (abstract)
- mail.message (inherit 'mail.message.common'). The doc says : "Model holding RFC2822 email messages".

*** In 7.0 there is :
- mail.message (inherits 'ir.needaction_mixin'). The doc says : "system notification (replacing res.log notifications), comments (OpenChatter discussion) and incoming emails."
- mail.mail (inherit 'mail.message'). The doc says : "Model holding RFC2822 email".

*** the migration should be :
- res.log, comment & other ----> mail.message
- mail.message ----> mail.mail

*** Propose :
- in mail / pre-migration.py, renaming the table mail_message in "openupgrade_old_mail_message" (and the 4 indexes of the table) ;
- the system recreate the table "mail_message" because it doesn't exist ;
- in mail / post-migration.py :
--> using "openupgrade_old_mail_message" to write in "mail_mail" ;
--> using "res_log" & other to write into the new "mail_message" ;

What do you think ?

Question information

Language:
English Edit question
Status:
Solved
For:
OpenUpgrade Addons Edit question
Assignee:
No assignee Edit question
Solved by:
Stefan Rijnhart (Opener)
Solved:
Last query:
Last reply:
Revision history for this message
Best Stefan Rijnhart (Opener) (stefan-opener) said :
#1

Hi Sylvain,

thank you for your analysis!

A lot of foreign key constraints in 6.1 on 'mail_message' are still valid in 7.0, such as on the following models, I believe mostly due to _inherits of 'mail.thread':

 crm.claim
 crm.helpdesk
 crm.lead
 crm.meeting
 crm.phonecall
 event.registration
 event.registration
 hr.applicant
 mail.thread
 project.issue
 project.task
 res.partner

Only fetchmail.server has moved to 'mail.mail', which as you note inherits mail.message.

How about leaving the 'mail.message' table as it is, for that reason? You could prefix all the obsolete columns with openupgrade.get_legacy_name(). The migration script for the fetchmail module should eventually migrate those fields to new entries in the mail_mail table for its retrieved emails. Indeed, 'res.log' and notes on various models are to be recreated as 'mail.mail' entries.

Cheers,
Stefan.

Revision history for this message
Sylvain LE GAL (GRAP) (sylvain-legal) said :
#2

Thanks Stefan Rijnhart (Therp), that solved my question.

Revision history for this message
Sylvain LE GAL (GRAP) (sylvain-legal) said :
#3

Hi Stefan,

thanks a lot, I think you're right.

Sylvain.

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) said :
#4

You are welcome. I notice I was confused by the terminology. For the record, I intended the last sentence to read

     'res.log' and notes on various models are to be recreated as 'mail.message'