We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN 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.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `account_payment_purchase/model/stock.py`
Content:
```
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 FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

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

{"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"}], "after_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.id or False,\n                'payment_mode_id':\n                picking.purchase_id.payment_mode_id.id or False,\n                })\n        return invoice_vals\n", "path": "account_payment_purchase/model/stock.py"}]}