prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  is:issue is:open [8.0][mrp_production_real_cost] Error when produce product
  Hi,
  
  there's new error from mrp_production_real_cost, after I do git pull from the last commit 
  
  ```
  
  ERROR demo1 openerp.sql_db: Programming error: can't adapt type 'mrp.production', in query  SELECT "mrp_production"."id" FROM "mrp_production"
                          WHERE "mrp_production".id IN %s  ORDER BY "mrp_production"."priority" DESC,"mrp_production"."date_planned" ASC         
  
    File "/opt/odoo/server/addons/mrp_production_real_cost/models/mrp_production.py", line 34, in action_production_end
      self.mapped('move_created_ids2').filtered(
  
  
    File "/usr/lib/python2.7/dist-packages/psycopg2/extensions.py", line 129, in getquoted
      pobjs = [adapt(o) for o in self._seq]
  ValueError: "can't adapt type 'mrp.production'" while evaluating
  u'action_production_end()'
  ```
  
  regards
  
  
  </issue>
  <code>
  [start of mrp_production_real_cost/models/mrp_production.py]
  1 # -*- coding: utf-8 -*-
  2 # © 2014-2015 Avanzosc
  3 # © 2014-2015 Pedro M. Baeza
  4 # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
  5 
  6 from openerp import api, fields, models
  7 
  8 
  9 class MrpProduction(models.Model):
  10     _inherit = 'mrp.production'
  11 
  12     @api.multi
  13     @api.depends('analytic_line_ids', 'analytic_line_ids.amount',
  14                  'product_qty')
  15     def _compute_real_cost(self):
  16         for production in self:
  17             cost_lines = production.analytic_line_ids.filtered(
  18                 lambda l: l.amount < 0)
  19             production.real_cost = -sum(cost_lines.mapped('amount'))
  20             production.unit_real_cost = (
  21                 production.real_cost / production.product_qty)
  22 
  23     analytic_line_ids = fields.One2many(
  24         comodel_name="account.analytic.line", inverse_name="mrp_production_id",
  25         string="Cost Lines")
  26     real_cost = fields.Float(
  27         "Total Real Cost", compute="_compute_real_cost", store=True)
  28     unit_real_cost = fields.Float(
  29         "Unit Real Cost", compute="_compute_real_cost", store=True)
  30 
  31     @api.multi
  32     def action_production_end(self):
  33         res = super(MrpProduction, self).action_production_end()
  34         self.mapped('move_created_ids2').filtered(
  35             lambda l: l.state == 'done').product_price_update_production_done()
  36         return res
  37 
  38     @api.model
  39     def _prepare_real_cost_analytic_line(
  40             self, journal, name, production, product, general_account=None,
  41             workorder=None, qty=1, amount=0):
  42         """
  43         Prepare the vals for creating an analytic entry for real cost
  44         :param journal: Journal of the entry
  45         :param name: Name of the entry
  46         :param production: Origin product
  47         :param product: Product for the entry
  48         :param general_account: General account for the entry
  49         :param workorder: Origin workorder
  50         :param qty: Quantity for the entry. This quantity will multiply both
  51         standard and average costs for the entry costs.
  52         :param amount: Cost for calculating real cost.
  53         :return: Dictionary with the analytic entry vals.
  54         """
  55         analytic_line_obj = self.env['account.analytic.line']
  56         property_obj = self.env['ir.property']
  57         general_account = (
  58             general_account or product.property_account_expense or
  59             product.categ_id.property_account_expense_categ or
  60             property_obj.get('property_account_expense_categ',
  61                              'product.category'))
  62         return {
  63             'name': name,
  64             'mrp_production_id': production.id,
  65             'workorder': workorder and workorder.id or False,
  66             'account_id': self.analytic_account_id.id,
  67             'journal_id': journal.id,
  68             'user_id': self.env.uid,
  69             'date': analytic_line_obj._get_default_date(),
  70             'product_id': product and product.id or False,
  71             'unit_amount': qty,
  72             'amount': amount,
  73             'product_uom_id': product.uom_id.id,
  74             'general_account_id': general_account.id,
  75         }
  76 
  77     @api.multi
  78     def _costs_generate(self):
  79         """
  80         As we are generating the account_analytic_lines for MO in the
  81         current module, we override this method in order to avoid
  82         duplicates created in the parent class. Any other module
  83         inheriting this method should take this into account!
  84         """
  85         return
  86
  [end of mrp_production_real_cost/models/mrp_production.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/mrp_production_real_cost/models/mrp_production.py b/mrp_production_real_cost/models/mrp_production.py
  --- a/mrp_production_real_cost/models/mrp_production.py
  +++ b/mrp_production_real_cost/models/mrp_production.py
  @@ -31,8 +31,15 @@
       @api.multi
       def action_production_end(self):
           res = super(MrpProduction, self).action_production_end()
  -        self.mapped('move_created_ids2').filtered(
  -            lambda l: l.state == 'done').product_price_update_production_done()
  +        for production in self:
  +            # This is needed because commit
  +            # https://github.com/odoo/odoo/commit/
  +            # 6f29bfc181d23d70d29776d96b4318e9ee2c93a9
  +            # introduces a weird behavior on the next call, provoking an error.
  +            production.sudo().refresh()
  +            production.mapped('move_created_ids2').filtered(
  +                lambda l: l.state == 'done'
  +                ).product_price_update_production_done()
           return res
   
       @api.model
  
verification_info: {"golden_diff": "diff --git a/mrp_production_real_cost/models/mrp_production.py b/mrp_production_real_cost/models/mrp_production.py\n--- a/mrp_production_real_cost/models/mrp_production.py\n+++ b/mrp_production_real_cost/models/mrp_production.py\n@@ -31,8 +31,15 @@\n     @api.multi\n     def action_production_end(self):\n         res = super(MrpProduction, self).action_production_end()\n-        self.mapped('move_created_ids2').filtered(\n-            lambda l: l.state == 'done').product_price_update_production_done()\n+        for production in self:\n+            # This is needed because commit\n+            # https://github.com/odoo/odoo/commit/\n+            # 6f29bfc181d23d70d29776d96b4318e9ee2c93a9\n+            # introduces a weird behavior on the next call, provoking an error.\n+            production.sudo().refresh()\n+            production.mapped('move_created_ids2').filtered(\n+                lambda l: l.state == 'done'\n+                ).product_price_update_production_done()\n         return res\n \n     @api.model\n", "issue": "is:issue is:open [8.0][mrp_production_real_cost] Error when produce product\nHi,\n\nthere's new error from mrp_production_real_cost, after I do git pull from the last commit \n\n```\n\nERROR demo1 openerp.sql_db: Programming error: can't adapt type 'mrp.production', in query  SELECT \"mrp_production\".\"id\" FROM \"mrp_production\"\n                        WHERE \"mrp_production\".id IN %s  ORDER BY \"mrp_production\".\"priority\" DESC,\"mrp_production\".\"date_planned\" ASC         \n\n  File \"/opt/odoo/server/addons/mrp_production_real_cost/models/mrp_production.py\", line 34, in action_production_end\n    self.mapped('move_created_ids2').filtered(\n\n\n  File \"/usr/lib/python2.7/dist-packages/psycopg2/extensions.py\", line 129, in getquoted\n    pobjs = [adapt(o) for o in self._seq]\nValueError: \"can't adapt type 'mrp.production'\" while evaluating\nu'action_production_end()'\n```\n\nregards\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n# \u00a9 2014-2015 Avanzosc\n# \u00a9 2014-2015 Pedro M. Baeza\n# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html\n\nfrom openerp import api, fields, models\n\n\nclass MrpProduction(models.Model):\n    _inherit = 'mrp.production'\n\n    @api.multi\n    @api.depends('analytic_line_ids', 'analytic_line_ids.amount',\n                 'product_qty')\n    def _compute_real_cost(self):\n        for production in self:\n            cost_lines = production.analytic_line_ids.filtered(\n                lambda l: l.amount < 0)\n            production.real_cost = -sum(cost_lines.mapped('amount'))\n            production.unit_real_cost = (\n                production.real_cost / production.product_qty)\n\n    analytic_line_ids = fields.One2many(\n        comodel_name=\"account.analytic.line\", inverse_name=\"mrp_production_id\",\n        string=\"Cost Lines\")\n    real_cost = fields.Float(\n        \"Total Real Cost\", compute=\"_compute_real_cost\", store=True)\n    unit_real_cost = fields.Float(\n        \"Unit Real Cost\", compute=\"_compute_real_cost\", store=True)\n\n    @api.multi\n    def action_production_end(self):\n        res = super(MrpProduction, self).action_production_end()\n        self.mapped('move_created_ids2').filtered(\n            lambda l: l.state == 'done').product_price_update_production_done()\n        return res\n\n    @api.model\n    def _prepare_real_cost_analytic_line(\n            self, journal, name, production, product, general_account=None,\n            workorder=None, qty=1, amount=0):\n        \"\"\"\n        Prepare the vals for creating an analytic entry for real cost\n        :param journal: Journal of the entry\n        :param name: Name of the entry\n        :param production: Origin product\n        :param product: Product for the entry\n        :param general_account: General account for the entry\n        :param workorder: Origin workorder\n        :param qty: Quantity for the entry. This quantity will multiply both\n        standard and average costs for the entry costs.\n        :param amount: Cost for calculating real cost.\n        :return: Dictionary with the analytic entry vals.\n        \"\"\"\n        analytic_line_obj = self.env['account.analytic.line']\n        property_obj = self.env['ir.property']\n        general_account = (\n            general_account or product.property_account_expense or\n            product.categ_id.property_account_expense_categ or\n            property_obj.get('property_account_expense_categ',\n                             'product.category'))\n        return {\n            'name': name,\n            'mrp_production_id': production.id,\n            'workorder': workorder and workorder.id or False,\n            'account_id': self.analytic_account_id.id,\n            'journal_id': journal.id,\n            'user_id': self.env.uid,\n            'date': analytic_line_obj._get_default_date(),\n            'product_id': product and product.id or False,\n            'unit_amount': qty,\n            'amount': amount,\n            'product_uom_id': product.uom_id.id,\n            'general_account_id': general_account.id,\n        }\n\n    @api.multi\n    def _costs_generate(self):\n        \"\"\"\n        As we are generating the account_analytic_lines for MO in the\n        current module, we override this method in order to avoid\n        duplicates created in the parent class. Any other module\n        inheriting this method should take this into account!\n        \"\"\"\n        return\n", "path": "mrp_production_real_cost/models/mrp_production.py"}]}