update 4.7

This commit is contained in:
Àngel Àlvarez 2018-05-09 11:07:24 +02:00
parent 159066bba9
commit adeca6ca65
11 changed files with 195 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

@ -2,12 +2,13 @@ from trytond.model import fields
from trytond.pool import PoolMeta
__all__ = ['Configuration']
__metaclass__ = PoolMeta
class Configuration:
'Sale Configuration'
__name__ = 'sale.configuration'
__metaclass__ = PoolMeta
sale_supply_production_default = fields.Boolean(
'Sale Line Supply Production',
help='Default Supply Production value for Sale Lines')

View File

@ -7,11 +7,11 @@ from trytond.transaction import Transaction
from trytond.wizard import Button, StateTransition, StateView, Wizard
__all__ = ['Production', 'ChangeQuantityStart', 'ChangeQuantity']
__metaclass__ = PoolMeta
class Production:
__name__ = 'production'
__metaclass__ = PoolMeta
@classmethod
def _get_origin(cls):

View File

@ -2,17 +2,17 @@
# copyright notices and license terms.
from trytond.model import fields
from trytond.pool import PoolMeta, Pool
from trytond.pyson import Eval
from trytond.transaction import Transaction
from .tools import prepare_vals
__all__ = ['Sale', 'SaleLine', 'ChangeLineQuantityStart', 'ChangeLineQuantity']
__metaclass__ = PoolMeta
class Sale:
__name__ = 'sale.sale'
__metaclass__ = PoolMeta
productions = fields.Function(fields.One2Many('production', None,
'Productions'), 'get_productions')
@ -64,6 +64,7 @@ class Sale:
class SaleLine:
__name__ = 'sale.line'
__metaclass__ = PoolMeta
supply_production = fields.Boolean('Supply Production')
productions = fields.One2Many('production', 'origin', 'Productions')
@ -95,7 +96,7 @@ class SaleLine:
'quantity': self.quantity,
}
if hasattr(self.product, 'bom') and self.product.bom:
producction_values.update({'bom': self.product.bom})
production_values.update({'bom': self.product.bom})
productions_values = [production_values]
productions = []
@ -163,6 +164,7 @@ class SaleLine:
class ChangeLineQuantityStart:
__name__ = 'sale.change_line_quantity.start'
__metaclass__ = PoolMeta
def on_change_with_minimal_quantity(self):
pool = Pool()
@ -183,6 +185,7 @@ class ChangeLineQuantityStart:
class ChangeLineQuantity:
__name__ = 'sale.change_line_quantity'
__metaclass__ = PoolMeta
@classmethod
def __setup__(cls):

View File

@ -4,44 +4,97 @@
from setuptools import setup
import re
import os
import ConfigParser
import io
try:
from configparser import ConfigParser
except ImportError:
from ConfigParser import ConfigParser
MODULE = 'sale_supply_production'
PREFIX = 'nantic'
MODULE2PREFIX = {}
MODULE2PREFIX = {
'production_origin': 'nantic',
'sale_change_quantity': 'nantic',
'sale_cost_plan': 'nantic',
'sale_discount': 'trytonspain',
'product_cost_plan_margin': 'nantic',
'product_cost_plan_operation': 'nantic',
'product_cost_plan_process': 'nantic',
'production_external_party': 'nantic',
'production_quality_control': 'nantic',
}
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()
config = ConfigParser.ConfigParser()
def get_require_version(name):
if minor_version % 2:
require = '%s >= %s.%s.dev0, < %s.%s'
else:
require = '%s >= %s.%s, < %s.%s'
require %= (name, major_version, minor_version,
major_version, minor_version + 1)
return require
config = ConfigParser()
config.readfp(open('tryton.cfg'))
info = dict(config.items('tryton'))
for key in ('depends', 'extras_depend', 'xml'):
if key in info:
info[key] = info[key].strip().splitlines()
major_version, minor_version, _ = info.get('version', '0.0.1').split('.', 2)
version = info.get('version', '0.0.1')
major_version, minor_version, _ = version.split('.', 2)
major_version = int(major_version)
minor_version = int(minor_version)
requires = []
for dep in info.get('depends', []):
if not re.match(r'(ir|res|webdav)(\W|$)', dep):
for dep in info.get('depends', []) + ['sale_change_quantity']:
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('trytond >= %s.%s, < %s.%s' %
(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 = ['proteus >= %s.%s, < %s.%s' %
(major_version, minor_version, major_version, minor_version + 1)]
tests_require = [
get_require_version('proteus'),
get_require_version('nantic-sale_change_quantity')
]
series = '%s.%s' % (major_version, minor_version)
if minor_version % 2:
branch = 'default'
else:
branch = series
dependency_links = [
('hg+https://bitbucket.org/nantic/'
'trytond-production_origin@%(branch)s'
'#egg=nantic-production_origin-%(series)s' % {
'branch': branch,
'series': series,
}),
('hg+https://bitbucket.org/nantic/'
'trytond-sale_change_quantity@%(branch)s'
'#egg=nantic-sale_change_quantity-%(series)s' % {
'branch': branch,
'series': series,
}),
]
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=info.get('version', '0.0.1'),
version=version,
description='',
long_description=read('README'),
author='NaN·tic',
author_email='info@nan-tic.com',
url='http://www.nan-tic.com/',
download_url="https://bitbucket.org/nantic/trytond-%s" % MODULE,
package_dir={'trytond.modules.%s' % MODULE: '.'},
@ -71,12 +124,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]
@ -85,4 +143,9 @@ 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_sale_supply_production.rst',
'tests/scenario_sale_supply_production_change_quantity.rst',
],
)

