~compassion/banking-addons/banking-addons-mandate

« back to all changes in this revision

Viewing changes to account_payment_sale_stock/model/stock.py

  • Committer: Cyril Sester
  • Date: 2014-07-29 07:43:14 UTC
  • mfrom: (256.1.8 banking-addons)
  • Revision ID: cyril.sester@outlook.com-20140729074314-mzpf1tef2idtfvjk
MergedĀ trunkĀ modifs

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- encoding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
4
#    Account Payment Sale Stock 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 payment mode from sale order 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.sale_id:
 
36
            invoice_vals.update({
 
37
                'partner_bank_id':
 
38
                picking.sale_id.payment_mode_id and
 
39
                picking.sale_id.payment_mode_id.bank_id.id or False,
 
40
                'payment_mode_id':
 
41
                picking.sale_id.payment_mode_id.id or False,
 
42
                })
 
43
        return invoice_vals