From f1ba1fba51983cd3aa93d30c175a8ad0ed6ca113 Mon Sep 17 00:00:00 2001 From: Albert Cervera i Areny Date: Mon, 29 Oct 2018 00:04:47 +0100 Subject: [PATCH] Migrate to python 3 --- product.py | 3 +-- production.py | 17 ++++++++--------- setup.py | 4 ++-- tests/scenario_production.rst | 4 ++-- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/product.py b/product.py index 7b8cf52..e5664e5 100644 --- a/product.py +++ b/product.py @@ -5,10 +5,9 @@ from trytond.pyson import Eval, Get, If, Bool from trytond.pool import Pool, PoolMeta __all__ = ['ProductBom'] -__metaclass__ = PoolMeta -class ProductBom: +class ProductBom(metaclass=PoolMeta): __name__ = 'product.product-production.bom' process = fields.Many2One('production.process', 'Process', diff --git a/production.py b/production.py index 151eb54..18f84dd 100644 --- a/production.py +++ b/production.py @@ -1,4 +1,4 @@ -from itertools import izip + from trytond.model import ModelSQL, ModelView, fields from trytond.pool import Pool, PoolMeta from trytond.pyson import Bool, Eval @@ -8,7 +8,6 @@ from trytond.transaction import Transaction __all__ = ['Process', 'Step', 'BOMInput', 'BOMOutput', 'Operation', 'BOM', 'Route', 'Production', 'StockMove'] -__metaclass__ = PoolMeta class Process(ModelSQL, ModelView): @@ -90,7 +89,7 @@ class Process(ModelSQL, ModelView): if without_boms: boms = BOM.create(boms_to_create) routes = Route.create(routes_to_create) - for values, bom, route in izip(without_boms, boms, routes): + for values, bom, route in zip(without_boms, boms, routes): values['bom'] = bom.id values['route'] = route.id return super(Process, cls).create(with_boms + without_boms) @@ -223,7 +222,7 @@ class Step(ModelSQL, ModelView): return res -class BOMMixin: +class BOMMixin(metaclass=PoolMeta): step = fields.Many2One('production.process.step', 'Step') step_sequence = fields.Integer('Step Sequence') @@ -245,7 +244,7 @@ class BOMOutput(BOMMixin): __name__ = 'production.bom.output' -class Operation: +class Operation(metaclass=PoolMeta): __name__ = 'production.route.operation' step = fields.Many2One('production.process.step', 'Step') @@ -289,7 +288,7 @@ class Operation: return step.process.route.id -class BOM: +class BOM(metaclass=PoolMeta): __name__ = 'production.bom' @classmethod @@ -314,7 +313,7 @@ class BOM: super(BOM, cls).delete(boms) -class Route: +class Route(metaclass=PoolMeta): __name__ = 'production.route' @classmethod @@ -340,7 +339,7 @@ class Route: super(Route, cls).delete(routes) -class Production: +class Production(metaclass=PoolMeta): __name__ = 'production' process = fields.Many2One('production.process', 'Process', @@ -394,7 +393,7 @@ class Production: return move -class StockMove: +class StockMove(metaclass=PoolMeta): __name__ = 'stock.move' production_step = fields.Many2One('production.process.step', 'Process') diff --git a/setup.py b/setup.py index 6741a0b..d668304 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ from setuptools import setup import re import os -import ConfigParser +import configparser MODULE = 'production_process' PREFIX = 'nantic' @@ -14,7 +14,7 @@ MODULE2PREFIX = {} def read(fname): return open(os.path.join(os.path.dirname(__file__), fname)).read() -config = ConfigParser.ConfigParser() +config = configparser.ConfigParser() config.readfp(open('tryton.cfg')) info = dict(config.items('tryton')) for key in ('depends', 'extras_depend', 'xml'): diff --git a/tests/scenario_production.rst b/tests/scenario_production.rst index 86aa274..b54dded 100644 --- a/tests/scenario_production.rst +++ b/tests/scenario_production.rst @@ -200,7 +200,7 @@ Create an Inventory:: >>> inventory.save() >>> Inventory.confirm([inventory.id], config.context) >>> inventory.state - u'done' + 'done' Make a production:: @@ -235,7 +235,7 @@ Make a production:: >>> production.reload() >>> output, = production.outputs >>> output.state - u'done' + 'done' >>> config._context['locations'] = [storage.id] >>> product = Product(product.id) >>> product.quantity == 2