This file is indexed.

/usr/lib/python2.7/dist-packages/trytond/modules/sale_shipment_grouping/sale.py is in tryton-modules-sale-shipment-grouping 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
53
#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 trytond.pool import PoolMeta
from trytond.transaction import Transaction

__metaclass__ = PoolMeta
__all__ = ['Sale']


class Sale:
    __name__ = 'sale.sale'

    @property
    def shipment_grouping_method(self):
        return self.party.sale_shipment_grouping_method

    @property
    def _shipment_grouping_fields(self):
        return ('customer', 'delivery_address', 'company', 'warehouse')

    def _get_grouped_shipment_planned_date(self, shipment):
        return [('planned_date', '=', shipment.planned_date)]

    def _get_grouped_shipment_order(self):
        "Returns the order used to find shipments that should be grouped"
        return None

    def _get_grouped_shipment_domain(self, shipment):
        "Returns a domain that will find shipments that should be grouped"
        Shipment = shipment.__class__
        shipment_domain = [
            ('moves.origin', 'like', 'sale.line,%'),
            ('state', 'in', ['draft', 'waiting']),
            ]
        shipment_domain += self._get_grouped_shipment_planned_date(shipment)
        defaults = Shipment.default_get(self._shipment_grouping_fields,
            with_rec_name=False)
        for field in self._shipment_grouping_fields:
            shipment_domain.append((field, '=',
                    getattr(shipment, field, defaults.get(field))))
        return shipment_domain

    def _get_shipment_sale(self, shipment_type, values):
        shipment = super(Sale, self)._get_shipment_sale(shipment_type, values)
        Shipment = shipment.__class__
        if self.shipment_grouping_method:
            domain = self._get_grouped_shipment_domain(shipment)
            order = self._get_grouped_shipment_order()
            grouped_shipments = Shipment.search(domain, order=order, limit=1)
            if grouped_shipments:
                shipment, = grouped_shipments
        return shipment