{ "info": { "author": "Savoir-faire Linux", "author_email": "virgil.dupras@savoirfairelinux.com", "bugtrack_url": null, "classifiers": [], "description": "openerp-sane: Bring sanity back, one step at a time\n===================================================\n\nopenerp-sane is a collection of small utilities, making OpenERP development seem less like ancient\nwarfare with blood and guts everywhere, and more like Python.\n\nFor now, there's two utilities: ``@oemeth`` and ``s2d/d2s`` (date conversion). The ``@oemeth``\nmethod decorator which straightens out our we manage the famous ``ids`` argument in our model\nmethods. Example:\n\n.. code-block:: python\n\n def myaction(self, cr, uid, ids, context=None): pass\n\nNormally, ``ids`` is supposed to be a list of ``int``, but *sometimes*, just, **sometimes**, we get\na naked ``int``, then our method crashes. We have to add code like:\n\n.. code-block:: python\n\n if isinstance(ids, (int, long)):\n ids = [ids]\n\nOn top of that, there's another annoyance: why, oh *why* do all my methods have to handle cases\nwith multiple ``ids``? When I have an action for some button in a form, I *know* it's only ever\ngoing to handle one id at a time. I can do ``ids[0]`` easily enough, but if I really want to be\non the safe side, I'll make sure that ``ids`` is a list first. Aren't you tired of that ridiculous\ndance? Well, that's why we have ``@oemeth``\n\nInstall\n-------\n\nYou can't wait to start using it in your modules, right? openerp-sane can be installed from PyPI::\n\n $ pip install openerp-sane\n\nWhen you use it in a module, you can document its dependency to it in your ``__openerp__.py``:\n\n.. code-block:: python\n\n {\n # [...]\n 'external_dependencies': {\n 'python': ['openerp_sane'],\n },\n # [...]\n }\n\n@oemeth\n-------\n\n``@oemeth`` is a method decorator that takes 2 (optional, default to ``False``) arguments:\n``single`` and ``browse``. By default, it simply makes sure that ``ids`` is a list:\n\n.. code-block:: python\n\n from openerp_sane import oemeth\n\n # [...]\n\n @oemeth\n def myaction(self, cr, uid, ids, context=None):\n # Write code that assumes ids is a list\n\nWith ``single`` to ``True``, we enforce a single ``int`` id:\n\n.. code-block:: python\n\n @oemeth(single=True)\n def myaction(self, cr, uid, objid, context=None):\n # objid is an ``int``.\n # WARNING: Use this only when you're sure that you'll only ever have single arguments.\n # If the input is a list with a len() != 1, an exception is raised.\n\nWith ``browse`` to ``True``, we wrap our id(s) in a ``self.browse()`` call:\n\n.. code-block:: python\n\n @oemeth(browse=True)\n def myaction(self, cr, uid, objs, context=None):\n # objs is a list of browse records\n\ns2d/d2s\n-------\n\n``s2d()`` and ``d2s()`` (meaning \"string-to-date\" and \"date-to-string\") are there to alleviate the\nhorrible problem we face when we actually have to process and compare dates. Without these helpers,\nwe have to manually convert those with the right date format, which can get heavy quick.\n\n``s2d(string_date)`` takes the string value from a date field and returns a ``datetime.date``. If\nit can't parse it, it returns ``False``.\n\n``d2s(date)`` takes a ``datetime.date`` and returns a string which can be written to a date field.\nIf ``date`` isn't a date, we return ``False`` (which can also be written to a date field).\n\nIn both those functions, we use OE's ``DEFAULT_SERVER_DATE_FORMAT`` constant.\n\nBits of wisdom\n--------------\n\nDon't use ``single`` (which requires to always have exactly one id all the time) on ``on_change``\nmethods. Sure, most of the time you get a single id, but if your call is made on a record that\nisn't committed yet, you will get zero ids, which will raise an exception. In the future, maybe the\n``single`` mode will support zero ids situations.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/savoirfairelinux/openerp-sane", "keywords": null, "license": "AGPL", "maintainer": null, "maintainer_email": null, "name": "openerp-sane", "package_url": "https://pypi.org/project/openerp-sane/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/openerp-sane/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/savoirfairelinux/openerp-sane" }, "release_url": "https://pypi.org/project/openerp-sane/0.2.1/", "requires_dist": null, "requires_python": null, "summary": "Small utilities to ease OpenERP development", "version": "0.2.1" }, "last_serial": 991592, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "67d6175ffebd4724f8801ca1352f3e56", "sha256": "9901770063286f1778cc6e40f1ad964c4ee24633919008c9e678b1ff9e3a8e0f" }, "downloads": -1, "filename": "openerp-sane-0.1.tar.gz", "has_sig": false, "md5_digest": "67d6175ffebd4724f8801ca1352f3e56", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14184, "upload_time": "2014-01-10T13:56:01", "url": "https://files.pythonhosted.org/packages/0b/98/08e42cb2adab4add651cf7f4640fee62284f82418c4360bd524952d57350/openerp-sane-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "4ee305e365d32f6c882084441ffd75c4", "sha256": "a831921b916ae9c686e20bba7ed60358155e70637b5580a08f6f4fcd754c01dc" }, "downloads": -1, "filename": "openerp-sane-0.2.tar.gz", "has_sig": false, "md5_digest": "4ee305e365d32f6c882084441ffd75c4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15117, "upload_time": "2014-02-05T16:37:53", "url": "https://files.pythonhosted.org/packages/ed/f9/c1ba50cc9cf182818cc8e9ddf79d6a9ab5b071d9e7752b64d134d97b9055/openerp-sane-0.2.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "d7ae812147d14df9981091dfadaecca7", "sha256": "8be0b1bab45b2aa32c3d79c40c3eb150490462688a38922b006327ec0e480b5b" }, "downloads": -1, "filename": "openerp-sane-0.2.1.tar.gz", "has_sig": false, "md5_digest": "d7ae812147d14df9981091dfadaecca7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15159, "upload_time": "2014-02-05T19:46:24", "url": "https://files.pythonhosted.org/packages/32/4c/5fb4a171204d9d623e43879ef32295e8b2ab093281c68fb4a7e86d39d9d8/openerp-sane-0.2.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d7ae812147d14df9981091dfadaecca7", "sha256": "8be0b1bab45b2aa32c3d79c40c3eb150490462688a38922b006327ec0e480b5b" }, "downloads": -1, "filename": "openerp-sane-0.2.1.tar.gz", "has_sig": false, "md5_digest": "d7ae812147d14df9981091dfadaecca7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15159, "upload_time": "2014-02-05T19:46:24", "url": "https://files.pythonhosted.org/packages/32/4c/5fb4a171204d9d623e43879ef32295e8b2ab093281c68fb4a7e86d39d9d8/openerp-sane-0.2.1.tar.gz" } ] }