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
1d78ae16
Commit
1d78ae16
authored
14 years ago
by
Fabien Pinckaers
Browse files
Options
Downloads
Patches
Plain Diff
[FIX] computation in pricelist
bzr revid: fp@tinyerp.com-20101018094306-2of34548d0us4qrw
parent
37680303
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
addons/product/pricelist.py
+0
-157
0 additions, 157 deletions
addons/product/pricelist.py
with
0 additions
and
157 deletions
addons/product/pricelist.py
+
0
−
157
View file @
1d78ae16
...
@@ -126,161 +126,6 @@ class product_pricelist(osv.osv):
...
@@ -126,161 +126,6 @@ class product_pricelist(osv.osv):
"
currency_id
"
:
_get_currency
"
currency_id
"
:
_get_currency
}
}
def
price_get_multi_old
(
self
,
cr
,
uid
,
product_map
,
context
=
None
):
"""
multi products
'
price_get
'
@param context: {
'
date
'
: Date of the pricelist (%Y-%m-%d),
@return: a dict with product_id as key and the product price as value
}
"""
def
_create_parent_category_list
(
id
,
lst
):
if
not
id
:
return
[]
parent
=
product_category_tree
.
get
(
id
)
if
parent
:
lst
.
append
(
parent
)
return
_create_parent_category_list
(
parent
,
lst
)
else
:
return
lst
# _create_parent_category_list
context
=
context
or
{}
# XXX
date
=
time
.
strftime
(
'
%Y-%m-%d
'
)
if
'
date
'
in
context
:
date
=
context
[
'
date
'
]
currency_obj
=
self
.
pool
.
get
(
'
res.currency
'
)
product_obj
=
self
.
pool
.
get
(
'
product.product
'
)
product_category_obj
=
self
.
pool
.
get
(
'
product.category
'
)
product_uom_obj
=
self
.
pool
.
get
(
'
product.uom
'
)
supplierinfo_obj
=
self
.
pool
.
get
(
'
product.supplierinfo
'
)
price_type_obj
=
self
.
pool
.
get
(
'
product.price.type
'
)
product_pricelist_version_obj
=
self
.
pool
.
get
(
'
product.pricelist.version
'
)
# product.pricelist.version:
pricelist_version_ids
=
list
(
set
([
k
[
1
]
for
k
in
product_map
.
keys
()]))
plversions_search_args
=
[
(
'
pricelist_id
'
,
'
in
'
,
pricelist_version_ids
),
'
|
'
,
(
'
date_start
'
,
'
=
'
,
False
),
(
'
date_start
'
,
'
<=
'
,
date
),
'
|
'
,
(
'
date_end
'
,
'
=
'
,
False
),
(
'
date_end
'
,
'
>=
'
,
date
),
]
plversion_ids
=
product_pricelist_version_obj
.
search
(
cr
,
uid
,
plversions_search_args
)
if
len
(
pricelist_version_ids
)
!=
len
(
plversion_ids
):
msg
=
"
At least one pricelist has no active version !
\n
Please create or activate one.
"
raise
osv
.
except_osv
(
_
(
'
Warning !
'
),
_
(
msg
))
# product.product:
product_ids
=
list
(
set
([
k
[
0
]
for
k
in
product_map
.
keys
()]))
products
=
dict
([(
item
[
'
id
'
],
item
)
for
item
in
product_obj
.
read
(
cr
,
uid
,
product_ids
,
[
'
categ_id
'
,
'
product_tmpl_id
'
,
'
uos_id
'
,
'
uom_id
'
])])
# product.category:
product_category_ids
=
product_category_obj
.
search
(
cr
,
uid
,
[])
product_categories
=
product_category_obj
.
read
(
cr
,
uid
,
product_category_ids
,
[
'
parent_id
'
])
product_category_tree
=
dict
([(
item
[
'
id
'
],
item
[
'
parent_id
'
][
0
])
for
item
in
product_categories
if
item
[
'
parent_id
'
]])
results
=
{}
for
(
product_id
,
pricelist_id
),
line
in
product_map
.
items
():
price
=
False
partner
=
line
[
'
partner_id
'
]
qty
=
line
[
'
qty
'
]
tmpl_id
=
products
[
product_id
][
'
product_tmpl_id
'
]
and
products
[
product_id
][
'
product_tmpl_id
'
][
0
]
or
False
categ_id
=
products
[
product_id
][
'
categ_id
'
]
and
products
[
product_id
][
'
categ_id
'
][
0
]
or
False
categ_ids
=
_create_parent_category_list
(
categ_id
,
[
categ_id
])
if
categ_ids
:
categ_where
=
'
(categ_id IN (
'
+
'
,
'
.
join
(
map
(
str
,
categ_ids
))
+
'
))
'
else
:
categ_where
=
'
(categ_id IS NULL)
'
cr
.
execute
(
'
SELECT i.*, pl.currency_id
'
'
FROM product_pricelist_item AS i,
'
'
product_pricelist_version AS v, product_pricelist AS pl
'
'
WHERE (product_tmpl_id IS NULL OR product_tmpl_id = %s)
'
'
AND (product_id IS NULL OR product_id = %s)
'
'
AND (
'
+
categ_where
+
'
OR (categ_id IS NULL))
'
'
AND price_version_id = %s
'
'
AND (min_quantity IS NULL OR min_quantity <= %s)
'
'
AND i.price_version_id = v.id AND v.pricelist_id = pl.id
'
'
ORDER BY sequence
'
,
(
tmpl_id
,
product_id
,
pricelist_id
,
qty
))
res1
=
cr
.
dictfetchall
()
for
res
in
res1
:
if
res
:
if
res
[
'
base
'
]
==
-
1
:
if
not
res
[
'
base_pricelist_id
'
]:
price
=
0.0
else
:
price_tmp
=
self
.
price_get
(
cr
,
uid
,
[
res
[
'
base_pricelist_id
'
]],
product_id
,
qty
)[
res
[
'
base_pricelist_id
'
]]
ptype_src
=
self
.
browse
(
cr
,
uid
,
res
[
'
base_pricelist_id
'
]).
currency_id
.
id
price
=
currency_obj
.
compute
(
cr
,
uid
,
ptype_src
,
res
[
'
currency_id
'
],
price_tmp
,
round
=
False
)
break
elif
res
[
'
base
'
]
==
-
2
:
# this section could be improved by moving the queries outside the loop:
where
=
[]
if
partner
:
where
=
[(
'
name
'
,
'
=
'
,
partner
)
]
sinfo
=
supplierinfo_obj
.
search
(
cr
,
uid
,
[(
'
product_id
'
,
'
=
'
,
tmpl_id
)]
+
where
)
price
=
0.0
if
sinfo
:
cr
.
execute
(
'
SELECT *
'
\
'
FROM pricelist_partnerinfo
'
\
'
WHERE suppinfo_id IN %s
'
\
'
AND min_quantity <= %s
'
\
'
ORDER BY min_quantity DESC LIMIT 1
'
,
(
tuple
(
sinfo
),
qty
,))
res2
=
cr
.
dictfetchone
()
if
res2
:
price
=
res2
[
'
price
'
]
break
else
:
price_type
=
price_type_obj
.
browse
(
cr
,
uid
,
int
(
res
[
'
base
'
]))
price
=
currency_obj
.
compute
(
cr
,
uid
,
price_type
.
currency_id
.
id
,
res
[
'
currency_id
'
],
product_obj
.
price_get
(
cr
,
uid
,
[
product_id
],
price_type
.
field
)[
product_id
],
round
=
False
,
context
=
context
)
if
price
:
price_limit
=
price
price
=
price
*
(
1.0
+
(
res
[
'
price_discount
'
]
or
0.0
))
price
=
rounding
(
price
,
res
[
'
price_round
'
])
price
+=
(
res
[
'
price_surcharge
'
]
or
0.0
)
if
res
[
'
price_min_margin
'
]:
price
=
max
(
price
,
price_limit
+
res
[
'
price_min_margin
'
])
if
res
[
'
price_max_margin
'
]:
price
=
min
(
price
,
price_limit
+
res
[
'
price_max_margin
'
])
break
else
:
# False means no valid line found ! But we may not raise an
# exception here because it breaks the search
price
=
False
if
price
:
p_uom_id
=
products
[
product_id
][
'
uos_id
'
]
and
products
[
product_id
][
'
uos_id
'
][
0
]
or
products
[
product_id
][
'
uom_id
'
]
and
products
[
product_id
][
'
uom_id
'
][
0
]
or
False
if
p_uom_id
:
price
=
product_uom_obj
.
_compute_price
(
cr
,
uid
,
p_uom_id
,
price
,
context
.
get
(
'
uom
'
,
False
))
if
results
.
get
(
product_id
):
results
[
product_id
][
pricelist_id
]
=
price
else
:
results
[
product_id
]
=
{
pricelist_id
:
price
}
return
results
#def price_get_multi(self, cr, uid, product_ids, context=None):
#def price_get_multi(self, cr, uid, product_ids, context=None):
def
price_get_multi
(
self
,
cr
,
uid
,
pricelist_ids
,
products_by_qty_by_partner
,
context
=
None
):
def
price_get_multi
(
self
,
cr
,
uid
,
pricelist_ids
,
products_by_qty_by_partner
,
context
=
None
):
"""
multi products
'
price_get
'
.
"""
multi products
'
price_get
'
.
...
@@ -392,7 +237,6 @@ class product_pricelist(osv.osv):
...
@@ -392,7 +237,6 @@ class product_pricelist(osv.osv):
qty
)[
res
[
'
base_pricelist_id
'
]]
qty
)[
res
[
'
base_pricelist_id
'
]]
ptype_src
=
self
.
browse
(
cr
,
uid
,
res
[
'
base_pricelist_id
'
]).
currency_id
.
id
ptype_src
=
self
.
browse
(
cr
,
uid
,
res
[
'
base_pricelist_id
'
]).
currency_id
.
id
price
=
currency_obj
.
compute
(
cr
,
uid
,
ptype_src
,
res
[
'
currency_id
'
],
price_tmp
,
round
=
False
)
price
=
currency_obj
.
compute
(
cr
,
uid
,
ptype_src
,
res
[
'
currency_id
'
],
price_tmp
,
round
=
False
)
break
elif
res
[
'
base
'
]
==
-
2
:
elif
res
[
'
base
'
]
==
-
2
:
# this section could be improved by moving the queries outside the loop:
# this section could be improved by moving the queries outside the loop:
where
=
[]
where
=
[]
...
@@ -410,7 +254,6 @@ class product_pricelist(osv.osv):
...
@@ -410,7 +254,6 @@ class product_pricelist(osv.osv):
res2
=
cr
.
dictfetchone
()
res2
=
cr
.
dictfetchone
()
if
res2
:
if
res2
:
price
=
res2
[
'
price
'
]
price
=
res2
[
'
price
'
]
break
else
:
else
:
price_type
=
price_type_obj
.
browse
(
cr
,
uid
,
int
(
res
[
'
base
'
]))
price_type
=
price_type_obj
.
browse
(
cr
,
uid
,
int
(
res
[
'
base
'
]))
price
=
currency_obj
.
compute
(
cr
,
uid
,
price
=
currency_obj
.
compute
(
cr
,
uid
,
...
...
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