Repository navigation
Conversation
Keep chatter tracking history by installing mail_tracking and reusing mail_tracking_value, and migrate the stored mail and im_livechat changes that would otherwise drop or mis-read 19.0 data. Co-authored-by: André de Kock <adekock11@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Migration scripts and annotated analysis for the 19.0 → 20.0 discuss/mail cluster:
mail, the newmail_trackingmodule (and its auto-install glue),bus,im_livechat, plus the small livechat satelliteswebsite_livechatandhr_livechat.mail.tracking.valuekeeps the same model name and the same table (mail_tracking_value). Nothing auto-installsmail_tracking. Without a script, chatter field-change history stays in an unowned table and the UI stops reading it. The mail pre-migration marksmail_trackingto install during the same registry load (the module graph loop picks upto installbeforeir.model.data._process_end), and renames the moved xmlids ontomail_trackingso those records are updated instead of deleted.No commit from OCA#6068 is in this branch. The
upgrade_analysis.txtfiles anddocsource/modules190-200.rstwere copied fromhbrunn/20.0-base(that PR) and then annotated. The base module migration itself is not included; a real upgrade still needs OCA#6068 (see Testing).Overlap with #2
#2 (
cursor/crm-190-200-91bd) already addsopenupgrade_scripts/scripts/im_livechat/20.0.1.0/pre-migration.pywhose only job is_preserve_chatbot_script_source: ifcrm_livechatis installed or queued, copychatbot.script.source_idintoou_crm_livechat_chatbot_sourcebefore im_livechat drops the column. Its crm_livechat post-migration reads that table intocrm.lead.utm_referenceand drops it. That PR says the rest of im_livechat belongs in a dedicated PR and that the function should be merged into it.This PR is that dedicated PR.
im_livechat/20.0.1.0/pre-migration.pycalls_preserve_chatbot_script_sourcewith the same SQL and the same guards as #2, then does the rating,waitingstatus, and looking-for-help timestamp work.upgrade_analysis.txtis byte-identical to #2 (same blob as OCA#6068).upgrade_analysis_work.txtreplaces #2'sDEFERREDnotes with the real handling, and markssource_idDONE by that shared function.When the two PRs merge, keep this im_livechat
pre-migration.pyandupgrade_analysis_work.txt(they contain #2's function plus the rest). Ondocsource/modules190-200.rst, take this PR'sim_livechatline (Done). Leavecrm_livechatto #2: this branch does not touch that module. #2 ownscreate_lead_and_forward→create_lead, theutm.utm_source_livechatmerge, andcrm.lead.utm_reference. Those files are intentionally absent here so the two PRs do not both addscripts/crm_livechat/.What changed between 19 and 20, and what the scripts do
File references are
odoo/odoo20.0 vs 19.0. OCA#6068's analysis is the field-by-field list; the notes below are the rows that lose or misread data.mail_tracking (new, not auto_install)
addons/mail_tracking/__manifest__.pydepends onmailonly.addons/mail_tracking/models/mail_tracking_value.pyis the same modelmail.tracking.value.addons/mail_tracking_mass_mailingandaddons/mail_tracking_smsareauto_installon top of mass_mailing / sms.Without a script the table survives as an orphan (Odoo 20 does not drop models that are simply absent from the registry; it logs them), but new tracking is not written and old rows are not shown.
update_list()runs before any module pre-migration, so the auto_install glue is missed unless something marks itto installaftermail_trackingis scheduled.pre-migration (
mail/20.0.1.19/pre-migration.py):mail_trackingtoto installwhen it isuninstalled. Logs an error if the module row is missing (addons path does not contain it).mass_mailingorsmsis installed, to upgrade, or to install, schedulesmail_tracking_mass_mailing/mail_tracking_smsthe same way. Their only schema change is a new empty column (source_mailing_id,source_sms_template_id). Nothing to copy.mail_tracking: the tracking action, menu, form, list, andmodel_mail_tracking_value. The access xmlid is left to base: [20.0][MIG] base OCA/OpenUpgrade#6068 renames everyir.model.access/ir.rulexmlid before mail runs, and mail_tracking's CSV creates their.accessrow.mail_tracking_value.currency_idintofield_info.currency_idbefore the column goes away. 20.0 stores the currency there (addons/mail/models/mail_track_mixin.py, monetary branch) and drops the many2one. Verified: the column is gone after upgrade andfield_infois{"currency_id": 1}.mail.messagerows of typenotificationthat have tracking values tomessage_type = 'tracking'. 20.0's "changes" filter (mail/models/mail_message.py,_message_fetch) only matches that type. Comments that also carry tracking values stay comments.Bookmarks (renamed stars)
mail.message.starred_partner_ids(mail_message_res_partner_starred_rel) becamebookmarked_partner_ids(mail_message_res_partner_bookmarked_rel) inaddons/mail/models/mail_message.py. Same column names. Pre-migration renames the relation table before the new field'supdate_dbwould create an empty one. Verified: 1 row survived in the new table.Activity chaining
addons/mail/models/mail_activity_type.py:chaining_type,suggested_next_type_ids(m2mmail_activity_rel) andtriggered_next_type_idare replaced by a singlesuggested_next_type_id.previous_type_idsstill usesmail_activity_rel, so every old suggestion remains visible as a preceding activity.Pre-migration creates
suggested_next_type_idand fills it fromtriggered_next_type_idwhenchaining_type = 'trigger', otherwise from the lowestmail_activity_rel.recommended_id. Automatic triggering is gone; the link is kept as a suggestion. Extra suggestions are not copied into the single many2one. Verified: Email (suggest → Call and Meeting) kept Call; Call (trigger → To-Do) kept To-Do; both m2m rows remain.mail.activity.previous_activity_type_idandrecommended_activity_type_idare wizard hints, not the audit trail. Nothing to do.mail.activity.plan.template.next_activity_idsis a denormalized copy of the type's suggestions. Nothing to do.Server actions: notes vs email
addons/mail/models/ir_actions_server.pyremovesmail_post_method(email/comment/note) and adds statelog_notewithlog_note_note. A 19.0 note action renderedtemplate_id. 20.0 posts the HTML field and does not render a template.Pre-migration, for
state = mail_postandmail_post_method = note: setstate = log_noteand copymail_template.body_html(jsonb, translations included) intolog_note_note.commentstaysmail_post.emailalso staysmail_post: on a mail.thread model, 20.0 always posts the template as a comment. There is no email-only path left. Verified: the seeded note action islog_noteand the template body is inlog_note_note.Views that still name removed fields
Loading
mail/views/ir_cron_views.xmlvalidates the cron form beforeir_actions_server_views.xmlreplaces the 19.0 inherit. The stored arch still containsmail_post_method(and activity views still containchaining_type,triggered_next_type_id, and so on). The upgrade aborted on that until pre-migration emptied those view archs. Standard mail views are not noupdate, so the module XML reloads them. Verified after upgrade: the server-action form is 5888 characters and no longer mentionsmail_post_method.A custom view that still names one of those removed fields is reduced to an empty arch as well. That customization is not reconstructed. The fields are:
mail_post_method,chaining_type,triggered_next_type_id,suggested_next_type_ids,previous_activity_type_id,recommended_activity_type_id,has_recommended_activities,custom_channel_name,fetched_message_id,starred_partner_ids.Channel owners
discuss.channel.member.channel_roleis new (owner/admin) inaddons/mail/models/discuss/discuss_channel_member.py. Archiving a channel or a group, and editing a read-only channel, requires an owner (or a system administrator). Post-migration setsowneron the creating user's membership when they are still a member, otherwise on the oldest active internal member. Chats are left without a role (the model forbids a role there). The standard #general admin membership (mail.channel_member_general_channel_for_admin) is set to owner, matchingdiscuss_channel_data.xml. Verified: both seeded channels have the admin partner as owner.member_indicesis a new stored compute for chats, with a partial unique index. The ORM fills it. Two chats with the same members will fail that index. This script does not merge chats, because merging would drop messages.Noupdate data that is applied, and noupdate data that is not
The generated
noupdate_changes.xmlfrom OCA#6068 is not loaded. It would write emptynameanddescriptionon#generaland the admin channel (20.0 fills those in Python for translation reasons).Post-migration instead:
fa-envelope→mail, and the same for call, meeting, todo, upload, warning). Verified: Email's icon ismail.mt_comment/mt_noteEnglish source terms (Discussions→Messages,Note→Notes) and swaps sequences (note 100 → 90, activities 90 → 100) only when the old value is still there.base.group_usertomail.group_mail_canned_response_adminimplied groups if it is missing (mail/data/mail_groups.xml).bus and im_status
Checked, not assumed.
bus20.0 has no model or column change. The deletedir.model.accessrow is their.model.access→ir.accessmerge done in base (OCA#6068); bus no longer ships a security CSV.im_statusis not a bus column. Onres.usersandmail.guestit is a non-stored compute in both versions (addons/mail/models/res_users.py,addons/mail/models/discuss/mail_guest.py). The type change Char → Selection does not touch a column. The values were alreadyonline/away/busy/offline, coming frommail.presence.status(still that selection, unchanged inaddons/mail/models/mail_presence.py) andmanual_im_status(unchanged). The old partner valuebotwas also a non-stored compute;res.partnerno longer hasim_status. Nothing to do.im_livechat
addons/im_livechat/models/discuss_channel.pydropsrating.mixin.rating_last_value(float 1/3/5) becomes selectionlivechat_rating. Pre-migration adds the column and copies rounded 1, 3 and 5 before the float column is removed.rating.ratingrows are left in place.im_livechat.channel.member.history.ratingwas a non-stored related; 20.0 recomputes the stored selection fromlivechat_rating.rating_percentage_satisfactionwas a non-stored integer compute and is now a non-stored float. Nothing to cast.Status key
waiting("Waiting for customer") is removed. Open sessions becomein_progress. A session withlivechat_end_dtset must have a null status (the existing check).need_helpnow requireslivechat_looking_for_help_since_dt. 19.0 did not store that instant, so pre-migration fills "now" for sessions already inneed_help. The stored compute may overwrite it during init. Verified: waiting →in_progresswith rating5; need_help kept with rating3and a timestamp; a closed session stayed without a status and got rating1.livechat_operator_idis dropped. 19.0 already stores the agent onim_livechat.channel.member.history, which 20.0 uses. Nothing to copy.Conversation tags (
im_livechat.conversation.tagand the m2m) are removed with no replacement. Tag names are dropped. Nothing to do, and the loss is real.chatbot.scriptno longer inheritsutm.source.mixin(addons/im_livechat/models/chatbot_script.py). Per-botsource_idis preserved only by the #2 function described above, and only whencrm_livechatis installed. Theutm.sourcerows themselves are not deleted. New chatbot leads useim_livechat.utm_source_chatbot.The redesigned transcript email and the noupdate channel rename YourWebsite.com → Support are not forced onto existing databases.
ir.model.access/ir.rule/ir.accessrows everywhere in this analysis are the base merge from OCA#6068. This PR does not touch them. Standard rows are reloaded from module data. Rows without an xmlid are preserved by base.website_livechat and hr_livechat
website.visitor.livechat_operator_idwas a stored compute of the channel operator. The operator still lives on the channel members and the history model, so the cache column can go. The noupdate website record now points atbase.default_website, which base renames fromwebsite.default_website;channel_iditself is unchanged, so the generated noupdate file is not loaded.hr_livechatonly deletes a search view for the removed looking-for-help action.Deliberately not in this PR
crm_livechat(steps, UTM source,utm_reference): [OU-ADD] crm: migrate CRM and close modules from 19.0 to 20.0 #2.mail_group,mass_mailing(beyond scheduling its tracking glue),snailmail,mail_plugin(res.partner.iapis removed there),resource_mail,auth_totp_mail. Each has its own analysis and should be its own PR.mail_botandmail_bot_hr: no database layout change. Coverage lines areNothing to do.mail.thread.ccis an abstract model with no table.crm.lead,project.taskandproject.updateinherit it in 19.0 and do not redeclareemail_ccin 20.0, so those columns drop when those modules upgrade. That belongs in the crm and project scripts, not here.discuss.channel.member.custom_channel_nameandfetched_message_id: feature removed, no successor.fetched_message_idis a read cursor;seen_message_idremains.pinned_message_idsis a non-stored one2many; pins stay onmail.message.pinned_at.res.users.settings: feature removed.res.usersmail.thread / activity fields that changed from related to stored computes: the ORM adds the columns and recomputes them.contact_address_inlinemoved to base with the same column; base loads first.How it was tested
Local only. No external server.
odoo/odoobranch 19.0) installedbus,mail,im_livechatinto databaseou_mail(--stop-after-init). That pulled 41 modules.ir_module_module.demostayed false, so this was not a demo-data database; the cases below were inserted with SQL instead.currency_id = 1; one starred message; activity type Email suggesting Call and Meeting, Call triggering To-Do; a server actionmail_post/notewith a mail template; three livechat channels (waiting + rating 5, need_help + rating 3, closed + rating 1).--upgrade-pathpointing at this branch'sopenupgrade_scripts/scriptsand, for base only, the scripts fromhbrunn/20.0-base([20.0][MIG] base OCA/OpenUpgrade#6068). Those base files are not in this commit.Two local patches were required for the upgrade process and are not in this PR:
odoo/modules/migration.pycallsinspect.signatureonmigrate. That follows__wrapped__, so@openupgrade.migrate()(def migrate(env, version)inside a(cr, version)wrapper) is rejected. The test usedfollow_wrapped=False. Every script in this PR uses the decorator the same way [20.0][MIG] base OCA/OpenUpgrade#6068 does, so this blocks the whole 20.0 series until openupgradelib or the framework adjusts it.openupgradelibload_datacallsodoo.tools.convert_xml_import. Odoo 20 no longer exports that name fromodoo.tools(it lives inodoo.tools.convert). [20.0][MIG] base OCA/OpenUpgrade#6068's base post-migration dies there (AttributeError) before mail runs. The test re-exportedconvert_xml_import. After that, base from [20.0][MIG] base OCA/OpenUpgrade#6068 finished (base19.0.1.3→20.0.1.3) and these scripts ran.First mail attempt then failed in
mail/views/ir_cron_views.xml(Field "mail_post_method" does not exist). The view neutralization above fixes that. The successful run was-u mail,im_livechaton the database whose base and bus were already at 20.0. Exit code 0,Modules loaded.Checked after that run:
mail_trackinginstalled and the tracking xmlids live there; tracking row kept withfield_info.currency_id; message typetracking; bookmark relation renamed with the row intact; activity suggestions as described; note action converted; livechat ratings and statuses as described; channel owners set; activity icon and subtype labels updated.mail_tracking_smsinstalled becausesmswas already installed;mail_tracking_mass_mailingstayed uninstalled becausemass_mailingwas not.crm_livechatwas not installed, so_preserve_chatbot_script_sourcecorrectly no-op'd andcreate_lead_and_forwardwas left for #2 (the seeded step still has that value).Known gaps and risks
ir.model.access+ir.rule→ir.access, and for the upgrade to get past base. This branch does not vendor those commits.migratesignature mismatch and the missingconvert_xml_importexport will stop a stock 20.0 + current openupgradelib run before these scripts do anything useful. They need a framework or openupgradelib fix, not a per-module workaround.previous_type_ids.member_indicesunique index.email_ccon crm leads and project tasks/updates is out of scope and will be dropped by those modules' ORM updates.im_livechat/20.0.1.0/pre-migration.py.