update to 4.7

This commit is contained in:
?ngel ?lvarez 2018-05-03 16:45:55 +02:00
parent 79974ce3e7
commit 30c47486c7
10 changed files with 164 additions and 67 deletions

57
.drone.yml Normal file
View File

@ -0,0 +1,57 @@
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}"
notify:
image: drillster/drone-email
from: drone@localhost
host: smtp
port: 25
skip_verify: true
when:
status: [ changed, failure ]
services:
postgresql:
image: postgres
when:
matrix:
DATABASE: postgresql
matrix:
include:
- IMAGE: python:2.7
TOXENV: py27
DATABASE: sqlite
- IMAGE: python:2.7
TOXENV: py27
DATABASE: postgresql
- IMAGE: python:3.4
TOXENV: py34
DATABASE: sqlite
- IMAGE: python:3.4
TOXENV: py34
DATABASE: postgresql
- IMAGE: python:3.5
TOXENV: py35
DATABASE: sqlite
- IMAGE: python:3.5
TOXENV: py35
DATABASE: postgresql
- IMAGE: python:3.6
TOXENV: py36
DATABASE: sqlite
- IMAGE: python:3.6
TOXENV: py36
DATABASE: postgresql

View File

@ -27,6 +27,13 @@
<field name="view" ref="bom_drawing_line_view_form"/>
<field name="act_window" ref="act_production_bom_drawing_line"/>
</record>
<record model="ir.model.access" id="access_production_bom_drawing_line_base">
<field name="model" search="[('model', '=', 'production.bom.drawing.line')]"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="False"/>
<field name="perm_create" eval="False"/>
<field name="perm_delete" eval="False"/>
</record>
<record model="ir.model.access" id="access_production_bom_drawing_line">
<field name="model" search="[('model', '=', 'production.bom.drawing.line')]"/>
<field name="group" ref="production.group_production"/>

View File

@ -35,6 +35,14 @@
<field name="perm_create" eval="False"/>
<field name="perm_delete" eval="False"/>
</record>
<record model="ir.model.access" id="access_production_drawing_base">
<field name="model" search="[('model', '=', 'production.drawing')]"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="True"/>
<field name="perm_delete" eval="True"/>
</record>
<record model="ir.model.access" id="access_production_drawing_admin">
<field name="model" search="[('model', '=', 'production.drawing')]"/>
<field name="group" ref="production.group_production_admin"/>
@ -67,6 +75,13 @@
<field name="view" ref="drawing_position_view_form"/>
<field name="act_window" ref="act_production_drawing_position"/>
</record>
<record model="ir.model.access" id="access_production_drawing_position_base">
<field name="model" search="[('model', '=', 'production.drawing.position')]"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="False"/>
<field name="perm_create" eval="False"/>
<field name="perm_delete" eval="False"/>
</record>
<record model="ir.model.access" id="access_production_drawing_position">
<field name="model" search="[('model', '=', 'production.drawing.position')]"/>
<field name="group" ref="production.group_production"/>
@ -83,6 +98,8 @@
<field name="perm_create" eval="True"/>
<field name="perm_delete" eval="True"/>
</record>
<!-- Menus -->
<menuitem action="act_production_drawing" id="menu_production_drawing"
parent="production.menu_configuration" sequence="1"

View File

@ -34,7 +34,7 @@ class Production:
@fields.depends('drawing')
def on_change_with_drawing_lines(self):
if not self.bom or not self.bom.drawing:
to_remove = [x.id for x in self.drawing_lines]
to_remove = [x.id for x in getattr(self, 'drawing_lines')]
return {
'remove': to_remove,
}

View File

