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
94ea5dd460f7
Commit
94ea5dd460f7
authored
1 year ago
by
Houzefa Abbasbhay
Browse files
Options
Downloads
Patches
Plain Diff
Fix period overlaps / wrong years during tests/populate
parent
d52326576a47
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!30
Add period_id in aml tree view (cf account_consult MO16-190)
,
!29
🚑 fix populate
Pipeline
#60512
failed
1 year ago
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
__init__.py
+1
-1
1 addition, 1 deletion
__init__.py
models/account_move.py
+34
-38
34 additions, 38 deletions
models/account_move.py
populate/__init__.py
+0
-1
0 additions, 1 deletion
populate/__init__.py
populate/account_move.py
+0
-27
0 additions, 27 deletions
populate/account_move.py
with
35 additions
and
67 deletions
__init__.py
+
1
−
1
View file @
94ea5dd4
from
.
import
demo
,
models
,
populate
,
wizards
from
.
import
demo
,
models
,
wizards
This diff is collapsed.
Click to expand it.
models/account_move.py
+
34
−
38
View file @
94ea5dd4
...
...
@@ -17,7 +17,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import
logging
from
odoo
import
_
,
exceptions
,
fields
,
models
,
tools
...
...
@@ -21,8 +20,6 @@
from
odoo
import
_
,
exceptions
,
fields
,
models
,
tools
_logger
=
logging
.
getLogger
(
__name__
)
class
AccountMove
(
models
.
Model
):
"""
Add a period & dates onto accounting documents.
"""
...
...
@@ -40,7 +37,6 @@
def
action_post
(
self
):
"""
Override accounting document validation to fill period.
"""
self
.
fetch_period
()
test
=
super
().
action_post
()
return
test
self
.
fill_period
()
return
super
().
action_post
()
...
...
@@ -46,9 +42,6 @@
def
fetch_period
(
self
):
"""
Force the period to always be around the current date.
Only select open periods.
"""
def
fill_period
(
self
):
"""
Find an open period around move date, set it onto that move.
"""
today
=
fields
.
Date
.
today
()
for
accdoc
in
self
:
...
...
@@ -52,6 +45,5 @@
today
=
fields
.
Date
.
today
()
for
accdoc
in
self
:
# Cache some data.
acc_date
=
accdoc
.
date
or
today
company
=
accdoc
.
company_id
...
...
@@ -56,5 +48,10 @@
acc_date
=
accdoc
.
date
or
today
company
=
accdoc
.
company_id
period_domain
=
[
(
"
company_id
"
,
"
=
"
,
company
.
id
),
(
"
date_start
"
,
"
<=
"
,
acc_date
),
(
"
date_effective_cutoff
"
,
"
>=
"
,
acc_date
),
]
# Periods are ordered by date so selecting the first one is fine.
period
=
self
.
env
[
"
account.period
"
].
search
(
...
...
@@ -58,12 +55,7 @@
# Periods are ordered by date so selecting the first one is fine.
period
=
self
.
env
[
"
account.period
"
].
search
(
[
(
"
company_id
"
,
"
=
"
,
company
.
id
),
(
"
date_start
"
,
"
<=
"
,
acc_date
),
(
"
date_effective_cutoff
"
,
"
>=
"
,
acc_date
),
(
"
state
"
,
"
!=
"
,
"
done
"
),
],
period_domain
+
[(
"
state
"
,
"
!=
"
,
"
done
"
)],
limit
=
1
,
)
if
not
period
:
...
...
@@ -67,9 +59,8 @@
limit
=
1
,
)
if
not
period
:
# if doing tests or installing demo data, and any matching period not
# closed
# Create missing periods on-the-fly when running tests / DB populate.
if
(
tools
.
config
[
"
test_enable
"
]
or
tools
.
config
[
"
test_file
"
]
or
self
.
env
.
context
.
get
(
"
install_demo
"
,
False
)
...
...
@@ -72,7 +63,8 @@
if
(
tools
.
config
[
"
test_enable
"
]
or
tools
.
config
[
"
test_file
"
]
or
self
.
env
.
context
.
get
(
"
install_demo
"
,
False
)
or
hasattr
(
self
.
env
.
registry
,
"
populated_models
"
)
)
and
(
not
self
.
env
.
context
.
get
(
"
period_close_enable
"
)
or
not
self
.
env
[
"
account.period
"
].
search
(
...
...
@@ -76,12 +68,7 @@
)
and
(
not
self
.
env
.
context
.
get
(
"
period_close_enable
"
)
or
not
self
.
env
[
"
account.period
"
].
search
(
[
(
"
company_id
"
,
"
=
"
,
company
.
id
),
(
"
date_start
"
,
"
<=
"
,
acc_date
),
(
"
date_effective_cutoff
"
,
"
>=
"
,
acc_date
),
(
"
state
"
,
"
=
"
,
"
done
"
),
],
period_domain
+
[(
"
state
"
,
"
=
"
,
"
done
"
)],
limit
=
1
,
)
):
...
...
@@ -85,14 +72,20 @@
limit
=
1
,
)
):
start_date
=
acc_date
.
replace
(
month
=
1
)
end_date
=
acc_date
.
replace
(
month
=
12
)
year_str
=
str
(
end_date
.
year
)
fiscalyear
=
self
.
env
[
"
account.fiscal.year
"
].
search
(
[(
"
name
"
,
"
=
"
,
year_str
)],
limit
=
1
)
# Fiscal year already exists in this company; ?
year_start
=
acc_date
.
replace
(
day
=
1
,
month
=
1
)
year_end
=
acc_date
.
replace
(
day
=
31
,
month
=
12
)
fiscalyear
=
(
self
.
env
[
"
account.fiscal.year
"
]
.
sudo
()
.
search
(
[
(
"
company_id
"
,
"
=
"
,
company
.
id
),
(
"
date_from
"
,
"
<=
"
,
year_start
),
(
"
date_to
"
,
"
>=
"
,
year_end
),
],
limit
=
1
,
)
)
if
not
fiscalyear
:
fiscalyear
=
(
self
.
env
[
"
account.fiscal.year
"
]
...
...
@@ -100,10 +93,10 @@
.
create
(
{
"
company_id
"
:
company
.
id
,
"
date_from
"
:
start
_date
,
"
date_to
"
:
end_date
,
"
name
"
:
str
(
end
_date
.
year
),
"
date_from
"
:
year_
start
,
"
date_to
"
:
year_end
,
"
name
"
:
str
(
acc
_date
.
year
),
}
)
)
fiscalyear
.
create_periods
()
...
...
@@ -106,8 +99,11 @@
}
)
)
fiscalyear
.
create_periods
()
period
=
fiscalyear
.
period_ids
[
0
]
period
=
self
.
env
[
"
account.period
"
].
search
(
period_domain
+
[(
"
state
"
,
"
!=
"
,
"
done
"
)],
limit
=
1
,
)
else
:
raise
exceptions
.
UserError
(
...
...
This diff is collapsed.
Click to expand it.
populate/__init__.py
deleted
100644 → 0
+
0
−
1
View file @
d5232657
from
.
import
account_move
This diff is collapsed.
Click to expand it.
populate/account_move.py
deleted
100644 → 0
+
0
−
27
View file @
d5232657
##############################################################################
#
# Part of Accounting periods, for Odoo
# Copyright © 2023 XCG Consulting <https://xcg-consulting.fr/>
#
# Accounting periods 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.
#
# Accounting periods 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 Accounting periods. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from
odoo
import
models
class
AccountMove
(
models
.
Model
):
_inherit
=
"
account.move
"
def
_populate
(
self
,
size
):
return
super
(
AccountMove
,
self
.
with_context
(
install_demo
=
True
)).
_populate
(
size
)
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