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
552143d0
Commit
552143d0
authored
Jan 09, 2023
by
François C.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Miscellious changes to make debug easier
parent
e180c8f7
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
100 additions
and
5 deletions
+100
-5
models.py
inventory/models.py
+29
-0
urls.py
inventory/urls.py
+1
-0
views.py
inventory/views.py
+11
-0
models.py
members/models.py
+31
-0
views.py
members_space/views.py
+14
-2
views.py
orders/views.py
+6
-1
urls.py
outils/urls.py
+1
-0
models.py
stock/models.py
+7
-2
No files found.
inventory/models.py
View file @
552143d0
...
...
@@ -456,6 +456,35 @@ class CagetteInventory(models.Model):
return
{
'missed'
:
missed
,
'done'
:
done
}
@staticmethod
def
general_reset_stock
(
qty
=
0
):
missed
=
[]
done
=
[]
api
=
OdooAPI
()
# cond = [['active', '=', False], ['qty_available', '!=', 0]]
cond
=
[[
'active'
,
'='
,
True
]]
fields
=
[
'uom_id'
,
'name'
,
'qty_available'
]
res
=
api
.
search_read
(
'product.product'
,
cond
,
fields
,
100
)
if
len
(
res
)
>
0
:
fields
=
{
'company_id'
:
1
,
'name'
:
'RAZ archivés'
,
'location_id'
:
settings
.
STOCK_LOC_ID
}
inv
=
api
.
create
(
'stock.inventory'
,
fields
)
if
not
(
inv
is
None
):
for
p
in
res
:
try
:
if
p
[
'qty_available'
]
!=
qty
:
fields
=
{
'product_id'
:
p
[
'id'
],
'inventory_id'
:
inv
,
'product_qty'
:
qty
,
'product_uom_id'
:
p
[
'uom_id'
][
0
],
'location_id'
:
settings
.
STOCK_LOC_ID
}
li
=
api
.
create
(
'stock.inventory.line'
,
fields
)
done
.
append
({
'product'
:
p
,
'id'
:
li
})
except
Exception
as
e
:
missed
.
append
({
'product'
:
p
,
'msg'
:
str
(
e
)})
api
.
execute
(
'stock.inventory'
,
'action_done'
,
[
inv
])
return
{
'missed'
:
missed
,
'done'
:
done
}
@staticmethod
def
raz_negative_stock
():
missed
=
[]
done
=
[]
...
...
inventory/urls.py
View file @
552143d0
...
...
@@ -16,6 +16,7 @@ urlpatterns = [
url
(
r'^get_product_categories$'
,
views
.
get_product_categories
),
url
(
r'^create_inventory$'
,
views
.
create_inventory
),
url
(
r'^update_odoo_stock$'
,
views
.
update_odoo_stock
),
url
(
r'^general_reset_stock/?([0-9]*)$'
,
views
.
general_reset_stock
),
url
(
r'^raz_archived_stock$'
,
views
.
raz_archived_stock
),
url
(
r'^raz_negative_stock$'
,
views
.
raz_negative_stock
),
url
(
r'^raz_not_saleable$'
,
views
.
raz_not_saleable
),
...
...
inventory/views.py
View file @
552143d0
...
...
@@ -168,6 +168,17 @@ def update_odoo_stock(request):
res
[
'msg'
]
=
'Forbidden'
return
JsonResponse
(
res
)
def
general_reset_stock
(
request
,
qty
):
res
=
{}
if
CagetteUser
.
are_credentials_ok
(
request
):
try
:
res
[
'action'
]
=
CagetteInventory
.
general_reset_stock
(
qty
)
except
Exception
as
e
:
res
[
'msg'
]
=
str
(
e
)
else
:
res
[
'msg'
]
=
'Forbidden'
return
JsonResponse
(
res
)
def
raz_archived_stock
(
request
):
res
=
{}
if
CagetteUser
.
are_credentials_ok
(
request
):
...
...
members/models.py
View file @
552143d0
...
...
@@ -1344,3 +1344,34 @@ class CagetteUser(models.Model):
pass
return
answer
@staticmethod
def
get_groups
(
request
):
groups
=
[]
if
'authtoken'
in
request
.
COOKIES
and
'uid'
in
request
.
COOKIES
:
api
=
OdooAPI
()
cond
=
[[
'id'
,
'='
,
request
.
COOKIES
[
'uid'
]]]
fields
=
[
'groups_id'
]
try
:
res
=
api
.
search_read
(
'res.users'
,
cond
,
fields
)
if
len
(
res
)
>
0
:
cond
=
[[
'id'
,
'in'
,
res
[
0
][
'groups_id'
]]]
fields
=
[
'full_name'
]
groups
=
api
.
search_read
(
'res.groups'
,
cond
,
fields
)
except
:
pass
return
groups
@staticmethod
def
isAllowedToAdmin
(
request
):
"""Need to create an odoo Group called 'django admin'."""
answer
=
False
groups
=
CagetteUser
.
get_groups
(
request
)
for
g
in
groups
:
if
g
[
'full_name'
]
==
'django admin'
:
answer
=
True
continue
return
answer
members_space/views.py
View file @
552143d0
...
...
@@ -176,12 +176,12 @@ def home(request):
Consequently, the front-end url should be unknown from the server so the user is redirected to the index,
then the front-end index will call this endpoint to load the home page
"""
if
'id'
in
request
.
COOKIES
:
partner_id
=
request
.
COOKIES
[
'id'
]
template
=
loader
.
get_template
(
getattr
(
settings
,
'MEMBERS_SPACE_HOME_TEMPLATE'
,
'members_space/home.html'
))
coop_can_change_shift_template
=
getattr
(
settings
,
'COOP_CAN_CHANGE_SHIFT_TEMPLATE'
,
False
)
if
coop_can_change_shift_template
is
True
:
# make further investigation only if COOP_CAN_CHANGE_SHIFT_TEMPLATE is True
if
'id'
in
request
.
COOKIES
:
partner_id
=
request
.
COOKIES
[
'id'
]
cs
=
CagetteShift
()
partnerData
=
cs
.
get_data_partner
(
partner_id
)
if
partnerData
[
'cooperative_state'
]
==
"unsubscribed"
:
...
...
@@ -201,9 +201,13 @@ def home(request):
if
'shop_opening_hours'
in
msettings
:
context
[
'shop_opening_hours'
]
=
msettings
[
'shop_opening_hours'
][
'value'
]
return
HttpResponse
(
template
.
render
(
context
,
request
))
else
:
# may occur : found in log
return
redirect
(
"../"
)
def
my_info
(
request
):
""" Endpoint the front-end will call to load the "My info" page. """
if
'id'
in
request
.
COOKIES
:
template
=
loader
.
get_template
(
'members_space/my_info.html'
)
context
=
{
'title'
:
'Mes Infos'
,
...
...
@@ -211,17 +215,23 @@ def my_info(request):
'understand_my_status_template'
:
getattr
(
settings
,
'MEMBERS_SPACE_UNDERSTAND_MY_STATUS_TEMPLATE'
,
"members_space/understand_my_status.html"
)
}
return
HttpResponse
(
template
.
render
(
context
,
request
))
else
:
return
redirect
(
"../"
)
def
my_shifts
(
request
):
""" Endpoint the front-end will call to load the "My shifts" page. """
if
'id'
in
request
.
COOKIES
:
template
=
loader
.
get_template
(
'members_space/my_shifts.html'
)
context
=
{
'title'
:
'Mes Services'
,
}
return
HttpResponse
(
template
.
render
(
context
,
request
))
else
:
return
redirect
(
"../"
)
def
shifts_exchange
(
request
):
""" Endpoint the front-end will call to load the "Shifts exchange" page. """
if
'id'
in
request
.
COOKIES
:
template
=
loader
.
get_template
(
getattr
(
settings
,
'MEMBERS_SPACE_SHIFTS_EXCHANGE_TEMPLATE'
,
'members_space/shifts_exchange.html'
))
m
=
CagetteMembersSpace
()
context
=
{
...
...
@@ -230,6 +240,8 @@ def shifts_exchange(request):
'extension_duration'
:
m
.
get_extension_duration
()
}
return
HttpResponse
(
template
.
render
(
context
,
request
))
else
:
return
redirect
(
"../"
)
def
faqBDM
(
request
):
template_path
=
getattr
(
settings
,
'MEMBERS_SPACE_FAQ_TEMPLATE'
,
'members_space/faq.html'
)
...
...
orders/views.py
View file @
552143d0
...
...
@@ -156,8 +156,13 @@ def export_one(request, oid):
'Qté'
,
'Référence'
,
'code-barre'
,
'Prix Unitaire'
,
'Remise'
,
'Sous-total'
])
for
line
in
order_data
[
'lines'
]:
taxes
+=
line
[
'price_tax'
]
if
'supplier_code'
in
line
:
supplier_code
=
line
[
'supplier_code'
]
else
:
supplier_code
=
""
# may occur : found in error log
ws1
.
append
([
line
[
'product_id'
][
1
],
line
[
'product_qty_package'
],
line
[
'package_qty'
],
line
[
'product_qty'
],
line
[
'supplier_code'
]
,
line
[
'barcode'
],
line
[
'price_unit'
],
line
[
'discount'
],
line
[
'price_subtotal'
]])
line
[
'product_qty'
],
supplier_code
,
line
[
'barcode'
],
line
[
'price_unit'
],
line
[
'discount'
],
line
[
'price_subtotal'
]])
ws1
.
append
([])
ws1
.
append
([
''
,
''
,
''
,
''
,
''
,
''
,
''
,
'Montant HT'
,
order_data
[
'order'
][
'amount_untaxed'
],
'euros'
])
ws1
.
append
([
''
,
''
,
''
,
''
,
''
,
''
,
''
,
'Taxes'
,
taxes
,
'euros'
])
...
...
outils/urls.py
View file @
552143d0
...
...
@@ -25,6 +25,7 @@ from .views import ExportOrders
urlpatterns
=
[
url
(
'^$'
,
RedirectView
.
as_view
(
url
=
'/members/inscriptions/2'
)),
url
(
r'^administration/'
,
include
(
'administration.urls'
)),
url
(
r'^data/(.*)'
,
views
.
data
),
url
(
r'^log_js_error$'
,
views
.
log_js_error
),
url
(
r'^test_compta$'
,
views
.
test_compta
),
...
...
stock/models.py
View file @
552143d0
...
...
@@ -35,7 +35,11 @@ class CagetteStock(models.Model):
@staticmethod
def
do_stock_movement
(
stock_movement_data
):
"""Do a stock movement : """
if
getattr
(
settings
,
'APP_ENV'
,
'prod'
)
==
'dev'
:
coop_logger
.
info
(
"do_stock_movement : reçu
%
s
%
s
%
s"
,
"movement type : "
+
str
(
stock_movement_data
[
'movement_type'
]),
"operator : "
+
str
(
stock_movement_data
[
'operator'
][
'name'
]),
"products : "
+
str
(
stock_movement_data
[
'products'
]))
TWOPLACES
=
Decimal
(
10
)
**
-
2
api
=
OdooAPI
()
errors
=
[]
...
...
@@ -115,7 +119,8 @@ class CagetteStock(models.Model):
"fresh_record"
:
False
}
])
if
getattr
(
settings
,
'APP_ENV'
,
'prod'
)
==
'dev'
:
coop_logger
.
info
(
"fields =
%
s"
,
str
(
fields
))
# Exception rises when odoo method returns nothing
marshal_none_error
=
'cannot marshal None unless allow_none is enabled'
try
:
...
...
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