Skip to Content
Menu
This question has been flagged
1 Reply
4322 Views

been using odoo for over 3 years. i have modified some base code and template  in core, base, account, website, website_sale so on.

moved most of these modifications to custom modules, i mean each modified module nowadays have *_ext  where modified code lives its own life.

there are some templates I forgot to restore to original version while moving them to *_ext 

it causes me some problems lately because of updates. V8 started with version 20150201 now 20170501 running on server. 

question is: how to restore these forgotten templates to original ones. i tried full upgrade "-i base -u base_ext" etc...

Avatar
Discard
Author Best Answer

i guess i figured that out. here is the working code. take backup and use it at own risk.


get the list of whole views registered in system.

--- SELECT

 irmm.id, irmm.name, irmd.model, irmd.res_id FROM

 ir_module_module AS irmm

 LEFT JOIN ir_model_data AS irmd ON irmm.name = irmd.module WHERE

 irmm.state = 'installed' AND

 irmd.model = 'ir.ui.view'

ORDER BY

 irmm.name ASC ---



fetch inherited views from modules where *_ext --- SELECT

 array_to_string(array_agg(distinct "inherit_id"), ', ') AS modified_views FROM

 ir_ui_view WHERE

 name LIKE '%_ext%' AND 

 inherit_id IS NOT NULL ---


should give you output like this one: (inherited views)

"163, 167, 181, 182, 978, 981, 1320, 1399, 1801, 1804, 1809, 1822, 1824, 1973"





copy the function from website/controllers/main.py ----

    @http.route('/website/reset_templates', type='http', auth='user', methods=['POST'], website=True)

    def reset_template(self, templates, redirect='/'):

        templates = request.httprequest.form.getlist('templates')

        modules_to_update = []

        for temp_id in templates:

            view = request.registry['ir.ui.view'].browse(request.cr, request.uid, int(temp_id), context=request.context)

            if view.page:

                continue

            view.model_data_id.write({

                'noupdate': False

            })

            if view.model_data_id.module not in modules_to_update:

                modules_to_update.append(view.model_data_id.module)


        if modules_to_update:

            module_obj = request.registry['ir.module.module']

            module_ids = module_obj.search(request.cr, request.uid, [('name', 'in', modules_to_update)], context=request.context)

            if module_ids:

                module_obj.button_immediate_upgrade(request.cr, request.uid, module_ids, context=request.context)

        return request.redirect(redirect)



good to go :)

Avatar
Discard
Related Posts Replies Views Activity
1
Nov 24
102
0
Jul 24
225
1
Apr 24
333
1
Sep 23
708
1
Jun 23
1872