@ -24,6 +24,13 @@
<field name="view" ref="production_drawing_line_view_form"/>
<field name="act_window" ref="act_production_drawing_line"/>
</record>
<record model="ir.model.access" id="access_production_drawing_line_base">
<field name="model" search="[('model', '=', 'production.drawing.line')]"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="False"/>
<field name="perm_create" eval="False"/>
<field name="perm_delete" eval="False"/>
</record>
<record model="ir.model.access" id="access_production_drawing_line">
<field name="model" search="[('model', '=', 'production.drawing.line')]"/>
<field name="group" ref="production.group_production"/>

View File

@ -4,7 +4,11 @@
from setuptools import setup
import re
import os
import ConfigParser
import io
try:
from configparser import ConfigParser
except ImportError:
from ConfigParser import ConfigParser
MODULE = 'production_drawing'
PREFIX = 'nantic'
@ -12,7 +16,9 @@ MODULE2PREFIX = {}
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
return io.open(
os.path.join(os.path.dirname(__file__), fname),
'r', encoding='utf-8').read()
def get_require_version(name):
@ -24,7 +30,7 @@ def get_require_version(name):
major_version, minor_version + 1)
return require
config = ConfigParser.ConfigParser()
config = ConfigParser()
config.readfp(open('tryton.cfg'))
info = dict(config.items('tryton'))
for key in ('depends', 'extras_depend', 'xml'):
@ -38,14 +44,26 @@ minor_version = int(minor_version)
requires = []
for dep in info.get('depends', []):
if not re.match(r'(ir|res|webdav)(\W|$)', dep):
if not re.match(r'(ir|res)(\W|$)', dep):
prefix = MODULE2PREFIX.get(dep, 'trytond')
requires.append('%s_%s >= %s.%s, < %s.%s' %
(prefix, dep, major_version, minor_version,
major_version, minor_version + 1))
requires.append(get_require_version('%s_%s' % (prefix, dep)))
requires.append(get_require_version('trytond'))
tests_require = [get_require_version('proteus')]
tests_require = [
get_require_version('proteus'),
]
series = '%s.%s' % (major_version, minor_version)
if minor_version % 2:
branch = 'default'
else:
branch = series
dependency_links = []
if minor_version % 2:
# Add development index for testing with proteus
dependency_links.append('https://trydevpi.tryton.org/')
setup(name='%s_%s' % (PREFIX, MODULE),
version=version,
@ -82,12 +100,17 @@ setup(name='%s_%s' % (PREFIX, MODULE),
'Natural Language :: Russian',
'Natural Language :: Spanish',
'Operating System :: OS Independent',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Topic :: Office/Business',
],
license='GPL-3',
install_requires=requires,
dependency_links=dependency_links,
zip_safe=False,
entry_points="""
[trytond.modules]
@ -96,4 +119,8 @@ 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_production.rst',
],
)

View File

@ -12,46 +12,25 @@ Imports::
>>> from dateutil.relativedelta import relativedelta
>>> from decimal import Decimal
>>> from proteus import config, Model, Wizard
>>> from trytond.tests.tools import activate_modules
>>> today = datetime.date.today()
>>> yesterday = today - relativedelta(days=1)
>>> from trytond.modules.company.tests.tools import create_company, \
... get_company
Create database::
Install product_cost_plan Module::
>>> config = config.set_trytond()
>>> config.pool.test = True
>>> config = activate_modules('production_drawing')
Install production Module::
>>> Module = Model.get('ir.module.module')
>>> modules = Module.find([('name', '=', 'production_drawing')])
>>> Module.install([x.id for x in modules], config.context)
>>> Wizard('ir.module.module.install_upgrade').execute('upgrade')
Create company::
>>> Currency = Model.get('currency.currency')
>>> CurrencyRate = Model.get('currency.currency.rate')
>>> Company = Model.get('company.company')
>>> Party = Model.get('party.party')
>>> company_config = Wizard('company.company.config')
>>> company_config.execute('company')
>>> company = company_config.form
>>> party = Party(name='Dunder Mifflin')
>>> party.save()
>>> company.party = party
>>> currencies = Currency.find([('code', '=', 'USD')])
>>> if not currencies:
... currency = Currency(name='Euro', symbol=u'$', code='USD',
... rounding=Decimal('0.01'), mon_grouping='[3, 3, 0]',
... mon_decimal_point=',')
... currency.save()
... CurrencyRate(date=today + relativedelta(month=1, day=1),
... rate=Decimal('1.0'), currency=currency).save()
... else:
... currency, = currencies
>>> company.currency = currency
>>> company_config.execute('add')
>>> company, = Company.find()
>>> _ = create_company()
>>> company = get_company()
>>> tax_identifier = company.party.identifiers.new()
>>> tax_identifier.type = 'eu_vat'
>>> tax_identifier.code = 'BE0897290877'
>>> company.party.save()
Reload the context::
@ -67,12 +46,13 @@ Create product::
>>> product = Product()
>>> template = ProductTemplate()
>>> template.name = 'product'
>>> template.producible = True
>>> template.default_uom = unit
>>> template.type = 'goods'
>>> template.list_price = Decimal(30)
>>> template.cost_price = Decimal(20)
>>> template.save()
>>> product.template = template
>>> product.cost_price = Decimal(20)
>>> product.save()
Create Components::
@ -132,10 +112,7 @@ Create Bill of Material::
>>> output.product = product
>>> output.quantity = 1
>>> bom.drawing = drawing
>>> names = [str(x.position.name) for x in bom.drawing_positions]
>>> names = [str(x.position.name) for x in bom.drawing_lines]
>>> sorted(names)
['R1', 'R2']
>>> bom.drawing_positions[0].product = component1
>>> bom.drawing_positions[1].product = component2
>>> bom.save()
>>> bom.reload()

View File

@ -3,29 +3,22 @@
import unittest
import doctest
import trytond.tests.test_tryton
from trytond.tests.test_tryton import test_view, test_depends
from trytond.tests.test_tryton import doctest_setup, doctest_teardown
from trytond.tests.test_tryton import ModuleTestCase
from trytond.tests.test_tryton import doctest_teardown
from trytond.tests.test_tryton import doctest_checker
class TestCase(unittest.TestCase):
class ProductionDrawingTestCase(ModuleTestCase):
'Test module'
def setUp(self):
trytond.tests.test_tryton.install_module('production_drawing')
def test0005views(self):
'Test views'
test_view('production_drawing')
def test0006depends(self):
'Test depends'
test_depends()
module = 'production_drawing'
def suite():
suite = trytond.tests.test_tryton.suite()
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(TestCase))
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(
ProductionDrawingTestCase))
suite.addTests(doctest.DocFileSuite('scenario_production.rst',
setUp=doctest_setup, tearDown=doctest_teardown, encoding='utf-8',
tearDown=doctest_teardown, encoding='utf-8',
checker=doctest_checker,
optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
return suite

15
tox.ini Normal file
View File

@ -0,0 +1,15 @@
[tox]
envlist = {py27,py34,py35,py36}-{sqlite,postgresql},pypy-{sqlite,postgresql}
[testenv]
commands = {envpython} setup.py test
deps =
{py27,py34,py35,py36}-postgresql: psycopg2 >= 2.5
pypy-postgresql: psycopg2cffi >= 2.5
sqlite: sqlitebck
setenv =
sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://}
postgresql: TRYTOND_DATABASE_URI={env:POSTGRESQL_URI:postgresql://}
sqlite: DB_NAME={env:SQLITE_NAME::memory:}
postgresql: DB_NAME={env:POSTGRESQL_NAME:test}
install_command = pip install --pre --process-dependency-links {opts} {packages}

View File

@ -2,9 +2,6 @@
<!-- The COPYRIGHT file at the top level of this repository contains the full
copyright notices and license terms. -->
<form>
<label name="bom"/>
<field name="bom"/>
<newline/>
<label name="position"/>
<field name="position"/>
<label name="product"/>