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

    :copyright: (c) 2015 by Openlabs Technologies & Consulting (P) Limited
    :license: GPLv3, see LICENSE for more details.
"""
from datetime import datetime

import pytz
import requests
import pystashop
from mockstashop import MockstaShopWebservice
from trytond.model import ModelView, fields
from trytond.transaction import Transaction
from trytond.pool import Pool, PoolMeta
from trytond.wizard import Wizard, StateView, Button
from trytond.pyson import Eval

__metaclass__ = PoolMeta
__all__ = [
    'Channel', 'PrestashopImportOrdersWizardView',
    'PrestashopImportOrdersWizard', 'PrestashopExportOrdersWizardView',
    'PrestashopExportOrdersWizard',
    'PrestashopConnectionWizardView', 'PrestashopConnectionWizard',
]
TIMEZONES = [(None, '')] + [(x, x) for x in pytz.common_timezones]

PRESTASHOP_STATES = {
    'required': Eval('source') == 'prestashop',
    'invisible': ~(Eval('source') == 'prestashop')
}
INVISIBLE_IF_NOT_PRESTASHOP = {
    'invisible': ~(Eval('source') == 'prestashop')
}


class Channel:
    """
    Sale Channel model
    """
    __name__ = 'sale.channel'

    #: The URL of prestashop site
    prestashop_url = fields.Char(
        'Prestashop URL', states=PRESTASHOP_STATES, depends=['source']
    )

    #: The webservices key for access to site
    prestashop_key = fields.Char(
        'Prestashop Key', states=PRESTASHOP_STATES, depends=['source']
    )

    #: Last time at which the orders were imported from prestashop
    last_prestashop_order_import_time = fields.DateTime(
        'Last Prestashop Order Import Time', states=INVISIBLE_IF_NOT_PRESTASHOP,
        depends=['source']
    )

    #: Last time at which the orders were exported to prestashop
    last_prestashop_order_export_time = fields.DateTime(
        'Last Prestashop order export time', states=INVISIBLE_IF_NOT_PRESTASHOP,
        depends=['source']
    )
    prestashop_shipping_product = fields.Many2One(
        'product.product', 'Shipping Product', states=PRESTASHOP_STATES,
        domain=[
            ('type', '=', 'service'),
            ('template.type', '=', 'service'),
        ], depends=['source']
    )

    #: The timezone set on prestashop site
    #: The orders imported will bear time in this timezone and that will need
    #: to be converted to UTC
    #: Also in order to determine what orders are to be imported, we need
    #: to convert UTC to this timezone to ensure correct time interval
    prestashop_timezone = fields.Selection(
        TIMEZONES, 'Timezone', translate=False, states=PRESTASHOP_STATES,
        depends=['source']
    )

    #: Allowed languages to be synced for the site<commit_msg>Shipping product must be salable #7696<commit_after># -*- coding: utf-8 -*-
"""
    prestashop

    :copyright: (c) 2015 by Openlabs Technologies & Consulting (P) Limited
    :license: GPLv3, see LICENSE for more details.
"""
from datetime import datetime

import pytz
import requests
import pystashop
from mockstashop import MockstaShopWebservice
from trytond.model import ModelView, fields
from trytond.transaction import Transaction
from trytond.pool import Pool, PoolMeta
from trytond.wizard import Wizard, StateView, Button
from trytond.pyson import Eval

__metaclass__ = PoolMeta
__all__ = [
    'Channel', 'PrestashopImportOrdersWizardView',
    'PrestashopImportOrdersWizard', 'PrestashopExportOrdersWizardView',
    'PrestashopExportOrdersWizard',
    'PrestashopConnectionWizardView', 'PrestashopConnectionWizard',
]
TIMEZONES = [(None, '')] + [(x, x) for x in pytz.common_timezones]

PRESTASHOP_STATES = {
    'required': Eval('source') == 'prestashop',
    'invisible': ~(Eval('source') == 'prestashop')
}
INVISIBLE_IF_NOT_PRESTASHOP = {
    'invisible': ~(Eval('source') == 'prestashop')
}


class Channel:
    """
    Sale Channel model
    """
    __name__ = 'sale.channel'

    #: The URL of prestashop site
    prestashop_url = fields.Char(
        'Prestashop URL', states=PRESTASHOP_STATES, depends=['source']
    )

    #: The webservices key for access to site
    prestashop_key = fields.Char(
        'Prestashop Key', states=PRESTASHOP_STATES, depends=['source']
    )

    #: Last time at which the orders were imported from prestashop
    last_prestashop_order_import_time = fields.DateTime(
        'Last Prestashop Order Import Time', states=INVISIBLE_IF_NOT_PRESTASHOP,
        depends=['source']
    )

    #: Last time at which the orders were exported to prestashop
    last_prestashop_order_export_time = fields.DateTime(
        'Last Prestashop order export time', states=INVISIBLE_IF_NOT_PRESTASHOP,
        depends=['source']
    )
    prestashop_shipping_product = fields.Many2One(
        'product.product', 'Shipping Product', states=PRESTASHOP_STATES,
        domain=[
            ('type', '=', 'service'),
            ('template.type', '=', 'service'),
            ('salable', '=', True),
        ], depends=['source']
    )

    #: The timezone set on prestashop site
    #: The orders imported will bear time in this timezone and that will need
    #: to be converted to UTC
    #: Also in order to determine what orders are to be imported, we need
    #: to convert UTC to this timezone to ensure correct time interval
    prestashop_timezone = fields.Selection(
        TIMEZONES, 'Timezone', translate=False, states=PRESTASHOP_STATES,
        depends=['source']
    )

    #: Allowed languages to be synced for the site
{'fraction_non_alphanumeric': 0.10290623286419302, 'fraction_numerical': 0.003290074940595869, 'mean_word_length': 3.7294727744165947, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1002671', 'n_tokens_mistral': 1755, 'n_tokens_neox': 1704, 'n_words': 468}