From 3bfc3a6018001982687146aadd2de3760cd4cc07 Mon Sep 17 00:00:00 2001 From: Albert Cervera i Areny Date: Fri, 17 Aug 2018 22:59:55 +0200 Subject: [PATCH] Migrate to python 3. --- __init__.py | 4 ++-- account.py | 20 +++++++------------- payment.py | 12 ++++-------- setup.py | 5 +---- tests/scenario_compensation_move.rst | 6 +++--- 5 files changed, 17 insertions(+), 30 deletions(-) diff --git a/__init__.py b/__init__.py index 5373fd4..0752058 100644 --- a/__init__.py +++ b/__init__.py @@ -2,8 +2,8 @@ # The COPYRIGHT file at the top level of this repository contains # the full copyright notices and license terms. from trytond.pool import Pool -import account -import payment +from . import account +from . import payment def register(): diff --git a/account.py b/account.py index 9b1b75f..68b10bd 100644 --- a/account.py +++ b/account.py @@ -23,8 +23,7 @@ ACCOUNT_BANK_KIND = [ ] -class PaymentType: - __metaclass__ = PoolMeta +class PaymentType(metaclass=PoolMeta): __name__ = 'account.payment.type' account_bank = fields.Selection(ACCOUNT_BANK_KIND, 'Account Bank Kind', select=True, required=True) @@ -58,8 +57,7 @@ class PaymentType: return 'none' -class BankAccount: - __metaclass__ = PoolMeta +class BankAccount(metaclass=PoolMeta): __name__ = 'bank.account' @classmethod @@ -114,8 +112,7 @@ class BankAccount: error_args) -class Party: - __metaclass__ = PoolMeta +class Party(metaclass=PoolMeta): __name__ = 'party.party' @classmethod @@ -217,8 +214,7 @@ class BankMixin(object): return payment_type.party.id -class Invoice(BankMixin): - __metaclass__ = PoolMeta +class Invoice(BankMixin, metaclass=PoolMeta): __name__ = 'account.invoice' @classmethod @@ -271,8 +267,7 @@ class Invoice(BankMixin): super(Invoice, cls).post(invoices) -class Reconciliation: - __metaclass__ = PoolMeta +class Reconciliation(metaclass=PoolMeta): __name__ = 'account.move.reconciliation' @classmethod @@ -307,8 +302,7 @@ class Reconciliation: Invoice.process(invoices) -class Line: - __metaclass__ = PoolMeta +class Line(metaclass=PoolMeta): __name__ = 'account.move.line' reverse_moves = fields.Function(fields.Boolean('With Reverse Moves'), @@ -580,7 +574,7 @@ class CompensationMove(Wizard): extra_line.credit = abs(amount) origin = None - for line_origin, line_amount in sorted(origins.iteritems(), + for line_origin, line_amount in sorted(origins.items(), key=lambda x: x[1]): if abs(amount) < line_amount: origin = line_origin diff --git a/payment.py b/payment.py index 5a3d8a0..f49cacb 100644 --- a/payment.py +++ b/payment.py @@ -11,8 +11,7 @@ __all__ = ['Journal', 'Group', 'Payment', 'PayLine'] _ZERO = Decimal('0.0') -class Journal: - __metaclass__ = PoolMeta +class Journal(metaclass=PoolMeta): __name__ = 'account.payment.journal' payment_type = fields.Many2One('account.payment.type', 'Payment Type', @@ -22,8 +21,7 @@ class Journal: 'the company.')) -class Group: - __metaclass__ = PoolMeta +class Group(metaclass=PoolMeta): __name__ = 'account.payment.group' payment_type = fields.Function(fields.Many2One('account.payment.type', @@ -60,8 +58,7 @@ class Group: return amount -class Payment: - __metaclass__ = PoolMeta +class Payment(metaclass=PoolMeta): __name__ = 'account.payment' bank_account = fields.Many2One('bank.account', 'Bank Account', states={ @@ -149,8 +146,7 @@ class Payment: return mandates2 -class PayLine: - __metaclass__ = PoolMeta +class PayLine(metaclass=PoolMeta): __name__ = 'account.move.line.pay' def get_payment(self, line, journals): diff --git a/setup.py b/setup.py index 4196ab0..2accd46 100644 --- a/setup.py +++ b/setup.py @@ -7,10 +7,7 @@ from setuptools import setup import re import os import io -try: - from configparser import ConfigParser -except ImportError: - from ConfigParser import ConfigParser +from configparser import ConfigParser MODULE = 'account_bank' PREFIX = 'trytonspain' diff --git a/tests/scenario_compensation_move.rst b/tests/scenario_compensation_move.rst index 2d59119..841d018 100644 --- a/tests/scenario_compensation_move.rst +++ b/tests/scenario_compensation_move.rst @@ -125,7 +125,7 @@ Create invoice:: >>> Invoice.post([invoice.id], config.context) >>> invoice.reload() >>> invoice.state - u'posted' + 'posted' >>> invoice.amount_to_pay == Decimal(240) True @@ -153,7 +153,7 @@ Create credit note:: >>> Invoice.post([credit_note.id], config.context) >>> credit_note.reload() >>> credit_note.state - u'posted' + 'posted' >>> credit_note.amount_to_pay == Decimal(-44) True @@ -213,4 +213,4 @@ Create a move that pays the pending amount:: >>> invoice.amount_to_pay Decimal('0.0') >>> invoice.state - u'paid' + 'paid'