Migrate to 5.0
This commit is contained in:
parent
4ba27b7971
commit
9532b938f9
|
@ -0,0 +1,46 @@
|
|||
clone:
|
||||
hg:
|
||||
image: plugins/hg
|
||||
|
||||
pipeline:
|
||||
tox:
|
||||
image: ${IMAGE}
|
||||
environment:
|
||||
- CFLAGS=-O0
|
||||
- DB_CACHE=/cache
|
||||
- TOX_TESTENV_PASSENV=CFLAGS DB_CACHE
|
||||
- POSTGRESQL_URI=postgresql://postgres@postgresql:5432/
|
||||
commands:
|
||||
- pip install tox
|
||||
- tox -e "${TOXENV}-${DATABASE}"
|
||||
volumes:
|
||||
- cache:/root/.cache
|
||||
notify:
|
||||
image: drillster/drone-email
|
||||
from: drone@datalife.com.es
|
||||
skip_verify: true
|
||||
secrets: [ email_host, email_port ]
|
||||
when:
|
||||
status: [ changed, failure ]
|
||||
|
||||
services:
|
||||
postgresql:
|
||||
image: postgres
|
||||
when:
|
||||
matrix:
|
||||
DATABASE: postgresql
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- IMAGE: python:3.6
|
||||
TOXENV: py36
|
||||
DATABASE: sqlite
|
||||
- IMAGE: python:3.6
|
||||
TOXENV: py36
|
||||
DATABASE: postgresql
|
||||
- IMAGE: python:3.7
|
||||
TOXENV: py37
|
||||
DATABASE: sqlite
|
||||
- IMAGE: python:3.7
|
||||
TOXENV: py37
|
||||
DATABASE: postgresql
|
|
@ -6,7 +6,7 @@ include LICENSE
|
|||
include tryton.cfg
|
||||
include *.xml
|
||||
include view/*.xml
|
||||
include *.odt
|
||||
include *.fodt
|
||||
include locale/*.po
|
||||
include doc/*
|
||||
include icons/*
|
||||
|
|
10
__init__.py
10
__init__.py
|
@ -12,6 +12,12 @@ def register():
|
|||
invoice.Configuration,
|
||||
invoice.Invoice,
|
||||
invoice.InvoiceLine,
|
||||
invoice.Purchase,
|
||||
invoice.Sale,
|
||||
module='account_invoice_discount_global', type_='model')
|
||||
Pool.register(
|
||||
invoice.Purchase,
|
||||
module='account_invoice_discount_global', type_='model',
|
||||
depends=['purchase'])
|
||||
Pool.register(
|
||||
invoice.Sale,
|
||||
module='account_invoice_discount_global', type_='model',
|
||||
depends=['sale'])
|
||||
|
|
15
invoice.py
15
invoice.py
|
@ -12,15 +12,13 @@ __all__ = ['Configuration', 'Invoice', 'InvoiceLine', 'Sale', 'Purchase']
|
|||
DISCOUNT_DIGITS = (16, config.getint('product', 'price_decimal', default=4))
|
||||
|
||||
|
||||
class Configuration:
|
||||
class Configuration(metaclass=PoolMeta):
|
||||
__name__ = 'account.configuration'
|
||||
__metaclass__ = PoolMeta
|
||||
discount_product = fields.Many2One('product.product', 'Discount Product')
|
||||
|
||||
|
||||
class Invoice:
|
||||
class Invoice(metaclass=PoolMeta):
|
||||
__name__ = 'account.invoice'
|
||||
__metaclass__ = PoolMeta
|
||||
invoice_discount = fields.Numeric('Invoice Discount',
|
||||
digits=DISCOUNT_DIGITS, states={
|
||||
'readonly': Eval('state') != 'draft',
|
||||
|
@ -158,9 +156,8 @@ class Invoice:
|
|||
cls.remove_discount_global(invoices)
|
||||
|
||||
|
||||
class InvoiceLine:
|
||||
class InvoiceLine(metaclass=PoolMeta):
|
||||
__name__ = 'account.invoice.line'
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
def _update_taxes(self, invoice_type, party):
|
||||
Tax = Pool().get('account.tax')
|
||||
|
@ -194,9 +191,8 @@ class InvoiceLine:
|
|||
self.taxes = Tax.browse(taxes)
|
||||
|
||||
|
||||
class Sale:
|
||||
class Sale(metaclass=PoolMeta):
|
||||
__name__ = 'sale.sale'
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
def _get_invoice_sale(self):
|
||||
invoice = super(Sale, self)._get_invoice_sale()
|
||||
|
@ -206,9 +202,8 @@ class Sale:
|
|||
return invoice
|
||||
|
||||
|
||||
class Purchase:
|
||||
class Purchase(metaclass=PoolMeta):
|
||||
__name__ = 'purchase.purchase'
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
def _get_invoice_purchase(self):
|
||||
invoice = super(Purchase, self)._get_invoice_purchase()
|
||||
|
|
6
party.py
6
party.py
|
@ -10,9 +10,8 @@ __all__ = ['Party', 'PartyAccount']
|
|||
DISCOUNT_DIGITS = (16, config.getint('product', 'price_decimal', default=4))
|
||||
|
||||
|
||||
class Party:
|
||||
class Party(metaclass=PoolMeta):
|
||||
__name__ = 'party.party'
|
||||
__metaclass__ = PoolMeta
|
||||
customer_invoice_discount = fields.MultiValue(fields.Numeric(
|
||||
'Customer Invoice Discount', digits=DISCOUNT_DIGITS,
|
||||
states={
|
||||
|
@ -32,9 +31,8 @@ class Party:
|
|||
return super(Party, cls).multivalue_model(field)
|
||||
|
||||
|
||||
class PartyAccount:
|
||||
class PartyAccount(metaclass=PoolMeta):
|
||||
__name__ = 'party.party.account'
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
customer_invoice_discount = fields.Numeric(
|
||||
"Customer Invoice Discount", digits=DISCOUNT_DIGITS)
|
||||
|
|
25
setup.py
25
setup.py
|
@ -1,14 +1,11 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# encoding: utf-8
|
||||
|
||||
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_invoice_discount_global'
|
||||
PREFIX = 'nantic'
|
||||
|
@ -21,6 +18,7 @@ def read(fname):
|
|||
'r', encoding='utf-8').read()
|
||||
|
||||
|
||||
|
||||
def get_require_version(name):
|
||||
if minor_version % 2:
|
||||
require = '%s >= %s.%s.dev0, < %s.%s'
|
||||
|
@ -30,6 +28,7 @@ def get_require_version(name):
|
|||
major_version, minor_version + 1)
|
||||
return require
|
||||
|
||||
|
||||
config = ConfigParser()
|
||||
config.readfp(open('tryton.cfg'))
|
||||
info = dict(config.items('tryton'))
|
||||
|
@ -49,12 +48,16 @@ for dep in info.get('depends', []):
|
|||
requires.append('%s_%s >= %s.%s, < %s.%s' %
|
||||
(prefix, dep, major_version, minor_version,
|
||||
major_version, minor_version + 1))
|
||||
|
||||
requires.append(get_require_version('trytond'))
|
||||
|
||||
tests_require = [
|
||||
|
||||
get_require_version('proteus'),
|
||||
get_require_version('sale'),
|
||||
get_require_version('purchase'),
|
||||
|
||||
get_require_version('trytond_sale'),
|
||||
|
||||
get_require_version('trytond_purchase'),
|
||||
]
|
||||
dependency_links = []
|
||||
if minor_version % 2:
|
||||
|
@ -97,13 +100,14 @@ setup(name='%s_%s' % (PREFIX, MODULE),
|
|||
'Natural Language :: Russian',
|
||||
'Natural Language :: Spanish',
|
||||
'Operating System :: OS Independent',
|
||||
'Programming Language :: Python :: 2.7',
|
||||
'Programming Language :: Python :: 3.4',
|
||||
'Programming Language :: Python :: 3.5',
|
||||
'Programming Language :: Python :: 3.6',
|
||||
'Programming Language :: Python :: 3.7',
|
||||
'Topic :: Office/Business',
|
||||
],
|
||||
license='GPL-3',
|
||||
python_requires='>=3.4',
|
||||
install_requires=requires,
|
||||
zip_safe=False,
|
||||
entry_points="""
|
||||
|
@ -113,9 +117,4 @@ setup(name='%s_%s' % (PREFIX, MODULE),
|
|||
test_suite='tests',
|
||||
test_loader='trytond.test_loader:Loader',
|
||||
tests_require=tests_require,
|
||||
use_2to3=True,
|
||||
convert_2to3_doctests=[
|
||||
'tests/scenario_invoice.rst',
|
||||
'tests/scenario_invoice_sale_purchase.rst',
|
||||
],
|
||||
)
|
||||
|
|
|
@ -11,7 +11,7 @@ Imports::
|
|||
>>> from trytond.modules.company.tests.tools import create_company, \
|
||||
... get_company
|
||||
>>> from trytond.modules.account.tests.tools import create_fiscalyear, \
|
||||
... create_chart, get_accounts, create_tax, set_tax_code
|
||||
... create_chart, get_accounts, create_tax, create_tax_code
|
||||
>>> from trytond.modules.account_invoice.tests.tools import \
|
||||
... set_fiscalyear_invoice_sequences, create_payment_term
|
||||
>>> today = datetime.date.today()
|
||||
|
@ -45,13 +45,18 @@ Create chart of accounts::
|
|||
|
||||
Create tax::
|
||||
|
||||
>>> TaxCode = Model.get('account.tax.code')
|
||||
>>> Tax = Model.get('account.tax')
|
||||
>>> tax = set_tax_code(create_tax(Decimal('.10')))
|
||||
>>> tax = create_tax(Decimal('.10'))
|
||||
>>> tax.save()
|
||||
>>> invoice_base_code = tax.invoice_base_code
|
||||
>>> invoice_tax_code = tax.invoice_tax_code
|
||||
>>> credit_note_base_code = tax.credit_note_base_code
|
||||
>>> credit_note_tax_code = tax.credit_note_tax_code
|
||||
>>> invoice_base_code = create_tax_code(tax, 'base', 'invoice')
|
||||
>>> invoice_base_code.save()
|
||||
>>> invoice_tax_code = create_tax_code(tax, 'tax', 'invoice')
|
||||
>>> invoice_tax_code.save()
|
||||
>>> credit_note_base_code = create_tax_code(tax, 'base', 'credit')
|
||||
>>> credit_note_base_code.save()
|
||||
>>> credit_note_tax_code = create_tax_code(tax, 'tax', 'credit')
|
||||
>>> credit_note_tax_code.save()
|
||||
|
||||
Create party with customer invoice discount of 5% and supplier discount of 3%::
|
||||
|
||||
|
@ -61,6 +66,22 @@ Create party with customer invoice discount of 5% and supplier discount of 3%::
|
|||
>>> party.supplier_invoice_discount = Decimal('0.03')
|
||||
>>> 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.supplier_taxes.append(Tax(tax.id))
|
||||
>>> account_category.save()
|
||||
>>> account_category2 = ProductCategory(name="Account Category 2")
|
||||
>>> account_category2.accounting = True
|
||||
>>> account_category2.account_expense = expense
|
||||
>>> account_category2.account_revenue = revenue
|
||||
>>> account_category2.save()
|
||||
|
||||
Create product::
|
||||
|
||||
>>> ProductUom = Model.get('product.uom')
|
||||
|
@ -71,10 +92,7 @@ Create product::
|
|||
>>> template.default_uom = unit
|
||||
>>> template.type = 'service'
|
||||
>>> template.list_price = Decimal('40')
|
||||
>>> template.account_expense = expense
|
||||
>>> template.account_revenue = revenue
|
||||
>>> template.customer_taxes.append(tax)
|
||||
>>> template.supplier_taxes.append(Tax(tax.id))
|
||||
>>> template.account_category = account_category
|
||||
>>> template.save()
|
||||
>>> product, = template.products
|
||||
|
||||
|
@ -86,8 +104,7 @@ Create discount product::
|
|||
>>> template.type = 'service'
|
||||
>>> template.list_price = Decimal('0')
|
||||
>>> template.cost_price = Decimal('0')
|
||||
>>> template.account_expense = expense
|
||||
>>> template.account_revenue = revenue
|
||||
>>> template.account_category = account_category2
|
||||
>>> template.save()
|
||||
>>> discount_product, = template.products
|
||||
|
||||
|
@ -143,10 +160,10 @@ Post invoice and check discount is applied::
|
|||
|
||||
>>> invoice.click('validate_invoice')
|
||||
>>> invoice.state
|
||||
u'validated'
|
||||
'validated'
|
||||
>>> invoice.click('post')
|
||||
>>> invoice.state
|
||||
u'posted'
|
||||
'posted'
|
||||
>>> invoice.invoice_discount
|
||||
Decimal('0.1')
|
||||
>>> discount_line, = [l for l in invoice.lines
|
||||
|
@ -168,7 +185,7 @@ Credit invoice with refund::
|
|||
>>> credit.form.with_refund = True
|
||||
>>> credit.execute('credit')
|
||||
>>> invoice.state
|
||||
u'paid'
|
||||
'paid'
|
||||
>>> credit_note, = Invoice.find([('untaxed_amount', '<', Decimal(0))])
|
||||
>>> credit_note.untaxed_amount
|
||||
Decimal('-198.00')
|
||||
|
@ -208,10 +225,10 @@ Post invoice and check discount is applied::
|
|||
|
||||
>>> invoice.click('validate_invoice')
|
||||
>>> invoice.state
|
||||
u'validated'
|
||||
'validated'
|
||||
>>> invoice.click('post')
|
||||
>>> invoice.state
|
||||
u'posted'
|
||||
'posted'
|
||||
>>> invoice.invoice_discount
|
||||
Decimal('0.03')
|
||||
>>> discount_line, = [l for l in invoice.lines
|
||||
|
|
|
@ -13,7 +13,7 @@ Imports::
|
|||
>>> from trytond.modules.company.tests.tools import create_company, \
|
||||
... get_company
|
||||
>>> from trytond.modules.account.tests.tools import create_fiscalyear, \
|
||||
... create_chart, get_accounts, create_tax, set_tax_code
|
||||
... create_chart, get_accounts, create_tax, create_tax_code
|
||||
>>> from trytond.modules.account_invoice.tests.tools import \
|
||||
... set_fiscalyear_invoice_sequences, create_payment_term
|
||||
>>> today = datetime.date.today()
|
||||
|
@ -48,13 +48,18 @@ Create chart of accounts::
|
|||
|
||||
Create tax::
|
||||
|
||||
>>> TaxCode = Model.get('account.tax.code')
|
||||
>>> Tax = Model.get('account.tax')
|
||||
>>> tax = set_tax_code(create_tax(Decimal('.10')))
|
||||
>>> tax = create_tax(Decimal('.10'))
|
||||
>>> tax.save()
|
||||
>>> invoice_base_code = tax.invoice_base_code
|
||||
>>> invoice_tax_code = tax.invoice_tax_code
|
||||
>>> credit_note_base_code = tax.credit_note_base_code
|
||||
>>> credit_note_tax_code = tax.credit_note_tax_code
|
||||
>>> invoice_base_code = create_tax_code(tax, 'base', 'invoice')
|
||||
>>> invoice_base_code.save()
|
||||
>>> invoice_tax_code = create_tax_code(tax, 'tax', 'invoice')
|
||||
>>> invoice_tax_code.save()
|
||||
>>> credit_note_base_code = create_tax_code(tax, 'base', 'credit')
|
||||
>>> credit_note_base_code.save()
|
||||
>>> credit_note_tax_code = create_tax_code(tax, 'tax', 'credit')
|
||||
>>> credit_note_tax_code.save()
|
||||
|
||||
Create parties::
|
||||
|
||||
|
@ -66,6 +71,22 @@ Create parties::
|
|||
>>> customer.customer_invoice_discount = Decimal('0.05')
|
||||
>>> customer.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.supplier_taxes.append(Tax(tax.id))
|
||||
>>> account_category.save()
|
||||
>>> account_category2 = ProductCategory(name="Account Category 2")
|
||||
>>> account_category2.accounting = True
|
||||
>>> account_category2.account_expense = expense
|
||||
>>> account_category2.account_revenue = revenue
|
||||
>>> account_category2.save()
|
||||
|
||||
Create product::
|
||||
|
||||
>>> ProductUom = Model.get('product.uom')
|
||||
|
@ -78,10 +99,7 @@ Create product::
|
|||
>>> template.purchasable = True
|
||||
>>> template.salable = True
|
||||
>>> template.list_price = Decimal('40')
|
||||
>>> template.account_expense = expense
|
||||
>>> template.account_revenue = revenue
|
||||
>>> template.customer_taxes.append(tax)
|
||||
>>> template.supplier_taxes.append(Tax(tax.id))
|
||||
>>> template.account_category = account_category
|
||||
>>> template.save()
|
||||
>>> product, = template.products
|
||||
>>> product.cost_price = Decimal('25')
|
||||
|
@ -94,8 +112,7 @@ Create discount product::
|
|||
>>> template.default_uom = unit
|
||||
>>> template.type = 'service'
|
||||
>>> template.list_price = Decimal('0')
|
||||
>>> template.account_expense = expense
|
||||
>>> template.account_revenue = revenue
|
||||
>>> template.account_category = account_category2
|
||||
>>> template.save()
|
||||
>>> discount_product, = template.products
|
||||
|
||||
|
@ -128,7 +145,7 @@ Sale 5 services::
|
|||
>>> Sale.confirm([sale.id], config.context)
|
||||
>>> Sale.process([sale.id], config.context)
|
||||
>>> sale.state
|
||||
u'processing'
|
||||
'processing'
|
||||
>>> sale.reload()
|
||||
>>> sale.untaxed_amount
|
||||
Decimal('200.00')
|
||||
|
@ -180,7 +197,7 @@ Purchase 3 services::
|
|||
>>> purchase.click('confirm')
|
||||
>>> purchase.click('process')
|
||||
>>> purchase.state
|
||||
u'processing'
|
||||
'processing'
|
||||
>>> purchase.reload()
|
||||
>>> purchase.untaxed_amount
|
||||
Decimal('75.00')
|
||||
|
|
13
tox.ini
13
tox.ini
|
@ -1,18 +1,15 @@
|
|||
[tox]
|
||||
envlist = {py27,py34,py35,py36}-{sqlite,postgresql,mysql},pypy-{sqlite,postgresql}
|
||||
envlist = {py36,py37}-{sqlite,postgresql},pypy3-{sqlite,postgresql}
|
||||
|
||||
[testenv]
|
||||
commands = {envpython} setup.py test
|
||||
deps =
|
||||
{py27,py34,py35,py36}-postgresql: psycopg2 >= 2.5
|
||||
pypy-postgresql: psycopg2cffi >= 2.5
|
||||
mysql: MySQL-python
|
||||
sqlite: sqlitebck
|
||||
{py36,py37}-postgresql: psycopg2 >= 2.5
|
||||
pypy3-postgresql: psycopg2cffi >= 2.5
|
||||
{py36}-sqlite: sqlitebck
|
||||
setenv =
|
||||
sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://}
|
||||
postgresql: TRYTOND_DATABASE_URI={env:POSTGRESQL_URI:postgresql://}
|
||||
mysql: TRYTOND_DATABASE_URI={env:MYSQL_URI:mysql://}
|
||||
sqlite: DB_NAME={env:SQLITE_NAME::memory:}
|
||||
postgresql: DB_NAME={env:POSTGRESQL_NAME:test}
|
||||
mysql: DB_NAME={env:MYSQL_NAME:test}
|
||||
install_command = pip install --pre --find-links https://trydevpi.tryton.org/ {opts} {packages}
|
||||
install_command = pip install --pre {opts} {packages}
|
|
@ -1,5 +1,5 @@
|
|||
[tryton]
|
||||
version=4.7.0
|
||||
version=5.0.0
|
||||
depends:
|
||||
account_invoice
|
||||
company
|
||||
|
|
Loading…
Reference in New Issue