mharenz
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with
303 additions and
0 deletions
web_edit_mode/README.rst
web_edit_mode/__init__.py
web_edit_mode/__manifest__.py
web_edit_mode/i18n/de.po
web_edit_mode/i18n/web_edit_mode.pot
web_edit_mode/models/__init__.py
web_edit_mode/models/res_users.py
web_edit_mode/static/src/js/web_edit_mode_view.js
web_edit_mode/static/src/xml/web_edit_mode_view.xml
web_edit_mode/views/res_users_view.xml
web_edit_mode/views/web_edit_mode_view.xml
@ -0,0 +1,53 @@
.. image :: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:alt: License
Web edit mode
===================
With this module the user can change the read mode to edit mode and do
not have to click the edit button every time he wants to change something
in a form view.
Configuration
=============
At user settings the user can change the default behavior from read mode
to edit mode.
Usage
=====
Known Issues
============
Bug Tracker
===========
Bugs are tracked on `GitHub Issues
<https://github.com/OCA/web/issues> `_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smashing it by providing a detailed and welcomed feedback.
Credits
=======
Contributors
------------
* Michael Harenz (mharenz) <m.harenz@kjellberg.de>
Maintainer
----------
.. image :: http://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: http://odoo-community.org
This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.
To contribute to this module, please visit http://odoo-community.org.
@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import models
@ -0,0 +1,25 @@
# Copyright 2019 mharenz https://github.com/mharenz
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
' name ' : ' Web edit mode ' ,
' version ' : ' 11.0.2.0.0 ' ,
' category ' : ' Web ' ,
' author ' : ' Michael Harenz <m.harenz@kjellberg.de>, '
' Odoo Community Association (OCA) ' ,
' website ' : ' https://github.com/OCA/web ' ,
' license ' : ' AGPL-3 ' ,
' depends ' : [
' web ' ,
] ,
" data " : [
' views/res_users_view.xml ' ,
' views/web_edit_mode_view.xml ' ,
] ,
' qweb ' : [
" static/src/xml/web_edit_mode_view.xml " ,
] ,
' installable ' : True ,
' auto_install ' : False ,
}
@ -0,0 +1,48 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_edit_mode
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-04-12 12:35+0000\n"
"PO-Revision-Date: 2019-04-12 12:35+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: web_edit_mode
#. openerp-web
#: code:addons/web_edit_mode/static/src/xml/web_edit_mode_view.xml:7
#, python-format
msgid "Create"
msgstr "Erstellen"
#. module: web_edit_mode
#: model:ir.model.fields,field_description:web_edit_mode.field_res_users_context_default_view_mode
msgid "Default view mode"
msgstr "Standardansichtsmodus"
#. module: web_edit_mode
#: selection:res.users,context_default_view_mode:0
msgid "Edit-Mode"
msgstr "Bearbeitungsmodus"
#. module: web_edit_mode
#: model:ir.model.fields,help:web_edit_mode.field_res_users_context_default_view_mode
msgid "Set the default mode when form views are opened."
msgstr "Legt den Modus fest in dem Formulare geöffnet werden."
#. module: web_edit_mode
#: model:ir.model,name:web_edit_mode.model_res_users
msgid "Users"
msgstr "Benutzer"
#. module: web_edit_mode
#: selection:res.users,context_default_view_mode:0
msgid "View-Mode"
msgstr "Ansichtsmodus"
@ -0,0 +1,48 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_edit_mode
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-04-12 12:35+0000\n"
"PO-Revision-Date: 2019-04-12 12:35+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: web_edit_mode
#. openerp-web
#: code:addons/web_edit_mode/static/src/xml/web_edit_mode_view.xml:7
#, python-format
msgid "Create"
msgstr ""
#. module: web_edit_mode
#: model:ir.model.fields,field_description:web_edit_mode.field_res_users_context_default_view_mode
msgid "Default view mode"
msgstr ""
#. module: web_edit_mode
#: selection:res.users,context_default_view_mode:0
msgid "Edit-Mode"
msgstr ""
#. module: web_edit_mode
#: model:ir.model.fields,help:web_edit_mode.field_res_users_context_default_view_mode
msgid "Set the default mode when form views are opened."
msgstr ""
#. module: web_edit_mode
#: model:ir.model,name:web_edit_mode.model_res_users
msgid "Users"
msgstr ""
#. module: web_edit_mode
#: selection:res.users,context_default_view_mode:0
msgid "View-Mode"
msgstr ""
@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from . import res_users
@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
from odoo import fields , models
class ResUsers ( models . Model ) :
_inherit = ' res.users '
def __init__ ( self , pool , cr ) :
""" Override of __init__ to add access rights.
Access rights are disabled by default , but allowed on some specific
fields defined in self . SELF_ { READ / WRITE } ABLE_FIELDS .
"""
super ( ) . __init__ ( pool , cr )
# duplicate list to avoid modifying the original reference
type ( self ) . SELF_WRITEABLE_FIELDS = list ( self . SELF_WRITEABLE_FIELDS )
type ( self ) . SELF_WRITEABLE_FIELDS . extend ( [ ' default_view_mode ' ] )
# duplicate list to avoid modifying the original reference
type ( self ) . SELF_READABLE_FIELDS = list ( self . SELF_READABLE_FIELDS )
type ( self ) . SELF_READABLE_FIELDS . extend ( [ ' default_view_mode ' ] )
context_default_view_mode = fields . Selection (
[ ( ' view ' , ' View-Mode ' ) , ( ' edit ' , ' Edit-Mode ' ) ] ,
string = ' Default view mode ' ,
default = ' view ' ,
required = True ,
help = " Set the default mode when form views are opened. " )
@ -0,0 +1,60 @@
odoo . define ( 'web_edit_mode' , function ( require ) {
"use strict" ;
var FormView = require ( 'web.FormView' ) ;
var FormController = require ( 'web.FormController' ) ;
FormView . include ( {
/ * *
* On opening a record in form view enable edit mode .
* /
init : function ( viewInfo , params ) {
if ( typeof params . context !== 'undefined' && params . context . default_view_mode === 'edit' ) {
var mode = 'edit' ;
params . mode = mode ;
}
this . _super ( viewInfo , params ) ;
} ,
} ) ;
FormController . include ( {
/ * *
* Method is triggered by CreateButton .
* If in edit mode check if model is dirty and ask to discard the changes .
* /
_onCreate : function ( ) {
var myself = this ;
this . canBeDiscarded ( this . handle )
. then ( function ( ) {
myself . createRecord ( ) ;
} ) ;
} ,
/ * *
* If view mode is edit set mode for Buttons to edit so the correct buttons are visible .
* /
_updateButtons : function ( ) {
if ( this . $buttons && this . renderer . state . context . default_view_mode === 'edit' ) {
this . mode = 'edit' ;
}
this . _super ( ) ;
} ,
/ * *
* If view mode is edit show the sidebar .
* /
_updateSidebar : function ( ) {
this . _super ( ) ;
if ( this . sidebar && this . renderer . state . context . default_view_mode === 'edit' ) {
this . sidebar . do_toggle ( true ) ;
}
} ,
/ * *
* _setMode is triggered after saving a record , so we don ' t want back to read mode and stay in edit .
* /
_setMode : function ( mode , recordID ) {
if ( this . renderer . state . context . default_view_mode === 'edit' ) {
mode = 'edit' ;
}
return this . _super ( mode , recordID ) ;
} ,
} ) ;
} ) ;
@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<templates id= "form_view" xml:space= "preserve" >
<t t-extend= "FormView.buttons" >
<t t-jquery= "button.o_form_button_save" t-operation= "before" >
<button t-if= "widget.is_action_enabled('create')" type= "button"
class="btn btn-default btn-sm o_form_button_create" accesskey="c">
Create
</button>
</t>
</t>
</templates>
@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo >
<data >
<record id= "view_users_form_simple_modif" model= "ir.ui.view" >
<field name= "name" > res.users.preferences.form</field>
<field name= "model" > res.users</field>
<field name= "inherit_id" ref= "base.view_users_form_simple_modif" />
<field eval= "20" name= "priority" />
<field name= "arch" type= "xml" >
<xpath expr= "//field[@name='company_id']" position= "after" >
<field name= "context_default_view_mode" readonly= "0" />
</xpath>
</field>
</record>
</data>
</odoo>
@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo >
<template id= "assets_backend" name= "web_edit_mode assets" inherit_id= "web.assets_backend" >
<xpath expr= "." position= "inside" >
<script type= "text/javascript" src= "/web_edit_mode/static/src/js/web_edit_mode_view.js" > </script>
</xpath>
</template>
</odoo>