Skip to content

Commit

Permalink
Merge pull request #16 from gisce/add_exists_to_orm
Browse files Browse the repository at this point in the history
Add orm_mongodb.exists method
  • Loading branch information
ecarreras authored Oct 24, 2017
2 parents dbf61a5 + 48b6fc6 commit fd74eb1
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.pydevproject
.settings
*.pyc
.idea
45 changes: 45 additions & 0 deletions i18n/ca_ES.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
#
# Translators:
# Jaume Florez Valenzuela <[email protected]>, 2017.
msgid ""
msgstr ""
"Project-Id-Version: GISCE-ERP\n"
"Report-Msgid-Bugs-To: https://github.com/gisce/erp/issues\n"
"POT-Creation-Date: 2017-10-24 11:27\n"
"PO-Revision-Date: 2017-10-24 09:36+0000\n"
"Last-Translator: Jaume Florez Valenzuela <[email protected]>\n"
"Language-Team: Catalan (Spain) <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: ca_ES\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#. module: mongodb_backend
#: model:ir.module.module,shortdesc:mongodb_backend.module_meta_information
msgid "MongoDB Backend"
msgstr "MongoDB Backend"

#. module: mongodb_backend
#: model:ir.module.module,description:mongodb_backend.module_meta_information
msgid ""
"\n"
"NoSQL MongoDB backend for OpenERP. It allows to create objects and store\n"
"all the data in a NoSQL way. You can interact with this data the same way\n"
"as it was stored in PostgreSQL from the client.\n"
" "
msgstr "\nNoSQL MongoDB backend per OpenERP. Permet la creació i emmagatzematge d'objectes mitjançant NoSQL. Es pot interactuar amb les dades de la mateixa manera que amb PostgreSQL desde el client.\n "

#. module: mongodb_backend
#: code:addons/mongodb_backend/orm_mongodb.py:437
#, python-format
msgid "Error"
msgstr "Error"

#. module: mongodb_backend
#: code:addons/mongodb_backend/orm_mongodb.py:438
#, python-format
msgid "Bad order declaration for model %s"
msgstr "Declaració incorrecta del ordre per al model %s"
45 changes: 45 additions & 0 deletions i18n/es_ES.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
#
# Translators:
# Jaume Florez Valenzuela <[email protected]>, 2017.
msgid ""
msgstr ""
"Project-Id-Version: GISCE-ERP\n"
"Report-Msgid-Bugs-To: https://github.com/gisce/erp/issues\n"
"POT-Creation-Date: 2017-10-24 11:27\n"
"PO-Revision-Date: 2017-10-24 09:34+0000\n"
"Last-Translator: Jaume Florez Valenzuela <[email protected]>\n"
"Language-Team: Spanish (Spain) <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: es_ES\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#. module: mongodb_backend
#: model:ir.module.module,shortdesc:mongodb_backend.module_meta_information
msgid "MongoDB Backend"
msgstr "MongoDB Backend"

#. module: mongodb_backend
#: model:ir.module.module,description:mongodb_backend.module_meta_information
msgid ""
"\n"
"NoSQL MongoDB backend for OpenERP. It allows to create objects and store\n"
"all the data in a NoSQL way. You can interact with this data the same way\n"
"as it was stored in PostgreSQL from the client.\n"
" "
msgstr "\nNoSQL MongoDB backend para OpenERP. Permite la creación y almacenaje de datos con NoSQL. Puede interactuar con los datos de la misma forma que con PostgreSQL desde el cliente.\n "

#. module: mongodb_backend
#: code:addons/mongodb_backend/orm_mongodb.py:437
#, python-format
msgid "Error"
msgstr "Error"

#. module: mongodb_backend
#: code:addons/mongodb_backend/orm_mongodb.py:438
#, python-format
msgid "Bad order declaration for model %s"
msgstr "Mala declaración del orden para el modelo %s"
43 changes: 43 additions & 0 deletions i18n/mongodb_backend.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * mongodb_backend
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 5.0.14\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2017-10-24 11:27\n"
"PO-Revision-Date: 2017-10-24 11:27\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: mongodb_backend
#: model:ir.module.module,shortdesc:mongodb_backend.module_meta_information
msgid "MongoDB Backend"
msgstr ""

#. module: mongodb_backend
#: model:ir.module.module,description:mongodb_backend.module_meta_information
msgid "\n"
"NoSQL MongoDB backend for OpenERP. It allows to create objects and store\n"
"all the data in a NoSQL way. You can interact with this data the same way\n"
"as it was stored in PostgreSQL from the client.\n"
" "
msgstr ""

#. module: mongodb_backend
#: code:addons/mongodb_backend/orm_mongodb.py:437
#, python-format
msgid "Error"
msgstr ""

#. module: mongodb_backend
#: code:addons/mongodb_backend/orm_mongodb.py:438
#, python-format
msgid "Bad order declaration for model %s"
msgstr ""

12 changes: 12 additions & 0 deletions orm_mongodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,18 @@ def preformat_write_fields(self, vals):
ss = self._columns[key]._symbol_set
vals[key] = ss[1](value)

def exists(self, cr, uid, ids, context=None):
collection = mdbpool.get_collection(self._table)

if not context:
context = {}
if not ids:
return False

mongo_cr = collection.find({'id': ids}, ['id'])
res = [x for x in mongo_cr]
return True if res else False

def read(self, cr, user, ids, fields=None, context=None,
load='_classic_read'):

Expand Down

0 comments on commit fd74eb1

Please sign in to comment.