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
c2b7bca4
Commit
c2b7bca4
authored
10 years ago
by
Nicolas Seinlet
Committed by
Josse Colpaert
10 years ago
Browse files
Options
Downloads
Patches
Plain Diff
- Fix #1253
- avoid using sale objects in stock_account module - check the purchase side
parent
2bd1ec9e
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
addons/purchase/stock.py
+8
-0
8 additions, 0 deletions
addons/purchase/stock.py
addons/sale_stock/sale_stock.py
+11
-0
11 additions, 0 deletions
addons/sale_stock/sale_stock.py
addons/stock_account/stock.py
+10
-8
10 additions, 8 deletions
addons/stock_account/stock.py
with
29 additions
and
8 deletions
addons/purchase/stock.py
+
8
−
0
View file @
c2b7bca4
...
...
@@ -83,6 +83,14 @@ class stock_move(osv.osv):
class
stock_picking
(
osv
.
osv
):
_inherit
=
'
stock.picking
'
def
_get_partner_to_invoice
(
self
,
cr
,
uid
,
picking
,
context
=
None
):
"""
Inherit the original function of the
'
stock
'
module
We select the partner of the purchase order as the partner of the invoice
"""
if
picking
.
move_lines
and
picking
.
move_lines
[
0
]
and
picking
.
move_lines
[
0
].
purchase_line_id
:
return
picking
.
move_lines
[
0
].
purchase_line_id
.
order_id
.
partner_id
and
picking
.
move_lines
[
0
].
purchase_line_id
.
order_id
.
partner_id
.
id
return
super
(
stock_picking
,
self
).
_get_partner_to_invoice
(
cr
,
uid
,
picking
,
context
=
context
)
def
_get_to_invoice
(
self
,
cr
,
uid
,
ids
,
name
,
args
,
context
=
None
):
res
=
{}
for
picking
in
self
.
browse
(
cr
,
uid
,
ids
,
context
=
context
):
...
...
This diff is collapsed.
Click to expand it.
addons/sale_stock/sale_stock.py
+
11
−
0
View file @
c2b7bca4
...
...
@@ -396,6 +396,17 @@ class stock_location_route(osv.osv):
class
stock_picking
(
osv
.
osv
):
_inherit
=
"
stock.picking
"
def
_get_partner_to_invoice
(
self
,
cr
,
uid
,
picking
,
context
=
None
):
"""
Inherit the original function of the
'
stock
'
module
We select the partner of the sales order as the partner of the customer invoice
"""
saleorder_ids
=
self
.
pool
[
'
sale.order
'
].
search
(
cr
,
uid
,
[(
'
procurement_group_id
'
,
'
=
'
,
picking
.
group_id
.
id
)],
context
=
context
)
saleorders
=
self
.
pool
[
'
sale.order
'
].
browse
(
cr
,
uid
,
saleorder_ids
,
context
=
context
)
if
saleorders
and
saleorders
[
0
]:
saleorder
=
saleorders
[
0
]
return
saleorder
.
partner_invoice_id
.
id
return
super
(
stock_picking
,
self
).
_get_partner_to_invoice
(
cr
,
uid
,
picking
,
context
=
context
)
def
_get_sale_id
(
self
,
cr
,
uid
,
ids
,
name
,
args
,
context
=
None
):
sale_obj
=
self
.
pool
.
get
(
"
sale.order
"
)
res
=
{}
...
...
This diff is collapsed.
Click to expand it.
addons/stock_account/stock.py
+
10
−
8
View file @
c2b7bca4
...
...
@@ -190,6 +190,14 @@ class stock_picking(osv.osv):
invoice_obj
=
self
.
pool
.
get
(
'
account.invoice
'
)
return
invoice_obj
.
create
(
cr
,
uid
,
vals
,
context
=
context
)
def
_get_partner_to_invoice
(
self
,
cr
,
uid
,
picking
,
context
=
None
):
"""
Gets the partner that will be invoiced
Note that this function is inherited in the sale and purchase modules
@param picking: object of the picking for which we are selecting the partner to invoice
@return: object of the partner to invoice
"""
return
picking
.
partner_id
and
picking
.
partner_id
.
id
def
action_invoice_create
(
self
,
cr
,
uid
,
ids
,
journal_id
,
group
=
False
,
type
=
'
out_invoice
'
,
context
=
None
):
"""
Creates invoice based on the invoice state selected for picking.
@param journal_id: Id of journal
...
...
@@ -197,20 +205,14 @@ class stock_picking(osv.osv):
@param type: Type invoice to be created
@return: Ids of created invoices for the pickings
"""
saleorder_model
=
self
.
pool
[
'
sale.order
'
]
context
=
context
or
{}
todo
=
{}
for
picking
in
self
.
browse
(
cr
,
uid
,
ids
,
context
=
context
):
partner
=
self
.
_get_partner_to_invoice
(
cr
,
uid
,
picking
,
context
)
#grouping is based on the invoiced partner
if
group
:
saleorder_ids
=
saleorder_model
.
search
(
cr
,
uid
,
[(
'
procurement_group_id
'
,
'
=
'
,
picking
.
group_id
.
id
)],
context
=
context
)
saleorders
=
saleorder_model
.
browse
(
cr
,
uid
,
saleorder_ids
,
context
=
context
)
if
saleorders
and
saleorders
[
0
]:
saleorder
=
saleorders
[
0
]
key
=
"
%s
"
%
saleorder
.
partner_invoice_id
.
id
else
:
key
=
"
Pick %s
"
%
picking
.
id
key
=
partner
else
:
key
=
picking
.
id
for
move
in
picking
.
move_lines
:
...
...
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