1
# -*- encoding: utf-8 -*-
2
###########################################################################
3
# Module Writen to OpenERP, Open Source Management Solution
5
# Copyright (c) 2010 Vauxoo - http://www.vauxoo.com/
7
# info Vauxoo (info@vauxoo.com)
8
############################################################################
9
# Coded by: Luis Torres (luis_t@vauxoo.com)
10
############################################################################
12
# This program is free software: you can redistribute it and/or modify
13
# it under the terms of the GNU Affero General Public License as
14
# published by the Free Software Foundation, either version 3 of the
15
# License, or (at your option) any later version.
17
# This program is distributed in the hope that it will be useful,
18
# but WITHOUT ANY WARRANTY; without even the implied warranty of
19
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
# GNU Affero General Public License for more details.
22
# You should have received a copy of the GNU Affero General Public License
23
# along with this program. If not, see <http://www.gnu.org/licenses/>.
25
##############################################################################
27
File to add functionalitity in account.invoice.line to get the amount without
28
discount and the value of the discount
30
from openerp.osv import osv, fields
33
class account_invoice_line(osv.osv):
35
Inherit from account.invoice.line to get by line the amount without
36
discount and the amount of this
38
_inherit = 'account.invoice.line'
40
def _get_subtotal_without_discount(self, cr, uid, ids, args, fields,
43
Method to get the subtotal of the amount without discount
44
@param self: The object pointer.
45
@param cr: A database cursor
46
@param uid: ID of the user currently logged in
47
@param ids: list of ids for which name should be read
48
@param field_name: field that call the method
49
@param arg: Extra arguments
50
@param context: A standard dictionary
51
@return : Dict with values
53
context = context or {}
55
for line in self.browse(cr, uid, ids, context=context):
56
res[line.id] = (line.quantity * line.price_unit)
59
def _get_discount(self, cr, uid, ids, args, fields, context=None):
61
Method to get the amount of discount, is used subtraction by rounding
62
@param self: The object pointer.
63
@param cr: A database cursor
64
@param uid: ID of the user currently logged in
65
@param ids: list of ids for which name should be read
66
@param field_name: field that call the method
67
@param arg: Extra arguments
68
@param context: A standard dictionary
69
@return : Dict with values
71
context = context or {}
73
for line in self.browse(cr, uid, ids, context=context):
74
res[line.id] = line.discount * line.subtotal_wo_discount / 100
78
'subtotal_wo_discount': fields.function(_get_subtotal_without_discount,
80
store=True, type='float'),
81
'discount_amount':fields.function(_get_discount, string='Discount',
82
store=False, type='float'),