mirror of
https://github.com/NaN-tic/trytond-contract_shipment_work.git
synced 2023-12-14 03:52:53 +01:00
Migrate to version 3.8
This commit is contained in:
parent
ee0a67e482
commit
ea547b657b
7 changed files with 50 additions and 202 deletions
|
@ -1 +1,2 @@
|
||||||
|
Version 3.8.0 - 2016-02-07
|
||||||
* Initial release
|
* Initial release
|
||||||
|
|
|
@ -12,7 +12,7 @@ from trytond.transaction import Transaction
|
||||||
from trytond.tools import reduce_ids
|
from trytond.tools import reduce_ids
|
||||||
from trytond.wizard import Wizard, StateView, StateAction, Button
|
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',
|
__all__ = ['ContractService', 'CreateShipmentsStart', 'CreateShipments',
|
||||||
'ContractLine', 'ShipmentWork', 'ShipmentWorkProduct', 'Asset']
|
'ContractLine', 'ShipmentWork', 'ShipmentWorkProduct', 'Asset']
|
||||||
|
@ -66,14 +66,12 @@ class ShipmentWork:
|
||||||
|
|
||||||
@fields.depends('asset', 'employees')
|
@fields.depends('asset', 'employees')
|
||||||
def on_change_asset(self):
|
def on_change_asset(self):
|
||||||
changes = {}
|
|
||||||
if self.asset:
|
if self.asset:
|
||||||
if (hasattr(self.asset, 'zone') and self.asset.zone and
|
if (hasattr(self.asset, 'zone') and self.asset.zone and
|
||||||
self.asset.zone.employee):
|
self.asset.zone.employee):
|
||||||
changes['employees'] = [self.asset.zone.employee.id]
|
self.employees = [self.asset.zone.employee.id]
|
||||||
if self.asset.owner:
|
if self.asset.owner:
|
||||||
changes['party'] = self.asset.owner.id
|
self.party = self.asset.owner.id
|
||||||
return changes
|
|
||||||
|
|
||||||
|
|
||||||
class ShipmentWorkProduct:
|
class ShipmentWorkProduct:
|
||||||
|
|
|
@ -49,7 +49,8 @@
|
||||||
<record model="ir.action.act_window" id="act_shipment_work_form">
|
<record model="ir.action.act_window" id="act_shipment_work_form">
|
||||||
<field name="name">Shipment Work</field>
|
<field name="name">Shipment Work</field>
|
||||||
<field name="res_model">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>
|
||||||
<record model="ir.action.keyword" id="act_open_shipment_work_keyword1">
|
<record model="ir.action.keyword" id="act_open_shipment_work_keyword1">
|
||||||
<field name="keyword">form_relate</field>
|
<field name="keyword">form_relate</field>
|
||||||
|
|
|
@ -9,6 +9,12 @@ Imports::
|
||||||
>>> from decimal import Decimal
|
>>> from decimal import Decimal
|
||||||
>>> from operator import attrgetter
|
>>> from operator import attrgetter
|
||||||
>>> from proteus import config, Model, Wizard
|
>>> 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(),
|
>>> today = datetime.datetime.combine(datetime.date.today(),
|
||||||
... datetime.datetime.min.time())
|
... datetime.datetime.min.time())
|
||||||
>>> tomorrow = datetime.date.today() + relativedelta(days=1)
|
>>> tomorrow = datetime.date.today() + relativedelta(days=1)
|
||||||
|
@ -20,37 +26,16 @@ Create database::
|
||||||
|
|
||||||
Install account_invoice::
|
Install account_invoice::
|
||||||
|
|
||||||
>>> Module = Model.get('ir.module.module')
|
>>> Module = Model.get('ir.module')
|
||||||
>>> contract_module, = Module.find([
|
>>> contract_module, = Module.find([
|
||||||
... ('name', '=', 'contract_shipment_work')])
|
... ('name', '=', 'contract_shipment_work')])
|
||||||
>>> contract_module.click('install')
|
>>> contract_module.click('install')
|
||||||
>>> Wizard('ir.module.module.install_upgrade').execute('upgrade')
|
>>> Wizard('ir.module.install_upgrade').execute('upgrade')
|
||||||
|
|
||||||
Create company::
|
Create company::
|
||||||
|
|
||||||
>>> Currency = Model.get('currency.currency')
|
>>> _ = create_company()
|
||||||
>>> CurrencyRate = Model.get('currency.currency.rate')
|
>>> company = get_company()
|
||||||
>>> 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([])
|
|
||||||
|
|
||||||
Reload the context::
|
Reload the context::
|
||||||
|
|
||||||
|
@ -59,85 +44,20 @@ Reload the context::
|
||||||
|
|
||||||
Create fiscal year::
|
Create fiscal year::
|
||||||
|
|
||||||
>>> FiscalYear = Model.get('account.fiscalyear')
|
>>> fiscalyear = set_fiscalyear_invoice_sequences(
|
||||||
>>> Sequence = Model.get('ir.sequence')
|
... create_fiscalyear(company))
|
||||||
>>> SequenceStrict = Model.get('ir.sequence.strict')
|
>>> fiscalyear.click('create_period')
|
||||||
>>> 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)
|
|
||||||
|
|
||||||
Create chart of accounts::
|
Create chart of accounts::
|
||||||
|
|
||||||
>>> AccountTemplate = Model.get('account.account.template')
|
>>> _ = create_chart(company)
|
||||||
>>> Account = Model.get('account.account')
|
>>> accounts = get_accounts(company)
|
||||||
>>> account_template, = AccountTemplate.find([('parent', '=', None)])
|
>>> revenue = accounts['revenue']
|
||||||
>>> create_chart = Wizard('account.create_chart')
|
>>> expense = accounts['expense']
|
||||||
>>> 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 tax::
|
Create tax::
|
||||||
|
|
||||||
>>> TaxCode = Model.get('account.tax.code')
|
>>> tax = create_tax(Decimal('.10'))
|
||||||
>>> 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.save()
|
>>> tax.save()
|
||||||
|
|
||||||
Create party::
|
Create party::
|
||||||
|
@ -229,4 +149,3 @@ Generate consumed lines::
|
||||||
>>> shipment, = Shipment.find([])
|
>>> shipment, = Shipment.find([])
|
||||||
>>> shipment.planned_date == datetime.date(2015,01,05)
|
>>> shipment.planned_date == datetime.date(2015,01,05)
|
||||||
True
|
True
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,12 @@ Imports::
|
||||||
>>> from decimal import Decimal
|
>>> from decimal import Decimal
|
||||||
>>> from operator import attrgetter
|
>>> from operator import attrgetter
|
||||||
>>> from proteus import config, Model, Wizard
|
>>> 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(),
|
>>> today = datetime.datetime.combine(datetime.date.today(),
|
||||||
... datetime.datetime.min.time())
|
... datetime.datetime.min.time())
|
||||||
>>> tomorrow = datetime.date.today() + relativedelta(days=1)
|
>>> tomorrow = datetime.date.today() + relativedelta(days=1)
|
||||||
|
@ -20,38 +26,17 @@ Create database::
|
||||||
|
|
||||||
Install sale::
|
Install sale::
|
||||||
|
|
||||||
>>> Module = Model.get('ir.module.module')
|
>>> Module = Model.get('ir.module')
|
||||||
>>> module, = Module.find([('name', '=', 'asset_contract')])
|
>>> module, = Module.find([('name', '=', 'asset_contract')])
|
||||||
>>> module.click('install')
|
>>> module.click('install')
|
||||||
>>> module, = Module.find([('name', '=', 'contract_shipment_work')])
|
>>> module, = Module.find([('name', '=', 'contract_shipment_work')])
|
||||||
>>> module.click('install')
|
>>> module.click('install')
|
||||||
>>> Wizard('ir.module.module.install_upgrade').execute('upgrade')
|
>>> Wizard('ir.module.install_upgrade').execute('upgrade')
|
||||||
|
|
||||||
Create company::
|
Create company::
|
||||||
|
|
||||||
>>> Currency = Model.get('currency.currency')
|
>>> _ = create_company()
|
||||||
>>> CurrencyRate = Model.get('currency.currency.rate')
|
>>> company = get_company()
|
||||||
>>> 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([])
|
|
||||||
|
|
||||||
Reload the context::
|
Reload the context::
|
||||||
|
|
||||||
|
@ -60,66 +45,21 @@ Reload the context::
|
||||||
|
|
||||||
Create fiscal year::
|
Create fiscal year::
|
||||||
|
|
||||||
>>> FiscalYear = Model.get('account.fiscalyear')
|
>>> fiscalyear = set_fiscalyear_invoice_sequences(
|
||||||
>>> Sequence = Model.get('ir.sequence')
|
... create_fiscalyear(company))
|
||||||
>>> SequenceStrict = Model.get('ir.sequence.strict')
|
>>> fiscalyear.click('create_period')
|
||||||
>>> 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)
|
|
||||||
|
|
||||||
Create chart of accounts::
|
Create chart of accounts::
|
||||||
|
|
||||||
>>> AccountTemplate = Model.get('account.account.template')
|
>>> _ = create_chart(company)
|
||||||
>>> Account = Model.get('account.account')
|
>>> accounts = get_accounts(company)
|
||||||
>>> Journal = Model.get('account.journal')
|
>>> revenue = accounts['revenue']
|
||||||
>>> account_template, = AccountTemplate.find([('parent', '=', None)])
|
>>> expense = accounts['expense']
|
||||||
>>> create_chart = Wizard('account.create_chart')
|
|
||||||
>>> create_chart.execute('account')
|
Create tax::
|
||||||
>>> create_chart.form.account_template = account_template
|
|
||||||
>>> create_chart.form.company = company
|
>>> tax = create_tax(Decimal('.10'))
|
||||||
>>> create_chart.execute('create_account')
|
>>> tax.save()
|
||||||
>>> 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 parties::
|
Create parties::
|
||||||
|
|
||||||
|
@ -248,4 +188,3 @@ The asset has a maintenance planned for the same date::
|
||||||
>>> asset.reload()
|
>>> asset.reload()
|
||||||
>>> asset.shipments[0].planned_date == today.date()
|
>>> asset.shipments[0].planned_date == today.date()
|
||||||
True
|
True
|
||||||
|
|
||||||
|
|
|
@ -3,23 +3,13 @@
|
||||||
import unittest
|
import unittest
|
||||||
import doctest
|
import doctest
|
||||||
import trytond.tests.test_tryton
|
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
|
from trytond.tests.test_tryton import doctest_setup, doctest_teardown
|
||||||
|
|
||||||
|
|
||||||
class TestCase(unittest.TestCase):
|
class TestCase(ModuleTestCase):
|
||||||
'Test module'
|
'Test module'
|
||||||
|
module = 'contract_shipment_work'
|
||||||
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()
|
|
||||||
|
|
||||||
|
|
||||||
def suite():
|
def suite():
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[tryton]
|
[tryton]
|
||||||
version=3.4.0
|
version=3.8.0
|
||||||
depends:
|
depends:
|
||||||
contract
|
contract
|
||||||
shipment_work
|
shipment_work
|
||||||
|
|
Loading…
Reference in a new issue