Migrate to python 3

This commit is contained in:
Albert Cervera i Areny 2018-10-29 00:58:10 +01:00
parent 6dc7610ec8
commit 984087aa64
3 changed files with 9 additions and 14 deletions

View file

@ -4,7 +4,7 @@
from setuptools import setup
import re
import os
import ConfigParser
import configparser
MODULE = 'stock_external_reception'
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'):

View file

@ -14,9 +14,8 @@ _STATES = {
_DEPENDS = ['state']
class Configuration:
class Configuration(metaclass=PoolMeta):
__name__ = 'stock.configuration'
__metaclass__ = PoolMeta
external_reception_sequence = fields.MultiValue(fields.Many2One(
'ir.sequence', "External Reception Sequence", required=True,
domain=[
@ -40,9 +39,8 @@ class Configuration:
'sequence_external_reception')
class ConfigurationSequence:
class ConfigurationSequence(metaclass=PoolMeta):
__name__ = 'stock.configuration.sequence'
__metaclass__ = PoolMeta
external_reception_sequence = fields.Many2One(
'ir.sequence', "External Reception Sequence", required=True,
domain=[
@ -281,9 +279,8 @@ class ExternalReceptionLine(ModelSQL, ModelView):
return move
class ShipmentExternal:
class ShipmentExternal(metaclass=PoolMeta):
__name__ = 'stock.shipment.external'
__metaclass__ = PoolMeta
reception = fields.Many2One('stock.external.reception',
'External Reception', readonly=True)

View file

@ -57,15 +57,13 @@ Create product::
>>> ProductTemplate = Model.get('product.template')
>>> Product = Model.get('product.product')
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
>>> product = Product()
>>> template = ProductTemplate()
>>> template.name = 'Product'
>>> template.default_uom = unit
>>> template.type = 'goods'
>>> template.list_price = Decimal('20')
>>> template.cost_price = Decimal('8')
>>> template.save()
>>> product.template = template
>>> product, = template.products
>>> product.save()
Get stock locations::
@ -100,7 +98,7 @@ Create external shipment from received products::
>>> reception.click('done') # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
UserError: ('UserError', (u'Missing product on Line "Test product" of reception "1".', ''))
UserError: ('UserError', ('Missing product on Line "Test product" of reception "1".', ''))
>>> line, = reception.lines
>>> line.product = product
>>> reception.click('done')
@ -108,12 +106,12 @@ Create external shipment from received products::
>>> shipment.party == reception.party
True
>>> shipment.state
u'done'
'done'
>>> shipment.effective_date == reception.effective_date
True
>>> move, = shipment.moves
>>> move.state
u'done'
'done'
>>> move.product == product
True
>>> move.quantity == 1.0