<commit_before># -*- coding: utf-8 -*-
"""
    sale

"""
from trytond.model import fields
from trytond.transaction import Transaction
from trytond.pool import Pool, PoolMeta
from trytond.pyson import Eval, Or, Bool

__all__ = ['Sale', 'SaleLine']
__metaclass__ = PoolMeta


class Sale:
    __name__ = 'sale.sale'

    #: A many2one field decides to which channel this sale
    #: belongs to. This helps filling lot of default values on sale.
    channel = fields.Many2One(
        'sale.channel', 'Channel', required=True, select=True, domain=[
            ('id', 'in', Eval('context', {}).get('allowed_read_channels', [])),
        ],
        states={
            'readonly': Or(
                (Eval('id', 0) > 0),
                Bool(Eval('lines', [])),
            )
        }, depends=['id']<commit_msg>While creating sale order only create permission channels should be listed<commit_after># -*- coding: utf-8 -*-
"""
    sale

"""
from trytond.model import fields
from trytond.transaction import Transaction
from trytond.pool import Pool, PoolMeta
from trytond.pyson import Eval, Or, Bool, If

__all__ = ['Sale', 'SaleLine']
__metaclass__ = PoolMeta


class Sale:
    __name__ = 'sale.sale'

    #: A many2one field decides to which channel this sale
    #: belongs to. This helps filling lot of default values on sale.
    channel = fields.Many2One(
        'sale.channel', 'Channel', required=True, select=True, domain=[
            ('id', 'in', If(
                Eval('id', 0) > 0,
                Eval('context', {}).get('allowed_read_channels', []),
                Eval('context', {}).get('allowed_create_channels', [])
            )),
        ],
        states={
            'readonly': Or(
                (Eval('id', 0) > 0),
                Bool(Eval('lines', [])),
            )
        }, depends=['id']
{'fraction_non_alphanumeric': 0.1456736035049288, 'fraction_numerical': 0.0065717415115005475, 'mean_word_length': 2.4213483146067416, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2023836', 'n_tokens_mistral': 566, 'n_tokens_neox': 531, 'n_words': 158}