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
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
142 additions
and
47 deletions
+142
-47
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
+56
-44
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):
...
@@ -456,6 +456,35 @@ class CagetteInventory(models.Model):
return
{
'missed'
:
missed
,
'done'
:
done
}
return
{
'missed'
:
missed
,
'done'
:
done
}
@staticmethod
@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
():
def
raz_negative_stock
():
missed
=
[]
missed
=
[]
done
=
[]
done
=
[]
...
...
inventory/urls.py
View file @
552143d0
...
@@ -16,6 +16,7 @@ urlpatterns = [
...
@@ -16,6 +16,7 @@ urlpatterns = [
url
(
r'^get_product_categories$'
,
views
.
get_product_categories
),
url
(
r'^get_product_categories$'
,
views
.
get_product_categories
),
url
(
r'^create_inventory$'
,
views
.
create_inventory
),
url
(
r'^create_inventory$'
,
views
.
create_inventory
),
url
(
r'^update_odoo_stock$'
,
views
.
update_odoo_stock
),
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_archived_stock$'
,
views
.
raz_archived_stock
),
url
(
r'^raz_negative_stock$'
,
views
.
raz_negative_stock
),
url
(
r'^raz_negative_stock$'
,
views
.
raz_negative_stock
),
url
(
r'^raz_not_saleable$'
,
views
.
raz_not_saleable
),
url
(
r'^raz_not_saleable$'
,
views
.
raz_not_saleable
),
...
...
inventory/views.py
View file @
552143d0
...
@@ -168,6 +168,17 @@ def update_odoo_stock(request):
...
@@ -168,6 +168,17 @@ def update_odoo_stock(request):
res
[
'msg'
]
=
'Forbidden'
res
[
'msg'
]
=
'Forbidden'
return
JsonResponse
(
res
)
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
):
def
raz_archived_stock
(
request
):
res
=
{}
res
=
{}
if
CagetteUser
.
are_credentials_ok
(
request
):
if
CagetteUser
.
are_credentials_ok
(
request
):
...
...
members/models.py
View file @
552143d0
...
@@ -1344,3 +1344,34 @@ class CagetteUser(models.Model):
...
@@ -1344,3 +1344,34 @@ class CagetteUser(models.Model):
pass
pass
return
answer
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,60 +176,72 @@ def home(request):
...
@@ -176,60 +176,72 @@ def home(request):
Consequently, the front-end url should be unknown from the server so the user is redirected to the index,
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
then the front-end index will call this endpoint to load the home page
"""
"""
template
=
loader
.
get_template
(
getattr
(
settings
,
'MEMBERS_SPACE_HOME_TEMPLATE'
,
'members_space/home.html'
))
if
'id'
in
request
.
COOKIES
:
coop_can_change_shift_template
=
getattr
(
settings
,
'COOP_CAN_CHANGE_SHIFT_TEMPLATE'
,
False
)
partner_id
=
request
.
COOKIES
[
'id'
]
if
coop_can_change_shift_template
is
True
:
template
=
loader
.
get_template
(
getattr
(
settings
,
'MEMBERS_SPACE_HOME_TEMPLATE'
,
'members_space/home.html'
))
# make further investigation only if COOP_CAN_CHANGE_SHIFT_TEMPLATE is True
coop_can_change_shift_template
=
getattr
(
settings
,
'COOP_CAN_CHANGE_SHIFT_TEMPLATE'
,
False
)
if
'id'
in
request
.
COOKIES
:
if
coop_can_change_shift_template
is
True
:
partner_id
=
request
.
COOKIES
[
'id'
]
# make further investigation only if COOP_CAN_CHANGE_SHIFT_TEMPLATE is True
cs
=
CagetteShift
()
cs
=
CagetteShift
()
partnerData
=
cs
.
get_data_partner
(
partner_id
)
partnerData
=
cs
.
get_data_partner
(
partner_id
)
if
partnerData
[
'cooperative_state'
]
==
"unsubscribed"
:
if
partnerData
[
'cooperative_state'
]
==
"unsubscribed"
:
coop_can_change_shift_template
=
False
if
getattr
(
settings
,
'ASSOCIATE_PEOPLE_CAN_CHANGE_SHIFT_TEMPLE_REGISTRATION'
,
False
)
is
False
:
if
partnerData
[
'is_associated_people'
]
is
True
:
coop_can_change_shift_template
=
False
coop_can_change_shift_template
=
False
context
=
{
if
getattr
(
settings
,
'ASSOCIATE_PEOPLE_CAN_CHANGE_SHIFT_TEMPLE_REGISTRATION'
,
False
)
is
False
:
'title'
:
'Espace Membres'
,
if
partnerData
[
'is_associated_people'
]
is
True
:
'coop_can_change_shift_template'
:
coop_can_change_shift_template
,
coop_can_change_shift_template
=
False
'max_begin_hour'
:
settings
.
MAX_BEGIN_HOUR
,
context
=
{
}
'title'
:
'Espace Membres'
,
# Get messages to display
'coop_can_change_shift_template'
:
coop_can_change_shift_template
,
msettings
=
MConfig
.
get_settings
(
'members'
)
'max_begin_hour'
:
settings
.
MAX_BEGIN_HOUR
,
if
'msg_accueil'
in
msettings
:
}
context
[
'msg_accueil'
]
=
msettings
[
'msg_accueil'
][
'value'
]
# Get messages to display
if
'shop_opening_hours'
in
msettings
:
msettings
=
MConfig
.
get_settings
(
'members'
)
context
[
'shop_opening_hours'
]
=
msettings
[
'shop_opening_hours'
][
'value'
]
if
'msg_accueil'
in
msettings
:
return
HttpResponse
(
template
.
render
(
context
,
request
))
context
[
'msg_accueil'
]
=
msettings
[
'msg_accueil'
][
'value'
]
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
):
def
my_info
(
request
):
""" Endpoint the front-end will call to load the "My info" page. """
""" Endpoint the front-end will call to load the "My info" page. """
template
=
loader
.
get_template
(
'members_space/my_info.html'
)
if
'id'
in
request
.
COOKIES
:
context
=
{
template
=
loader
.
get_template
(
'members_space/my_info.html'
)
'title'
:
'Mes Infos'
,
context
=
{
'understand_my_status'
:
getattr
(
settings
,
'MEMBERS_SPACE_SHOW_UNDERSTAND_MY_STATUS'
,
True
),
'title'
:
'Mes Infos'
,
'understand_my_status_template'
:
getattr
(
settings
,
'MEMBERS_SPACE_UNDERSTAND_MY_STATUS_TEMPLATE'
,
"members_space/understand_my_status.html"
)
'understand_my_status'
:
getattr
(
settings
,
'MEMBERS_SPACE_SHOW_UNDERSTAND_MY_STATUS'
,
True
),
}
'understand_my_status_template'
:
getattr
(
settings
,
'MEMBERS_SPACE_UNDERSTAND_MY_STATUS_TEMPLATE'
,
"members_space/understand_my_status.html"
)
return
HttpResponse
(
template
.
render
(
context
,
request
))
}
return
HttpResponse
(
template
.
render
(
context
,
request
))
else
:
return
redirect
(
"../"
)
def
my_shifts
(
request
):
def
my_shifts
(
request
):
""" Endpoint the front-end will call to load the "My shifts" page. """
""" Endpoint the front-end will call to load the "My shifts" page. """
template
=
loader
.
get_template
(
'members_space/my_shifts.html'
)
if
'id'
in
request
.
COOKIES
:
context
=
{
template
=
loader
.
get_template
(
'members_space/my_shifts.html'
)
'title'
:
'Mes Services'
,
context
=
{
}
'title'
:
'Mes Services'
,
return
HttpResponse
(
template
.
render
(
context
,
request
))
}
return
HttpResponse
(
template
.
render
(
context
,
request
))
else
:
return
redirect
(
"../"
)
def
shifts_exchange
(
request
):
def
shifts_exchange
(
request
):
""" Endpoint the front-end will call to load the "Shifts exchange" page. """
""" Endpoint the front-end will call to load the "Shifts exchange" page. """
template
=
loader
.
get_template
(
getattr
(
settings
,
'MEMBERS_SPACE_SHIFTS_EXCHANGE_TEMPLATE'
,
'members_space/shifts_exchange.html'
))
if
'id'
in
request
.
COOKIES
:
m
=
CagetteMembersSpace
()
template
=
loader
.
get_template
(
getattr
(
settings
,
'MEMBERS_SPACE_SHIFTS_EXCHANGE_TEMPLATE'
,
'members_space/shifts_exchange.html'
))
context
=
{
m
=
CagetteMembersSpace
()
'title'
:
'Échange de Services'
,
context
=
{
'canAddShift'
:
getattr
(
settings
,
'CAN_ADD_SHIFT'
,
False
),
'title'
:
'Échange de Services'
,
'extension_duration'
:
m
.
get_extension_duration
()
'canAddShift'
:
getattr
(
settings
,
'CAN_ADD_SHIFT'
,
False
),
}
'extension_duration'
:
m
.
get_extension_duration
()
return
HttpResponse
(
template
.
render
(
context
,
request
))
}
return
HttpResponse
(
template
.
render
(
context
,
request
))
else
:
return
redirect
(
"../"
)
def
faqBDM
(
request
):
def
faqBDM
(
request
):
template_path
=
getattr
(
settings
,
'MEMBERS_SPACE_FAQ_TEMPLATE'
,
'members_space/faq.html'
)
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):
...
@@ -156,8 +156,13 @@ def export_one(request, oid):
'Qté'
,
'Référence'
,
'code-barre'
,
'Prix Unitaire'
,
'Remise'
,
'Sous-total'
])
'Qté'
,
'Référence'
,
'code-barre'
,
'Prix Unitaire'
,
'Remise'
,
'Sous-total'
])
for
line
in
order_data
[
'lines'
]:
for
line
in
order_data
[
'lines'
]:
taxes
+=
line
[
'price_tax'
]
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'
],
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
([])
ws1
.
append
([
''
,
''
,
''
,
''
,
''
,
''
,
''
,
'Montant HT'
,
order_data
[
'order'
][
'amount_untaxed'
],
'euros'
])
ws1
.
append
([
''
,
''
,
''
,
''
,
''
,
''
,
''
,
'Montant HT'
,
order_data
[
'order'
][
'amount_untaxed'
],
'euros'
])
ws1
.
append
([
''
,
''
,
''
,
''
,
''
,
''
,
''
,
'Taxes'
,
taxes
,
'euros'
])
ws1
.
append
([
''
,
''
,
''
,
''
,
''
,
''
,
''
,
'Taxes'
,
taxes
,
'euros'
])
...
...
outils/urls.py
View file @
552143d0
...
@@ -25,6 +25,7 @@ from .views import ExportOrders
...
@@ -25,6 +25,7 @@ from .views import ExportOrders
urlpatterns
=
[
urlpatterns
=
[
url
(
'^$'
,
RedirectView
.
as_view
(
url
=
'/members/inscriptions/2'
)),
url
(
'^$'
,
RedirectView
.
as_view
(
url
=
'/members/inscriptions/2'
)),
url
(
r'^administration/'
,
include
(
'administration.urls'
)),
url
(
r'^data/(.*)'
,
views
.
data
),
url
(
r'^data/(.*)'
,
views
.
data
),
url
(
r'^log_js_error$'
,
views
.
log_js_error
),
url
(
r'^log_js_error$'
,
views
.
log_js_error
),
url
(
r'^test_compta$'
,
views
.
test_compta
),
url
(
r'^test_compta$'
,
views
.
test_compta
),
...
...
stock/models.py
View file @
552143d0
...
@@ -35,7 +35,11 @@ class CagetteStock(models.Model):
...
@@ -35,7 +35,11 @@ class CagetteStock(models.Model):
@staticmethod
@staticmethod
def
do_stock_movement
(
stock_movement_data
):
def
do_stock_movement
(
stock_movement_data
):
"""Do a stock movement : """
"""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
TWOPLACES
=
Decimal
(
10
)
**
-
2
api
=
OdooAPI
()
api
=
OdooAPI
()
errors
=
[]
errors
=
[]
...
@@ -115,7 +119,8 @@ class CagetteStock(models.Model):
...
@@ -115,7 +119,8 @@ class CagetteStock(models.Model):
"fresh_record"
:
False
"fresh_record"
:
False
}
}
])
])
if
getattr
(
settings
,
'APP_ENV'
,
'prod'
)
==
'dev'
:
coop_logger
.
info
(
"fields =
%
s"
,
str
(
fields
))
# Exception rises when odoo method returns nothing
# Exception rises when odoo method returns nothing
marshal_none_error
=
'cannot marshal None unless allow_none is enabled'
marshal_none_error
=
'cannot marshal None unless allow_none is enabled'
try
:
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