prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Code error in account_payment_sale
  I'm reporting a bug in my own code : in the 7.0 branch, in account_payment_sale/model/sale.py line 41, we have the following code:
  
   partner.customer_payment_mode.id or False,
  
  We should NOT have a coma at the end of this line. When we run the module in Odoo 8.0, it will crash when creating a sale order via a call to create because addons/sale/sale.py in odoo 8.0 silently plays the on_change and then it will try to create {"payment_mode_id: (False,)}, when leads to a crash
  
  
  --- 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_sale/model/sale.py`
  Content:
  ```
  1 # -*- encoding: utf-8 -*-
  2 ##############################################################################
  3 #
  4 #    Account Payment Sale 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, fields
  24 
  25 
  26 class sale_order(orm.Model):
  27     _inherit = "sale.order"
  28 
  29     _columns = {
  30         'payment_mode_id': fields.many2one(
  31             'payment.mode', 'Payment Mode'),
  32         }
  33 
  34     def onchange_partner_id(self, cr, uid, ids, part, context=None):
  35         res = super(sale_order, self).onchange_partner_id(
  36             cr, uid, ids, part, context=context)
  37         if part:
  38             partner = self.pool['res.partner'].browse(
  39                 cr, uid, part, context=context)
  40             res['value']['payment_mode_id'] = \
  41                 partner.customer_payment_mode.id or False,
  42         else:
  43             res['value']['payment_mode_id'] = False
  44         return res
  45 
  46     def _prepare_invoice(self, cr, uid, order, lines, context=None):
  47         """Copy bank partner from sale order to invoice"""
  48         invoice_vals = super(sale_order, self)._prepare_invoice(
  49             cr, uid, order, lines, context=context)
  50         invoice_vals.update({
  51             'payment_mode_id': order.payment_mode_id.id or False,
  52             'partner_bank_id': order.payment_mode_id and
  53             order.payment_mode_id.bank_id.id or False,
  54             })
  55         return invoice_vals
  56
  ```
  --- 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()
  
  ```
  
golden_diff: diff --git a/account_payment_sale/model/sale.py b/account_payment_sale/model/sale.py
  --- a/account_payment_sale/model/sale.py
  +++ b/account_payment_sale/model/sale.py
  @@ -38,7 +38,7 @@
               partner = self.pool['res.partner'].browse(
                   cr, uid, part, context=context)
               res['value']['payment_mode_id'] = \
  -                partner.customer_payment_mode.id or False,
  +                partner.customer_payment_mode.id or False
           else:
               res['value']['payment_mode_id'] = False
           return res
  
verification_info: {"golden_diff": "diff --git a/account_payment_sale/model/sale.py b/account_payment_sale/model/sale.py\n--- a/account_payment_sale/model/sale.py\n+++ b/account_payment_sale/model/sale.py\n@@ -38,7 +38,7 @@\n             partner = self.pool['res.partner'].browse(\n                 cr, uid, part, context=context)\n             res['value']['payment_mode_id'] = \\\n-                partner.customer_payment_mode.id or False,\n+                partner.customer_payment_mode.id or False\n         else:\n             res['value']['payment_mode_id'] = False\n         return res\n", "issue": "Code error in account_payment_sale\nI'm reporting a bug in my own code : in the 7.0 branch, in account_payment_sale/model/sale.py line 41, we have the following code:\n\n partner.customer_payment_mode.id or False,\n\nWe should NOT have a coma at the end of this line. When we run the module in Odoo 8.0, it will crash when creating a sale order via a call to create because addons/sale/sale.py in odoo 8.0 silently plays the on_change and then it will try to create {\"payment_mode_id: (False,)}, when leads to a crash\n\n", "before_files": [{"content": "# -*- encoding: utf-8 -*-\n##############################################################################\n#\n#    Account Payment Sale 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, fields\n\n\nclass sale_order(orm.Model):\n    _inherit = \"sale.order\"\n\n    _columns = {\n        'payment_mode_id': fields.many2one(\n            'payment.mode', 'Payment Mode'),\n        }\n\n    def onchange_partner_id(self, cr, uid, ids, part, context=None):\n        res = super(sale_order, self).onchange_partner_id(\n            cr, uid, ids, part, context=context)\n        if part:\n            partner = self.pool['res.partner'].browse(\n                cr, uid, part, context=context)\n            res['value']['payment_mode_id'] = \\\n                partner.customer_payment_mode.id or False,\n        else:\n            res['value']['payment_mode_id'] = False\n        return res\n\n    def _prepare_invoice(self, cr, uid, order, lines, context=None):\n        \"\"\"Copy bank partner from sale order to invoice\"\"\"\n        invoice_vals = super(sale_order, self)._prepare_invoice(\n            cr, uid, order, lines, context=context)\n        invoice_vals.update({\n            'payment_mode_id': order.payment_mode_id.id or False,\n            'partner_bank_id': order.payment_mode_id and\n            order.payment_mode_id.bank_id.id or False,\n            })\n        return invoice_vals\n", "path": "account_payment_sale/model/sale.py"}], "after_files": [{"content": "# -*- encoding: utf-8 -*-\n##############################################################################\n#\n#    Account Payment Sale 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, fields\n\n\nclass sale_order(orm.Model):\n    _inherit = \"sale.order\"\n\n    _columns = {\n        'payment_mode_id': fields.many2one(\n            'payment.mode', 'Payment Mode'),\n        }\n\n    def onchange_partner_id(self, cr, uid, ids, part, context=None):\n        res = super(sale_order, self).onchange_partner_id(\n            cr, uid, ids, part, context=context)\n        if part:\n            partner = self.pool['res.partner'].browse(\n                cr, uid, part, context=context)\n            res['value']['payment_mode_id'] = \\\n                partner.customer_payment_mode.id or False\n        else:\n            res['value']['payment_mode_id'] = False\n        return res\n\n    def _prepare_invoice(self, cr, uid, order, lines, context=None):\n        \"\"\"Copy bank partner from sale order to invoice\"\"\"\n        invoice_vals = super(sale_order, self)._prepare_invoice(\n            cr, uid, order, lines, context=context)\n        invoice_vals.update({\n            'payment_mode_id': order.payment_mode_id.id or False,\n            'partner_bank_id': order.payment_mode_id and\n            order.payment_mode_id.bank_id.id or False,\n            })\n        return invoice_vals\n", "path": "account_payment_sale/model/sale.py"}]}