71
def _get_lines_total_amount(self, cr, uid, ids, context=None):
73
:return : { 'id', lines_total, ... }
78
if isinstance(ids, (int, long)):
80
for so in self.browse(cr, uid, ids, context=context):
82
for sl in so.order_line:
84
amount += sl.price_subtotal
72
89
'global_discount': fields.float(
73
90
string='Remise globale',
215
232
return super(sale_order, self).button_dummy(cr, uid, ids, context=context)
217
234
def on_change_global_discount_rate(self, cr, uid, ids, global_discount_rate,
218
amount_untaxed, context = None):
220
237
from a user input of global discount rate, compute the global rate
221
238
amount truely used by the global amount system
225
if amount_untaxed and amount_untaxed > 0.:
226
discount_amount = amount_untaxed * global_discount_rate
227
res['value'] = { 'global_discount': discount_amount, }
242
if isinstance(ids, (int, long)):
244
lines_total = self._get_lines_total_amount(cr, uid, ids,
245
context=context)[ids[0]] # get so lines total to compute from
248
if global_discount_rate and \
249
isinstance(global_discount_rate, (str, unicode)):
250
# % widget conversion 2 float
251
global_discount_rate = float(global_discount_rate.replace(',', '.'))
252
if not global_discount_rate:
253
global_discount_rate = 0.
254
if lines_total and lines_total > 0.:
255
discount_amount = (lines_total * global_discount_rate) / 100
257
if discount_amount > lines_total:
258
err = 'La remise globale ne peut dépasser le montant'
259
elif discount_amount < 0:
260
err = 'La remise globale ne peut être négative'
263
'value': {'global_discount_rate': 0., 'global_discount': 0.,},
265
'title': 'Remise globale',
271
'value': {'global_discount': discount_amount, },