Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chris
repanier
Commits
5a3fbcd9
Commit
5a3fbcd9
authored
Mar 21, 2017
by
Patrick
Browse files
Add is_group field to customer to simplify the logic
parent
a5ec1709
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
repanier/admin/customer.py
View file @
5a3fbcd9
...
...
@@ -142,6 +142,7 @@ class CustomerResource(resources.ModelResource):
date_balance
=
fields
.
Field
(
attribute
=
'get_admin_date_balance'
,
widget
=
DateWidgetExcel
(),
readonly
=
True
)
balance
=
fields
.
Field
(
attribute
=
'get_admin_balance'
,
widget
=
TwoMoneysWidget
(),
readonly
=
True
)
may_order
=
fields
.
Field
(
attribute
=
'may_order'
,
default
=
False
,
widget
=
DecimalBooleanWidget
(),
readonly
=
False
)
is_group
=
fields
.
Field
(
attribute
=
'is_group'
,
default
=
False
,
widget
=
DecimalBooleanWidget
(),
readonly
=
False
)
represent_this_buyinggroup
=
fields
.
Field
(
attribute
=
'represent_this_buyinggroup'
,
widget
=
DecimalBooleanWidget
(),
readonly
=
True
)
is_active
=
fields
.
Field
(
attribute
=
'is_active'
,
widget
=
DecimalBooleanWidget
(),
readonly
=
True
)
...
...
@@ -202,7 +203,8 @@ class CustomerResource(resources.ModelResource):
'bank_account1'
,
'bank_account2'
,
'date_balance'
,
'balance'
,
'price_list_multiplier'
,
'membership_fee_valid_until'
,
'last_membership_fee'
,
'last_membership_fee_date'
,
'participation'
,
'purchase'
,
'represent_this_buyinggroup'
,
'is_active'
,
'delivery_point'
,
'valid_email'
'participation'
,
'purchase'
,
'represent_this_buyinggroup'
,
'is_group'
,
'is_active'
,
'delivery_point'
,
'valid_email'
)
export_order
=
fields
import_id_fields
=
(
'id'
,)
...
...
@@ -239,7 +241,7 @@ class CustomerWithUserDataAdmin(ImportExportMixin, admin.ModelAdmin):
search_fields
=
(
'short_basket_name'
,
'long_basket_name'
,
'user__email'
,
'email2'
)
list_per_page
=
16
list_max_show_all
=
16
list_filter
=
(
'is_active'
,
'may_order'
,
'valid_email'
)
list_filter
=
(
'is_active'
,
'may_order'
,
'is_group'
,
'valid_email'
)
def
has_delete_permission
(
self
,
request
,
customer
=
None
):
if
request
.
user
.
groups
.
filter
(
...
...
@@ -320,7 +322,7 @@ class CustomerWithUserDataAdmin(ImportExportMixin, admin.ModelAdmin):
else
:
fields_basic
+=
[
(
'get_admin_balance'
,
'price_list_multiplier'
,
'get_admin_date_balance'
),
(
'may_order'
,
'is_active'
),
(
'may_order'
,
'is_group'
,
'is_active'
),
]
else
:
fields_basic
+=
[
...
...
repanier/admin/lut.py
View file @
5a3fbcd9
...
...
@@ -103,10 +103,7 @@ class LUTDeliveryPointDataForm(TranslatableModelForm):
required
=
False
)
customer_responsible
=
forms
.
ModelChoiceField
(
Customer
.
objects
.
filter
(
may_order
=
False
,
is_active
=
True
,
delivery_point__isnull
=
True
,
represent_this_buyinggroup
=
False
),
Customer
.
objects
.
filter
(
is_group
=
True
,
is_active
=
True
),
label
=
_
(
"customer_responsible"
),
help_text
=
_
(
"Invoices are sent to this consumer who is responsible for collecting the payments."
),
required
=
False
)
...
...
repanier/locale/fr/LC_MESSAGES/django.mo
View file @
5a3fbcd9
No preview for this file type
repanier/locale/fr/LC_MESSAGES/django.po
View file @
5a3fbcd9
This diff is collapsed.
Click to expand it.
repanier/models/customer.py
View file @
5a3fbcd9
...
...
@@ -108,6 +108,7 @@ class Customer(models.Model):
verbose_name
=
_
(
"delivery point"
),
blank
=
True
,
null
=
True
,
default
=
None
)
is_active
=
models
.
BooleanField
(
_
(
"is_active"
),
default
=
True
)
is_group
=
models
.
BooleanField
(
_
(
"is_group"
),
default
=
False
)
may_order
=
models
.
BooleanField
(
_
(
"may_order"
),
default
=
True
)
valid_email
=
models
.
NullBooleanField
(
_
(
"valid_email"
),
default
=
None
)
preparation_order
=
models
.
IntegerField
(
null
=
True
,
blank
=
True
,
default
=
0
)
...
...
@@ -279,6 +280,7 @@ def customer_pre_save(sender, **kwargs):
if
customer
.
represent_this_buyinggroup
:
# The buying group may not be de activated
customer
.
is_active
=
True
customer
.
is_group
=
False
if
customer
.
email2
is
not
None
:
customer
.
email2
=
customer
.
email2
.
lower
()
if
customer
.
vat_id
is
not
None
and
len
(
customer
.
vat_id
.
strip
())
==
0
:
...
...
@@ -307,6 +309,9 @@ def customer_pre_save(sender, **kwargs):
customer
.
bank_account2
=
None
if
not
customer
.
is_active
:
customer
.
may_order
=
False
if
customer
.
is_group
:
customer
.
may_order
=
False
customer
.
delivery_point
=
None
if
customer
.
price_list_multiplier
<=
DECIMAL_ZERO
:
customer
.
price_list_multiplier
=
DECIMAL_ONE
if
customer
.
delivery_point
is
not
None
and
customer
.
delivery_point
.
customer_responsible
is
not
None
:
...
...
repanier/models/permanence.py
View file @
5a3fbcd9
...
...
@@ -209,14 +209,21 @@ class Permanence(TranslatableModel):
link
=
[]
for
ci
in
invoice
.
CustomerInvoice
.
objects
.
filter
(
permanence_id
=
self
.
id
).
select_related
(
"customer"
).
order_by
(
'customer'
):
ci_customer
=
ci
.
customer
if
ci
.
is_order_confirm_send
:
label
=
'%s (%s) %s'
%
(
label
=
'%s%s (%s) %s%s'
%
(
"<b><i>"
if
ci_customer
.
is_group
else
EMPTY_STRING
,
ci
.
customer
.
short_basket_name
,
ci
.
get_total_price_with_tax
(
customer_who_pays
=
True
),
ci
.
get_is_order_confirm_send_display
())
ci
.
get_is_order_confirm_send_display
(),
"</i></b>"
if
ci_customer
.
is_group
else
EMPTY_STRING
,
)
else
:
label
=
'%s (%s) %s'
%
(
label
=
'%s%s (%s) %s%s'
%
(
"<b><i>"
if
ci_customer
.
is_group
else
EMPTY_STRING
,
ci
.
customer
.
short_basket_name
,
ci
.
total_price_with_tax
,
ci
.
get_is_order_confirm_send_display
())
ci
.
get_is_order_confirm_send_display
(),
"</i></b>"
if
ci_customer
.
is_group
else
EMPTY_STRING
,
)
# Important : no target="_blank"
link
.
append
(
'<a href="%s?permanence=%d&customer=%d">%s</a>'
...
...
@@ -226,10 +233,13 @@ class Permanence(TranslatableModel):
link
=
[]
for
ci
in
invoice
.
CustomerInvoice
.
objects
.
filter
(
permanence_id
=
self
.
id
).
select_related
(
"customer"
).
order_by
(
'customer'
):
label
=
"%s (%s) %s"
%
(
ci
.
customer
.
short_basket_name
,
ci_customer
=
ci
.
customer
label
=
"%s%s (%s) %s%s"
%
(
"<b><i>"
if
ci_customer
.
is_group
else
EMPTY_STRING
,
ci_customer
.
short_basket_name
,
ci
.
get_total_price_with_tax
(
customer_who_pays
=
True
),
ci
.
get_is_order_confirm_send_display
()
ci
.
get_is_order_confirm_send_display
(),
"</i></b>"
if
ci_customer
.
is_group
else
EMPTY_STRING
,
)
# Important : target="_blank" because the invoices must be displayed without the cms_toolbar
# Such that they can be accessed by the customer and by the staff
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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