[IMP] document_page: black, isort

This commit is contained in:
ernesto
2019-11-06 17:58:38 -05:00
committed by Justine Doutreloux
parent 6aa4dece1f
commit 4cf81af527
10 changed files with 189 additions and 217 deletions

View File

@@ -10,65 +10,58 @@ class DocumentPageCreateMenu(models.TransientModel):
_name = "document.page.create.menu"
_description = "Wizard Create Menu"
menu_name = fields.Char(
'Menu Name',
required=True
)
menu_parent_id = fields.Many2one(
'ir.ui.menu',
'Parent Menu',
required=True
)
menu_name = fields.Char("Menu Name", required=True)
menu_parent_id = fields.Many2one("ir.ui.menu", "Parent Menu", required=True)
@api.model
def default_get(self, fields_list):
"""Get Page name of the menu."""
res = super(DocumentPageCreateMenu, self).default_get(fields_list)
page_id = self.env.context.get('active_id')
obj_page = self.env['document.page']
page_id = self.env.context.get("active_id")
obj_page = self.env["document.page"]
page = obj_page.browse(page_id)
res['menu_name'] = page.name
res["menu_name"] = page.name
return res
@api.multi
def document_page_menu_create(self):
"""Menu creation."""
obj_page = self.env['document.page']
obj_menu = self.env['ir.ui.menu']
obj_action = self.env['ir.actions.act_window']
obj_model_data = self.env['ir.model.data']
page_id = self.env.context.get('active_id', False)
obj_page = self.env["document.page"]
obj_menu = self.env["ir.ui.menu"]
obj_action = self.env["ir.actions.act_window"]
obj_model_data = self.env["ir.model.data"]
page_id = self.env.context.get("active_id", False)
page = obj_page.browse(page_id)
data = self[0]
view_id = obj_model_data.sudo().get_object_reference(
'document_page', 'view_wiki_menu_form')[1]
"document_page", "view_wiki_menu_form"
)[1]
value = {
'name': 'Document Page',
'view_type': 'form',
'view_mode': 'form,tree',
'res_model': 'document.page',
'view_id': view_id,
'type': 'ir.actions.act_window',
'target': 'current',
"name": "Document Page",
"view_type": "form",
"view_mode": "form,tree",
"res_model": "document.page",
"view_id": view_id,
"type": "ir.actions.act_window",
"target": "current",
}
value['domain'] = "[('parent_id','=',%d)]" % page.id
value['res_id'] = page.id
value["domain"] = "[('parent_id','=',%d)]" % page.id
value["res_id"] = page.id
# only the super user is allowed to create menu due to security rules
# on ir.values
# see.: http://goo.gl/Y99S7V
action_id = obj_action.sudo().create(value)
menu_id = obj_menu.sudo().create({
'name': data.menu_name,
'parent_id': data.menu_parent_id.id,
'action': 'ir.actions.act_window,' + str(action_id.id),
})
menu_id = obj_menu.sudo().create(
{
"name": data.menu_name,
"parent_id": data.menu_parent_id.id,
"action": "ir.actions.act_window," + str(action_id.id),
}
)
if page.menu_id:
page.menu_id.unlink()
page.write({'menu_id': menu_id.id})
return {
'type': 'ir.actions.client',
'tag': 'reload',
}
page.write({"menu_id": menu_id.id})
return {"type": "ir.actions.client", "tag": "reload"}

View File

@@ -9,13 +9,13 @@ from odoo.tools.translate import _
class DocumentPageShowDiff(models.TransientModel):
"""Display Difference for History."""
_name = 'wizard.document.page.history.show_diff'
_description = 'Document Page Show Diff'
_name = "wizard.document.page.history.show_diff"
_description = "Document Page Show Diff"
def _get_diff(self):
"""Return the Difference between two document."""
history = self.env["document.page.history"]
ids = self.env.context.get('active_ids', [])
ids = self.env.context.get("active_ids", [])
diff = False
if len(ids) == 2:
if ids[0] > ids[1]:
@@ -25,11 +25,7 @@ class DocumentPageShowDiff(models.TransientModel):
elif len(ids) == 1:
diff = history.browse(ids[0]).diff
else:
raise UserError(
_("Select one or maximum two history revisions!"))
raise UserError(_("Select one or maximum two history revisions!"))
return diff
diff = fields.Text(
readonly=True,
default=_get_diff,
)
diff = fields.Text(readonly=True, default=_get_diff)