update to 4.7
This commit is contained in:
parent
57c873e71c
commit
5956314c88
14
__init__.py
14
__init__.py
|
@ -1,13 +1,15 @@
|
||||||
# The COPYRIGHT file at the top level of this repository contains the full
|
# The COPYRIGHT file at the top level of this repository contains the full
|
||||||
# copyright notices and license terms.
|
# copyright notices and license terms.
|
||||||
from trytond.pool import Pool
|
from trytond.pool import Pool
|
||||||
from .production import *
|
from . import production
|
||||||
|
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
Pool.register(
|
Pool.register(
|
||||||
Party,
|
production.Party,
|
||||||
PurchaseRequest,
|
production.PurchaseRequest,
|
||||||
BOM,
|
production.BOM,
|
||||||
Production,
|
production.Production,
|
||||||
Purchase,
|
production.Purchase,
|
||||||
|
production.PartyProductionWarehouse,
|
||||||
module='production_subcontract', type_='model')
|
module='production_subcontract', type_='model')
|
||||||
|
|
|
@ -1,22 +1,69 @@
|
||||||
# The COPYRIGHT file at the top level of this repository contains the full
|
# The COPYRIGHT file at the top level of this repository contains the full
|
||||||
# copyright notices and license terms.
|
# copyright notices and license terms.
|
||||||
from trytond.pool import Pool, PoolMeta
|
from trytond.pool import Pool, PoolMeta
|
||||||
from trytond.model import Workflow, ModelView, fields
|
from trytond.model import (Workflow, ModelView, fields, MultiValueMixin,
|
||||||
|
ValueMixin, ModelSQL)
|
||||||
from trytond.pyson import Eval, Bool
|
from trytond.pyson import Eval, Bool
|
||||||
|
from trytond.tools.multivalue import migrate_property
|
||||||
__all__ = ['Party', 'PurchaseRequest', 'BOM', 'Production', 'Purchase']
|
from trytond import backend
|
||||||
|
from trytond.transaction import Transaction
|
||||||
|
|
||||||
|
|
||||||
class Party:
|
__all__ = ['Party', 'PurchaseRequest', 'BOM', 'Production', 'Purchase',
|
||||||
|
'PartyProductionWarehouse']
|
||||||
|
|
||||||
|
|
||||||
|
class Party(MultiValueMixin):
|
||||||
__name__ = 'party.party'
|
__name__ = 'party.party'
|
||||||
__metaclass__ = PoolMeta
|
__metaclass__ = PoolMeta
|
||||||
# TODO: Should be a property
|
production_warehouse = fields.MultiValue(fields.Many2One('stock.location',
|
||||||
production_warehouse = fields.Property(fields.Many2One('stock.location',
|
|
||||||
'Production Warehouse', domain=[
|
'Production Warehouse', domain=[
|
||||||
('type', '=', 'warehouse'),
|
('type', '=', 'warehouse'),
|
||||||
]))
|
]))
|
||||||
|
|
||||||
|
|
||||||
|
class PartyProductionWarehouse(ModelSQL, ValueMixin):
|
||||||
|
"Party Lang"
|
||||||
|
__name__ = 'party.party.production_warehouse'
|
||||||
|
party = fields.Many2One(
|
||||||
|
'party.party', "Party", ondelete='CASCADE', select=True)
|
||||||
|
production_warehouse = fields.Many2One('stock.location',
|
||||||
|
'Production Warehouse', domain=[
|
||||||
|
('type', '=', 'warehouse'),
|
||||||
|
])
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def __register__(cls, module_name):
|
||||||
|
pool = Pool()
|
||||||
|
Party = pool.get('party.party')
|
||||||
|
TableHandler = backend.get('TableHandler')
|
||||||
|
cursor = Transaction().connection.cursor()
|
||||||
|
exist = TableHandler.table_exist(cls._table)
|
||||||
|
table = cls.__table__()
|
||||||
|
party = Party.__table__()
|
||||||
|
|
||||||
|
super(PartyProductionWarehouse, cls).__register__(module_name)
|
||||||
|
|
||||||
|
if not exist:
|
||||||
|
party_h = TableHandler(Party, module_name)
|
||||||
|
if party_h.column_exist('production_warehouse'):
|
||||||
|
query = table.insert(
|
||||||
|
[table.party, table.production_warehouse],
|
||||||
|
party.select(party.id, party.production_warehouse))
|
||||||
|
cursor.execute(*query)
|
||||||
|
party_h.drop_column('production_warehouse')
|
||||||
|
else:
|
||||||
|
cls._migrate_property([], [], [])
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _migrate_property(cls, field_names, value_names, fields):
|
||||||
|
field_names.append('production_warehouse')
|
||||||
|
value_names.append('production_warehouse')
|
||||||
|
migrate_property(
|
||||||
|
'party.party', field_names, cls, value_names,
|
||||||
|
parent='party', fields=fields)
|
||||||
|
|
||||||
|
|
||||||
class PurchaseRequest:
|
class PurchaseRequest:
|
||||||
__name__ = 'purchase.request'
|
__name__ = 'purchase.request'
|
||||||
__metaclass__ = PoolMeta
|
__metaclass__ = PoolMeta
|
||||||
|
|
|
@ -26,5 +26,11 @@
|
||||||
<field name="inherit" ref="production.bom_view_list"/>
|
<field name="inherit" ref="production.bom_view_list"/>
|
||||||
<field name="name">bom_list</field>
|
<field name="name">bom_list</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.model.button" id="create_purchase_request_button">
|
||||||
|
<field name="name">create_purchase_request</field>
|
||||||
|
<field name="model"
|
||||||
|
search="[('model', '=', 'production')]"/>
|
||||||
|
</record>
|
||||||
</data>
|
</data>
|
||||||
</tryton>
|
</tryton>
|
||||||
|
|
69
setup.py
69
setup.py
|
@ -4,44 +4,74 @@
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
import ConfigParser
|
import io
|
||||||
|
try:
|
||||||
|
from configparser import ConfigParser
|
||||||
|
except ImportError:
|
||||||
|
from ConfigParser import ConfigParser
|
||||||
|
|
||||||
MODULE = 'production_subcontract'
|
MODULE = 'production_subcontract'
|
||||||
PREFIX = 'nantic'
|
PREFIX = 'nantic'
|
||||||
MODULE2PREFIX = {}
|
MODULE2PREFIX = {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def read(fname):
|
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'))
|
config.readfp(open('tryton.cfg'))
|
||||||
info = dict(config.items('tryton'))
|
info = dict(config.items('tryton'))
|
||||||
for key in ('depends', 'extras_depend', 'xml'):
|
for key in ('depends', 'extras_depend', 'xml'):
|
||||||
if key in info:
|
if key in info:
|
||||||
info[key] = info[key].strip().splitlines()
|
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)
|
major_version = int(major_version)
|
||||||
minor_version = int(minor_version)
|
minor_version = int(minor_version)
|
||||||
|
|
||||||
requires = []
|
requires = []
|
||||||
for dep in info.get('depends', []):
|
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')
|
prefix = MODULE2PREFIX.get(dep, 'trytond')
|
||||||
requires.append('%s_%s >= %s.%s, < %s.%s' %
|
requires.append(get_require_version('%s_%s' % (prefix, dep)))
|
||||||
(prefix, dep, major_version, minor_version,
|
requires.append(get_require_version('trytond'))
|
||||||
major_version, minor_version + 1))
|
|
||||||
requires.append('trytond >= %s.%s, < %s.%s' %
|
|
||||||
(major_version, minor_version, major_version, minor_version + 1))
|
|
||||||
|
|
||||||
tests_require = ['proteus >= %s.%s, < %s.%s' %
|
tests_require = [
|
||||||
(major_version, minor_version, major_version, minor_version + 1)]
|
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),
|
setup(name='%s_%s' % (PREFIX, MODULE),
|
||||||
version=info.get('version', '0.0.1'),
|
version=version,
|
||||||
description='',
|
description='',
|
||||||
long_description=read('README'),
|
long_description=read('README'),
|
||||||
author='NaN·tic',
|
author='NaN·tic',
|
||||||
|
author_email='info@nan-tic.com',
|
||||||
url='http://www.nan-tic.com/',
|
url='http://www.nan-tic.com/',
|
||||||
download_url="https://bitbucket.org/nantic/trytond-%s" % MODULE,
|
download_url="https://bitbucket.org/nantic/trytond-%s" % MODULE,
|
||||||
package_dir={'trytond.modules.%s' % MODULE: '.'},
|
package_dir={'trytond.modules.%s' % MODULE: '.'},
|
||||||
|
@ -71,12 +101,17 @@ setup(name='%s_%s' % (PREFIX, MODULE),
|
||||||
'Natural Language :: Russian',
|
'Natural Language :: Russian',
|
||||||
'Natural Language :: Spanish',
|
'Natural Language :: Spanish',
|
||||||
'Operating System :: OS Independent',
|
'Operating System :: OS Independent',
|
||||||
'Programming Language :: Python :: 2.6',
|
|
||||||
'Programming Language :: Python :: 2.7',
|
'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',
|
'Topic :: Office/Business',
|
||||||
],
|
],
|
||||||
license='GPL-3',
|
license='GPL-3',
|
||||||
install_requires=requires,
|
install_requires=requires,
|
||||||
|
dependency_links=dependency_links,
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
entry_points="""
|
entry_points="""
|
||||||
[trytond.modules]
|
[trytond.modules]
|
||||||
|
@ -85,4 +120,8 @@ setup(name='%s_%s' % (PREFIX, MODULE),
|
||||||
test_suite='tests',
|
test_suite='tests',
|
||||||
test_loader='trytond.test_loader:Loader',
|
test_loader='trytond.test_loader:Loader',
|
||||||
tests_require=tests_require,
|
tests_require=tests_require,
|
||||||
|
use_2to3=True,
|
||||||
|
convert_2to3_doctests=[
|
||||||
|
'tests/scenario_production_subcontract',
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
|
@ -18,20 +18,14 @@ Imports::
|
||||||
... create_chart, get_accounts, create_tax
|
... create_chart, get_accounts, create_tax
|
||||||
>>> from trytond.modules.account_invoice.tests.tools import \
|
>>> from trytond.modules.account_invoice.tests.tools import \
|
||||||
... set_fiscalyear_invoice_sequences
|
... set_fiscalyear_invoice_sequences
|
||||||
|
>>> from trytond.tests.tools import activate_modules
|
||||||
>>> today = datetime.date.today()
|
>>> today = datetime.date.today()
|
||||||
>>> yesterday = today - relativedelta(days=1)
|
>>> yesterday = today - relativedelta(days=1)
|
||||||
|
|
||||||
Create database::
|
Install party::
|
||||||
|
|
||||||
>>> config = config.set_trytond()
|
>>> config = activate_modules('production_subcontract')
|
||||||
>>> config.pool.test = True
|
|
||||||
|
|
||||||
Install production Module::
|
|
||||||
|
|
||||||
>>> Module = Model.get('ir.module')
|
|
||||||
>>> modules = Module.find([('name', '=', 'production_subcontract')])
|
|
||||||
>>> Module.install([x.id for x in modules], config.context)
|
|
||||||
>>> Wizard('ir.module.install_upgrade').execute('upgrade')
|
|
||||||
|
|
||||||
Create company::
|
Create company::
|
||||||
|
|
||||||
|
@ -112,10 +106,11 @@ Create product::
|
||||||
>>> template.name = 'product'
|
>>> template.name = 'product'
|
||||||
>>> template.default_uom = unit
|
>>> template.default_uom = unit
|
||||||
>>> template.type = 'goods'
|
>>> template.type = 'goods'
|
||||||
|
>>> template.producible = True
|
||||||
>>> template.list_price = Decimal(30)
|
>>> template.list_price = Decimal(30)
|
||||||
>>> template.cost_price = Decimal(20)
|
|
||||||
>>> template.save()
|
>>> template.save()
|
||||||
>>> product.template = template
|
>>> product.template = template
|
||||||
|
>>> product.cost_price = Decimal(20)
|
||||||
>>> product.save()
|
>>> product.save()
|
||||||
|
|
||||||
Create Components::
|
Create Components::
|
||||||
|
@ -126,9 +121,9 @@ Create Components::
|
||||||
>>> template1.default_uom = unit
|
>>> template1.default_uom = unit
|
||||||
>>> template1.type = 'goods'
|
>>> template1.type = 'goods'
|
||||||
>>> template1.list_price = Decimal(5)
|
>>> template1.list_price = Decimal(5)
|
||||||
>>> template1.cost_price = Decimal(1)
|
|
||||||
>>> template1.save()
|
>>> template1.save()
|
||||||
>>> component1.template = template1
|
>>> component1.template = template1
|
||||||
|
>>> component1.cost_price = Decimal(1)
|
||||||
>>> component1.save()
|
>>> component1.save()
|
||||||
|
|
||||||
>>> meter, = ProductUom.find([('name', '=', 'Meter')])
|
>>> meter, = ProductUom.find([('name', '=', 'Meter')])
|
||||||
|
@ -139,9 +134,9 @@ Create Components::
|
||||||
>>> template2.default_uom = meter
|
>>> template2.default_uom = meter
|
||||||
>>> template2.type = 'goods'
|
>>> template2.type = 'goods'
|
||||||
>>> template2.list_price = Decimal(7)
|
>>> template2.list_price = Decimal(7)
|
||||||
>>> template2.cost_price = Decimal(5)
|
|
||||||
>>> template2.save()
|
>>> template2.save()
|
||||||
>>> component2.template = template2
|
>>> component2.template = template2
|
||||||
|
>>> component2.cost_price = Decimal(5)
|
||||||
>>> component2.save()
|
>>> component2.save()
|
||||||
|
|
||||||
Create Subcontract Product::
|
Create Subcontract Product::
|
||||||
|
@ -155,9 +150,9 @@ Create Subcontract Product::
|
||||||
>>> stemplate.account_expense = expense
|
>>> stemplate.account_expense = expense
|
||||||
>>> stemplate.account_revenue = revenue
|
>>> stemplate.account_revenue = revenue
|
||||||
>>> stemplate.list_price = Decimal(0)
|
>>> stemplate.list_price = Decimal(0)
|
||||||
>>> stemplate.cost_price = Decimal(100)
|
|
||||||
>>> stemplate.save()
|
>>> stemplate.save()
|
||||||
>>> subcontract.template = stemplate
|
>>> subcontract.template = stemplate
|
||||||
|
>>> subcontract.cost_price = Decimal(100)
|
||||||
>>> subcontract.save()
|
>>> subcontract.save()
|
||||||
|
|
||||||
Create Bill of Material::
|
Create Bill of Material::
|
||||||
|
@ -268,8 +263,7 @@ Make a production::
|
||||||
True
|
True
|
||||||
>>> config._context['locations'] = [warehouse.id]
|
>>> config._context['locations'] = [warehouse.id]
|
||||||
>>> product.reload()
|
>>> product.reload()
|
||||||
>>> product.quantity == 2
|
|
||||||
True
|
|
||||||
|
|
||||||
Make a subcontract production::
|
Make a subcontract production::
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[tryton]
|
[tryton]
|
||||||
version=4.1.0
|
version=4.7.0
|
||||||
depends:
|
depends:
|
||||||
production
|
production
|
||||||
stock_supply
|
stock_supply
|
||||||
|
|
Loading…
Reference in New Issue