Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion base_optional_quick_create/AUTHORS.txt

This file was deleted.

86 changes: 86 additions & 0 deletions base_optional_quick_create/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

=====================
Optional quick create
=====================

This module allows to avoid to *quick create* new records, through many2one
fields, for a specific model.
You can configure which models should allow *quick create*.
When specified, the *quick create* option will always open the standard create
form.

Got the idea from https://twitter.com/nbessi/status/337869826028605441

Installation
============

To install this module, you need to: click Instal

#. Do this ...

Configuration
=============

To configure this module, you need to:

#. Go to in Setting/Technical Setting/Database Structure/Model
#. Tick Avoid Quick Create, to disabled the quick create

Usage
=====

To use this module, you need to:

#. No things

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/{repo_id}/{branch}

.. repo_id is available in https://github.com/OCA/maintainer-tools/blob/master/tools/repos_with_ids.txt
.. branch is "8.0" for example

Known issues / Roadmap
======================

* No roadmap

Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/{project_repo}/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
=======

Images
------

* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.

Contributors
------------

* Agile Business Group sagl (<http://www.agilebg.com>)
* Florent de Labarre

Maintainer
----------

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://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 https://odoo-community.org.
2 changes: 1 addition & 1 deletion base_optional_quick_create/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
#
##############################################################################

from . import model
from . import base_optional_quick_create
19 changes: 6 additions & 13 deletions base_optional_quick_create/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
##############################################################################
#
# Copyright (C) 2013 Agile Business Group sagl (<http://www.agilebg.com>)
# Contributor 2016 Florent de Labarre
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
Expand All @@ -20,26 +21,18 @@

{
'name': "Optional quick create",
'version': '8.0.0.1.0',
'version': '9.0.0.1.0',
'category': 'Tools',
'summary': "Avoid 'quick create' on m2o fields, on a 'by model' basis",
'description': """
This module allows to avoid to *quick create* new records, through many2one
fields, for a specific model.
You can configure which models should allow *quick create*.
When specified, the *quick create* option will always open the standard create
form.

Got the idea from https://twitter.com/nbessi/status/337869826028605441
""",
'author': "Agile Business Group,Odoo Community Association (OCA)",
'author': "Agile Business Group,Odoo Community \
Association (OCA), Florent de Labarre",
'website': 'http://www.agilebg.com',
'license': 'AGPL-3',
"depends": ['base'],
"data": [
'model_view.xml',
'base_optional_quick_create_view.xml',
],
"demo": [],
'test': [],
'installable': False
"installable": True
}
75 changes: 75 additions & 0 deletions base_optional_quick_create/base_optional_quick_create.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2013 Agile Business Group sagl (<http://www.agilebg.com>)
# Contributor 2016 Florent de Labarre
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

from openerp import api, fields, models, _
from openerp.exceptions import UserError
from openerp.tools.translate import _
from openerp import SUPERUSER_ID


class IrModel(models.Model):
_inherit = 'ir.model'

avoid_quick_create = fields.Boolean(string='Disabled quick create',)

@api.v7
def _patch_quick_create(self, cr, ids):

def _wrap_name_create():
def wrapper(self, cr, uid, name, context=None):
raise UserError(_("Can't create quickly. Opening create form"))
return wrapper

for model in self.browse(cr, SUPERUSER_ID, ids):
model_name = model.model
model_obj = self.pool.get(model_name)
if model_obj and not hasattr(model_obj.name_create, 'origin'):
model_obj._patch_method('name_create', _wrap_name_create())
return True

@api.v7
def _register_hook(self, cr):
ids = self.search(
cr, SUPERUSER_ID, [('avoid_quick_create', '=', True)])
self._patch_quick_create(cr, ids)
return super(IrModel, self)._register_hook(cr)

@api.v7
def create(self, cr, uid, vals, context=None):
res_id = super(IrModel, self).create(cr, uid, vals, context=context)
if vals.get('avoid_quick_create'):
self._patch_quick_create(cr, [res_id])
return res_id

@api.v7
def write(self, cr, uid, ids, vals, context=None):
if isinstance(ids, (int, long)):
ids = [ids]
res = super(IrModel, self).write(cr, uid, ids, vals, context=context)
if 'avoid_quick_create' in vals:
if vals['avoid_quick_create']:
self._patch_quick_create(cr, ids)
else:
for model in self.browse(cr, uid, ids, context=context):
model_obj = self.pool[model.model]
if hasattr(model_obj.name_create, 'origin'):
model_obj._revert_method('name_create')
return res
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<field name="model">ir.model</field>
<field name="inherit_id" ref="base.view_model_form"></field>
<field name="arch" type="xml">
<field name="osv_memory" position="after">
<field name="transient" position="after">
<field name="avoid_quick_create"/>
</field>
</field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Project-Id-Version: OpenERP Server 9.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-03-14 17:41+0000\n"
"PO-Revision-Date: 2014-03-14 17:41+0000\n"
Expand Down
41 changes: 41 additions & 0 deletions base_optional_quick_create/i18n/de.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_optional_quick_create
#
# Translators:
# Rudolf Schnapka <rs@techno-flex.de>, 2016
msgid ""
msgstr ""
"Project-Id-Version: server-tools (8.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-03-12 02:05+0000\n"
"PO-Revision-Date: 2016-01-18 14:01+0000\n"
"Last-Translator: Rudolf Schnapka <rs@techno-flex.de>\n"
"Language-Team: German (http://www.transifex.com/oca/OCA-server-tools-8-0/language/de/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: de\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#. module: base_optional_quick_create
#: field:ir.model,avoid_quick_create:0
msgid "Avoid quick create"
msgstr "Vermeide Schnellanlage"

#. module: base_optional_quick_create
#: code:addons/base_optional_quick_create/model.py:39
#, python-format
msgid "Can't create quickly. Opening create form"
msgstr "Kann nicht schnell-anlegen. Öffne Anlageformular"

#. module: base_optional_quick_create
#: code:addons/base_optional_quick_create/model.py:38
#, python-format
msgid "Error"
msgstr "Fehler"

#. module: base_optional_quick_create
#: model:ir.model,name:base_optional_quick_create.model_ir_model
msgid "Models"
msgstr "Modelle"
6 changes: 3 additions & 3 deletions base_optional_quick_create/i18n/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: server-tools (8.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-09-29 11:14+0000\n"
"POT-Creation-Date: 2016-03-12 02:05+0000\n"
"PO-Revision-Date: 2015-09-18 13:54+0000\n"
"Last-Translator: OCA Transbot <transbot@odoo-community.org>\n"
"Language-Team: English (http://www.transifex.com/oca/OCA-server-tools-8-0/language/en/)\n"
Expand All @@ -23,13 +23,13 @@ msgid "Avoid quick create"
msgstr "Avoid quick create"

#. module: base_optional_quick_create
#: code:addons/base_optional_quick_create/model.py:37
#: code:addons/base_optional_quick_create/model.py:39
#, python-format
msgid "Can't create quickly. Opening create form"
msgstr "Can't create quickly. Opening create form"

#. module: base_optional_quick_create
#: code:addons/base_optional_quick_create/model.py:36
#: code:addons/base_optional_quick_create/model.py:38
#, python-format
msgid "Error"
msgstr "Error"
Expand Down
42 changes: 42 additions & 0 deletions base_optional_quick_create/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_optional_quick_create
#
# Translators:
# Antonio Trueba, 2016
# Antonio Trueba, 2016
msgid ""
msgstr ""
"Project-Id-Version: server-tools (8.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-03-12 02:05+0000\n"
"PO-Revision-Date: 2016-02-10 16:46+0000\n"
"Last-Translator: Antonio Trueba\n"
"Language-Team: Spanish (http://www.transifex.com/oca/OCA-server-tools-8-0/language/es/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: es\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#. module: base_optional_quick_create
#: field:ir.model,avoid_quick_create:0
msgid "Avoid quick create"
msgstr ""

#. module: base_optional_quick_create
#: code:addons/base_optional_quick_create/model.py:39
#, python-format
msgid "Can't create quickly. Opening create form"
msgstr ""

#. module: base_optional_quick_create
#: code:addons/base_optional_quick_create/model.py:38
#, python-format
msgid "Error"
msgstr "Error"

#. module: base_optional_quick_create
#: model:ir.model,name:base_optional_quick_create.model_ir_model
msgid "Models"
msgstr "Modelos"
26 changes: 17 additions & 9 deletions base_optional_quick_create/i18n/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,22 @@
# * base_optional_quick_create
#
# Translators:
# FIRST AUTHOR <EMAIL@ADDRESS>, 2014
# Armando Vulcano Junior <vulcano@uol.com.br>, 2015
# Christophe CHAUVET <christophe.chauvet@gmail.com>, 2016
# FIRST AUTHOR <EMAIL@ADDRESS>, 2012,2014
# Hotellook, 2014
# Jarmo Kortetjärvi <jarmo.kortetjarvi@gmail.com>, 2016
# Matjaž Mozetič <m.mozetic@matmoz.si>, 2015-2016
# Paolo Valier, 2016
# Rudolf Schnapka <rs@techno-flex.de>, 2016
# SaFi J. <safi2266@gmail.com>, 2015
msgid ""
msgstr ""
"Project-Id-Version: server-tools (8.0)\n"
"Project-Id-Version: server-tools (9.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-09-29 11:14+0000\n"
"PO-Revision-Date: 2015-09-18 13:54+0000\n"
"Last-Translator: OCA Transbot <transbot@odoo-community.org>\n"
"POT-Creation-Date: 2016-05-12 14:33+0000\n"
"PO-Revision-Date: 2016-05-08 17:01+0000\n"
"Last-Translator: Christophe CHAUVET <christophe.chauvet@gmail.com>\n"
"Language-Team: French (http://www.transifex.com/oca/OCA-server-tools-8-0/language/fr/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand All @@ -21,16 +29,16 @@ msgstr ""
#. module: base_optional_quick_create
#: field:ir.model,avoid_quick_create:0
msgid "Avoid quick create"
msgstr ""
msgstr "Éviter la création rapide"

#. module: base_optional_quick_create
#: code:addons/base_optional_quick_create/model.py:37
#: code:addons/base_optional_quick_create/model.py:39
#, python-format
msgid "Can't create quickly. Opening create form"
msgstr ""
msgstr "Impossible de créer rapidement. Ouverture du formualire de création"

#. module: base_optional_quick_create
#: code:addons/base_optional_quick_create/model.py:36
#: code:addons/base_optional_quick_create/model.py:38
#, python-format
msgid "Error"
msgstr "Erreur"
Expand Down
Loading