Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
third-party
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cooperatic-foodcoops
third-party
Commits
1d83c96f
Commit
1d83c96f
authored
Nov 03, 2022
by
François C.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix wrong PO name displayed in Orders helper after PO has been created
parent
e29e6648
Pipeline
#2478
passed with stage
in 1 minute 29 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
62 deletions
+69
-62
models.py
orders/models.py
+68
-61
orders_helper.js
orders/static/js/orders_helper.js
+1
-1
No files found.
orders/models.py
View file @
1d83c96f
...
...
@@ -238,69 +238,76 @@ class Order(models.Model):
@staticmethod
def
create
(
supplier_id
,
date_planned
,
order_lines
):
order_data
=
{
"partner_id"
:
int
(
supplier_id
),
"partner_ref"
:
False
,
"currency_id"
:
1
,
"date_order"
:
datetime
.
datetime
.
now
()
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
),
"origin"
:
"Aide à la commande"
,
"company_id"
:
1
,
"order_line"
:
[],
"notes"
:
False
,
"date_planned"
:
date_planned
,
"picking_type_id"
:
1
,
"dest_address_id"
:
False
,
"incoterm_id"
:
False
,
"payment_term_id"
:
False
,
"fiscal_position_id"
:
False
,
"message_follower_ids"
:
False
,
"message_ids"
:
False
}
for
line
in
order_lines
:
product_line_name
=
line
[
"name"
]
if
"product_code"
in
line
and
line
[
"product_code"
]
is
not
False
:
product_code
=
str
(
line
[
"product_code"
])
product_line_name
=
"["
+
product_code
+
"] "
+
product_line_name
order_data
[
"order_line"
]
.
append
(
[
0
,
False
,
{
"package_qty"
:
line
[
"package_qty"
],
"price_policy"
:
"uom"
,
"indicative_package"
:
True
,
"product_id"
:
line
[
"product_variant_ids"
][
0
],
"name"
:
product_line_name
,
"date_planned"
:
date_planned
,
"account_analytic_id"
:
False
,
"product_qty_package"
:
line
[
"product_qty_package"
],
"product_qty"
:
line
[
"product_qty"
],
"product_uom"
:
line
[
"product_uom"
],
"price_unit"
:
line
[
"price_unit"
],
"discount"
:
0
,
"taxes_id"
:
[
[
6
,
False
,
line
[
"supplier_taxes_id"
]
res
=
{}
try
:
order_data
=
{
"partner_id"
:
int
(
supplier_id
),
"partner_ref"
:
False
,
"currency_id"
:
1
,
"date_order"
:
datetime
.
datetime
.
now
()
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
),
"origin"
:
"Aide à la commande"
,
"company_id"
:
1
,
"order_line"
:
[],
"notes"
:
False
,
"date_planned"
:
date_planned
,
"picking_type_id"
:
1
,
"dest_address_id"
:
False
,
"incoterm_id"
:
False
,
"payment_term_id"
:
False
,
"fiscal_position_id"
:
False
,
"message_follower_ids"
:
False
,
"message_ids"
:
False
}
for
line
in
order_lines
:
product_line_name
=
line
[
"name"
]
if
"product_code"
in
line
and
line
[
"product_code"
]
is
not
False
:
product_code
=
str
(
line
[
"product_code"
])
product_line_name
=
"["
+
product_code
+
"] "
+
product_line_name
order_data
[
"order_line"
]
.
append
(
[
0
,
False
,
{
"package_qty"
:
line
[
"package_qty"
],
"price_policy"
:
"uom"
,
"indicative_package"
:
True
,
"product_id"
:
line
[
"product_variant_ids"
][
0
],
"name"
:
product_line_name
,
"date_planned"
:
date_planned
,
"account_analytic_id"
:
False
,
"product_qty_package"
:
line
[
"product_qty_package"
],
"product_qty"
:
line
[
"product_qty"
],
"product_uom"
:
line
[
"product_uom"
],
"price_unit"
:
line
[
"price_unit"
],
"discount"
:
0
,
"taxes_id"
:
[
[
6
,
False
,
line
[
"supplier_taxes_id"
]
]
]
]
}
]
)
}
]
)
api
=
OdooAPI
()
id_po
=
api
.
create
(
'purchase.order'
,
order_data
)
res_confirm
=
api
.
execute
(
'purchase.order'
,
'button_confirm'
,
[
id_po
])
res
=
{
'id_po'
:
id_po
,
'confirm_po'
:
True
,
'supplier_id'
:
supplier_id
,
'date_planned'
:
date_planned
}
api
=
OdooAPI
()
id_po
=
api
.
create
(
'purchase.order'
,
order_data
)
res_confirm
=
api
.
execute
(
'purchase.order'
,
'button_confirm'
,
[
id_po
])
res_for_name
=
api
.
search_read
(
'purchase.order'
,
[[
'id'
,
'='
,
int
(
id_po
)]],
[
'display_name'
])
res
=
{
'id_po'
:
id_po
,
'display_name'
:
res_for_name
[
0
][
'display_name'
],
'confirm_po'
:
True
,
'supplier_id'
:
supplier_id
,
'date_planned'
:
date_planned
}
except
Exception
as
e
:
res
=
{
'error'
:
str
(
e
)}
coop_logger
.
error
(
"Error while creating PO :
%
s (order_data =
%
s order_lines =
%
s)"
,
str
(
e
),
str
(
order_data
),
str
(
order_lines
))
return
res
...
...
orders/static/js/orders_helper.js
View file @
1d83c96f
...
...
@@ -1344,7 +1344,7 @@ function create_orders() {
let
new_order_template
=
$
(
"#templates #new_order_item_template"
);
new_order_template
.
find
(
".new_order_supplier_name"
).
text
(
supplier_name
);
new_order_template
.
find
(
".new_order_po"
).
text
(
`
PO
${
new_order
.
id_po
}
`
);
new_order_template
.
find
(
".new_order_po"
).
text
(
`
${
new_order
.
display_name
}
`
);
new_order_template
.
find
(
".new_order_date_planned"
).
text
(
`Date de livraison prévue:
${
date_planned
}
`
);
new_order_template
.
find
(
".download_order_file_button"
).
attr
(
'id'
,
`download_attachment_
${
new_order
.
id_po
}
`
);
...
...
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