/usr/lib/python2.7/dist-packages/trytond/modules/account_tax_rule_country/purchase.py is in tryton-modules-account-tax-rule-country 3.8.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 | # 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.model import fields
from trytond.pyson import Eval
__all__ = ['Purchase', 'PurchaseLine']
__metaclass__ = PoolMeta
class Purchase:
__name__ = 'purchase.purchase'
@classmethod
def __setup__(cls):
super(Purchase, cls).__setup__()
for field in (cls.invoice_address, cls.warehouse):
field.states['readonly'] |= (
Eval('lines', [0]) & Eval('invoice_address'))
field.depends.extend(['invoice_address'])
class PurchaseLine:
__name__ = 'purchase.line'
def _get_tax_rule_pattern(self):
pattern = super(PurchaseLine, self)._get_tax_rule_pattern()
from_country, to_country = None, None
if self.purchase:
if self.purchase.invoice_address:
from_country = self.purchase.invoice_address.country
warehouse = self.purchase.warehouse
if warehouse and warehouse.address:
to_country = warehouse.address.country
pattern['from_country'] = from_country.id if from_country else None
pattern['to_country'] = to_country.id if to_country else None
return pattern
@fields.depends('_parent_purchase.warehouse',
'_parent_purchase.invoice_address')
def on_change_product(self):
super(PurchaseLine, self).on_change_product()
|