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
f1d5dfa8
Commit
f1d5dfa8
authored
10 years ago
by
Olivier Dony
Browse files
Options
Downloads
Patches
Plain Diff
[IMP] sale_stock: do not verify inventory for non-stockable products (sale.order.line onchange)
parent
0c204037
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/sale_stock/sale_stock.py
+33
-32
33 additions, 32 deletions
addons/sale_stock/sale_stock.py
with
33 additions
and
32 deletions
addons/sale_stock/sale_stock.py
+
33
−
32
View file @
f1d5dfa8
...
...
@@ -301,42 +301,43 @@ class sale_order_line(osv.osv):
res
[
'
value
'
].
update
(
res_packing
.
get
(
'
value
'
,
{}))
warning_msgs
=
res_packing
.
get
(
'
warning
'
)
and
res_packing
[
'
warning
'
][
'
message
'
]
or
''
#determine if the product is MTO or not (for a further check)
isMto
=
False
if
warehouse_id
:
warehouse
=
self
.
pool
.
get
(
'
stock.warehouse
'
).
browse
(
cr
,
uid
,
warehouse_id
,
context
=
context
)
for
product_route
in
product_obj
.
route_ids
:
if
warehouse
.
mto_pull_id
and
warehouse
.
mto_pull_id
.
route_id
and
warehouse
.
mto_pull_id
.
route_id
.
id
==
product_route
.
id
:
isMto
=
True
break
else
:
try
:
mto_route_id
=
self
.
pool
.
get
(
'
ir.model.data
'
).
get_object
(
cr
,
uid
,
'
stock
'
,
'
route_warehouse0_mto
'
).
id
except
:
# if route MTO not found in ir_model_data, we treat the product as in MTS
mto_route_id
=
False
if
mto_route_id
:
if
product_obj
.
type
==
'
product
'
:
#determine if the product is MTO or not (for a further check)
isMto
=
False
if
warehouse_id
:
warehouse
=
self
.
pool
.
get
(
'
stock.warehouse
'
).
browse
(
cr
,
uid
,
warehouse_id
,
context
=
context
)
for
product_route
in
product_obj
.
route_ids
:
if
product_
route
.
id
==
mto
_route
_
id
:
if
warehouse
.
mto_pull_id
and
warehouse
.
mto_pull_id
.
route_id
and
warehouse
.
mto_pull_id
.
route
_id
.
id
==
product
_route
.
id
:
isMto
=
True
break
else
:
try
:
mto_route_id
=
self
.
pool
.
get
(
'
ir.model.data
'
).
get_object
(
cr
,
uid
,
'
stock
'
,
'
route_warehouse0_mto
'
).
id
except
:
# if route MTO not found in ir_model_data, we treat the product as in MTS
mto_route_id
=
False
if
mto_route_id
:
for
product_route
in
product_obj
.
route_ids
:
if
product_route
.
id
==
mto_route_id
:
isMto
=
True
break
#check if product is available, and if not: raise a warning, but do this only for products that aren't processed in MTO
if
not
isMto
:
uom2
=
False
if
uom
:
uom2
=
product_uom_obj
.
browse
(
cr
,
uid
,
uom
,
context
=
context
)
if
product_obj
.
uom_id
.
category_id
.
id
!=
uom
2
.
category_id
.
id
:
uom
=
False
if
not
uom
2
:
uom2
=
product_obj
.
uom_id
compare_qty
=
float_compare
(
product_obj
.
virtual_available
,
qty
,
precision_rounding
=
uom
2
.
rounding
)
if
(
product_obj
.
type
==
'
product
'
)
and
int
(
compare_qty
)
==
-
1
:
warn_msg
=
_
(
'
You plan to sell %.2f %s but you only have %.2f %s available !
\n
The real stock is %.2f %s. (without reservations)
'
)
%
\
(
qty
,
uom
2
.
name
,
max
(
0
,
product_obj
.
virtual_available
),
uom
2
.
name
,
max
(
0
,
product_obj
.
qty_available
),
uom
2
.
name
)
warning_msgs
+=
_
(
"
Not enough stock ! :
"
)
+
warn_msg
+
"
\n\n
"
#check if product is available, and if not: raise a warning, but do this only for products that aren't processed in MTO
if
not
isMto
:
uom_record
=
False
if
uom
:
uom_record
=
product_uom_obj
.
browse
(
cr
,
uid
,
uom
,
context
=
context
)
if
product_obj
.
uom_id
.
category_id
.
id
!=
uom
_record
.
category_id
.
id
:
uom_record
=
False
if
not
uom
_record
:
uom_record
=
product_obj
.
uom_id
compare_qty
=
float_compare
(
product_obj
.
virtual_available
,
qty
,
precision_rounding
=
uom
_record
.
rounding
)
if
compare_qty
==
-
1
:
warn_msg
=
_
(
'
You plan to sell %.2f %s but you only have %.2f %s available !
\n
The real stock is %.2f %s. (without reservations)
'
)
%
\
(
qty
,
uom
_record
.
name
,
max
(
0
,
product_obj
.
virtual_available
),
uom
_record
.
name
,
max
(
0
,
product_obj
.
qty_available
),
uom
_record
.
name
)
warning_msgs
+=
_
(
"
Not enough stock ! :
"
)
+
warn_msg
+
"
\n\n
"
#update of warning messages
if
warning_msgs
:
...
...
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