prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Crash in account_payment_purchase
  When you create an invoice from an incoming products on v7 with account_payment_purchase:
  
    File "/home/erp_super/erp/prod/src/addons/stock/stock.py", line 1153, in action_invoice_create
      invoice_vals = self._prepare_invoice(cr, uid, picking, partner, inv_type, journal_id, context=context)
    File "/home/erp_super/erp/prod/src/banking/account_payment_sale_stock/model/stock.py", line 34, in _prepare_invoice
      cr, uid, picking, partner, inv_type, journal_id, context=context)
    File "/home/erp_super/erp/prod/src/banking/account_payment_purchase/model/stock.py", line 38, in _prepare_invoice
      picking.purchase_id.supplier_partner_bank.id or False,
    File "/home/erp_super/erp/prod/src/server/openerp/osv/orm.py", line 504, in __getattr__
      raise AttributeError(e)
  AttributeError: "Field 'supplier_partner_bank' does not exist in object 'browse_record(purchase.order, 774)'"
  
  It seems that, when we decided to change to datamodel of the account_payment_\* modules, the file account_payment_purchase/model/stock.py was not changed !!! I'll do a PR to fix this.
  
  
  </issue>
  <code>
  [start of account_payment_purchase/model/stock.py]
  1 # -*- encoding: utf-8 -*-
  2 ##############################################################################
  3 #
  4 #    Account Payment Purchase module for OpenERP
  5 #    Copyright (C) 2014 Akretion (http://www.akretion.com)
  6 #    @author Alexis de Lattre <alexis.delattre@akretion.com>
  7 #
  8 #    This program is free software: you can redistribute it and/or modify
  9 #    it under the terms of the GNU Affero General Public License as
  10 #    published by the Free Software Foundation, either version 3 of the
  11 #    License, or (at your option) any later version.
  12 #
  13 #    This program is distributed in the hope that it will be useful,
  14 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
  15 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16 #    GNU Affero General Public License for more details.
  17 #
  18 #    You should have received a copy of the GNU Affero General Public License
  19 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  20 #
  21 ##############################################################################
  22 
  23 from openerp.osv import orm
  24 
  25 
  26 class stock_picking(orm.Model):
  27     _inherit = "stock.picking"
  28 
  29     def _prepare_invoice(
  30             self, cr, uid, picking, partner, inv_type, journal_id,
  31             context=None):
  32         """Copy bank partner and payment type from PO to invoice"""
  33         invoice_vals = super(stock_picking, self)._prepare_invoice(
  34             cr, uid, picking, partner, inv_type, journal_id, context=context)
  35         if picking.purchase_id:
  36             invoice_vals.update({
  37                 'partner_bank_id':
  38                 picking.purchase_id.supplier_partner_bank.id or False,
  39                 'payment_mode_type':
  40                 picking.purchase_id.payment_mode_type.id or False,
  41                 })
  42         return invoice_vals
  43
  [end of account_payment_purchase/model/stock.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/account_payment_purchase/model/stock.py b/account_payment_purchase/model/stock.py
  --- a/account_payment_purchase/model/stock.py
  +++ b/account_payment_purchase/model/stock.py
  @@ -35,8 +35,8 @@
           if picking.purchase_id:
               invoice_vals.update({
                   'partner_bank_id':
  -                picking.purchase_id.supplier_partner_bank.id or False,
  -                'payment_mode_type':
  -                picking.purchase_id.payment_mode_type.id or False,
  +                picking.purchase_id.supplier_partner_bank_id.id or False,
  +                'payment_mode_id':
  +                picking.purchase_id.payment_mode_id.id or False,
                   })
           return invoice_vals
  
verification_info: {"golden_diff": "diff --git a/account_payment_purchase/model/stock.py b/account_payment_purchase/model/stock.py\n--- a/account_payment_purchase/model/stock.py\n+++ b/account_payment_purchase/model/stock.py\n@@ -35,8 +35,8 @@\n         if picking.purchase_id:\n             invoice_vals.update({\n                 'partner_bank_id':\n-                picking.purchase_id.supplier_partner_bank.id or False,\n-                'payment_mode_type':\n-                picking.purchase_id.payment_mode_type.id or False,\n+                picking.purchase_id.supplier_partner_bank_id.id or False,\n+                'payment_mode_id':\n+                picking.purchase_id.payment_mode_id.id or False,\n                 })\n         return invoice_vals\n", "issue": "Crash in account_payment_purchase\nWhen you create an invoice from an incoming products on v7 with account_payment_purchase:\n\n  File \"/home/erp_super/erp/prod/src/addons/stock/stock.py\", line 1153, in action_invoice_create\n    invoice_vals = self._prepare_invoice(cr, uid, picking, partner, inv_type, journal_id, context=context)\n  File \"/home/erp_super/erp/prod/src/banking/account_payment_sale_stock/model/stock.py\", line 34, in _prepare_invoice\n    cr, uid, picking, partner, inv_type, journal_id, context=context)\n  File \"/home/erp_super/erp/prod/src/banking/account_payment_purchase/model/stock.py\", line 38, in _prepare_invoice\n    picking.purchase_id.supplier_partner_bank.id or False,\n  File \"/home/erp_super/erp/prod/src/server/openerp/osv/orm.py\", line 504, in __getattr__\n    raise AttributeError(e)\nAttributeError: \"Field 'supplier_partner_bank' does not exist in object 'browse_record(purchase.order, 774)'\"\n\nIt seems that, when we decided to change to datamodel of the account_payment_\\* modules, the file account_payment_purchase/model/stock.py was not changed !!! I'll do a PR to fix this.\n\n", "before_files": [{"content": "# -*- encoding: utf-8 -*-\n##############################################################################\n#\n#    Account Payment Purchase module for OpenERP\n#    Copyright (C) 2014 Akretion (http://www.akretion.com)\n#    @author Alexis de Lattre <alexis.delattre@akretion.com>\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\nfrom openerp.osv import orm\n\n\nclass stock_picking(orm.Model):\n    _inherit = \"stock.picking\"\n\n    def _prepare_invoice(\n            self, cr, uid, picking, partner, inv_type, journal_id,\n            context=None):\n        \"\"\"Copy bank partner and payment type from PO to invoice\"\"\"\n        invoice_vals = super(stock_picking, self)._prepare_invoice(\n            cr, uid, picking, partner, inv_type, journal_id, context=context)\n        if picking.purchase_id:\n            invoice_vals.update({\n                'partner_bank_id':\n                picking.purchase_id.supplier_partner_bank.id or False,\n                'payment_mode_type':\n                picking.purchase_id.payment_mode_type.id or False,\n                })\n        return invoice_vals\n", "path": "account_payment_purchase/model/stock.py"}]}