Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chris
repanier
Commits
a5ec1709
Commit
a5ec1709
authored
Mar 20, 2017
by
Patrick
Browse files
Create purchase if needed when closing orders
parent
285b973d
Changes
1
Hide whitespace changes
Inline
Side-by-side
repanier/tools.py
View file @
a5ec1709
...
...
@@ -1315,6 +1315,21 @@ def create_or_update_one_purchase(customer, offer_item, q_order=None, batch_job=
is_box_content
=
is_box_content
).
order_by
(
'?'
).
first
()
if
batch_job
:
if
purchase
is
None
:
permanence
=
models
.
Permanence
.
objects
.
filter
(
id
=
offer_item
.
permanence_id
)
\
.
only
(
"permanence_date"
)
\
.
order_by
(
'?'
).
first
()
purchase
=
models
.
Purchase
.
objects
.
create
(
permanence_id
=
offer_item
.
permanence_id
,
permanence_date
=
permanence
.
permanence_date
,
offer_item_id
=
offer_item
.
id
,
producer_id
=
offer_item
.
producer_id
,
customer_id
=
customer
.
id
,
quantity_ordered
=
q_order
,
quantity_invoiced
=
DECIMAL_ZERO
,
is_box_content
=
is_box_content
,
status
=
PERMANENCE_OPENED
)
if
q_order
==
DECIMAL_ZERO
:
purchase
.
comment
=
_
(
"Cancelled qty : %s"
)
%
number_format
(
purchase
.
quantity_ordered
,
4
)
purchase
.
quantity_ordered
=
q_order
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment