From 63367551e516c5f6dc4174f9ca856d32bde3c9a3 Mon Sep 17 00:00:00 2001 From: Sergi Almacellas Abellana Date: Thu, 10 Jul 2014 10:49:07 +0200 Subject: [PATCH] Use field.depends decorator --- address.py | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/address.py b/address.py index 3a6b285..0f3d713 100644 --- a/address.py +++ b/address.py @@ -1,6 +1,7 @@ #This file is part country_zip module for Tryton. #The COPYRIGHT file at the top level of this repository contains #the full copyright notices and license terms. +from trytond.model import fields from trytond.pool import Pool, PoolMeta __all__ = ['Address'] @@ -10,20 +11,6 @@ __metaclass__ = PoolMeta class Address: __name__ = 'party.address' - @classmethod - def __setup__(cls): - super(Address, cls).__setup__() - if cls.zip.on_change is None: - cls.zip.on_change = [] - for field in ('zip', 'country'): - if not field in cls.zip.on_change: - cls.zip.on_change.add(field) - if cls.country.on_change is None: - cls.country.on_change = [] - for field in ('zip', 'country'): - if not field in cls.country.on_change: - cls.country.on_change.add(field) - @staticmethod def default_country(): Configuration = Pool().get('party.configuration') @@ -47,8 +34,10 @@ class Address: res['subdivision'] = zip_.subdivision.id return res + @fields.depends('zip', 'country') def on_change_zip(self): return self.get_subdivision_country() + @fields.depends('zip', 'country') def on_change_country(self): return self.get_subdivision_country()