Remove support for Python 2.7
issue7497 review53261002
This commit is contained in:
@@ -25,12 +25,6 @@ services:
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- IMAGE: python:2.7
|
||||
TOXENV: py27
|
||||
DATABASE: sqlite
|
||||
- IMAGE: python:2.7
|
||||
TOXENV: py27
|
||||
DATABASE: postgresql
|
||||
- IMAGE: python:3.4
|
||||
TOXENV: py34
|
||||
DATABASE: sqlite
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
* Remove support for Python 2.7
|
||||
* Remove journal type
|
||||
|
||||
Version 4.8.0 - 2018-04-23
|
||||
|
||||
@@ -4,7 +4,7 @@ Installing trytond_account
|
||||
Prerequisites
|
||||
-------------
|
||||
|
||||
* Python 2.7 or later (http://www.python.org/)
|
||||
* Python 3.4 or later (http://www.python.org/)
|
||||
* python-dateutil (http://labix.org/python-dateutil)
|
||||
* python-sql (http://code.google.com/p/python-sql/)
|
||||
* simpleeval (https://github.com/danthedeckie/simpleeval)
|
||||
|
||||
+5
-5
@@ -262,7 +262,7 @@ class Type(sequence_ordered(), tree(separator='\\'), ModelSQL, ModelView):
|
||||
if not current.get('comparison'):
|
||||
return dict.fromkeys([t.id for t in types], None)
|
||||
new = {}
|
||||
for key, value in current.iteritems():
|
||||
for key, value in current.items():
|
||||
if key.endswith('_cmp'):
|
||||
new[key[:-4]] = value
|
||||
with transaction.set_context(new):
|
||||
@@ -1302,7 +1302,7 @@ class GeneralLedgerAccount(DeactivableMixin, ModelSQL, ModelView):
|
||||
Account = pool.get('account.account')
|
||||
account = Account.__table__()
|
||||
columns = []
|
||||
for fname, field in cls._fields.iteritems():
|
||||
for fname, field in cls._fields.items():
|
||||
if not hasattr(field, 'set'):
|
||||
columns.append(Column(account, fname).as_(fname))
|
||||
return account.select(*columns,
|
||||
@@ -1574,7 +1574,7 @@ class GeneralLedgerLine(ModelSQL, ModelView):
|
||||
move = Move.__table__()
|
||||
account = Account.__table__()
|
||||
columns = []
|
||||
for fname, field in cls._fields.iteritems():
|
||||
for fname, field in cls._fields.items():
|
||||
if hasattr(field, 'set'):
|
||||
continue
|
||||
field_line = getattr(Line, fname, None)
|
||||
@@ -1985,9 +1985,9 @@ class AgedBalance(ModelSQL, ModelView):
|
||||
# Ensure None are before 0 to get the next index pointing to the next
|
||||
# value and not a None value
|
||||
term_values = sorted(
|
||||
terms.values(), key=lambda x: ((x is not None), x or 0))
|
||||
list(terms.values()), key=lambda x: ((x is not None), x or 0))
|
||||
|
||||
for name, value in terms.iteritems():
|
||||
for name, value in terms.items():
|
||||
if value is None or factor is None or date is None:
|
||||
columns.append(Literal(None).as_(name))
|
||||
continue
|
||||
|
||||
+2
-3
@@ -1,6 +1,5 @@
|
||||
# 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 __future__ import division
|
||||
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from trytond.model import ModelView, ModelSQL, Workflow, fields
|
||||
@@ -302,8 +301,8 @@ class FiscalYear(Workflow, ModelSQL, ModelView):
|
||||
accounts = Account.search([
|
||||
('company', '=', fiscalyear.company.id),
|
||||
])
|
||||
deferrals += filter(None, (fiscalyear.get_deferral(a)
|
||||
for a in accounts))
|
||||
deferrals += [_f for _f in (fiscalyear.get_deferral(a)
|
||||
for a in accounts) if _f]
|
||||
Deferral.save(deferrals)
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -238,7 +238,7 @@ class Move(ModelSQL, ModelView):
|
||||
all_moves = []
|
||||
args = []
|
||||
for moves, values in zip(actions, actions):
|
||||
keys = values.keys()
|
||||
keys = list(values.keys())
|
||||
for key in cls._check_modify_exclude:
|
||||
if key in keys:
|
||||
keys.remove(key)
|
||||
@@ -974,7 +974,7 @@ class Line(ModelSQL, ModelView):
|
||||
fiscalyear_id = fiscalyears[0].id
|
||||
else:
|
||||
fiscalyear_id = -1
|
||||
fiscalyear_ids = map(int, fiscalyears)
|
||||
fiscalyear_ids = list(map(int, fiscalyears))
|
||||
where &= period.fiscalyear == fiscalyear_id
|
||||
where &= move.date <= date
|
||||
elif fiscalyear_id or period_ids or from_date or to_date:
|
||||
@@ -994,7 +994,7 @@ class Line(ModelSQL, ModelView):
|
||||
('state', '=', 'open'),
|
||||
('company', '=', company),
|
||||
])
|
||||
fiscalyear_ids = map(int, fiscalyears)
|
||||
fiscalyear_ids = list(map(int, fiscalyears))
|
||||
|
||||
# Use LEFT JOIN to allow database optimization
|
||||
# if no joined table is used in the where clause.
|
||||
@@ -1625,7 +1625,7 @@ class Reconcile(Wizard):
|
||||
for lines in grouped_slice(self._all_lines(), chunk):
|
||||
lines = list(lines)
|
||||
best = None
|
||||
for n in xrange(len(lines), 1, -1):
|
||||
for n in range(len(lines), 1, -1):
|
||||
for comb_lines in combinations(lines, n):
|
||||
if requested and not requested.intersection(comb_lines):
|
||||
continue
|
||||
@@ -1638,7 +1638,7 @@ class Reconcile(Wizard):
|
||||
if best:
|
||||
default.extend(best)
|
||||
if not default and requested:
|
||||
default = map(int, requested)
|
||||
default = list(map(int, requested))
|
||||
return default
|
||||
|
||||
def transition_reconcile(self):
|
||||
@@ -1733,7 +1733,7 @@ class CancelMoves(Wizard):
|
||||
for line in move.lines + cancel_move.lines:
|
||||
if line.account.reconcile:
|
||||
to_reconcile[line.account].append(line)
|
||||
for lines in to_reconcile.itervalues():
|
||||
for lines in to_reconcile.values():
|
||||
Line.reconcile(lines)
|
||||
return 'end'
|
||||
|
||||
|
||||
+1
-1
@@ -138,7 +138,7 @@ class MoveTemplateKeyword(sequence_ordered(), ModelSQL, ModelView):
|
||||
])
|
||||
keywords = {k.name: k for k in template.keywords}
|
||||
|
||||
for k, v in values.iteritems():
|
||||
for k, v in values.items():
|
||||
keyword = keywords[k]
|
||||
func = getattr(keyword, '_format_%s' % keyword.type_, None)
|
||||
if func:
|
||||
|
||||
@@ -22,8 +22,7 @@ account_names = [
|
||||
'customer_tax_rule', 'supplier_tax_rule']
|
||||
|
||||
|
||||
class Party(CompanyMultiValueMixin):
|
||||
__metaclass__ = PoolMeta
|
||||
class Party(CompanyMultiValueMixin, metaclass=PoolMeta):
|
||||
__name__ = 'party.party'
|
||||
accounts = fields.One2Many('party.party.account', 'party', "Accounts")
|
||||
account_payable = fields.MultiValue(fields.Many2One(
|
||||
@@ -300,8 +299,7 @@ class PartyAccount(ModelSQL, CompanyValueMixin):
|
||||
parent='party', fields=fields)
|
||||
|
||||
|
||||
class PartyReplace:
|
||||
__metaclass__ = PoolMeta
|
||||
class PartyReplace(metaclass=PoolMeta):
|
||||
__name__ = 'party.replace'
|
||||
|
||||
@classmethod
|
||||
@@ -311,8 +309,7 @@ class PartyReplace:
|
||||
]
|
||||
|
||||
|
||||
class PartyErase:
|
||||
__metaclass__ = PoolMeta
|
||||
class PartyErase(metaclass=PoolMeta):
|
||||
__name__ = 'party.erase'
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -272,14 +272,14 @@ class Period(Workflow, ModelSQL, ModelView):
|
||||
actions = iter(args)
|
||||
args = []
|
||||
for periods, values in zip(actions, actions):
|
||||
for key, value in values.iteritems():
|
||||
for key, value in values.items():
|
||||
if key in ('start_date', 'end_date', 'fiscalyear'):
|
||||
def modified(period):
|
||||
if key in ['start_date', 'end_date']:
|
||||
return getattr(period, key) != value
|
||||
else:
|
||||
return period.fiscalyear .id != value
|
||||
cls._check(filter(modified, periods))
|
||||
cls._check(list(filter(modified, periods)))
|
||||
break
|
||||
if values.get('state') == 'open':
|
||||
for period in periods:
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# 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 setuptools import setup
|
||||
import re
|
||||
import os
|
||||
import io
|
||||
try:
|
||||
from configparser import ConfigParser
|
||||
except ImportError:
|
||||
from ConfigParser import ConfigParser
|
||||
import os
|
||||
import re
|
||||
from configparser import ConfigParser
|
||||
from setuptools import setup
|
||||
|
||||
|
||||
def read(fname):
|
||||
@@ -27,6 +24,7 @@ def get_require_version(name):
|
||||
major_version, minor_version + 1)
|
||||
return require
|
||||
|
||||
|
||||
config = ConfigParser()
|
||||
config.readfp(open('tryton.cfg'))
|
||||
info = dict(config.items('tryton'))
|
||||
@@ -102,7 +100,6 @@ setup(name=name,
|
||||
'Natural Language :: Slovenian',
|
||||
'Natural Language :: Spanish',
|
||||
'Operating System :: OS Independent',
|
||||
'Programming Language :: Python :: 2.7',
|
||||
'Programming Language :: Python :: 3.4',
|
||||
'Programming Language :: Python :: 3.5',
|
||||
'Programming Language :: Python :: 3.6',
|
||||
@@ -112,6 +109,7 @@ setup(name=name,
|
||||
'Topic :: Office/Business :: Financial :: Accounting',
|
||||
],
|
||||
license='GPL-3',
|
||||
python_requires='>=3.4',
|
||||
install_requires=requires,
|
||||
dependency_links=dependency_links,
|
||||
zip_safe=False,
|
||||
@@ -122,12 +120,4 @@ setup(name=name,
|
||||
test_suite='tests',
|
||||
test_loader='trytond.test_loader:Loader',
|
||||
tests_require=tests_require,
|
||||
use_2to3=True,
|
||||
convert_2to3_doctests=[
|
||||
'tests/scenario_account_reconciliation.rst',
|
||||
'tests/scenario_move_cancel.rst',
|
||||
'tests/scenario_move_template.rst',
|
||||
'tests/scenario_reports.rst',
|
||||
'tests/scenario_renew_fiscalyear.rst',
|
||||
],
|
||||
)
|
||||
|
||||
@@ -197,7 +197,7 @@ class TaxCode(DeactivableMixin, tree(), ModelSQL, ModelView):
|
||||
parents[code.id] = code.parent.id if code.parent else None
|
||||
|
||||
ids = set(map(int, childs))
|
||||
leafs = ids - set(parents.itervalues())
|
||||
leafs = ids - set(parents.values())
|
||||
while leafs:
|
||||
for code in leafs:
|
||||
ids.remove(code)
|
||||
@@ -817,7 +817,7 @@ class Tax(sequence_ordered(), ModelSQL, ModelView, DeactivableMixin):
|
||||
move_line = MoveLine.__table__()
|
||||
tax_line = TaxLine.__table__()
|
||||
|
||||
tax_ids = map(int, taxes)
|
||||
tax_ids = list(map(int, taxes))
|
||||
result = {}
|
||||
for name in names:
|
||||
result[name] = dict.fromkeys(tax_ids, Decimal(0))
|
||||
@@ -1140,7 +1140,7 @@ class TaxableMixin(object):
|
||||
def _round_taxes(self, taxes):
|
||||
if not self.currency:
|
||||
return
|
||||
for taxline in taxes.itervalues():
|
||||
for taxline in taxes.values():
|
||||
taxline['amount'] = self.currency.round(taxline['amount'])
|
||||
|
||||
def _get_taxes(self):
|
||||
|
||||
@@ -91,7 +91,7 @@ Cancel Move::
|
||||
>>> cancel_move.origin == move
|
||||
True
|
||||
>>> cancel_move.description
|
||||
u'Cancel'
|
||||
'Cancel'
|
||||
>>> revenue.reload()
|
||||
>>> revenue.credit
|
||||
Decimal('0.00')
|
||||
|
||||
@@ -116,7 +116,7 @@ Check the Move::
|
||||
>>> sorted((l.debit, l.credit) for l in move.lines)
|
||||
[(Decimal('0'), Decimal('12.24')), (Decimal('1.11'), Decimal('0')), (Decimal('11.13'), Decimal('0'))]
|
||||
>>> move.description
|
||||
u'Supplier - Test'
|
||||
'Supplier - Test'
|
||||
>>> with config.set_context(periods=period_ids):
|
||||
... base_code = TaxCode(base_code.id)
|
||||
... base_code.amount
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
[tox]
|
||||
envlist = {py27,py34,py35,py36}-{sqlite,postgresql},pypy-{sqlite,postgresql}
|
||||
envlist = {py34,py35,py36}-{sqlite,postgresql},pypy3-{sqlite,postgresql}
|
||||
|
||||
[testenv]
|
||||
commands = {envpython} setup.py test
|
||||
deps =
|
||||
{py27,py34,py35,py36}-postgresql: psycopg2 >= 2.5
|
||||
pypy-postgresql: psycopg2cffi >= 2.5
|
||||
{py34,py35,py36}-postgresql: psycopg2 >= 2.5
|
||||
pypy3-postgresql: psycopg2cffi >= 2.5
|
||||
sqlite: sqlitebck
|
||||
setenv =
|
||||
sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://}
|
||||
|
||||
Reference in New Issue
Block a user