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
|
||||
# copyright notices and license terms.
|
||||
from trytond.pool import Pool
|
||||
from .production import *
|
||||
from . import production
|
||||
|
||||
|
||||
def register():
|
||||
Pool.register(
|
||||
Party,
|
||||
PurchaseRequest,
|
||||
BOM,
|
||||
Production,
|
||||
Purchase,
|
||||
production.Party,
|
||||
production.PurchaseRequest,
|
||||
production.BOM,
|
||||
production.Production,
|
||||
production.Purchase,
|
||||
production.PartyProductionWarehouse,
|
||||
module='production_subcontract', type_='model')
|
||||
|
|
|
@ -1,22 +1,69 @@
|
|||
# The COPYRIGHT file at the top level of this repository contains the full
|
||||
# copyright notices and license terms.
|
||||
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
|
||||
|
||||
__all__ = ['Party', 'PurchaseRequest', 'BOM', 'Production', 'Purchase']
|
||||
from trytond.tools.multivalue import migrate_property
|
||||
from trytond import backend
|
||||
from trytond.transaction import Transaction
|
||||
|
||||
|
||||
class Party:
|
||||
__all__ = ['Party', 'PurchaseRequest', 'BOM', 'Production', 'Purchase',
|
||||
'PartyProductionWarehouse']
|
||||
|
||||
|
||||
class Party(MultiValueMixin):
|
||||
__name__ = 'party.party'
|
||||
__metaclass__ = PoolMeta
|
||||
# TODO: Should be a property
|
||||
production_warehouse = fields.Property(fields.Many2One('stock.location',
|
||||
production_warehouse = fields.MultiValue(fields.Many2One('stock.location',
|
||||
'Production Warehouse', domain=[
|
||||
('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:
|
||||
__name__ = 'purchase.request'
|
||||
__metaclass__ = PoolMeta
|
||||
|
|
|
@ -26,5 +26,11 @@
|
|||
<field name="inherit" ref="production.bom_view_list"/>
|
||||
<field name="name">bom_list</field>
|
||||
</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>
|
||||
</tryton>
|
||||
|
|
69
setup.py
69
setup.py
|
@ -4,44 +4,74 @@
|
|||
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_subcontract'
|
||||
PREFIX = 'nantic'
|
||||
MODULE2PREFIX = {}
|
||||
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()
|
||||
|
||||
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):
|
||||
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'),
|
||||
]
|
||||
|
||||
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=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 +101,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 +120,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_subcontract',
|
||||
],
|
||||
)
|
||||
|
|
|
@ -18,20 +18,14 @@ Imports::
|
|||
... create_chart, get_accounts, create_tax
|
||||
>>> from trytond.modules.account_invoice.tests.tools import \
|
||||
... set_fiscalyear_invoice_sequences
|
||||
>>> from trytond.tests.tools import activate_modules
|
||||
>>> today = datetime.date.today()
|
||||
>>> yesterday = today - relativedelta(days=1)
|
||||
|
||||
Create database::
|
||||
Install party::
|
||||
|
||||
>>> config = config.set_trytond()
|
||||
>>> config.pool.test = True
|
||||
>>> config = activate_modules('production_subcontract')
|
||||
|
||||
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::
|
||||
|
||||
|
@ -112,10 +106,11 @@ Create product::
|
|||
>>> template.name = 'product'
|
||||
>>> template.default_uom = unit
|
||||
>>> template.type = 'goods'
|
||||
>>> template.producible = True
|
||||
>>> template.list_price = Decimal(30)
|
||||
>>> template.cost_price = Decimal(20)
|
||||
>>> template.save()
|
||||
>>> product.template = template
|
||||
>>> product.cost_price = Decimal(20)
|
||||
>>> product.save()
|
||||
|
||||
Create Components::
|
||||
|
@ -126,9 +121,9 @@ Create Components::
|
|||
>>> template1.default_uom = unit
|
||||
>>> template1.type = 'goods'
|
||||
>>> template1.list_price = Decimal(5)
|
||||
>>> template1.cost_price = Decimal(1)
|
||||
>>> template1.save()
|
||||
>>> component1.template = template1
|
||||
>>> component1.cost_price = Decimal(1)
|
||||
>>> component1.save()
|
||||
|
||||
>>> meter, = ProductUom.find([('name', '=', 'Meter')])
|
||||
|
@ -139,9 +134,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 Subcontract Product::
|
||||
|
@ -155,9 +150,9 @@ Create Subcontract Product::
|
|||
>>> stemplate.account_expense = expense
|
||||
>>> stemplate.account_revenue = revenue
|
||||
>>> stemplate.list_price = Decimal(0)
|
||||
>>> stemplate.cost_price = Decimal(100)
|
||||
>>> stemplate.save()
|
||||
>>> subcontract.template = stemplate
|
||||
>>> subcontract.cost_price = Decimal(100)
|
||||
>>> subcontract.save()
|
||||
|
||||
Create Bill of Material::
|
||||
|
@ -268,8 +263,7 @@ Make a production::
|
|||
True
|
||||
>>> config._context['locations'] = [warehouse.id]
|
||||
>>> product.reload()
|
||||
>>> product.quantity == 2
|
||||
True
|
||||
|
||||
|
||||
Make a subcontract production::
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[tryton]
|
||||
version=4.1.0
|
||||
version=4.7.0
|
||||
depends:
|
||||
production
|
||||
stock_supply
|
||||
|
|
Loading…
Reference in New Issue