{"action":"created","comment":{"url":"https://api.github.com/repos/odoo/odoo/pulls/comments/25868644","id":25868644,"diff_hunk":"@@ -1,110 +1,71 @@\n-##############################################################################\n-#    \n-#    OpenERP, Open Source Management Solution\n-#    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).\n-#\n-#    This program is free software: you can redistribute it and/or modify\n-#    it under the terms of the GNU Affero General Public License as\n-#    published by the Free Software Foundation, either version 3 of the\n-#    License, or (at your option) any later version.\n-#\n-#    This program is distributed in the hope that it will be useful,\n-#    but WITHOUT ANY WARRANTY; without even the implied warranty of\n-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n-#    GNU Affero General Public License for more details.\n-#\n-#    You should have received a copy of the GNU Affero General Public License\n-#    along with this program.  If not, see <http://www.gnu.org/licenses/>.     \n-#\n-##############################################################################\n+# -*- coding: utf-8 -*-\n \n import datetime\n+from openerp import api, fields, models \n \n-import openerp\n-from openerp.osv import fields, osv\n \n-class stock_production_lot(osv.osv):\n+class stock_production_lot(models.Model):\n     _inherit = 'stock.production.lot'\n-\n-    def _get_date(dtype):\n+    \n+    @api.model\n+    def _get_date(self, dtype):\n         \"\"\"Return a function to compute the limit date for this type\"\"\"\n-        def calc_date(self, cr, uid, context=None):\n+        def calc_date(dtype):\n             \"\"\"Compute the limit date for a given date\"\"\"\n-            if context is None:\n-                context = {}\n-            if not context.get('product_id', False):\n+            if not self._context.get('product_id', False):\n                 date = False\n             else:\n-                product = openerp.registry(cr.dbname)['product.product'].browse(\n-                    cr, uid, context['product_id'])\n+                product = self.env['product.product'].browse(self._context.get('product_id'))\n                 duration = getattr(product, dtype)\n                 # set date to False when no expiry time specified on the product\n                 date = duration and (datetime.datetime.today()\n                     + datetime.timedelta(days=duration))\n             return date and date.strftime('%Y-%m-%d %H:%M:%S') or False\n-        return calc_date\n+        return calc_date(dtype)\n \n-    _columns = {\n-        'life_date': fields.datetime('End of Life Date',\n-            help='This is the date on which the goods with this Serial Number may become dangerous and must not be consumed.'),\n-        'use_date': fields.datetime('Best before Date',\n-            help='This is the date on which the goods with this Serial Number start deteriorating, without being dangerous yet.'),\n-        'removal_date': fields.datetime('Removal Date',\n-            help='This is the date on which the goods with this Serial Number should be removed from the stock.'),\n-        'alert_date': fields.datetime('Alert Date',\n-            help=\"This is the date on which an alert should be notified about the goods with this Serial Number.\"),\n-    }\n+    life_date = fields.Datetime('End of Life Date', default=lambda self: self._get_date('life_time'),\n+        help='This is the date on which the goods with this Serial Number may become dangerous and must not be consumed.')\n+    use_date = fields.Datetime('Best before Date', default=lambda self: self._get_date('use_time'),\n+        help='This is the date on which the goods with this Serial Number start deteriorating, without being dangerous yet.')\n+    removal_date = fields.Datetime('Removal Date', default=lambda self: self._get_date('removal_time'), ","path":"addons/product_expiry/product_expiry.py","position":71,"original_position":71,"commit_id":"72053b643055f9eb03a8cc78dc2f319f1923036c","original_commit_id":"72053b643055f9eb03a8cc78dc2f319f1923036c","user":{"login":"atp-odoo","id":7599410,"avatar_url":"https://avatars.githubusercontent.com/u/7599410?v=3","gravatar_id":"","url":"https://api.github.com/users/atp-odoo","html_url":"https://github.com/atp-odoo","followers_url":"https://api.github.com/users/atp-odoo/followers","following_url":"https://api.github.com/users/atp-odoo/following{/other_user}","gists_url":"https://api.github.com/users/atp-odoo/gists{/gist_id}","starred_url":"https://api.github.com/users/atp-odoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atp-odoo/subscriptions","organizations_url":"https://api.github.com/users/atp-odoo/orgs","repos_url":"https://api.github.com/users/atp-odoo/repos","events_url":"https://api.github.com/users/atp-odoo/events{/privacy}","received_events_url":"https://api.github.com/users/atp-odoo/received_events","type":"User","site_admin":false},"body":"not required string.","created_at":"2015-03-05T14:53:28Z","updated_at":"2015-03-05T14:53:28Z","html_url":"https://github.com/odoo/odoo/pull/5230#discussion_r25868644","pull_request_url":"https://api.github.com/repos/odoo/odoo/pulls/5230","_links":{"self":{"href":"https://api.github.com/repos/odoo/odoo/pulls/comments/25868644"},"html":{"href":"https://github.com/odoo/odoo/pull/5230#discussion_r25868644"},"pull_request":{"href":"https://api.github.com/repos/odoo/odoo/pulls/5230"}}},"pull_request":{"url":"https://api.github.com/repos/odoo/odoo/pulls/5230","id":29086197,"html_url":"https://github.com/odoo/odoo/pull/5230","diff_url":"https://github.com/odoo/odoo/pull/5230.diff","patch_url":"https://github.com/odoo/odoo/pull/5230.patch","issue_url":"https://api.github.com/repos/odoo/odoo/issues/5230","number":5230,"state":"open","locked":false,"title":"[ product_expiry ] :  Converted into new api.","user":{"login":"jir-odoo","id":7600392,"avatar_url":"https://avatars.githubusercontent.com/u/7600392?v=3","gravatar_id":"","url":"https://api.github.com/users/jir-odoo","html_url":"https://github.com/jir-odoo","followers_url":"https://api.github.com/users/jir-odoo/followers","following_url":"https://api.github.com/users/jir-odoo/following{/other_user}","gists_url":"https://api.github.com/users/jir-odoo/gists{/gist_id}","starred_url":"https://api.github.com/users/jir-odoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jir-odoo/subscriptions","organizations_url":"https://api.github.com/users/jir-odoo/orgs","repos_url":"https://api.github.com/users/jir-odoo/repos","events_url":"https://api.github.com/users/jir-odoo/events{/privacy}","received_events_url":"https://api.github.com/users/jir-odoo/received_events","type":"User","site_admin":false},"body":"Task Link: https://www.odoo.com/web#id=12034&view_type=form&model=project.task&menu_id=3942&action=327\r\nPad Link: https://pad.odoo.com/p/r.HQZeUb6GKwxEH09i","created_at":"2015-02-11T12:11:31Z","updated_at":"2015-03-05T14:53:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e3038a914c1c05128d4e693d7b55623093161732","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/odoo/odoo/pulls/5230/commits","review_comments_url":"https://api.github.com/repos/odoo/odoo/pulls/5230/comments","review_comment_url":"https://api.github.com/repos/odoo/odoo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/odoo/odoo/issues/5230/comments","statuses_url":"https://api.github.com/repos/odoo/odoo/statuses/72053b643055f9eb03a8cc78dc2f319f1923036c","head":{"label":"odoo-dev:convert_product_expiry_in_new_api-jir","ref":"convert_product_expiry_in_new_api-jir","sha":"72053b643055f9eb03a8cc78dc2f319f1923036c","user":{"login":"odoo-dev","id":7466976,"avatar_url":"https://avatars.githubusercontent.com/u/7466976?v=3","gravatar_id":"","url":"https://api.github.com/users/odoo-dev","html_url":"https://github.com/odoo-dev","followers_url":"https://api.github.com/users/odoo-dev/followers","following_url":"https://api.github.com/users/odoo-dev/following{/other_user}","gists_url":"https://api.github.com/users/odoo-dev/gists{/gist_id}","starred_url":"https://api.github.com/users/odoo-dev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odoo-dev/subscriptions","organizations_url":"https://api.github.com/users/odoo-dev/orgs","repos_url":"https://api.github.com/users/odoo-dev/repos","events_url":"https://api.github.com/users/odoo-dev/events{/privacy}","received_events_url":"https://api.github.com/users/odoo-dev/received_events","type":"Organization","site_admin":false},"repo":{"id":19853934,"name":"odoo","full_name":"odoo-dev/odoo","owner":{"login":"odoo-dev","id":7466976,"avatar_url":"https://avatars.githubusercontent.com/u/7466976?v=3","gravatar_id":"","url":"https://api.github.com/users/odoo-dev","html_url":"https://github.com/odoo-dev","followers_url":"https://api.github.com/users/odoo-dev/followers","following_url":"https://api.github.com/users/odoo-dev/following{/other_user}","gists_url":"https://api.github.com/users/odoo-dev/gists{/gist_id}","starred_url":"https://api.github.com/users/odoo-dev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odoo-dev/subscriptions","organizations_url":"https://api.github.com/users/odoo-dev/orgs","repos_url":"https://api.github.com/users/odoo-dev/repos","events_url":"https://api.github.com/users/odoo-dev/events{/privacy}","received_events_url":"https://api.github.com/users/odoo-dev/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/odoo-dev/odoo","description":"RD Dev Repository","fork":true,"url":"https://api.github.com/repos/odoo-dev/odoo","forks_url":"https://api.github.com/repos/odoo-dev/odoo/forks","keys_url":"https://api.github.com/repos/odoo-dev/odoo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/odoo-dev/odoo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/odoo-dev/odoo/teams","hooks_url":"https://api.github.com/repos/odoo-dev/odoo/hooks","issue_events_url":"https://api.github.com/repos/odoo-dev/odoo/issues/events{/number}","events_url":"https://api.github.com/repos/odoo-dev/odoo/events","assignees_url":"https://api.github.com/repos/odoo-dev/odoo/assignees{/user}","branches_url":"https://api.github.com/repos/odoo-dev/odoo/branches{/branch}","tags_url":"https://api.github.com/repos/odoo-dev/odoo/tags","blobs_url":"https://api.github.com/repos/odoo-dev/odoo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/odoo-dev/odoo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/odoo-dev/odoo/git/refs{/sha}","trees_url":"https://api.github.com/repos/odoo-dev/odoo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/odoo-dev/odoo/statuses/{sha}","languages_url":"https://api.github.com/repos/odoo-dev/odoo/languages","stargazers_url":"https://api.github.com/repos/odoo-dev/odoo/stargazers","contributors_url":"https://api.github.com/repos/odoo-dev/odoo/contributors","subscribers_url":"https://api.github.com/repos/odoo-dev/odoo/subscribers","subscription_url":"https://api.github.com/repos/odoo-dev/odoo/subscription","commits_url":"https://api.github.com/repos/odoo-dev/odoo/commits{/sha}","git_commits_url":"https://api.github.com/repos/odoo-dev/odoo/git/commits{/sha}","comments_url":"https://api.github.com/repos/odoo-dev/odoo/comments{/number}","issue_comment_url":"https://api.github.com/repos/odoo-dev/odoo/issues/comments{/number}","contents_url":"https://api.github.com/repos/odoo-dev/odoo/contents/{+path}","compare_url":"https://api.github.com/repos/odoo-dev/odoo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/odoo-dev/odoo/merges","archive_url":"https://api.github.com/repos/odoo-dev/odoo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/odoo-dev/odoo/downloads","issues_url":"https://api.github.com/repos/odoo-dev/odoo/issues{/number}","pulls_url":"https://api.github.com/repos/odoo-dev/odoo/pulls{/number}","milestones_url":"https://api.github.com/repos/odoo-dev/odoo/milestones{/number}","notifications_url":"https://api.github.com/repos/odoo-dev/odoo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/odoo-dev/odoo/labels{/name}","releases_url":"https://api.github.com/repos/odoo-dev/odoo/releases{/id}","created_at":"2014-05-16T11:16:19Z","updated_at":"2015-03-02T11:42:16Z","pushed_at":"2015-03-05T14:48:26Z","git_url":"git://github.com/odoo-dev/odoo.git","ssh_url":"git@github.com:odoo-dev/odoo.git","clone_url":"https://github.com/odoo-dev/odoo.git","svn_url":"https://github.com/odoo-dev/odoo","homepage":"https://www.odoo.com","size":1072502,"stargazers_count":44,"watchers_count":44,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":18,"mirror_url":null,"open_issues_count":10,"forks":18,"open_issues":10,"watchers":44,"default_branch":"master"}},"base":{"label":"odoo:master","ref":"master","sha":"08f9c6d7bd3b1c97e068f34ff827181c3f1746cd","user":{"login":"odoo","id":6368483,"avatar_url":"https://avatars.githubusercontent.com/u/6368483?v=3","gravatar_id":"","url":"https://api.github.com/users/odoo","html_url":"https://github.com/odoo","followers_url":"https://api.github.com/users/odoo/followers","following_url":"https://api.github.com/users/odoo/following{/other_user}","gists_url":"https://api.github.com/users/odoo/gists{/gist_id}","starred_url":"https://api.github.com/users/odoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odoo/subscriptions","organizations_url":"https://api.github.com/users/odoo/orgs","repos_url":"https://api.github.com/users/odoo/repos","events_url":"https://api.github.com/users/odoo/events{/privacy}","received_events_url":"https://api.github.com/users/odoo/received_events","type":"Organization","site_admin":false},"repo":{"id":19745004,"name":"odoo","full_name":"odoo/odoo","owner":{"login":"odoo","id":6368483,"avatar_url":"https://avatars.githubusercontent.com/u/6368483?v=3","gravatar_id":"","url":"https://api.github.com/users/odoo","html_url":"https://github.com/odoo","followers_url":"https://api.github.com/users/odoo/followers","following_url":"https://api.github.com/users/odoo/following{/other_user}","gists_url":"https://api.github.com/users/odoo/gists{/gist_id}","starred_url":"https://api.github.com/users/odoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odoo/subscriptions","organizations_url":"https://api.github.com/users/odoo/orgs","repos_url":"https://api.github.com/users/odoo/repos","events_url":"https://api.github.com/users/odoo/events{/privacy}","received_events_url":"https://api.github.com/users/odoo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/odoo/odoo","description":"Odoo (formerly OpenERP). Open Source Apps To Grow Your Business.","fork":false,"url":"https://api.github.com/repos/odoo/odoo","forks_url":"https://api.github.com/repos/odoo/odoo/forks","keys_url":"https://api.github.com/repos/odoo/odoo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/odoo/odoo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/odoo/odoo/teams","hooks_url":"https://api.github.com/repos/odoo/odoo/hooks","issue_events_url":"https://api.github.com/repos/odoo/odoo/issues/events{/number}","events_url":"https://api.github.com/repos/odoo/odoo/events","assignees_url":"https://api.github.com/repos/odoo/odoo/assignees{/user}","branches_url":"https://api.github.com/repos/odoo/odoo/branches{/branch}","tags_url":"https://api.github.com/repos/odoo/odoo/tags","blobs_url":"https://api.github.com/repos/odoo/odoo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/odoo/odoo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/odoo/odoo/git/refs{/sha}","trees_url":"https://api.github.com/repos/odoo/odoo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/odoo/odoo/statuses/{sha}","languages_url":"https://api.github.com/repos/odoo/odoo/languages","stargazers_url":"https://api.github.com/repos/odoo/odoo/stargazers","contributors_url":"https://api.github.com/repos/odoo/odoo/contributors","subscribers_url":"https://api.github.com/repos/odoo/odoo/subscribers","subscription_url":"https://api.github.com/repos/odoo/odoo/subscription","commits_url":"https://api.github.com/repos/odoo/odoo/commits{/sha}","git_commits_url":"https://api.github.com/repos/odoo/odoo/git/commits{/sha}","comments_url":"https://api.github.com/repos/odoo/odoo/comments{/number}","issue_comment_url":"https://api.github.com/repos/odoo/odoo/issues/comments{/number}","contents_url":"https://api.github.com/repos/odoo/odoo/contents/{+path}","compare_url":"https://api.github.com/repos/odoo/odoo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/odoo/odoo/merges","archive_url":"https://api.github.com/repos/odoo/odoo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/odoo/odoo/downloads","issues_url":"https://api.github.com/repos/odoo/odoo/issues{/number}","pulls_url":"https://api.github.com/repos/odoo/odoo/pulls{/number}","milestones_url":"https://api.github.com/repos/odoo/odoo/milestones{/number}","notifications_url":"https://api.github.com/repos/odoo/odoo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/odoo/odoo/labels{/name}","releases_url":"https://api.github.com/repos/odoo/odoo/releases{/id}","created_at":"2014-05-13T15:38:58Z","updated_at":"2015-03-05T14:20:11Z","pushed_at":"2015-03-05T14:38:33Z","git_url":"git://github.com/odoo/odoo.git","ssh_url":"git@github.com:odoo/odoo.git","clone_url":"https://github.com/odoo/odoo.git","svn_url":"https://github.com/odoo/odoo","homepage":"https://www.odoo.com","size":1098758,"stargazers_count":2156,"watchers_count":2156,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1712,"mirror_url":null,"open_issues_count":1969,"forks":1712,"open_issues":1969,"watchers":2156,"default_branch":"8.0"}},"_links":{"self":{"href":"https://api.github.com/repos/odoo/odoo/pulls/5230"},"html":{"href":"https://github.com/odoo/odoo/pull/5230"},"issue":{"href":"https://api.github.com/repos/odoo/odoo/issues/5230"},"comments":{"href":"https://api.github.com/repos/odoo/odoo/issues/5230/comments"},"review_comments":{"href":"https://api.github.com/repos/odoo/odoo/pulls/5230/comments"},"review_comment":{"href":"https://api.github.com/repos/odoo/odoo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/odoo/odoo/pulls/5230/commits"},"statuses":{"href":"https://api.github.com/repos/odoo/odoo/statuses/72053b643055f9eb03a8cc78dc2f319f1923036c"}}}}