~clearcorp-drivers/openerp-ccorp-addons/8.0

« back to all changes in this revision

Viewing changes to account_invoice_pricelist/wizard/sale_advance_payment_inv.py

[MRG] - account_invoice_pricelist: Added new module to assign and link the sale and purchase orders pricelist to the related invoice.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
4
#    OpenERP, Open Source Management Solution
 
5
#    Original Module by SIESA (<http://www.siesacr.com>)
 
6
#    Refactored by CLEARCORP S.A. (<http://clearcorp.co.cr>)
 
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
from openerp.osv import osv
 
23
 
 
24
class SaleAdvancePayment(osv.TransientModel):
 
25
 
 
26
    _inherit = 'sale.advance.payment.inv'
 
27
 
 
28
    def _create_invoices(self, cr, uid, inv_values, sale_id, context=None):
 
29
        inv_id = super(SaleAdvancePayment, self)._create_invoices(cr, uid, inv_values, sale_id, context=context)
 
30
        order_obj = self.pool.get('sale.order')
 
31
        order = order_obj.browse(cr, uid, sale_id, context=context)
 
32
        if order.pricelist_id:
 
33
            inv_obj = self.pool.get('account.invoice')
 
34
            inv_obj.write(cr, uid, inv_id, {'pricelist_id': order.pricelist_id.id}, context=context)
 
35
        return inv_id
 
 
b'\\ No newline at end of file'