diff --git a/address.py b/address.py index 2d91588eb8..06228ac28c 100644 --- a/address.py +++ b/address.py @@ -20,29 +20,23 @@ from trytond.transaction import Transaction from trytond.cache import Cache from .exceptions import InvalidFormat -STATES = { - 'readonly': ~Eval('active'), - } -DEPENDS = ['active'] - class Address(DeactivableMixin, sequence_ordered(), ModelSQL, ModelView): "Address" __name__ = 'party.address' party = fields.Many2One('party.party', 'Party', required=True, ondelete='CASCADE', select=True, states={ - 'readonly': If(~Eval('active'), True, Eval('id', 0) > 0), + 'readonly': Eval('id', 0) > 0, }, - depends=['active', 'id']) + depends=['id']) party_name = fields.Char( - "Party Name", states=STATES, depends=DEPENDS, + "Party Name", help="If filled, replace the name of the party for address formatting") - name = fields.Char("Building Name", states=STATES, depends=DEPENDS) - street = fields.Text("Street", states=STATES, depends=DEPENDS) - zip = fields.Char('Zip', states=STATES, depends=DEPENDS) - city = fields.Char('City', states=STATES, depends=DEPENDS) - country = fields.Many2One('country.country', 'Country', - states=STATES, depends=DEPENDS) + name = fields.Char("Building Name") + street = fields.Text("Street") + zip = fields.Char("Zip") + city = fields.Char("City") + country = fields.Many2One('country.country', "Country") subdivision_types = fields.Function( fields.MultiSelection( 'get_subdivision_types', "Subdivision Types"), @@ -56,8 +50,7 @@ class Address(DeactivableMixin, sequence_ordered(), ModelSQL, ModelView): () ), ], - states=STATES, - depends=['active', 'country', 'subdivision_types']) + depends=['country', 'subdivision_types']) full_address = fields.Function(fields.Text('Full Address'), 'get_full_address') diff --git a/category.py b/category.py index fb97eb0836..a35b8795bf 100644 --- a/category.py +++ b/category.py @@ -5,25 +5,19 @@ from sql.operators import Equal from trytond.model import ( ModelView, ModelSQL, DeactivableMixin, fields, Exclude, tree) -from trytond.pyson import Eval - -STATES = { - 'readonly': ~Eval('active'), -} -DEPENDS = ['active'] class Category(DeactivableMixin, tree(separator=' / '), ModelSQL, ModelView): "Category" __name__ = 'party.category' - name = fields.Char('Name', required=True, states=STATES, translate=True, - depends=DEPENDS, + name = fields.Char( + "Name", required=True, translate=True, help="The main identifier of the category.") - parent = fields.Many2One('party.category', 'Parent', - select=True, states=STATES, depends=DEPENDS, + parent = fields.Many2One( + 'party.category', "Parent", select=True, help="Add the category below the parent.") - childs = fields.One2Many('party.category', 'parent', - 'Children', states=STATES, depends=DEPENDS, + childs = fields.One2Many( + 'party.category', 'parent', "Children", help="Add children below the category.") @classmethod diff --git a/contact_mechanism.py b/contact_mechanism.py index d3955a965f..2b18241545 100644 --- a/contact_mechanism.py +++ b/contact_mechanism.py @@ -14,11 +14,6 @@ from trytond.model.exceptions import AccessError from trytond.pyson import Eval from .exceptions import InvalidPhoneNumber -STATES = { - 'readonly': ~Eval('active'), - } -DEPENDS = ['active'] - _TYPES = [ ('phone', 'Phone'), ('mobile', 'Mobile'), @@ -44,45 +39,41 @@ class ContactMechanism( "Contact Mechanism" __name__ = 'party.contact_mechanism' - type = fields.Selection(_TYPES, 'Type', required=True, states=STATES, - sort=False, depends=DEPENDS) - value = fields.Char('Value', select=True, states=STATES, depends=DEPENDS + type = fields.Selection(_TYPES, "Type", required=True, sort=False) + value = fields.Char("Value", select=True, # Add all function fields to ensure to always fill them via on_change - + ['email', 'website', 'skype', 'sip', 'other_value', 'value_compact']) + depends=[ + 'email', 'website', 'skype', 'sip', 'other_value', + 'value_compact']) value_compact = fields.Char('Value Compact', readonly=True) - name = fields.Char("Name", states=STATES, depends=DEPENDS) - comment = fields.Text('Comment', states=STATES, depends=DEPENDS) - party = fields.Many2One('party.party', 'Party', required=True, - ondelete='CASCADE', states=STATES, select=True, depends=DEPENDS) + name = fields.Char("Name") + comment = fields.Text("Comment") + party = fields.Many2One( + 'party.party', "Party", required=True, ondelete='CASCADE', select=True) email = fields.Function(fields.Char('E-Mail', states={ 'invisible': Eval('type') != 'email', 'required': Eval('type') == 'email', - 'readonly': ~Eval('active', True), - }, depends=['value', 'type', 'active']), + }, depends=['value', 'type']), 'get_value', setter='set_value') website = fields.Function(fields.Char('Website', states={ 'invisible': Eval('type') != 'website', 'required': Eval('type') == 'website', - 'readonly': ~Eval('active', True), - }, depends=['value', 'type', 'active']), + }, depends=['value', 'type']), 'get_value', setter='set_value') skype = fields.Function(fields.Char('Skype', states={ 'invisible': Eval('type') != 'skype', 'required': Eval('type') == 'skype', - 'readonly': ~Eval('active', True), - }, depends=['value', 'type', 'active']), + }, depends=['value', 'type']), 'get_value', setter='set_value') sip = fields.Function(fields.Char('SIP', states={ 'invisible': Eval('type') != 'sip', 'required': Eval('type') == 'sip', - 'readonly': ~Eval('active', True), - }, depends=['value', 'type', 'active']), + }, depends=['value', 'type']), 'get_value', setter='set_value') other_value = fields.Function(fields.Char('Value', states={ 'invisible': Eval('type').in_(['email', 'website', 'skype', 'sip']), 'required': ~Eval('type').in_(['email', 'website']), - 'readonly': ~Eval('active', True), - }, depends=['value', 'type', 'active']), + }, depends=['value', 'type']), 'get_value', setter='set_value') url = fields.Function(fields.Char('URL', states={ 'invisible': ~Eval('url'), diff --git a/party.py b/party.py index 8b371305d3..91d57c91ff 100644 --- a/party.py +++ b/party.py @@ -18,17 +18,13 @@ from trytond.tools import lstrip_wildcard from .exceptions import ( InvalidIdentifierCode, VIESUnavailable, SimilarityWarning, EraseError) -STATES = { - 'readonly': ~Eval('active', True), -} -DEPENDS = ['active'] - class Party(DeactivableMixin, ModelSQL, ModelView, MultiValueMixin): "Party" __name__ = 'party.party' - name = fields.Char('Name', select=True, states=STATES, depends=DEPENDS, + name = fields.Char( + "Name", select=True, help="The main identifier of the party.") code = fields.Char('Code', required=True, select=True, states={ @@ -39,23 +35,22 @@ class Party(DeactivableMixin, ModelSQL, ModelView, MultiValueMixin): code_readonly = fields.Function(fields.Boolean('Code Readonly'), 'get_code_readonly') lang = fields.MultiValue( - fields.Many2One('ir.lang', "Language", states=STATES, depends=DEPENDS, + fields.Many2One('ir.lang', "Language", help="Used to translate communications with the party.")) langs = fields.One2Many( 'party.party.lang', 'party', "Languages") - identifiers = fields.One2Many('party.identifier', 'party', 'Identifiers', - states=STATES, depends=DEPENDS, + identifiers = fields.One2Many( + 'party.identifier', 'party', "Identifiers", help="Add other identifiers of the party.") tax_identifier = fields.Function(fields.Many2One( 'party.identifier', 'Tax Identifier', help="The identifier used for tax report."), 'get_tax_identifier', searcher='search_tax_identifier') - addresses = fields.One2Many('party.address', 'party', - 'Addresses', states=STATES, depends=DEPENDS) - contact_mechanisms = fields.One2Many('party.contact_mechanism', 'party', - 'Contact Mechanisms', states=STATES, depends=DEPENDS) - categories = fields.Many2Many('party.party-party.category', - 'party', 'category', 'Categories', states=STATES, depends=DEPENDS, + addresses = fields.One2Many('party.address', 'party', "Addresses") + contact_mechanisms = fields.One2Many( + 'party.contact_mechanism', 'party', "Contact Mechanisms") + categories = fields.Many2Many( + 'party.party-party.category', 'party', 'category', "Categories", help="The categories the party belongs to.") replaced_by = fields.Many2One('party.party', "Replaced By", readonly=True, states={