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
0
Merge Requests
0
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
Alexis AOUN
third-party
Commits
d59c0d4b
Commit
d59c0d4b
authored
Jun 29, 2021
by
Damien Moulard
Committed by
Alexis Aoun
Jul 06, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AAC: fix & upgrade add product to supplier
parent
67eba34c
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
145 additions
and
17 deletions
+145
-17
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
+48
-1
No files found.
orders/static/css/oders_helper_style.css
View file @
d59c0d4b
...
...
@@ -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 @
d59c0d4b
...
...
@@ -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
};
}
/**
...
...
@@ -214,9 +223,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
...
...
@@ -228,8 +252,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
...
...
@@ -663,8 +697,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."
,
{
...
...
@@ -896,7 +929,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
;
...
...
@@ -942,7 +975,7 @@ function display_products(params) {
});
$
(
'.main'
).
show
();
$
(
'#
create_orders
'
).
show
();
$
(
'#
main_content_footer
'
).
show
();
$
(
'#do_inventory'
).
show
();
// On inputs change
...
...
@@ -994,8 +1027,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 @
d59c0d4b
...
...
@@ -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 @
d59c0d4b
...
...
@@ -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 @
d59c0d4b
...
...
@@ -59,13 +59,48 @@
<table
id=
"products_table"
class=
"display"
cellspacing=
"0"
width=
"100%"
></table>
</div>
</div>
<div
id=
"product_form_container"
style=
"margin-bottom: 50px;"
>
<div
id=
"main_content_footer"
style=
"display:none;"
>
<div
class=
"add_product_container"
>
<div
id=
"product_form_container"
>
<form
action=
"javascript:;"
id=
"product_form"
>
<input
type=
"text"
name=
"article"
id=
"product_input"
placeholder=
"Rechercher un article"
>
<button
type=
"submit"
class=
'btn--primary'
>
Ajouter l'article
</button>
</form>
</div>
</div>
<button
type=
"button"
class=
'btn--primary'
id=
"create_orders"
>
Générer les commandes
</button>
</div>
</div>
<div
id=
"orders_created"
class=
"page_content"
style=
"display:none;"
>
<div
id=
"back_to_order_selection_from_orders_created"
>
<button
type=
"button"
class=
"btn--danger"
><i
class=
"fas fa-arrow-left"
></i>
Retour
</button>
</div>
<div
class=
"order_created_header txtcenter"
>
<h2>
Commandes créées !
</h2>
</div>
<div
class=
"txtcenter"
>
Livraison prévue le :
<span
id=
"recap_delivery_date"
>
XX/XX/XX
</span>
</div>
<div
id=
"created_orders_area"
></div>
<br/><br/><hr/><br/>
<div
class=
"mail_example_container"
>
<p
class=
"mail_type_text"
>
Mail type :
</p>
<div
class=
"mail_example"
>
Objet : Cde Cagette JJ/MM
<br/>
<br/>
Bonjour XXXXXXX,
<br/>
<br/>
Voici la commande de La Cagette pour le XX/XX/XX.
<br/>
<br/>
Merci d'avance,
<br/>
Bonne journée
</div>
</div>
</div>
<div
id=
"templates"
style=
"display:none;"
>
<div
id=
"supplier_pill_template"
>
...
...
@@ -125,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