first commit

This commit is contained in:
root
2026-03-14 09:42:12 +00:00
commit 0adbd20c2c
10991 changed files with 1646955 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.

View File

@@ -0,0 +1,26 @@
==============
Country Import
==============
Imports::
>>> from proteus import Model
>>> from trytond.modules.country.scripts import (
... import_countries, import_postal_codes)
>>> from trytond.tests.tools import activate_modules
Activate modules::
>>> config = activate_modules('country')
Import countries::
>>> Country = Model.get('country.country')
>>> belgium = Country(name="Belgium", code='BE')
>>> belgium.save()
>>> import_countries.do_import()
Import postal codes::
>>> import_postal_codes.do_import(['us'])

View File

@@ -0,0 +1,115 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
import datetime as dt
from trytond.pool import Pool
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
class CountryTestCase(ModuleTestCase):
'Test Country module'
module = 'country'
def create_membership(self, from_date=None, to_date=None):
pool = Pool()
Country = pool.get('country.country')
Organization = pool.get('country.organization')
OrganizationMember = pool.get('country.organization.member')
organization = Organization(name="Organization")
organization.save()
country = Country(name="Country")
country.save()
member = OrganizationMember(
organization=organization, country=country,
from_date=from_date, to_date=to_date)
member.save()
return organization, country
@with_transaction()
def test_is_member_no_date(self):
"Test is member without date"
organization, country = self.create_membership()
self.assertTrue(country.is_member(organization))
self.assertTrue(country.is_member(organization, dt.date.min))
self.assertTrue(country.is_member(organization, dt.date.max))
@with_transaction()
def test_is_member_with_from_date(self):
"Test is member with from date"
today = dt.date.today()
yesterday = today - dt.timedelta(days=1)
tomorrow = today + dt.timedelta(days=1)
organization, country = self.create_membership(from_date=today)
self.assertTrue(country.is_member(organization, today))
self.assertFalse(country.is_member(organization, yesterday))
self.assertTrue(country.is_member(organization, tomorrow))
self.assertFalse(country.is_member(organization, dt.date.min))
self.assertTrue(country.is_member(organization, dt.date.max))
@with_transaction()
def test_is_member_with_to_date(self):
"Test is member with to date"
today = dt.date.today()
yesterday = today - dt.timedelta(days=1)
tomorrow = today + dt.timedelta(days=1)
organization, country = self.create_membership(to_date=today)
self.assertTrue(country.is_member(organization, today))
self.assertTrue(country.is_member(organization, yesterday))
self.assertFalse(country.is_member(organization, tomorrow))
self.assertTrue(country.is_member(organization, dt.date.min))
self.assertFalse(country.is_member(organization, dt.date.max))
@with_transaction()
def test_is_member_with_dates(self):
"Test is member with dates"
today = dt.date.today()
yesterday = today - dt.timedelta(days=1)
tomorrow = today + dt.timedelta(days=1)
organization, country = self.create_membership(
from_date=yesterday, to_date=tomorrow)
self.assertTrue(country.is_member(organization, today))
self.assertTrue(country.is_member(organization, yesterday))
self.assertFalse(country.is_member(organization, dt.date.min))
self.assertFalse(country.is_member(organization, dt.date.max))
@with_transaction()
def test_subdivision_code_search(self):
"Test search on subdivision code"
pool = Pool()
Country = pool.get('country.country')
Subdivision = pool.get('country.subdivision')
fr, = Country.create([{'name': 'France'}])
paris, nord = Subdivision.create([{
'name': 'Paris',
'code': 'FR-75',
'country': fr,
}, {
'name': 'Nord',
'code': 'FR-59',
'country': fr,
}])
for domain, result in [
([('code', '=', 'FR-59')], [nord]),
([('code', '!=', 'FR-59')], [paris]),
([('code', '=', '59')], []),
([('code', '!=', '59')], [nord, paris]),
([('code', 'like', '59%')], [nord]),
([('code', 'not like', '59%')], [paris]),
([('code', 'ilike', '59%')], [nord]),
([('code', 'not like', '59%')], [paris]),
]:
with self.subTest(domain=domain):
self.assertEqual(Subdivision.search(
domain, order=[('name', 'ASC')]),
result)
del ModuleTestCase

View File

@@ -0,0 +1,10 @@
# 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.tests.test_tryton import TEST_NETWORK, load_doc_tests
def load_tests(*args, **kwargs):
if not TEST_NETWORK:
kwargs.setdefault('skips', set()).add('scenario_country_import.rst')
return load_doc_tests(__name__, __file__, *args, **kwargs)