View File

@ -15,22 +15,16 @@ 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
>>> from trytond.modules.account_invoice.tests.tools import \
... set_fiscalyear_invoice_sequences, create_payment_term
>>> from trytond.tests.tools import activate_modules
>>> today = datetime.date.today()
Create database::
Install product_cost_plan Module::
>>> config = config.set_trytond()
>>> config.pool.test = True
>>> config = activate_modules('sale_supply_production')
Install production Module::
>>> Module = Model.get('ir.module')
>>> modules = Module.find([('name', '=', 'sale_supply_production')])
>>> Module.install([x.id for x in modules], config.context)
>>> Wizard('ir.module.install_upgrade').execute('upgrade')
Create company::
@ -100,15 +94,15 @@ Create product::
>>> template.name = 'product'
>>> template.default_uom = unit
>>> template.type = 'goods'
>>> template.purchasable = True
>>> template.producible = True
>>> template.salable = True
>>> template.list_price = Decimal(30)
>>> template.cost_price = Decimal(20)
>>> template.cost_price_method = 'fixed'
>>> template.account_expense = expense
>>> template.account_revenue = revenue
>>> template.save()
>>> product.template = template
>>> product.cost_price = Decimal(20)
>>> product.save()
Create Components::
@ -121,9 +115,9 @@ Create Components::
>>> templateA.default_uom = meter
>>> templateA.type = 'goods'
>>> templateA.list_price = Decimal(2)
>>> templateA.cost_price = Decimal(1)
>>> templateA.save()
>>> componentA.template = templateA
>>> componentA.cost_price = Decimal(1)
>>> componentA.save()
>>> componentB = Product()
@ -132,9 +126,9 @@ Create Components::
>>> templateB.default_uom = meter
>>> templateB.type = 'goods'
>>> templateB.list_price = Decimal(2)
>>> templateB.cost_price = Decimal(1)
>>> templateB.save()
>>> componentB.template = templateB
>>> componentB.cost_price = Decimal(1)
>>> componentB.save()
>>> component1 = Product()
@ -143,9 +137,9 @@ Create Components::
>>> template1.default_uom = unit
>>> template1.type = 'goods'
>>> template1.list_price = Decimal(5)
>>> template1.cost_price = Decimal(2)
>>> template1.save()
>>> component1.template = template1
>>> component1.cost_price = Decimal(2)
>>> component1.save()
>>> component2 = Product()
@ -154,9 +148,9 @@ Create Components::
>>> template2.default_uom = meter
>>> template2.type = 'goods'
>>> template2.list_price = Decimal(7)
>>> template2.cost_price = Decimal(5)
>>> template2.save()
>>> component2.template = template2
>>> component2.cost_price = Decimal(5)
>>> component2.save()
Create Bill of Material::
@ -235,4 +229,3 @@ Sale product::
True
>>> production.quantity == 2.0
True

View File

