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
37bd4c98
Commit
37bd4c98
authored
Jun 29, 2021
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AAC: fix & upgrade add product to supplier
parent
32241a99
Pipeline
#1110
failed with stage
in 1 minute 17 seconds
Changes
5
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
111 additions
and
18 deletions
+111
-18
oders_helper_style.css
orders/static/css/oders_helper_style.css
+20
-1
orders_helper.js
orders/static/js/orders_helper.js
+67
-11
views.py
orders/views.py
+1
-1
models.py
products/models.py
+9
-3
helper.html
templates/orders/helper.html
+14
-2
No files found.
orders/static/css/oders_helper_style.css
View file @
37bd4c98
...
...
@@ -135,7 +135,7 @@
/* -- Bottom action button */
#
orders_creation_area
{
#
main_content_footer
{
display
:
flex
;
justify-content
:
space-between
;
margin
:
15px
0
35px
0
;
...
...
@@ -160,6 +160,25 @@
cursor
:
pointer
;
}
/* -- Attach product to supplier modal */
.new_product_supplier_input_area
{
margin-bottom
:
15px
;
width
:
100%
;
display
:
flex
;
justify-content
:
center
;
}
.new_product_supplier_input
,
.new_product_supplier_label
{
width
:
50%
;
margin
:
0
15px
0
15px
;
}
.new_product_supplier_label
{
display
:
flex
;
justify-content
:
flex-end
;
align-items
:
center
;
}
/* - Orders created screen */
.order_created_header
{
...
...
orders/static/js/orders_helper.js
View file @
37bd4c98
...
...
@@ -19,7 +19,11 @@ var suppliers_list = [],
},
fingerprint
=
null
,
date_format
=
"dd/mm/yy"
product_orders
=
[];
product_orders
=
[],
new_product_supplier_association
=
{
package_qty
:
null
,
price
:
null
};
/* - UTILS */
...
...
@@ -28,9 +32,10 @@ var suppliers_list = [],
* Reset data that changes between screens
*/
function
reset_data
()
{
products
=
[],
selected_suppliers
=
[],
selected_rows
=
[],
products
=
[];
selected_suppliers
=
[];
selected_rows
=
[];
product_orders
=
[];
order_doc
=
{
_id
:
null
,
date_planned
:
null
,
...
...
@@ -41,6 +46,10 @@ function reset_data() {
products
:
[],
selected_suppliers
:
[]
};
new_product_supplier_association
=
{
package_qty
:
null
,
price
:
null
};
}
/**
...
...
@@ -225,9 +234,24 @@ function remove_supplier(supplier_id) {
function
save_supplier_product_association
(
product
,
supplier
,
cell
)
{
openModal
();
$
(
'.new_product_supplier_price'
).
off
();
$
(
'.new_product_supplier_package_pty'
).
off
();
const
package_qty
=
parseFloat
(
new_product_supplier_association
.
package_qty
);
const
price
=
parseFloat
(
new_product_supplier_association
.
price
);
// If value is a number
if
(
isNaN
(
package_qty
)
||
isNaN
(
price
))
{
closeModal
();
alert
(
`Les champs "Prix" et "Colisage" doivent être remplis et valides. L'association n'a pas été sauvegardée.`
)
return
-
1
;
}
const
data
=
{
product_tmpl_id
:
product
.
id
,
supplier_id
:
supplier
.
id
supplier_id
:
supplier
.
id
,
package_qty
:
package_qty
,
price
:
price
,
};
// Send request to create association
...
...
@@ -239,8 +263,18 @@ function save_supplier_product_association(product, supplier, cell) {
contentType
:
"application/json; charset=utf-8"
,
data
:
JSON
.
stringify
(
data
),
success
:
()
=>
{
// Save supplierinfo in product
if
(
!
'suppliersinfo'
in
product
)
{
product
.
suppliersinfo
=
[]
}
product
.
suppliersinfo
.
push
({
supplier_id
:
supplier
.
id
,
package_qty
:
package_qty
,
price
:
price
})
// Save relation locally
// TODO: save supplierinfo in product
save_supplier_products
(
supplier
,
[
product
]);
// Update table
...
...
@@ -674,8 +708,7 @@ function get_order_attachments() {
$
(
'#created_orders_area .download_order_file_loading'
).
hide
()
$
(
'#created_orders_area .download_order_file_button'
).
show
()
},
error
:
function
(
data
)
{
console
.
log
(
data
);
error
:
function
()
{
$
.
notify
(
"Échec de la récupération du lien de téléchargement des fichiers. Nouvelle tentative dans 10s."
,
{
...
...
@@ -907,7 +940,7 @@ function prepare_datatable_columns() {
function
display_products
(
params
)
{
if
(
products
.
length
==
0
)
{
$
(
'.main'
).
hide
();
$
(
'#
create_orders
'
).
hide
();
$
(
'#
main_content_footer
'
).
hide
();
$
(
'#do_inventory'
).
hide
();
return
-
1
;
...
...
@@ -953,7 +986,7 @@ function display_products(params) {
});
$
(
'.main'
).
show
();
$
(
'#
create_orders
'
).
show
();
$
(
'#
main_content_footer
'
).
show
();
$
(
'#do_inventory'
).
show
();
// On inputs change
...
...
@@ -1005,8 +1038,31 @@ function display_products(params) {
'Valider'
,
false
);
});
// Find existing price in another supplierinfo
let
default_price
=
null
;
for
(
let
psi
of
product
.
suppliersinfo
)
{
if
(
'price'
in
psi
&&
psi
.
price
!==
null
)
{
default_price
=
psi
.
price
;
break
;
}
}
// Set default value for price & package qty for new supplierinfo
$
(
".new_product_supplier_package_pty"
).
val
(
1
);
// Default package qty is 1
$
(
".new_product_supplier_price"
).
val
(
default_price
);
// Default price is existing price for other supplier
new_product_supplier_association
=
{
package_qty
:
1
,
price
:
default_price
}
$
(
'.new_product_supplier_price'
).
on
(
'input'
,
function
()
{
new_product_supplier_association
.
price
=
$
(
this
).
val
();
});
$
(
'.new_product_supplier_package_pty'
).
on
(
'input'
,
function
()
{
new_product_supplier_association
.
package_qty
=
$
(
this
).
val
();
});
});
// Select row(s) on checkbox change
$
(
products_table
.
table
().
header
()).
on
(
'click'
,
'th #select_all_products_cb'
,
function
()
{
if
(
this
.
checked
)
{
...
...
orders/views.py
View file @
37bd4c98
...
...
@@ -54,7 +54,7 @@ def associate_supplier_to_product(request):
res
=
{}
try
:
data
=
json
.
loads
(
request
.
body
.
decode
())
res
=
CagetteProduct
.
associate_supplier_to_product
(
data
[
"product_tmpl_id"
],
data
[
"supplier_id"
]
)
res
=
CagetteProduct
.
associate_supplier_to_product
(
data
)
except
Exception
as
e
:
res
[
"error"
]
=
str
(
e
)
return
JsonResponse
(
res
,
status
=
500
)
...
...
products/models.py
View file @
37bd4c98
...
...
@@ -128,9 +128,14 @@ class CagetteProduct(models.Model):
return
res
@staticmethod
def
associate_supplier_to_product
(
product_tmpl_id
,
partner_id
):
def
associate_supplier_to_product
(
data
):
api
=
OdooAPI
()
product_tmpl_id
=
data
[
"product_tmpl_id"
]
partner_id
=
data
[
"supplier_id"
]
package_qty
=
data
[
"package_qty"
]
price
=
data
[
"price"
]
f
=
[
"id"
,
"standard_price"
,
"purchase_ok"
]
c
=
[[
'product_tmpl_id'
,
'='
,
product_tmpl_id
]]
res_products
=
api
.
search_read
(
'product.product'
,
c
,
f
)
...
...
@@ -141,8 +146,9 @@ class CagetteProduct(models.Model):
'product_id'
:
product
[
"id"
],
'name'
:
partner_id
,
'product_purchase_ok'
:
product
[
"purchase_ok"
],
'price'
:
product
[
"standard_price"
],
# By default, use product price
'base_price'
:
product
[
"standard_price"
],
'price'
:
price
,
'base_price'
:
price
,
'package_qty'
:
package_qty
}
res
=
api
.
create
(
'product.supplierinfo'
,
f
)
...
...
templates/orders/helper.html
View file @
37bd4c98
...
...
@@ -60,7 +60,7 @@
</div>
</div>
<div
id=
"
orders_creation_area
"
>
<div
id=
"
main_content_footer"
style=
"display:none;
"
>
<div
class=
"add_product_container"
>
<div
id=
"product_form_container"
>
<form
action=
"javascript:;"
id=
"product_form"
>
...
...
@@ -69,7 +69,7 @@
</form>
</div>
</div>
<button
type=
"button"
class=
'btn--primary'
id=
"create_orders"
style=
"display:none;"
>
<button
type=
"button"
class=
'btn--primary'
id=
"create_orders"
>
Générer les commandes
</button>
</div>
...
...
@@ -160,6 +160,18 @@
<h3>
Attention !
</h3>
<p>
Vous vous apprêtez à associer le produit
<span
class=
"product_name"
></span>
au fournisseur
<span
class=
"supplier_name"
></span>
.
<br/>
</p>
<br/>
<div
class=
"new_product_supplier_input_area"
>
<span
class=
"new_product_supplier_label"
>
Prix du produit chez ce fournisseur:
</span>
<input
type=
"number"
class=
"new_product_supplier_input new_product_supplier_price"
>
</div>
<div
class=
"new_product_supplier_input_area"
>
<span
class=
"new_product_supplier_label"
>
Colisage chez ce fournisseur:
</span>
<input
type=
"number"
class=
"new_product_supplier_input new_product_supplier_package_pty"
>
</div>
<br/>
<p>
L'association sera sauvegardée dès que vous aurez cliqué sur "Valider".
<br/>
</p>
<p>
Êtez-vous sûr ?
</p>
...
...
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