Browse Source

Merge pull request #14 from Tecnativa/11.0-mig-base_optional_quick_create

[11.0] [MIG] base_optional_quick_create
pull/16/head
Pedro M. Baeza 7 years ago
committed by GitHub
parent
commit
0fcae785b4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 59
      base_optional_quick_create/README.rst
  2. 1
      base_optional_quick_create/__init__.py
  3. 17
      base_optional_quick_create/__manifest__.py
  4. 40
      base_optional_quick_create/i18n/base_optional_quick_create.pot
  5. 36
      base_optional_quick_create/i18n/de.po
  6. 35
      base_optional_quick_create/i18n/es.po
  7. 35
      base_optional_quick_create/i18n/fi.po
  8. 35
      base_optional_quick_create/i18n/fr.po
  9. 36
      base_optional_quick_create/i18n/hr.po
  10. 35
      base_optional_quick_create/i18n/hr_HR.po
  11. 32
      base_optional_quick_create/i18n/it.po
  12. 35
      base_optional_quick_create/i18n/nb_NO.po
  13. 35
      base_optional_quick_create/i18n/pt_BR.po
  14. 35
      base_optional_quick_create/i18n/sl.po
  15. 35
      base_optional_quick_create/i18n/tr.po
  16. 35
      base_optional_quick_create/i18n/tr_TR.po
  17. 35
      base_optional_quick_create/i18n/zh_CN.po
  18. 1
      base_optional_quick_create/models/__init__.py
  19. 52
      base_optional_quick_create/models/ir_model.py
  20. BIN
      base_optional_quick_create/static/description/icon.png
  21. 1
      base_optional_quick_create/tests/__init__.py
  22. 33
      base_optional_quick_create/tests/test_quick_create.py
  23. 12
      base_optional_quick_create/views/model_view.xml

59
base_optional_quick_create/README.rst

@ -0,0 +1,59 @@
.. 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
==========================
Base 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
Usage
=====
To use this module, you need to:
* go into the menu of *ir_model*,
* select the model for which you want to disable the quick create option,
* enable the option *Avoid quick create*.
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/250/11.0
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-tools/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
------------
* Jonathan Nemry <jonathan.nemry@acsone.eu>
* Lorenzo Battistini <lorenzo.battistini@agilebg.com>
* Alexis de Lattre <alexis.delattre@akretion.com>
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.

1
base_optional_quick_create/__init__.py

@ -0,0 +1 @@
from . import models

17
base_optional_quick_create/__manifest__.py

@ -0,0 +1,17 @@
# Copyright 2013 Agile Business Group sagl (<http://www.agilebg.com>)
# Copyright 2016 ACSONE SA/NA (<http://acsone.eu>)
{
'name': "Optional quick create",
'version': '11.0.1.0.0',
'category': 'Tools',
'summary': "Avoid 'quick create' on m2o fields, on a 'by model' basis",
'author': "Agile Business Group,Odoo Community Association (OCA)",
'website': 'http://github.com/OCA/server-ux',
'license': 'AGPL-3',
'depends': ['base'],
'data': [
'views/model_view.xml',
],
'installable': True,
}

40
base_optional_quick_create/i18n/base_optional_quick_create.pot

@ -0,0 +1,40 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * base_optional_quick_create
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.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"
"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: base_optional_quick_create
#: model:_description:0
#: model:ir.model,name:base_optional_quick_create.model_ir_model
msgid "Models"
msgstr ""
#. module: base_optional_quick_create
#: code:addons/base_optional_quick_create/model.py:35
#, python-format
msgid "Can't create quickly. Opening create form"
msgstr ""
#. 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:35
#, python-format
msgid "Error"
msgstr ""

36
base_optional_quick_create/i18n/de.po

@ -0,0 +1,36 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_optional_quick_create
#
# Translators:
# OCA Transbot <transbot@odoo-community.org>, 2017
# Rudolf Schnapka <rs@techno-flex.de>, 2017
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-05-10 00:47+0000\n"
"PO-Revision-Date: 2017-05-10 00:47+0000\n"
"Last-Translator: Rudolf Schnapka <rs@techno-flex.de>, 2017\n"
"Language-Team: German (https://www.transifex.com/oca/teams/23907/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
#: model:ir.model.fields,field_description:base_optional_quick_create.field_ir_model_avoid_quick_create
msgid "Avoid quick create"
msgstr "Unterbinde Schnellanlage"
#. module: base_optional_quick_create
#: code:addons/base_optional_quick_create/models/ir_model.py:21
#, python-format
msgid "Can't create quickly. Opening create form"
msgstr "Kann Schnellanlage nicht ausführen. Verwenden Sie Formularanlage"
#. module: base_optional_quick_create
#: model:ir.model,name:base_optional_quick_create.model_ir_model
msgid "Models"
msgstr "Datenmodelle"

35
base_optional_quick_create/i18n/es.po

@ -0,0 +1,35 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_optional_quick_create
#
# Translators:
# OCA Transbot <transbot@odoo-community.org>, 2017
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-05-01 10:38+0000\n"
"PO-Revision-Date: 2017-05-01 10:38+0000\n"
"Last-Translator: OCA Transbot <transbot@odoo-community.org>, 2017\n"
"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/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
#: model:ir.model.fields,field_description:base_optional_quick_create.field_ir_model_avoid_quick_create
msgid "Avoid quick create"
msgstr ""
#. module: base_optional_quick_create
#: code:addons/base_optional_quick_create/models/ir_model.py:21
#, python-format
msgid "Can't create quickly. Opening create form"
msgstr ""
#. module: base_optional_quick_create
#: model:ir.model,name:base_optional_quick_create.model_ir_model
msgid "Models"
msgstr "Modelos"

35
base_optional_quick_create/i18n/fi.po

@ -0,0 +1,35 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_optional_quick_create
#
# Translators:
# OCA Transbot <transbot@odoo-community.org>, 2017
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-05-01 10:38+0000\n"
"PO-Revision-Date: 2017-05-01 10:38+0000\n"
"Last-Translator: OCA Transbot <transbot@odoo-community.org>, 2017\n"
"Language-Team: Finnish (https://www.transifex.com/oca/teams/23907/fi/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: fi\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: base_optional_quick_create
#: model:ir.model.fields,field_description:base_optional_quick_create.field_ir_model_avoid_quick_create
msgid "Avoid quick create"
msgstr ""
#. module: base_optional_quick_create
#: code:addons/base_optional_quick_create/models/ir_model.py:21
#, python-format
msgid "Can't create quickly. Opening create form"
msgstr ""
#. module: base_optional_quick_create
#: model:ir.model,name:base_optional_quick_create.model_ir_model
msgid "Models"
msgstr "Mallit"

35
base_optional_quick_create/i18n/fr.po

@ -0,0 +1,35 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_optional_quick_create
#
# Translators:
# OCA Transbot <transbot@odoo-community.org>, 2016
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 9.0c\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-07-30 00:58+0000\n"
"PO-Revision-Date: 2016-07-30 00:58+0000\n"
"Last-Translator: OCA Transbot <transbot@odoo-community.org>, 2016\n"
"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: fr\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#. module: base_optional_quick_create
#: model:ir.model.fields,field_description:base_optional_quick_create.field_ir_model_avoid_quick_create
msgid "Avoid quick create"
msgstr ""
#. module: base_optional_quick_create
#: code:addons/base_optional_quick_create/models/ir_model.py:19
#, python-format
msgid "Can't create quickly. Opening create form"
msgstr ""
#. module: base_optional_quick_create
#: model:ir.model,name:base_optional_quick_create.model_ir_model
msgid "Models"
msgstr "Modèles"

36
base_optional_quick_create/i18n/hr.po

@ -0,0 +1,36 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_optional_quick_create
#
# Translators:
# OCA Transbot <transbot@odoo-community.org>, 2017
# Bole <bole@dajmi5.com>, 2017
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-07-13 01:00+0000\n"
"PO-Revision-Date: 2017-07-13 01:00+0000\n"
"Last-Translator: Bole <bole@dajmi5.com>, 2017\n"
"Language-Team: Croatian (https://www.transifex.com/oca/teams/23907/hr/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: hr\n"
"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
#. module: base_optional_quick_create
#: model:ir.model.fields,field_description:base_optional_quick_create.field_ir_model_avoid_quick_create
msgid "Avoid quick create"
msgstr "Izbjegni brzo kreiranje"
#. module: base_optional_quick_create
#: code:addons/base_optional_quick_create/models/ir_model.py:21
#, python-format
msgid "Can't create quickly. Opening create form"
msgstr "Nije moguće brzo kreiranje, otvaram formu za kreiranje"
#. module: base_optional_quick_create
#: model:ir.model,name:base_optional_quick_create.model_ir_model
msgid "Models"
msgstr "Modeli"

35
base_optional_quick_create/i18n/hr_HR.po

@ -0,0 +1,35 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_optional_quick_create
#
# Translators:
# OCA Transbot <transbot@odoo-community.org>, 2017
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-05-01 10:38+0000\n"
"PO-Revision-Date: 2017-05-01 10:38+0000\n"
"Last-Translator: OCA Transbot <transbot@odoo-community.org>, 2017\n"
"Language-Team: Croatian (Croatia) (https://www.transifex.com/oca/teams/23907/hr_HR/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: hr_HR\n"
"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
#. module: base_optional_quick_create
#: model:ir.model.fields,field_description:base_optional_quick_create.field_ir_model_avoid_quick_create
msgid "Avoid quick create"
msgstr ""
#. module: base_optional_quick_create
#: code:addons/base_optional_quick_create/models/ir_model.py:21
#, python-format
msgid "Can't create quickly. Opening create form"
msgstr ""
#. module: base_optional_quick_create
#: model:ir.model,name:base_optional_quick_create.model_ir_model
msgid "Models"
msgstr "Modeli"

32
base_optional_quick_create/i18n/it.po

@ -0,0 +1,32 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_optional_quick_create
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-03-19 17:10+0000\n"
"PO-Revision-Date: 2018-03-19 17:10+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: base_optional_quick_create
#: model:ir.model.fields,field_description:base_optional_quick_create.field_ir_model_avoid_quick_create
msgid "Avoid quick create"
msgstr "Evita creazione veloce"
#. module: base_optional_quick_create
#: code:addons/base_optional_quick_create/models/ir_model.py:21
#, python-format
msgid "Can't create %s with name %s quickly.\nPlease contact your system administrator to disable this behaviour."
msgstr "Non è possibile creare velocemente un %s con nome %s.\nSi prega di contattare l'amministratore di sistema per disabilitare questo comportamento."
#. module: base_optional_quick_create
#: model:ir.model,name:base_optional_quick_create.model_ir_model
msgid "Models"
msgstr "Modelli"

35
base_optional_quick_create/i18n/nb_NO.po

@ -0,0 +1,35 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_optional_quick_create
#
# Translators:
# OCA Transbot <transbot@odoo-community.org>, 2017
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-05-01 10:38+0000\n"
"PO-Revision-Date: 2017-05-01 10:38+0000\n"
"Last-Translator: OCA Transbot <transbot@odoo-community.org>, 2017\n"
"Language-Team: Norwegian Bokmål (Norway) (https://www.transifex.com/oca/teams/23907/nb_NO/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: nb_NO\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: base_optional_quick_create
#: model:ir.model.fields,field_description:base_optional_quick_create.field_ir_model_avoid_quick_create
msgid "Avoid quick create"
msgstr ""
#. module: base_optional_quick_create
#: code:addons/base_optional_quick_create/models/ir_model.py:21
#, python-format
msgid "Can't create quickly. Opening create form"
msgstr ""
#. module: base_optional_quick_create
#: model:ir.model,name:base_optional_quick_create.model_ir_model
msgid "Models"
msgstr "Modeller"

35
base_optional_quick_create/i18n/pt_BR.po

@ -0,0 +1,35 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_optional_quick_create
#
# Translators:
# OCA Transbot <transbot@odoo-community.org>, 2017
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-05-01 10:38+0000\n"
"PO-Revision-Date: 2017-05-01 10:38+0000\n"
"Last-Translator: OCA Transbot <transbot@odoo-community.org>, 2017\n"
"Language-Team: Portuguese (Brazil) (https://www.transifex.com/oca/teams/23907/pt_BR/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: pt_BR\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#. module: base_optional_quick_create
#: model:ir.model.fields,field_description:base_optional_quick_create.field_ir_model_avoid_quick_create
msgid "Avoid quick create"
msgstr "Evite criação rápida"
#. module: base_optional_quick_create
#: code:addons/base_optional_quick_create/models/ir_model.py:21
#, python-format
msgid "Can't create quickly. Opening create form"
msgstr "Não pode criar rapidamente; Abrindo formulário de criação"
#. module: base_optional_quick_create
#: model:ir.model,name:base_optional_quick_create.model_ir_model
msgid "Models"
msgstr "Modelos"

35
base_optional_quick_create/i18n/sl.po

@ -0,0 +1,35 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_optional_quick_create
#
# Translators:
# OCA Transbot <transbot@odoo-community.org>, 2017
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-05-01 10:38+0000\n"
"PO-Revision-Date: 2017-05-01 10:38+0000\n"
"Last-Translator: OCA Transbot <transbot@odoo-community.org>, 2017\n"
"Language-Team: Slovenian (https://www.transifex.com/oca/teams/23907/sl/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: sl\n"
"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n"
#. module: base_optional_quick_create
#: model:ir.model.fields,field_description:base_optional_quick_create.field_ir_model_avoid_quick_create
msgid "Avoid quick create"
msgstr "Izogibanje hitremu ustvarjanju"
#. module: base_optional_quick_create
#: code:addons/base_optional_quick_create/models/ir_model.py:21
#, python-format
msgid "Can't create quickly. Opening create form"
msgstr "Ne morete hitro ustvariti. Odpiram obrazec za ustvarjanje"
#. module: base_optional_quick_create
#: model:ir.model,name:base_optional_quick_create.model_ir_model
msgid "Models"
msgstr "Modeli"

35
base_optional_quick_create/i18n/tr.po

@ -0,0 +1,35 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_optional_quick_create
#
# Translators:
# OCA Transbot <transbot@odoo-community.org>, 2017
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-05-01 10:38+0000\n"
"PO-Revision-Date: 2017-05-01 10:38+0000\n"
"Last-Translator: OCA Transbot <transbot@odoo-community.org>, 2017\n"
"Language-Team: Turkish (https://www.transifex.com/oca/teams/23907/tr/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: tr\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#. module: base_optional_quick_create
#: model:ir.model.fields,field_description:base_optional_quick_create.field_ir_model_avoid_quick_create
msgid "Avoid quick create"
msgstr ""
#. module: base_optional_quick_create
#: code:addons/base_optional_quick_create/models/ir_model.py:21
#, python-format
msgid "Can't create quickly. Opening create form"
msgstr ""
#. module: base_optional_quick_create
#: model:ir.model,name:base_optional_quick_create.model_ir_model
msgid "Models"
msgstr "Modeller"

35
base_optional_quick_create/i18n/tr_TR.po

@ -0,0 +1,35 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_optional_quick_create
#
# Translators:
# OCA Transbot <transbot@odoo-community.org>, 2017
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-05-01 10:38+0000\n"
"PO-Revision-Date: 2017-05-01 10:38+0000\n"
"Last-Translator: OCA Transbot <transbot@odoo-community.org>, 2017\n"
"Language-Team: Turkish (Turkey) (https://www.transifex.com/oca/teams/23907/tr_TR/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: tr_TR\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#. module: base_optional_quick_create
#: model:ir.model.fields,field_description:base_optional_quick_create.field_ir_model_avoid_quick_create
msgid "Avoid quick create"
msgstr ""
#. module: base_optional_quick_create
#: code:addons/base_optional_quick_create/models/ir_model.py:21
#, python-format
msgid "Can't create quickly. Opening create form"
msgstr ""
#. module: base_optional_quick_create
#: model:ir.model,name:base_optional_quick_create.model_ir_model
msgid "Models"
msgstr "Tipler"

35
base_optional_quick_create/i18n/zh_CN.po

@ -0,0 +1,35 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_optional_quick_create
#
# Translators:
# Jeffery Chenn <jeffery9@gmail.com>, 2016
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 9.0c\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-08-31 11:58+0000\n"
"PO-Revision-Date: 2016-08-31 11:58+0000\n"
"Last-Translator: Jeffery Chenn <jeffery9@gmail.com>, 2016\n"
"Language-Team: Chinese (China) (https://www.transifex.com/oca/teams/23907/zh_CN/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: zh_CN\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#. module: base_optional_quick_create
#: model:ir.model.fields,field_description:base_optional_quick_create.field_ir_model_avoid_quick_create
msgid "Avoid quick create"
msgstr "避免快速创建"
#. module: base_optional_quick_create
#: code:addons/base_optional_quick_create/models/ir_model.py:19
#, python-format
msgid "Can't create quickly. Opening create form"
msgstr ""
#. module: base_optional_quick_create
#: model:ir.model,name:base_optional_quick_create.model_ir_model
msgid "Models"
msgstr "模型"

1
base_optional_quick_create/models/__init__.py

@ -0,0 +1 @@
from . import ir_model

52
base_optional_quick_create/models/ir_model.py

@ -0,0 +1,52 @@
# Copyright 2016 ACSONE SA/NA (<http://acsone.eu>)
# Copyright 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# Copyright 2018 Simone Rubino - Agile Business Group
from odoo import api, fields, models, _
from odoo.exceptions import UserError
class IrModel(models.Model):
_inherit = 'ir.model'
avoid_quick_create = fields.Boolean()
@api.multi
def _patch_quick_create(self):
def _wrap_name_create():
@api.model
def wrapper(self, name):
raise UserError(_(
"Can't create %s with name %s quickly.\n"
"Please contact your system administrator to disable "
"this behaviour.") % (self._name, name))
return wrapper
method_name = 'name_create'
for model in self:
model_obj = self.env.get(model.model)
if model.avoid_quick_create:
model_obj._patch_method(method_name, _wrap_name_create())
else:
method = getattr(model_obj, method_name, None)
if method and hasattr(method, 'origin'):
model_obj._revert_method(method_name)
return True
def _register_hook(self):
models = self.search([])
models._patch_quick_create()
return super(IrModel, self)._register_hook()
@api.model
def create(self, vals):
ir_model = super(IrModel, self).create(vals)
ir_model._patch_quick_create()
return ir_model
@api.multi
def write(self, vals):
res = super(IrModel, self).write(vals)
self._patch_quick_create()
return res

BIN
base_optional_quick_create/static/description/icon.png

After

Width: 128  |  Height: 128  |  Size: 9.2 KiB

1
base_optional_quick_create/tests/__init__.py

@ -0,0 +1 @@
from . import test_quick_create

33
base_optional_quick_create/tests/test_quick_create.py

@ -0,0 +1,33 @@
# Copyright 2018 Simone Rubino - Agile Business Group
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo.exceptions import UserError
from odoo.tests.common import TransactionCase
class TestQuickCreate(TransactionCase):
def setUp(self, *args, **kwargs):
super(TestQuickCreate, self).setUp()
model_model = self.env['ir.model']
self.partner_model = model_model.search([
('model', '=', 'res.partner')])
def test_quick_create(self):
partner_id = self.env['res.partner'].name_create('TEST partner')
self.assertEqual(bool(partner_id), True)
# Setting the flag, patches the method
self.partner_model.avoid_quick_create = True
with self.assertRaises(UserError):
self.env['res.partner'].name_create('TEST partner')
# Unsetting the flag, unpatches the method
self.partner_model.avoid_quick_create = False
partner_id = self.env['res.partner'].name_create('TEST partner')
self.assertEqual(bool(partner_id), True)
def test_create_model(self):
model_id = self.env['ir.model'].create({'name': 'Test',
'model': 'x_test_model'})
self.assertEqual(bool(model_id), True)

12
base_optional_quick_create/views/model_view.xml

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_model_form" model="ir.ui.view">
<field name="model">ir.model</field>
<field name="inherit_id" ref="base.view_model_form"></field>
<field name="arch" type="xml">
<field name="transient" position="after">
<field name="avoid_quick_create"/>
</field>
</field>
</record>
</odoo>
Loading…
Cancel
Save