Migrate to version 3.8

This commit is contained in:
Sergi Almacellas Abellana 2016-04-14 10:57:25 +02:00
parent ee0a67e482
commit ea547b657b
7 changed files with 50 additions and 202 deletions

View file

@ -1 +1,2 @@
Version 3.8.0 - 2016-02-07
* Initial release

View file

@ -12,7 +12,7 @@ from trytond.transaction import Transaction
from trytond.tools import reduce_ids
from trytond.wizard import Wizard, StateView, StateAction, Button
from trytond.modules.contract import RRuleMixin
from trytond.modules.contract.contract import RRuleMixin
__all__ = ['ContractService', 'CreateShipmentsStart', 'CreateShipments',
'ContractLine', 'ShipmentWork', 'ShipmentWorkProduct', 'Asset']
@ -66,14 +66,12 @@ class ShipmentWork:
@fields.depends('asset', 'employees')
def on_change_asset(self):
changes = {}
if self.asset:
if (hasattr(self.asset, 'zone') and self.asset.zone and
self.asset.zone.employee):
changes['employees'] = [self.asset.zone.employee.id]
self.employees = [self.asset.zone.employee.id]
if self.asset.owner:
changes['party'] = self.asset.owner.id
return changes
self.party = self.asset.owner.id
class ShipmentWorkProduct:

View file

@ -49,7 +49,8 @@
<record model="ir.action.act_window" id="act_shipment_work_form">
<field name="name">Shipment Work</field>
<field name="res_model">shipment.work</field>
<field name="domain">[('asset', 'in', Eval('active_ids'))]</field>
<field name="domain" eval="[('asset', 'in', Eval('active_ids'))]"
pyson="1"/>
</record>
<record model="ir.action.keyword" id="act_open_shipment_work_keyword1">
<field name="keyword">form_relate</field>

View file

