This file is indexed.

/usr/lib/python2.7/dist-packages/trytond/modules/carrier_percentage/carrier.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#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.model import fields
from trytond.transaction import Transaction
from trytond.pool import Pool, PoolMeta
from trytond.pyson import Eval

__all__ = ['Carrier']
__metaclass__ = PoolMeta


class Carrier:
    __name__ = 'carrier'
    percentage = fields.Numeric('Percentage', digits=(16, 8),
        states={
            'invisible': Eval('carrier_cost_method') != 'percentage',
            },
        depends=['carrier_cost_method'])

    @classmethod
    def __setup__(cls):
        super(Carrier, cls).__setup__()
        selection = ('percentage', 'Percentage')
        if selection not in cls.carrier_cost_method.selection:
            cls.carrier_cost_method.selection.append(selection)

    def compute_percentage(self, amount, currency_id):
        "Compute price based on a percentage of amount"
        Currency = Pool().get('currency.currency')

        price = amount * self.percentage / Decimal(100)
        if not currency_id:
            return price, currency_id
        currency = Currency(currency_id)
        return currency.round(price), currency_id

    def get_sale_price(self):
        price, currency_id = super(Carrier, self).get_sale_price()
        if self.carrier_cost_method == 'percentage':
            amount = Transaction().context.get('amount', Decimal(0))
            currency_id = Transaction().context.get('currency', currency_id)
            return self.compute_percentage(amount, currency_id)
        return price, currency_id

    def get_purchase_price(self):
        price, currency_id = super(Carrier, self).get_purchase_price()
        if self.carrier_cost_method == 'percentage':
            amount = Transaction().context.get('amount', Decimal(0))
            currency_id = Transaction().context.get('currency', currency_id)
            return self.compute_percentage(amount, currency_id)
        return price, currency_id