Migrate to python 3
This commit is contained in:
parent
3be36bbc79
commit
835fe2595a
|
@ -10,9 +10,8 @@ from .aeat import (BOOK_KEY, SEND_SPECIAL_REGIME_KEY,
|
|||
__all__ = ['TemplateTax', 'Tax']
|
||||
|
||||
|
||||
class TemplateTax:
|
||||
class TemplateTax(metaclass=PoolMeta):
|
||||
__name__ = 'account.tax.template'
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
sii_book_key = fields.Selection(BOOK_KEY, 'Book Key')
|
||||
sii_issued_key = fields.Selection(SEND_SPECIAL_REGIME_KEY, 'Issued Key')
|
||||
|
@ -37,9 +36,8 @@ class TemplateTax:
|
|||
return res
|
||||
|
||||
|
||||
class Tax:
|
||||
class Tax(metaclass=PoolMeta):
|
||||
__name__ = 'account.tax'
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
sii_book_key = fields.Selection(BOOK_KEY, 'Book Key')
|
||||
sii_issued_key = fields.Selection(SEND_SPECIAL_REGIME_KEY, 'Issued Key')
|
||||
|
|
4
aeat.py
4
aeat.py
|
@ -222,14 +222,14 @@ def remove_accents(unicode_string):
|
|||
except UnicodeDecodeError:
|
||||
return unicode_string_bak
|
||||
|
||||
if not isinstance(unicode_string, unicode):
|
||||
if not isinstance(unicode_string, str):
|
||||
return unicode_string
|
||||
|
||||
# From http://www.leccionespracticas.com/uncategorized/eliminar-tildes-con-python-solucionado
|
||||
unicode_string_nfd = ''.join(
|
||||
(c for c in unicodedata.normalize('NFD', unicode_string)
|
||||
if (unicodedata.category(c) != 'Mn'
|
||||
or c in (u'\u0327', u'\u0303')) # ç or ñ
|
||||
or c in ('\u0327', '\u0303')) # ç or ñ
|
||||
))
|
||||
# It converts nfd to nfc to allow unicode.decode()
|
||||
return unicodedata.normalize('NFC', unicode_string_nfd)
|
||||
|
|
|
@ -15,9 +15,8 @@ __all__ = ['Company']
|
|||
_logger = getLogger(__name__)
|
||||
|
||||
|
||||
class Company:
|
||||
class Company(metaclass=PoolMeta):
|
||||
__name__ = 'company.company'
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
pem_certificate = fields.Binary('PEM Certificate')
|
||||
encrypted_private_key = fields.Binary('Encrypted Private Key')
|
||||
|
|
|
@ -22,8 +22,7 @@ _SII_INVOICE_KEYS = ['sii_book_key', 'sii_issued_key', 'sii_received_key',
|
|||
'sii_intracomunity_key']
|
||||
|
||||
|
||||
class Invoice:
|
||||
__metaclass__ = PoolMeta
|
||||
class Invoice(metaclass=PoolMeta):
|
||||
__name__ = 'account.invoice'
|
||||
|
||||
sii_book_key = fields.Selection(BOOK_KEY, 'SII Book Key')
|
||||
|
@ -219,8 +218,7 @@ class Invoice:
|
|||
cls.raise_user_warning(warning_name, 'invoices_sii', invoices_sii)
|
||||
|
||||
|
||||
class Sale:
|
||||
__metaclass__ = PoolMeta
|
||||
class Sale(metaclass=PoolMeta):
|
||||
__name__ = 'sale.sale'
|
||||
|
||||
def create_invoice(self):
|
||||
|
@ -239,8 +237,7 @@ class Sale:
|
|||
return invoice
|
||||
|
||||
|
||||
class Purchase:
|
||||
__metaclass__ = PoolMeta
|
||||
class Purchase(metaclass=PoolMeta):
|
||||
__name__ = 'purchase.purchase'
|
||||
|
||||
def create_invoice(self):
|
||||
|
|
3
party.py
3
party.py
|
@ -7,9 +7,8 @@ from . import aeat
|
|||
__all__ = ['Party']
|
||||
|
||||
|
||||
class Party:
|
||||
class Party(metaclass=PoolMeta):
|
||||
__name__ = 'party.party'
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
sii_identifier_type = fields.Selection(aeat.PARTY_IDENTIFIER_TYPE,
|
||||
'SII Identifier Type')
|
||||
|
|
3
setup.py
3
setup.py
|
@ -5,10 +5,7 @@ from setuptools import setup
|
|||
import re
|
||||
import os
|
||||
import io
|
||||
try:
|
||||
from configparser import ConfigParser
|
||||
except ImportError:
|
||||
from ConfigParser import ConfigParser
|
||||
|
||||
MODULE = 'aeat_sii'
|
||||
PREFIX = 'trytonspain'
|
||||
|
|
|
@ -70,6 +70,16 @@ Create party::
|
|||
>>> party = Party(name='Party')
|
||||
>>> party.save()
|
||||
|
||||
Create account category::
|
||||
|
||||
>>> ProductCategory = Model.get('product.category')
|
||||
>>> account_category = ProductCategory(name="Account Category")
|
||||
>>> account_category.accounting = True
|
||||
>>> account_category.account_expense = expense
|
||||
>>> account_category.account_revenue = revenue
|
||||
>>> account_category.customer_taxes.append(tax)
|
||||
>>> account_category.save()
|
||||
|
||||
Create product::
|
||||
|
||||
>>> ProductUom = Model.get('product.uom')
|
||||
|
@ -83,11 +93,9 @@ Create product::
|
|||
>>> template.type = 'service'
|
||||
>>> template.list_price = Decimal('40')
|
||||
>>> template.cost_price = Decimal('25')
|
||||
>>> template.account_expense = expense
|
||||
>>> template.account_revenue = revenue
|
||||
>>> template.customer_taxes.append(tax)
|
||||
>>> template.account_category = account_category
|
||||
>>> template.save()
|
||||
>>> product.template = template
|
||||
>>> product, = template.products
|
||||
>>> product.save()
|
||||
|
||||
Create payment term::
|
||||
|
@ -120,11 +128,11 @@ Create invoice::
|
|||
>>> line.unit_price = Decimal(20)
|
||||
>>> invoice.save()
|
||||
>>> invoice.sii_book_key
|
||||
u'E'
|
||||
'E'
|
||||
>>> invoice.sii_operation_key
|
||||
u'F1'
|
||||
'F1'
|
||||
>>> invoice.sii_issued_key
|
||||
u'01'
|
||||
'01'
|
||||
|
||||
>>> invoice.sii_book_key = 'I'
|
||||
>>> invoice.sii_operation_key = 'F2'
|
||||
|
@ -143,7 +151,7 @@ Create invoice::
|
|||
True
|
||||
>>> invoice.click('post')
|
||||
>>> invoice.state
|
||||
u'posted'
|
||||
'posted'
|
||||
|
||||
Create Credit invoice::
|
||||
|
||||
|
@ -164,11 +172,11 @@ Create Credit invoice::
|
|||
>>> invoice.sii_operation_key = 'R1'
|
||||
>>> invoice.save()
|
||||
>>> invoice.sii_book_key
|
||||
u'E'
|
||||
'E'
|
||||
>>> invoice.sii_operation_key
|
||||
u'R1'
|
||||
'R1'
|
||||
>>> invoice.sii_issued_key
|
||||
u'01'
|
||||
'01'
|
||||
|
||||
>>> invoice.sii_book_key = 'I'
|
||||
>>> invoice.sii_operation_key = 'F2'
|
||||
|
@ -184,7 +192,7 @@ Create Credit invoice::
|
|||
True
|
||||
>>> invoice.click('post')
|
||||
>>> invoice.state
|
||||
u'posted'
|
||||
'posted'
|
||||
|
||||
Create AEAT Report::
|
||||
|
||||
|
@ -196,7 +204,7 @@ Create AEAT Report::
|
|||
>>> report.book = 'E'
|
||||
>>> report.save()
|
||||
>>> report.state
|
||||
u'draft'
|
||||
'draft'
|
||||
>>> report.click('load_invoices')
|
||||
>>> len(report.lines)
|
||||
2
|
||||
|
@ -208,7 +216,7 @@ Credit invoice with refund::
|
|||
>>> credit.execute('credit')
|
||||
>>> invoice.reload()
|
||||
>>> invoice.state
|
||||
u'paid'
|
||||
'paid'
|
||||
>>> credit, = Invoice.find([('total_amount', '<', 0)])
|
||||
>>> credit.sii_operation_key
|
||||
u'R1'
|
||||
'R1'
|
||||
|
|
10
tools.py
10
tools.py
|
@ -3,21 +3,21 @@
|
|||
# copyright notices and license terms.
|
||||
import unicodedata
|
||||
|
||||
src_chars = u"/*+?¿!$[]{}@#`^:;<>=~%\\"
|
||||
dst_chars = u"________________________"
|
||||
src_chars = "/*+?¿!$[]{}@#`^:;<>=~%\\"
|
||||
dst_chars = "________________________"
|
||||
|
||||
|
||||
def normalize(text):
|
||||
if isinstance(text, unicode):
|
||||
if isinstance(text, str):
|
||||
text = text.encode('utf-8')
|
||||
return text
|
||||
|
||||
|
||||
def unaccent(text):
|
||||
if isinstance(text, bytes):
|
||||
text = unicode(text, 'utf-8')
|
||||
text = str(text, 'utf-8')
|
||||
output = text
|
||||
for c in xrange(len(src_chars)):
|
||||
for c in range(len(src_chars)):
|
||||
if c >= len(dst_chars):
|
||||
break
|
||||
output = output.replace(src_chars[c], dst_chars[c])
|
||||
|
|
Loading…
Reference in New Issue