@ -9,6 +9,12 @@ Imports::
>>> from decimal import Decimal
>>> from operator import attrgetter
>>> from proteus import config, Model, Wizard
>>> 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
>>> from trytond.modules.account_invoice.tests.tools import \
... set_fiscalyear_invoice_sequences, create_payment_term
>>> today = datetime.datetime.combine(datetime.date.today(),
... datetime.datetime.min.time())
>>> tomorrow = datetime.date.today() + relativedelta(days=1)
@ -20,37 +26,16 @@ Create database::
Install account_invoice::
>>> Module = Model.get('ir.module.module')
>>> Module = Model.get('ir.module')
>>> contract_module, = Module.find([
... ('name', '=', 'contract_shipment_work')])
>>> contract_module.click('install')
>>> Wizard('ir.module.module.install_upgrade').execute('upgrade')
>>> Wizard('ir.module.install_upgrade').execute('upgrade')
Create company::
>>> Currency = Model.get('currency.currency')
>>> CurrencyRate = Model.get('currency.currency.rate')
>>> currencies = Currency.find([('code', '=', 'USD')])
>>> if not currencies:
... currency = Currency(name='US Dollar', symbol=u'$', code='USD',
... rounding=Decimal('0.01'), mon_grouping='[]',
... mon_decimal_point='.')
... currency.save()
... CurrencyRate(date=today + relativedelta(month=1, day=1),
... rate=Decimal('1.0'), currency=currency).save()
... else:
... currency, = currencies
>>> 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
>>> company.currency = currency
>>> company_config.execute('add')
>>> company, = Company.find([])
>>> _ = create_company()
>>> company = get_company()
Reload the context::
@ -59,85 +44,20 @@ Reload the context::
Create fiscal year::
>>> FiscalYear = Model.get('account.fiscalyear')
>>> Sequence = Model.get('ir.sequence')
>>> SequenceStrict = Model.get('ir.sequence.strict')
>>> fiscalyear = FiscalYear(name=str(today.year))
>>> fiscalyear.start_date = today + relativedelta(month=1, day=1)
>>> fiscalyear.end_date = today + relativedelta(month=12, day=31)
>>> fiscalyear.company = company
>>> post_move_seq = Sequence(name=str(today.year), code='account.move',
... company=company)
>>> post_move_seq.save()
>>> fiscalyear.post_move_sequence = post_move_seq
>>> invoice_seq = SequenceStrict(name=str(today.year),
... code='account.invoice', company=company)
>>> invoice_seq.save()
>>> fiscalyear.out_invoice_sequence = invoice_seq
>>> fiscalyear.in_invoice_sequence = invoice_seq
>>> fiscalyear.out_credit_note_sequence = invoice_seq
>>> fiscalyear.in_credit_note_sequence = invoice_seq
>>> fiscalyear.save()
>>> FiscalYear.create_period([fiscalyear.id], config.context)
>>> fiscalyear = set_fiscalyear_invoice_sequences(
... create_fiscalyear(company))
>>> fiscalyear.click('create_period')
Create chart of accounts::
>>> AccountTemplate = Model.get('account.account.template')
>>> Account = Model.get('account.account')
>>> account_template, = AccountTemplate.find([('parent', '=', None)])
>>> create_chart = Wizard('account.create_chart')
>>> create_chart.execute('account')
>>> create_chart.form.account_template = account_template
>>> create_chart.form.company = company
>>> create_chart.execute('create_account')
>>> receivable, = Account.find([
... ('kind', '=', 'receivable'),
... ('company', '=', company.id),
... ])
>>> payable, = Account.find([
... ('kind', '=', 'payable'),
... ('company', '=', company.id),
... ])
>>> revenue, = Account.find([
... ('kind', '=', 'revenue'),
... ('company', '=', company.id),
... ])
>>> expense, = Account.find([
... ('kind', '=', 'expense'),
... ('company', '=', company.id),
... ])
>>> account_tax, = Account.find([
... ('kind', '=', 'other'),
... ('company', '=', company.id),
... ('name', '=', 'Main Tax'),
... ])
>>> create_chart.form.account_receivable = receivable
>>> create_chart.form.account_payable = payable
>>> create_chart.execute('create_properties')
>>> _ = create_chart(company)
>>> accounts = get_accounts(company)
>>> revenue = accounts['revenue']
>>> expense = accounts['expense']
Create tax::
>>> TaxCode = Model.get('account.tax.code')
>>> Tax = Model.get('account.tax')
>>> tax = Tax()
>>> tax.name = 'Tax'
>>> tax.description = 'Tax'
>>> tax.type = 'percentage'
>>> tax.rate = Decimal('.10')
>>> tax.invoice_account = account_tax
>>> tax.credit_note_account = account_tax
>>> invoice_base_code = TaxCode(name='invoice base')
>>> invoice_base_code.save()
>>> tax.invoice_base_code = invoice_base_code
>>> invoice_tax_code = TaxCode(name='invoice tax')
>>> invoice_tax_code.save()
>>> tax.invoice_tax_code = invoice_tax_code
>>> credit_note_base_code = TaxCode(name='credit note base')
>>> credit_note_base_code.save()
>>> tax.credit_note_base_code = credit_note_base_code
>>> credit_note_tax_code = TaxCode(name='credit note tax')
>>> credit_note_tax_code.save()
>>> tax.credit_note_tax_code = credit_note_tax_code
>>> tax = create_tax(Decimal('.10'))
>>> tax.save()
Create party::
@ -229,4 +149,3 @@ Generate consumed lines::
>>> shipment, = Shipment.find([])
>>> shipment.planned_date == datetime.date(2015,01,05)
True

View file

@ -9,6 +9,12 @@ Imports::
>>> from decimal import Decimal
>>> from operator import attrgetter
>>> from proteus import config, Model, Wizard
>>> 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
>>> from trytond.modules.account_invoice.tests.tools import \
... set_fiscalyear_invoice_sequences, create_payment_term
>>> today = datetime.datetime.combine(datetime.date.today(),
... datetime.datetime.min.time())
>>> tomorrow = datetime.date.today() + relativedelta(days=1)
@ -20,38 +26,17 @@ Create database::
Install sale::
>>> Module = Model.get('ir.module.module')
>>> Module = Model.get('ir.module')
>>> module, = Module.find([('name', '=', 'asset_contract')])
>>> module.click('install')
>>> module, = Module.find([('name', '=', 'contract_shipment_work')])
>>> module.click('install')
>>> Wizard('ir.module.module.install_upgrade').execute('upgrade')
>>> Wizard('ir.module.install_upgrade').execute('upgrade')
Create company::
>>> Currency = Model.get('currency.currency')
>>> CurrencyRate = Model.get('currency.currency.rate')
>>> currencies = Currency.find([('code', '=', 'USD')])
>>> if not currencies:
... currency = Currency(name='U.S. Dollar', symbol='$', code='USD',
... rounding=Decimal('0.01'), mon_grouping='[3, 3, 0]',
... mon_decimal_point='.', mon_thousands_sep=',')
... currency.save()
... CurrencyRate(date=today + relativedelta(month=1, day=1),
... rate=Decimal('1.0'), currency=currency).save()
... else:
... currency, = currencies
>>> 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
>>> company.currency = currency
>>> company_config.execute('add')
>>> company, = Company.find([])
>>> _ = create_company()
>>> company = get_company()
Reload the context::
@ -60,66 +45,21 @@ Reload the context::
Create fiscal year::
>>> FiscalYear = Model.get('account.fiscalyear')
>>> Sequence = Model.get('ir.sequence')
>>> SequenceStrict = Model.get('ir.sequence.strict')
>>> fiscalyear = FiscalYear(name=str(today.year))
>>> fiscalyear.start_date = today + relativedelta(month=1, day=1)
>>> fiscalyear.end_date = today + relativedelta(month=12, day=31)
>>> fiscalyear.company = company
>>> post_move_seq = Sequence(name=str(today.year), code='account.move',
... company=company)
>>> post_move_seq.save()
>>> fiscalyear.post_move_sequence = post_move_seq
>>> invoice_seq = SequenceStrict(name=str(today.year),
... code='account.invoice', company=company)
>>> invoice_seq.save()
>>> fiscalyear.out_invoice_sequence = invoice_seq
>>> fiscalyear.in_invoice_sequence = invoice_seq
>>> fiscalyear.out_credit_note_sequence = invoice_seq
>>> fiscalyear.in_credit_note_sequence = invoice_seq
>>> fiscalyear.save()
>>> FiscalYear.create_period([fiscalyear.id], config.context)
>>> fiscalyear = set_fiscalyear_invoice_sequences(
... create_fiscalyear(company))
>>> fiscalyear.click('create_period')
Create chart of accounts::
>>> AccountTemplate = Model.get('account.account.template')
>>> Account = Model.get('account.account')
>>> Journal = Model.get('account.journal')
>>> account_template, = AccountTemplate.find([('parent', '=', None)])
>>> create_chart = Wizard('account.create_chart')
>>> create_chart.execute('account')
>>> create_chart.form.account_template = account_template
>>> create_chart.form.company = company
>>> create_chart.execute('create_account')
>>> receivable, = Account.find([
... ('kind', '=', 'receivable'),
... ('company', '=', company.id),
... ])
>>> payable, = Account.find([
... ('kind', '=', 'payable'),
... ('company', '=', company.id),
... ])
>>> revenue, = Account.find([
... ('kind', '=', 'revenue'),
... ('company', '=', company.id),
... ])
>>> expense, = Account.find([
... ('kind', '=', 'expense'),
... ('company', '=', company.id),
... ])
>>> create_chart.form.account_receivable = receivable
>>> create_chart.form.account_payable = payable
>>> create_chart.execute('create_properties')
>>> cash, = Account.find([
... ('kind', '=', 'other'),
... ('name', '=', 'Main Cash'),
... ('company', '=', company.id),
... ])
>>> cash_journal, = Journal.find([('type', '=', 'cash')])
>>> cash_journal.credit_account = cash
>>> cash_journal.debit_account = cash
>>> cash_journal.save()
>>> _ = create_chart(company)
>>> accounts = get_accounts(company)
>>> revenue = accounts['revenue']
>>> expense = accounts['expense']
Create tax::
>>> tax = create_tax(Decimal('.10'))
>>> tax.save()
Create parties::
@ -248,4 +188,3 @@ The asset has a maintenance planned for the same date::
>>> asset.reload()
>>> asset.shipments[0].planned_date == today.date()
True

View file

@ -3,23 +3,13 @@
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 ModuleTestCase
from trytond.tests.test_tryton import doctest_setup, doctest_teardown
class TestCase(unittest.TestCase):
class TestCase(ModuleTestCase):
'Test module'
def setUp(self):
trytond.tests.test_tryton.install_module('contract_shipment_work')
def test0005views(self):
'Test views'
test_view('contract_shipment_work')
def test0006depends(self):
'Test depends'
test_depends()
module = 'contract_shipment_work'
def suite():

View file

@ -1,5 +1,5 @@
[tryton]
version=3.4.0
version=3.8.0
depends:
contract
shipment_work