合并企业版代码(未测试,先提交到测试分支)
This commit is contained in:
1
web_studio/wizard/__init__.py
Normal file
1
web_studio/wizard/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import base_module_uninstall
|
||||
61
web_studio/wizard/base_module_uninstall.py
Normal file
61
web_studio/wizard/base_module_uninstall.py
Normal file
@@ -0,0 +1,61 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import models, fields, api
|
||||
|
||||
|
||||
class BaseModuleUninstall(models.TransientModel):
|
||||
_inherit = "base.module.uninstall"
|
||||
|
||||
is_studio = fields.Boolean(compute='_compute_is_studio')
|
||||
custom_views = fields.Integer(compute='_compute_custom_views')
|
||||
custom_reports = fields.Integer(compute='_compute_custom_reports')
|
||||
custom_models = fields.Integer(compute='_compute_custom_models')
|
||||
custom_fields = fields.Integer(compute='_compute_custom_fields')
|
||||
|
||||
@api.depends('module_ids')
|
||||
def _compute_is_studio(self):
|
||||
for wizard in self:
|
||||
wizard.is_studio = 'web_studio' in wizard.module_ids.mapped('name')
|
||||
|
||||
@api.depends('module_ids')
|
||||
def _compute_custom_views(self):
|
||||
for wizard in self:
|
||||
view_ids = self.env['ir.model.data'].search([
|
||||
('module', '=', 'studio_customization'),
|
||||
('model', '=', 'ir.ui.view'),
|
||||
]).mapped('res_id')
|
||||
wizard.custom_views = self.env['ir.ui.view'].search_count([
|
||||
('id', 'in', view_ids),
|
||||
('type', '!=', 'qweb'),
|
||||
])
|
||||
|
||||
@api.depends('module_ids')
|
||||
def _compute_custom_reports(self):
|
||||
for wizard in self:
|
||||
wizard.custom_reports = self.env['ir.model.data'].search_count([
|
||||
('module', '=', 'studio_customization'),
|
||||
('model', '=', 'ir.actions.report'),
|
||||
])
|
||||
|
||||
def _get_models(self):
|
||||
# Overridden to include customizations made with studio
|
||||
res = super()._get_models()
|
||||
if self.is_studio:
|
||||
res |= self.env['ir.model'].search([
|
||||
('transient', '=', False),
|
||||
('state', '=', 'manual')
|
||||
])
|
||||
return res
|
||||
|
||||
@api.depends('model_ids')
|
||||
def _compute_custom_models(self):
|
||||
for wizard in self:
|
||||
wizard.custom_models = len(wizard.model_ids.filtered(lambda x: x.state == 'manual'))
|
||||
|
||||
@api.depends('module_ids')
|
||||
def _compute_custom_fields(self):
|
||||
for wizard in self:
|
||||
wizard.custom_fields = self.env['ir.model.fields'].search_count([
|
||||
('state', '=', 'manual'),
|
||||
])
|
||||
23
web_studio/wizard/base_module_uninstall_view.xml
Normal file
23
web_studio/wizard/base_module_uninstall_view.xml
Normal file
@@ -0,0 +1,23 @@
|
||||
<odoo>
|
||||
<data>
|
||||
<record id="view_base_module_uninstall_studio" model="ir.ui.view">
|
||||
<field name="name">base.module.uninstall.view.form.studio</field>
|
||||
<field name="model">base.module.uninstall</field>
|
||||
<field name="inherit_id" ref="base.view_base_module_uninstall"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='model_ids']" position="after">
|
||||
<field name="is_studio" invisible="1"/>
|
||||
<div class="alert alert-danger" role="alert" attrs="{'invisible': ['|',('is_studio', '!=', True),'&','&','&',('custom_models', '=', 0),('custom_fields', '=', 0),('custom_views', '=', 0),('custom_reports', '=', 0)]}">
|
||||
<h3 class="text-danger">Customization made with Studio will be permanently lost</h3>
|
||||
<group>
|
||||
<field string="Custom models:" name="custom_models"/>
|
||||
<field string="Custom fields:" name="custom_fields"/>
|
||||
<field string="Custom views:" name="custom_views"/>
|
||||
<field string="Custom reports:" name="custom_reports"/>
|
||||
</group>
|
||||
</div>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user