Migrate to py3
This commit is contained in:
parent
3d870e30ae
commit
9b0b44e121
29
__init__.py
29
__init__.py
|
@ -2,22 +2,21 @@
|
|||
# The COPYRIGHT file at the top level of this repository contains
|
||||
# the full copyright notices and license terms.
|
||||
from trytond.pool import Pool
|
||||
from .configuration import *
|
||||
from .attachment import *
|
||||
from .menu import *
|
||||
from .product import *
|
||||
from . import configuration
|
||||
from . import attachment
|
||||
from . import menu
|
||||
from . import product
|
||||
|
||||
def register():
|
||||
Pool.register(
|
||||
Configuration,
|
||||
ConfigurationProductESale,
|
||||
Attachment,
|
||||
CatalogMenu,
|
||||
Template,
|
||||
Product,
|
||||
ProductMenu,
|
||||
ProductRelated,
|
||||
ProductUpSell,
|
||||
ProductCrossSell,
|
||||
configuration.Configuration,
|
||||
configuration.ConfigurationProductESale,
|
||||
attachment.Attachment,
|
||||
menu.CatalogMenu,
|
||||
product.Template,
|
||||
product.Product,
|
||||
product.ProductMenu,
|
||||
product.ProductRelated,
|
||||
product.ProductUpSell,
|
||||
product.ProductCrossSell,
|
||||
module='product_esale', type_='model')
|
||||
|
||||
|
|
|
@ -12,8 +12,7 @@ STATES = {
|
|||
DEPENDS = ['esale_available']
|
||||
|
||||
|
||||
class Attachment:
|
||||
__metaclass__ = PoolMeta
|
||||
class Attachment(metaclass=PoolMeta):
|
||||
__name__ = 'ir.attachment'
|
||||
esale_available = fields.Boolean('Available eSale',
|
||||
help='This image are available in your e-commerce.')
|
||||
|
|
|
@ -21,8 +21,8 @@ product_attribute_set_options = fields.Char('Product Attribute Set Options',
|
|||
'key:value|key2:value2'))
|
||||
default_uom = fields.Many2One('product.uom', 'Default UOM')
|
||||
|
||||
class Configuration:
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
class Configuration(metaclass=PoolMeta):
|
||||
__name__ = 'product.configuration'
|
||||
template_attribute_set = fields.MultiValue(template_attribute_set)
|
||||
template_attribute_set_options = fields.MultiValue(
|
||||
|
|
14
product.py
14
product.py
|
@ -28,8 +28,7 @@ def attribute2dict(s):
|
|||
return d
|
||||
|
||||
|
||||
class Template:
|
||||
__metaclass__ = PoolMeta
|
||||
class Template(metaclass=PoolMeta):
|
||||
__name__ = 'product.template'
|
||||
esale_visibility = fields.Selection([
|
||||
('all','All'),
|
||||
|
@ -56,7 +55,7 @@ class Template:
|
|||
esale_metatitle = fields.Char('Meta Title', translate=True)
|
||||
esale_menus = fields.Many2Many('product.template-esale.catalog.menu',
|
||||
'template', 'menu', 'Menus')
|
||||
esale_relateds = fields.Many2Many('product.template-product.related',
|
||||
esale_relateds = fields.Many2Many('product.template-product.related',
|
||||
'template', 'related', 'Relateds',
|
||||
domain=[
|
||||
('id', '!=', Eval('id')),
|
||||
|
@ -77,7 +76,7 @@ class Template:
|
|||
('esale_available', '=', True),
|
||||
('salable', '=', True),
|
||||
], depends=['id'])
|
||||
esale_sequence = fields.Integer('Sequence',
|
||||
esale_sequence = fields.Integer('Sequence',
|
||||
help='Gives the sequence order when displaying category list.')
|
||||
esale_images = fields.Function(fields.Char('eSale Images'), 'get_esale_images')
|
||||
esale_default_images = fields.Function(fields.Char('eSale Default Images'), 'get_esale_default_images')
|
||||
|
@ -187,7 +186,7 @@ class Template:
|
|||
thumb = None
|
||||
for attachment in self.attachments:
|
||||
if not attachment.esale_available or attachment.esale_exclude:
|
||||
continue
|
||||
continue
|
||||
if attachment.esale_base_image and not base:
|
||||
base = attachment.name
|
||||
if attachment.esale_small_image and not small:
|
||||
|
@ -332,8 +331,7 @@ class Template:
|
|||
return options
|
||||
|
||||
|
||||
class Product:
|
||||
__metaclass__ = PoolMeta
|
||||
class Product(metaclass=PoolMeta):
|
||||
__name__ = 'product.product'
|
||||
esale_available = fields.Function(fields.Boolean('eSale'),
|
||||
'get_esale_available', searcher='search_esale_available')
|
||||
|
@ -341,7 +339,7 @@ class Product:
|
|||
'get_esale_active', searcher='search_esale_active')
|
||||
esale_slug = fields.Char('Slug', translate=True, states=STATES,
|
||||
depends=DEPENDS)
|
||||
esale_sequence = fields.Integer('Sequence',
|
||||
esale_sequence = fields.Integer('Sequence',
|
||||
help='Gives the sequence order when displaying variants list.')
|
||||
unique_variant = fields.Function(fields.Boolean('Unique Variant'),
|
||||
'on_change_with_unique_variant')
|
||||
|
|
5
setup.py
5
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
|
||||
|
||||
MODULE2PREFIX = {}
|
||||
|
||||
|
|
40
tools.py
40
tools.py
|
@ -11,30 +11,22 @@ from trytond.config import config as config_
|
|||
|
||||
template_engine = config_.get('product', 'template_engine', default='genshi')
|
||||
|
||||
SRC_CHARS = u""" .'"()/*-+?¿!&$[]{}@#`'^:;<>=~%,|\\"""
|
||||
DST_CHARS = u""" """
|
||||
SRC_CHARS = u"""/*+?¿!&$[]{}`^<>=~%|\\"""
|
||||
|
||||
def unaccent(text):
|
||||
if not text:
|
||||
return ''
|
||||
for c in range(len(SRC_CHARS)):
|
||||
text = text.replace(SRC_CHARS[c], '')
|
||||
text = text.replace('º', '. ')
|
||||
text = text.replace('ª', '. ')
|
||||
text = text.replace(' ', ' ')
|
||||
output = unicodedata.normalize('NFKD', text).encode('ASCII', 'ignore')
|
||||
return output.decode('utf-8')
|
||||
|
||||
def slugify(value):
|
||||
"""Convert value to slug: az09 and replace spaces by -"""
|
||||
try:
|
||||
if isinstance(value, unicode):
|
||||
name = slug.slug(value)
|
||||
else:
|
||||
name = slug.slug(unicode(value, 'UTF-8'))
|
||||
except:
|
||||
name = ''
|
||||
return name
|
||||
|
||||
def unaccent(text):
|
||||
if not (isinstance(text, str) or isinstance(text, unicode)):
|
||||
return str(text)
|
||||
if isinstance(text, str):
|
||||
text = unicode(text, 'utf-8')
|
||||
for c in xrange(len(SRC_CHARS)):
|
||||
if c >= len(DST_CHARS):
|
||||
break
|
||||
text = text.replace(SRC_CHARS[c], DST_CHARS[c])
|
||||
return unicodedata.normalize('NFKD', text).encode('ASCII', 'ignore')
|
||||
return slug.slug(value)
|
||||
|
||||
def seo_lenght(string):
|
||||
'''Get first 155 characters from string'''
|
||||
|
@ -65,7 +57,7 @@ def _engine_python(expression, record):
|
|||
'''Evaluate the pythonic expression and return its value
|
||||
'''
|
||||
if expression is None:
|
||||
return u''
|
||||
return ''
|
||||
tpl_context = template_context(record)
|
||||
return simple_eval(expression, tpl_context)
|
||||
|
||||
|
@ -75,7 +67,7 @@ def _engine_genshi(expression, record):
|
|||
:param record: Browse record
|
||||
'''
|
||||
if not expression:
|
||||
return u''
|
||||
return ''
|
||||
template = TextTemplate(expression)
|
||||
tpl_context = template_context(record)
|
||||
return template.generate(**tpl_context).render(encoding='UTF-8')
|
||||
|
@ -86,7 +78,7 @@ def _engine_jinja2(expression, record):
|
|||
:param record: Browse record
|
||||
'''
|
||||
if not expression:
|
||||
return u''
|
||||
return ''
|
||||
template = Jinja2Template(expression)
|
||||
tpl_context = template_context(record)
|
||||
return template.render(tpl_context).encode('utf-8')
|
||||
|
|
|
@ -97,20 +97,8 @@ The COPYRIGHT file at the top level of this repository contains the full copyrig
|
|||
<field name="categories" colspan="4"/>
|
||||
</page>
|
||||
<page string="Accounting" col="4" id="accounting">
|
||||
<separator string="Accounts" id="accounts" colspan="4"/>
|
||||
<label name="account_category"/>
|
||||
<field name="account_category"/>
|
||||
<newline/>
|
||||
<label name="account_revenue"/>
|
||||
<field name="account_revenue"/>
|
||||
<label name="account_expense"/>
|
||||
<field name="account_expense"/>
|
||||
<separator string="Taxes" id="taxes" colspan="4"/>
|
||||
<label name="taxes_category"/>
|
||||
<field name="taxes_category"/>
|
||||
<newline/>
|
||||
<field name="customer_taxes" colspan="2"/>
|
||||
<field name="supplier_taxes" colspan="2"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</form>
|
||||
|
|
Loading…
Reference in New Issue