Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Coopdevs OCB mirror
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Coopdevs
Odoo
Coopdevs OCB mirror
Commits
463e31f4
Commit
463e31f4
authored
9 years ago
by
Fabien Pinckaers
Browse files
Options
Downloads
Patches
Plain Diff
[FIX] Average price is based on product, not template
parent
1b700668
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
addons/stock_account/stock_account.py
+6
-6
6 additions, 6 deletions
addons/stock_account/stock_account.py
with
6 additions
and
6 deletions
addons/stock_account/stock_account.py
+
6
−
6
View file @
463e31f4
...
...
@@ -388,12 +388,12 @@ class stock_move(osv.osv):
#adapt standard price on incomming moves if the product cost_method is 'average'
if
(
move
.
location_id
.
usage
==
'
supplier
'
)
and
(
move
.
product_id
.
cost_method
==
'
average
'
):
product
=
move
.
product_id
prod
_tmpl
_id
=
move
.
product_id
.
product_tmpl_id
.
id
qty_available
=
move
.
product_id
.
product_tmpl_id
.
qty_available
if
tmpl_dict
.
get
(
prod
_tmpl
_id
):
product_avail
=
qty_available
+
tmpl_dict
[
prod
_tmpl
_id
]
prod
uct
_id
=
move
.
product_id
.
id
qty_available
=
move
.
product_id
.
qty_available
if
tmpl_dict
.
get
(
prod
uct
_id
):
product_avail
=
qty_available
+
tmpl_dict
[
prod
uct
_id
]
else
:
tmpl_dict
[
prod
_tmpl
_id
]
=
0
tmpl_dict
[
prod
uct
_id
]
=
0
product_avail
=
qty_available
if
product_avail
<=
0
:
new_std_price
=
move
.
price_unit
...
...
@@ -401,7 +401,7 @@ class stock_move(osv.osv):
# Get the standard price
amount_unit
=
product
.
standard_price
new_std_price
=
((
amount_unit
*
product_avail
)
+
(
move
.
price_unit
*
move
.
product_qty
))
/
(
product_avail
+
move
.
product_qty
)
tmpl_dict
[
prod
_tmpl
_id
]
+=
move
.
product_qty
tmpl_dict
[
prod
uct
_id
]
+=
move
.
product_qty
# Write the standard price, as SUPERUSER_ID because a warehouse manager may not have the right to write on products
ctx
=
dict
(
context
or
{},
force_company
=
move
.
company_id
.
id
)
product_obj
.
write
(
cr
,
SUPERUSER_ID
,
[
product
.
id
],
{
'
standard_price
'
:
new_std_price
},
context
=
ctx
)
...
...
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