Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Accounting Periods
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
XCG
Odoo modules
Accounting Periods
Commits
9400a2f5e868
Commit
9400a2f5e868
authored
6 years ago
by
Houzefa Abbasbhay
Browse files
Options
Downloads
Patches
Plain Diff
Tests: Check invoice date propagation to acc docs
parent
291273d1524f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/__init__.py
+2
-0
2 additions, 0 deletions
tests/__init__.py
tests/test_account_period.py
+163
-0
163 additions, 0 deletions
tests/test_account_period.py
with
165 additions
and
0 deletions
tests/__init__.py
+
2
−
0
View file @
9400a2f5
# flake8: noqa
from
.
import
test_account_period
This diff is collapsed.
Click to expand it.
tests/test_account_period.py
0 → 100644
+
163
−
0
View file @
9400a2f5
##############################################################################
#
# Accounting periods, for Odoo
# Copyright (C) 2018 XCG Consulting <http://odoo.consulting>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import
odoo
from
.util.odoo_tests
import
TestBase
from
.util.singleton
import
Singleton
from
.util.uuidgen
import
genUuid
class
TestMemory
(
object
):
"""
Keep records in memory across tests.
"""
__metaclass__
=
Singleton
@odoo.tests.common.at_install
(
False
)
@odoo.tests.common.post_install
(
True
)
class
Test
(
TestBase
):
"""
Test fiscal years & accounting periods.
These tests assume an Odoo database with demo data.
"""
def
setUp
(
self
):
super
(
Test
,
self
).
setUp
()
self
.
memory
=
TestMemory
()
def
test_0000_create_accounting_account
(
self
):
"""
Create accounting accounts for use in further tests.
"""
acctype
,
=
self
.
createAndTest
(
'
account.account.type
'
,
[{
'
name
'
:
genUuid
(),
'
type
'
:
'
other
'
,
}])
self
.
memory
.
account
,
=
self
.
createAndTest
(
'
account.account
'
,
[{
'
code
'
:
genUuid
(
max_chars
=
4
),
'
internal_type
'
:
'
other
'
,
'
name
'
:
genUuid
(
max_chars
=
8
),
'
reconcile
'
:
True
,
'
user_type_id
'
:
acctype
.
id
,
}],
)
def
test_0001_create_partners
(
self
):
"""
Create simple partners, that will be used in other tests.
"""
self
.
memory
.
partner
,
=
self
.
createAndTest
(
'
res.partner
'
,
[{
'
customer
'
:
True
,
'
name
'
:
genUuid
(),
}],
)
def
test_0002_create_products
(
self
):
"""
Create products for use in further tests.
"""
def
createProduct
(
values
):
"""
Create a product template and return its product variant.
"""
ptemplate
,
=
self
.
createAndTest
(
'
product.template
'
,
[
values
])
product
=
ptemplate
.
product_variant_ids
self
.
assertEqual
(
len
(
product
),
1
)
return
product
self
.
memory
.
product
=
createProduct
({
'
name
'
:
genUuid
(),
'
property_account_expense_id
'
:
self
.
memory
.
account
.
id
,
'
property_account_income_id
'
:
self
.
memory
.
account
.
id
,
'
type
'
:
'
service
'
,
})
def
test_0100_invoice_dates
(
self
):
"""
Check invoice date propagation to accounting documents.
"""
# Find the period around today. We should have one in demo data.
today
=
odoo
.
fields
.
Date
.
today
()
period_today
=
self
.
env
[
'
account.period
'
].
search
([
(
'
date_start
'
,
'
<=
'
,
today
),
(
'
date_stop
'
,
'
>=
'
,
today
),
])
self
.
assertEqual
(
len
(
period_today
),
1
)
# Control: Default dates & period around today.
invoice
=
self
.
_makeInvoice
()
self
.
_validateInvoice
(
invoice
)
accdoc
=
invoice
.
move_id
self
.
assertEqual
(
accdoc
.
date
,
today
)
self
.
assertEqual
(
accdoc
.
transaction_date
,
today
)
self
.
assertEqual
(
accdoc
.
period_id
.
id
,
period_today
.
id
)
# Force a date on the invoice; check its propagation.
invoice
=
self
.
_makeInvoice
()
invoice
.
date_invoice
=
'
2017-01-15
'
self
.
_validateInvoice
(
invoice
)
accdoc
=
invoice
.
move_id
self
.
assertEqual
(
accdoc
.
date
,
today
)
self
.
assertEqual
(
accdoc
.
transaction_date
,
'
2017-01-15
'
)
self
.
assertEqual
(
accdoc
.
period_id
.
id
,
period_today
.
id
)
def
_makeInvoice
(
self
):
"""
Create an invoice and return it.
:return: The invoice.
:rtype: Odoo
"
account.invoice
"
record set.
"""
# Create the invoice first and add lines afterwards.
invoice
,
=
self
.
createAndTest
(
'
account.invoice
'
,
[{
'
partner_id
'
:
self
.
memory
.
partner
.
id
,
'
type
'
:
'
out_invoice
'
,
}],
)
self
.
createAndTest
(
'
account.invoice.line
'
,
[
{
'
account_id
'
:
self
.
memory
.
account
.
id
,
'
invoice_id
'
:
invoice
.
id
,
'
name
'
:
genUuid
(),
'
price_unit
'
:
42.0
,
'
product_id
'
:
self
.
memory
.
product
.
id
,
},
],
)
return
invoice
def
_validateInvoice
(
self
,
invoice
):
"""
Validate the specified invoice.
:type invoice: Odoo
"
account.invoice
"
record set.
"""
self
.
assertEqual
(
invoice
.
state
,
'
draft
'
)
invoice
.
action_invoice_open
()
self
.
assertEqual
(
invoice
.
state
,
'
open
'
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment