~account-core-editors/account-invoice-report/github-7.0

« back to all changes in this revision

Viewing changes to account_invoice_delivery_address/model/stock_picking.py

  • Committer: Yannick Vaucher
  • Author(s): unknown
  • Date: 2014-06-30 12:35:11 UTC
  • mfrom: (49.2.1)
  • Revision ID: git-v1:d1ef0ed59caa496aa1c8351b19f84654831231c9
[ADD] module account_invoice_delivery_address
Adds delivery address / shipping address to invoice.

Delivery address can be entered directly, or will be taken from partner or sales order.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- encoding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
4
#    OpenERP, Open Source Management Solution
 
5
#    This module Copyright (C) 2014 Therp BV (<http://therp.nl>).
 
6
#    All Rights Reserved
 
7
#
 
8
#    This program is free software: you can redistribute it and/or modify
 
9
#    it under the terms of the GNU General Public License as published by
 
10
#    the Free Software Foundation, either version 3 of the License, or
 
11
#    (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 General Public License for more details.
 
17
#
 
18
#    You should have received a copy of the GNU General Public License
 
19
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
20
#
 
21
##############################################################################
 
22
'''Extend model stock.picking'''
 
23
from openerp.osv import orm
 
24
 
 
25
 
 
26
class StockPicking(orm.Model):
 
27
    '''Modify stock picking to fill delivery address'''
 
28
    _inherit = 'stock.picking'
 
29
 
 
30
    def _prepare_invoice(
 
31
        self, cr, uid, picking, partner, inv_type, journal_id, context=None):
 
32
        """\
 
33
Inherit the original function of the 'stock' module in order to fill delivery
 
34
address when present in sales order.
 
35
"""
 
36
        invoice_vals = super(StockPicking, self)._prepare_invoice(
 
37
            cr, uid, picking, partner, inv_type, journal_id, context=context)
 
38
        if picking.sale_id and picking.sale_id.partner_shipping_id:
 
39
            invoice_vals['partner_shipping_id'] = (
 
40
                picking.sale_id.partner_shipping_id.id)
 
41
        return invoice_vals
 
42