@ -15,23 +15,16 @@ 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
>>> from trytond.modules.account_invoice.tests.tools import \
... set_fiscalyear_invoice_sequences, create_payment_term
>>> from trytond.tests.tools import activate_modules
>>> today = datetime.date.today()
Create database::
Install product_cost_plan Module::
>>> config = config.set_trytond()
>>> config.pool.test = True
Install production Module::
>>> Module = Model.get('ir.module')
>>> modules = Module.find([
... ('name', 'in', ['sale_supply_production', 'sale_change_quantity'])])
>>> Module.install([x.id for x in modules], config.context)
>>> Wizard('ir.module.install_upgrade').execute('upgrade')
>>> config = activate_modules(['sale_supply_production',
... 'sale_change_quantity'])
Create company::
@ -88,15 +81,15 @@ Create product::
>>> template.name = 'product'
>>> template.default_uom = unit
>>> template.type = 'goods'
>>> template.purchasable = True
>>> template.producible = True
>>> template.salable = True
>>> template.list_price = Decimal(30)
>>> template.cost_price = Decimal(20)
>>> template.cost_price_method = 'fixed'
>>> template.account_expense = expense
>>> template.account_revenue = revenue
>>> template.save()
>>> product.template = template
>>> product.cost_price = Decimal(20)
>>> product.cost_price_method = 'fixed'
>>> product.save()
Create Components::
@ -109,9 +102,9 @@ Create Components::
>>> templateA.default_uom = meter
>>> templateA.type = 'goods'
>>> templateA.list_price = Decimal(2)
>>> templateA.cost_price = Decimal(1)
>>> templateA.save()
>>> componentA.template = templateA
>>> componentA.cost_price = Decimal(1)
>>> componentA.save()
>>> componentB = Product()
@ -120,9 +113,9 @@ Create Components::
>>> templateB.default_uom = meter
>>> templateB.type = 'goods'
>>> templateB.list_price = Decimal(2)
>>> templateB.cost_price = Decimal(1)
>>> templateB.save()
>>> componentB.template = templateB
>>> componentB.cost_price = Decimal(1)
>>> componentB.save()
>>> component1 = Product()
@ -131,9 +124,10 @@ Create Components::
>>> template1.default_uom = unit
>>> template1.type = 'goods'
>>> template1.list_price = Decimal(5)
>>> template1.cost_price = Decimal(2)
>>> template1.producible = True
>>> template1.save()
>>> component1.template = template1
>>> component1.cost_price = Decimal(2)
>>> component1.save()
>>> component2 = Product()
@ -142,9 +136,10 @@ Create Components::
>>> template2.default_uom = meter
>>> template2.type = 'goods'
>>> template2.list_price = Decimal(7)
>>> template2.cost_price = Decimal(5)
>>> template2.save()
>>> component2.template = template2
>>> component2.cost_price = Decimal(5)
>>> component2.save()
Create Bill of Material::

View File

@ -5,26 +5,27 @@ import unittest
import doctest
import trytond.tests.test_tryton
from trytond.tests.test_tryton import ModuleTestCase
from trytond.tests.test_tryton import doctest_setup, doctest_teardown
from trytond.tests.test_tryton import doctest_teardown
from trytond.tests.test_tryton import doctest_checker
class TestCase(ModuleTestCase):
class SaleSupplyProductionTestCase(ModuleTestCase):
'Test module'
module = 'sale_supply_production'
def suite():
suite = trytond.tests.test_tryton.suite()
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(TestCase))
suite.addTests(doctest.DocFileSuite(
'scenario_sale_supply_production.rst',
setUp=doctest_setup, tearDown=doctest_teardown, encoding='utf-8',
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(
SaleSupplyProductionTestCase))
suite.addTests(doctest.DocFileSuite('scenario_sale_supply_production.rst',
tearDown=doctest_teardown, encoding='utf-8',
checker=doctest_checker,
optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
suite.addTests(doctest.DocFileSuite(
suite.addTests(
doctest.DocFileSuite(
'scenario_sale_supply_production_change_quantity.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

@ -1,5 +1,5 @@
[tryton]
version=4.0.0
version=4.8.0
depends:
production_origin
sale

View File

@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!-- The COPYRIGHT file at the top level of this repository contains the full
copyright notices and license terms. -->
<form string="Change Sale Quantity" col="6">
<form col="6">
<image name="tryton-dialog-warning" xexpand="0" xfill="0"/>
<label string="It will change the quantity of the origin sale line which has been confirmed by the customer. The orinal one will be mantained in the Confirmed Quantity field."
id="advice" yalign="0.0" xalign="0.0" xexpand="1" colspan="5"/>