{"action":"created","comment":{"url":"https://api.github.com/repos/OCA/manufacture/pulls/comments/43008232","id":43008232,"diff_hunk":"@@ -0,0 +1,299 @@\n+# -*- coding: utf-8 -*-\n+##############################################################################\n+# For copyright and license notices, see __openerp__.py file in root directory\n+##############################################################################\n+from openerp import models, fields, api, exceptions, _\n+\n+\n+class QcInspection(models.Model):\n+    _name = 'qc.inspection'\n+    _description = 'Quality control inspection'\n+    _inherit = ['mail.thread', 'ir.needaction_mixin']\n+\n+    @api.one\n+    @api.depends('inspection_lines', 'inspection_lines.success')\n+    def _success(self):\n+        self.success = all([x.success for x in self.inspection_lines])\n+\n+    @api.multi\n+    def _links_get(self):\n+        link_obj = self.env['res.request.link']\n+        return [(r.object, r.name) for r in link_obj.search([])]\n+\n+    @api.one\n+    @api.depends('object_id')\n+    def _get_product(self):\n+        if self.object_id and self.object_id._name == 'product.product':\n+            self.product = self.object_id\n+        else:\n+            self.product = False\n+\n+    @api.one\n+    @api.depends('object_id')\n+    def _get_qty(self):\n+        self.qty = 1.0\n+\n+    name = fields.Char(\n+        string='Inspection number', required=True, default='/', select=True,\n+        readonly=True, states={'draft': [('readonly', False)]}, copy=False)\n+    date = fields.Datetime(\n+        string='Date', required=True, readonly=True, copy=False,\n+        default=fields.Datetime.now,\n+        states={'draft': [('readonly', False)]}, select=True)\n+    object_id = fields.Reference(\n+        string='Reference', selection=_links_get, readonly=True,\n+        states={'draft': [('readonly', False)]}, ondelete=\"set null\")\n+    product = fields.Many2one(\n+        comodel_name=\"product.product\", compute=\"_get_product\", store=True,\n+        help=\"Product associated with the inspection\")\n+    qty = fields.Float(string=\"Quantity\", compute=\"_get_qty\", store=True)\n+    test = fields.Many2one(\n+        comodel_name='qc.test', string='Test', readonly=True, select=True)\n+    inspection_lines = fields.One2many(\n+        comodel_name='qc.inspection.line', inverse_name='inspection_id',\n+        string='Inspection lines', readonly=True,\n+        states={'ready': [('readonly', False)]})\n+    internal_notes = fields.Text(string='Internal notes')\n+    external_notes = fields.Text(\n+        string='External notes',\n+        states={'success': [('readonly', True)],\n+                'failed': [('readonly', True)]})\n+    state = fields.Selection(\n+        [('draft', 'Draft'),\n+         ('ready', 'Ready'),\n+         ('waiting', 'Waiting supervisor approval'),\n+         ('success', 'Quality success'),\n+         ('failed', 'Quality failed'),\n+         ('canceled', 'Cancelled')],\n+        string='State', readonly=True, default='draft')\n+    success = fields.Boolean(\n+        compute=\"_success\", string='Success',\n+        help='This field will be marked if all tests have been succeeded.',\n+        store=True)\n+    auto_generated = fields.Boolean(\n+        string='Auto-generated', readonly=True, copy=False,\n+        help='If an inspection is auto-generated, it can be cancelled nor '\n+             'removed')\n+    company_id = fields.Many2one(\n+        comodel_name='res.company', string='Company', readonly=True,\n+        states={'draft': [('readonly', False)]},\n+        default=lambda self: self.env['res.company']._company_default_get(\n+            'qc.inspection'))\n+    user = fields.Many2one(\n+        comodel_name='res.users', string='Responsible',\n+        track_visibility='always', default=lambda self: self.env.user)\n+\n+    @api.model\n+    def create(self, vals):\n+        if vals.get('name', '/') == '/':\n+            vals['name'] = self.env['ir.sequence'].get('qc.inspection')\n+        return super(QcInspection, self).create(vals)\n+\n+    @api.multi\n+    def unlink(self):\n+        for inspection in self:\n+            if inspection.auto_generated:\n+                raise exceptions.Warning(\n+                    _(\"You cannot remove an auto-generated inspection\"))\n+            if inspection.state != 'draft':\n+                raise exceptions.Warning(\n+                    _(\"You cannot remove an inspection that it's not in draft \"\n+                      \"state\"))","path":"quality_control/models/qc_inspection.py","position":101,"original_position":101,"commit_id":"6e885ac09944fcfec384886a4711643ae73421ac","original_commit_id":"6e885ac09944fcfec384886a4711643ae73421ac","user":{"login":"elicoidal","id":7600613,"avatar_url":"https://avatars.githubusercontent.com/u/7600613?v=3","gravatar_id":"","url":"https://api.github.com/users/elicoidal","html_url":"https://github.com/elicoidal","followers_url":"https://api.github.com/users/elicoidal/followers","following_url":"https://api.github.com/users/elicoidal/following{/other_user}","gists_url":"https://api.github.com/users/elicoidal/gists{/gist_id}","starred_url":"https://api.github.com/users/elicoidal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elicoidal/subscriptions","organizations_url":"https://api.github.com/users/elicoidal/orgs","repos_url":"https://api.github.com/users/elicoidal/repos","events_url":"https://api.github.com/users/elicoidal/events{/privacy}","received_events_url":"https://api.github.com/users/elicoidal/received_events","type":"User","site_admin":false},"body":"add period","created_at":"2015-10-26T15:30:46Z","updated_at":"2015-10-26T15:30:46Z","html_url":"https://github.com/OCA/manufacture/pull/43#discussion_r43008232","pull_request_url":"https://api.github.com/repos/OCA/manufacture/pulls/43","_links":{"self":{"href":"https://api.github.com/repos/OCA/manufacture/pulls/comments/43008232"},"html":{"href":"https://github.com/OCA/manufacture/pull/43#discussion_r43008232"},"pull_request":{"href":"https://api.github.com/repos/OCA/manufacture/pulls/43"}}},"pull_request":{"url":"https://api.github.com/repos/OCA/manufacture/pulls/43","id":48734699,"html_url":"https://github.com/OCA/manufacture/pull/43","diff_url":"https://github.com/OCA/manufacture/pull/43.diff","patch_url":"https://github.com/OCA/manufacture/pull/43.patch","issue_url":"https://api.github.com/repos/OCA/manufacture/issues/43","number":43,"state":"open","locked":false,"title":"[8.0][ADD] New module quality_control","user":{"login":"oihane","id":2323616,"avatar_url":"https://avatars.githubusercontent.com/u/2323616?v=3","gravatar_id":"","url":"https://api.github.com/users/oihane","html_url":"https://github.com/oihane","followers_url":"https://api.github.com/users/oihane/followers","following_url":"https://api.github.com/users/oihane/following{/other_user}","gists_url":"https://api.github.com/users/oihane/gists{/gist_id}","starred_url":"https://api.github.com/users/oihane/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oihane/subscriptions","organizations_url":"https://api.github.com/users/oihane/orgs","repos_url":"https://api.github.com/users/oihane/repos","events_url":"https://api.github.com/users/oihane/events{/privacy}","received_events_url":"https://api.github.com/users/oihane/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-10-26T12:48:16Z","updated_at":"2015-10-26T15:30:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9b1e1a0adb527643ac1a2a472e79401baad45abe","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/OCA/manufacture/pulls/43/commits","review_comments_url":"https://api.github.com/repos/OCA/manufacture/pulls/43/comments","review_comment_url":"https://api.github.com/repos/OCA/manufacture/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OCA/manufacture/issues/43/comments","statuses_url":"https://api.github.com/repos/OCA/manufacture/statuses/6e885ac09944fcfec384886a4711643ae73421ac","head":{"label":"odoomrp:8.0-quality","ref":"8.0-quality","sha":"6e885ac09944fcfec384886a4711643ae73421ac","user":{"login":"odoomrp","id":7858947,"avatar_url":"https://avatars.githubusercontent.com/u/7858947?v=3","gravatar_id":"","url":"https://api.github.com/users/odoomrp","html_url":"https://github.com/odoomrp","followers_url":"https://api.github.com/users/odoomrp/followers","following_url":"https://api.github.com/users/odoomrp/following{/other_user}","gists_url":"https://api.github.com/users/odoomrp/gists{/gist_id}","starred_url":"https://api.github.com/users/odoomrp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odoomrp/subscriptions","organizations_url":"https://api.github.com/users/odoomrp/orgs","repos_url":"https://api.github.com/users/odoomrp/repos","events_url":"https://api.github.com/users/odoomrp/events{/privacy}","received_events_url":"https://api.github.com/users/odoomrp/received_events","type":"Organization","site_admin":false},"repo":{"id":43489133,"name":"manufacture","full_name":"odoomrp/manufacture","owner":{"login":"odoomrp","id":7858947,"avatar_url":"https://avatars.githubusercontent.com/u/7858947?v=3","gravatar_id":"","url":"https://api.github.com/users/odoomrp","html_url":"https://github.com/odoomrp","followers_url":"https://api.github.com/users/odoomrp/followers","following_url":"https://api.github.com/users/odoomrp/following{/other_user}","gists_url":"https://api.github.com/users/odoomrp/gists{/gist_id}","starred_url":"https://api.github.com/users/odoomrp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odoomrp/subscriptions","organizations_url":"https://api.github.com/users/odoomrp/orgs","repos_url":"https://api.github.com/users/odoomrp/repos","events_url":"https://api.github.com/users/odoomrp/events{/privacy}","received_events_url":"https://api.github.com/users/odoomrp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/odoomrp/manufacture","description":"Odoo Manufacturing Addons","fork":true,"url":"https://api.github.com/repos/odoomrp/manufacture","forks_url":"https://api.github.com/repos/odoomrp/manufacture/forks","keys_url":"https://api.github.com/repos/odoomrp/manufacture/keys{/key_id}","collaborators_url":"https://api.github.com/repos/odoomrp/manufacture/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/odoomrp/manufacture/teams","hooks_url":"https://api.github.com/repos/odoomrp/manufacture/hooks","issue_events_url":"https://api.github.com/repos/odoomrp/manufacture/issues/events{/number}","events_url":"https://api.github.com/repos/odoomrp/manufacture/events","assignees_url":"https://api.github.com/repos/odoomrp/manufacture/assignees{/user}","branches_url":"https://api.github.com/repos/odoomrp/manufacture/branches{/branch}","tags_url":"https://api.github.com/repos/odoomrp/manufacture/tags","blobs_url":"https://api.github.com/repos/odoomrp/manufacture/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/odoomrp/manufacture/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/odoomrp/manufacture/git/refs{/sha}","trees_url":"https://api.github.com/repos/odoomrp/manufacture/git/trees{/sha}","statuses_url":"https://api.github.com/repos/odoomrp/manufacture/statuses/{sha}","languages_url":"https://api.github.com/repos/odoomrp/manufacture/languages","stargazers_url":"https://api.github.com/repos/odoomrp/manufacture/stargazers","contributors_url":"https://api.github.com/repos/odoomrp/manufacture/contributors","subscribers_url":"https://api.github.com/repos/odoomrp/manufacture/subscribers","subscription_url":"https://api.github.com/repos/odoomrp/manufacture/subscription","commits_url":"https://api.github.com/repos/odoomrp/manufacture/commits{/sha}","git_commits_url":"https://api.github.com/repos/odoomrp/manufacture/git/commits{/sha}","comments_url":"https://api.github.com/repos/odoomrp/manufacture/comments{/number}","issue_comment_url":"https://api.github.com/repos/odoomrp/manufacture/issues/comments{/number}","contents_url":"https://api.github.com/repos/odoomrp/manufacture/contents/{+path}","compare_url":"https://api.github.com/repos/odoomrp/manufacture/compare/{base}...{head}","merges_url":"https://api.github.com/repos/odoomrp/manufacture/merges","archive_url":"https://api.github.com/repos/odoomrp/manufacture/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/odoomrp/manufacture/downloads","issues_url":"https://api.github.com/repos/odoomrp/manufacture/issues{/number}","pulls_url":"https://api.github.com/repos/odoomrp/manufacture/pulls{/number}","milestones_url":"https://api.github.com/repos/odoomrp/manufacture/milestones{/number}","notifications_url":"https://api.github.com/repos/odoomrp/manufacture/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/odoomrp/manufacture/labels{/name}","releases_url":"https://api.github.com/repos/odoomrp/manufacture/releases{/id}","created_at":"2015-10-01T09:47:09Z","updated_at":"2015-10-01T09:47:09Z","pushed_at":"2015-10-26T13:47:19Z","git_url":"git://github.com/odoomrp/manufacture.git","ssh_url":"git@github.com:odoomrp/manufacture.git","clone_url":"https://github.com/odoomrp/manufacture.git","svn_url":"https://github.com/odoomrp/manufacture","homepage":"","size":303,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"8.0"}},"base":{"label":"OCA:8.0","ref":"8.0","sha":"ed2d27223b033566472f3775fc6b38eff08f8608","user":{"login":"OCA","id":7600578,"avatar_url":"https://avatars.githubusercontent.com/u/7600578?v=3","gravatar_id":"","url":"https://api.github.com/users/OCA","html_url":"https://github.com/OCA","followers_url":"https://api.github.com/users/OCA/followers","following_url":"https://api.github.com/users/OCA/following{/other_user}","gists_url":"https://api.github.com/users/OCA/gists{/gist_id}","starred_url":"https://api.github.com/users/OCA/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OCA/subscriptions","organizations_url":"https://api.github.com/users/OCA/orgs","repos_url":"https://api.github.com/users/OCA/repos","events_url":"https://api.github.com/users/OCA/events{/privacy}","received_events_url":"https://api.github.com/users/OCA/received_events","type":"Organization","site_admin":false},"repo":{"id":20894327,"name":"manufacture","full_name":"OCA/manufacture","owner":{"login":"OCA","id":7600578,"avatar_url":"https://avatars.githubusercontent.com/u/7600578?v=3","gravatar_id":"","url":"https://api.github.com/users/OCA","html_url":"https://github.com/OCA","followers_url":"https://api.github.com/users/OCA/followers","following_url":"https://api.github.com/users/OCA/following{/other_user}","gists_url":"https://api.github.com/users/OCA/gists{/gist_id}","starred_url":"https://api.github.com/users/OCA/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OCA/subscriptions","organizations_url":"https://api.github.com/users/OCA/orgs","repos_url":"https://api.github.com/users/OCA/repos","events_url":"https://api.github.com/users/OCA/events{/privacy}","received_events_url":"https://api.github.com/users/OCA/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OCA/manufacture","description":"Odoo Manufacturing Addons","fork":false,"url":"https://api.github.com/repos/OCA/manufacture","forks_url":"https://api.github.com/repos/OCA/manufacture/forks","keys_url":"https://api.github.com/repos/OCA/manufacture/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OCA/manufacture/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OCA/manufacture/teams","hooks_url":"https://api.github.com/repos/OCA/manufacture/hooks","issue_events_url":"https://api.github.com/repos/OCA/manufacture/issues/events{/number}","events_url":"https://api.github.com/repos/OCA/manufacture/events","assignees_url":"https://api.github.com/repos/OCA/manufacture/assignees{/user}","branches_url":"https://api.github.com/repos/OCA/manufacture/branches{/branch}","tags_url":"https://api.github.com/repos/OCA/manufacture/tags","blobs_url":"https://api.github.com/repos/OCA/manufacture/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OCA/manufacture/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OCA/manufacture/git/refs{/sha}","trees_url":"https://api.github.com/repos/OCA/manufacture/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OCA/manufacture/statuses/{sha}","languages_url":"https://api.github.com/repos/OCA/manufacture/languages","stargazers_url":"https://api.github.com/repos/OCA/manufacture/stargazers","contributors_url":"https://api.github.com/repos/OCA/manufacture/contributors","subscribers_url":"https://api.github.com/repos/OCA/manufacture/subscribers","subscription_url":"https://api.github.com/repos/OCA/manufacture/subscription","commits_url":"https://api.github.com/repos/OCA/manufacture/commits{/sha}","git_commits_url":"https://api.github.com/repos/OCA/manufacture/git/commits{/sha}","comments_url":"https://api.github.com/repos/OCA/manufacture/comments{/number}","issue_comment_url":"https://api.github.com/repos/OCA/manufacture/issues/comments{/number}","contents_url":"https://api.github.com/repos/OCA/manufacture/contents/{+path}","compare_url":"https://api.github.com/repos/OCA/manufacture/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OCA/manufacture/merges","archive_url":"https://api.github.com/repos/OCA/manufacture/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OCA/manufacture/downloads","issues_url":"https://api.github.com/repos/OCA/manufacture/issues{/number}","pulls_url":"https://api.github.com/repos/OCA/manufacture/pulls{/number}","milestones_url":"https://api.github.com/repos/OCA/manufacture/milestones{/number}","notifications_url":"https://api.github.com/repos/OCA/manufacture/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OCA/manufacture/labels{/name}","releases_url":"https://api.github.com/repos/OCA/manufacture/releases{/id}","created_at":"2014-06-16T17:48:41Z","updated_at":"2015-10-14T12:29:30Z","pushed_at":"2015-10-26T13:47:19Z","git_url":"git://github.com/OCA/manufacture.git","ssh_url":"git@github.com:OCA/manufacture.git","clone_url":"https://github.com/OCA/manufacture.git","svn_url":"https://github.com/OCA/manufacture","homepage":"","size":1558,"stargazers_count":7,"watchers_count":7,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":27,"mirror_url":null,"open_issues_count":20,"forks":27,"open_issues":20,"watchers":7,"default_branch":"9.0"}},"_links":{"self":{"href":"https://api.github.com/repos/OCA/manufacture/pulls/43"},"html":{"href":"https://github.com/OCA/manufacture/pull/43"},"issue":{"href":"https://api.github.com/repos/OCA/manufacture/issues/43"},"comments":{"href":"https://api.github.com/repos/OCA/manufacture/issues/43/comments"},"review_comments":{"href":"https://api.github.com/repos/OCA/manufacture/pulls/43/comments"},"review_comment":{"href":"https://api.github.com/repos/OCA/manufacture/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OCA/manufacture/pulls/43/commits"},"statuses":{"href":"https://api.github.com/repos/OCA/manufacture/statuses/6e885ac09944fcfec384886a4711643ae73421ac"}}}}