/usr/lib/python2.7/dist-packages/trytond/modules/carrier_percentage/sale.py is in tryton-modules-carrier-percentage 3.4.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | #This file is part of Tryton. The COPYRIGHT file at the top level of
#this repository contains the full copyright notices and license terms.
from decimal import Decimal
from trytond.pool import PoolMeta
__all__ = ['Sale']
__metaclass__ = PoolMeta
class Sale:
__name__ = 'sale.sale'
def _get_carrier_context(self):
context = super(Sale, self)._get_carrier_context()
if self.carrier.carrier_cost_method != 'percentage':
return context
if not self.currency:
return context
context = context.copy()
amount = 0
for line in self.lines or []:
if (getattr(line, 'unit_price', None)
and getattr(line, 'quantity', None)
and not getattr(line, 'shipment_cost', None)):
amount += (line.unit_price
* Decimal(str(line.quantity or 0)))
context['amount'] = amount
context['currency'] = self.currency.id
return context
|