Commit 3201817b authored by Patrick's avatar Patrick

Work in progress

parent 4021606f
......@@ -241,7 +241,12 @@ class BankAccountFilterByStatus(SimpleListFilter):
parameter_name = 'is_filled_exact'
def lookups(self, request, model_admin):
return [(1, _('not invoiced')), (2, _('balance')), (3, _('subscriptions')), (4, _('losts and profits')), (5, _('taxes'))]
return [
(1, _('not invoiced')),
(2, _('balance')),
(3, _('membership fees')),
(4, _('losts and profits')),
(5, _('taxes'))]
def queryset(self, request, queryset):
value = self.value()
......@@ -254,7 +259,7 @@ class BankAccountFilterByStatus(SimpleListFilter):
elif value == "2":
return queryset.filter(permanence_id__isnull=False, customer_id__isnull=True, producer_id__isnull=True)
elif value == "3":
return queryset.filter(operation_status=BANK_SUBSCRIPTION)
return queryset.filter(operation_status=BANK_MEMBERSHIP_FEE)
elif value == "4":
return queryset.filter(operation_status=BANK_PROFIT)
else:
......
......@@ -2,7 +2,10 @@
from __future__ import unicode_literals
from django import forms
from django.conf.urls import url
from django.contrib import admin
from django.core import urlresolvers
from django.http import HttpResponseRedirect
from django.utils.translation import ugettext_lazy as _
from easy_select2 import apply_select2
from import_export import resources, fields
......@@ -278,6 +281,13 @@ class BankAccountAdmin(ImportExportMixin, admin.ModelAdmin):
def has_change_permission(self, request, bank_account=None):
return self.has_add_permission(request)
# def get_urls(self):
# urls = super(BankAccountAdmin, self).get_urls()
# my_urls = [
# url(r'^expenses_to_be_apportioned/$', self.expenses_to_be_apportioned),
# ]
# return my_urls + urls
def get_readonly_fields(self, request, obj=None):
readonly_fields = [
'is_updated_on',
......@@ -285,6 +295,10 @@ class BankAccountAdmin(ImportExportMixin, admin.ModelAdmin):
]
return readonly_fields
# def expenses_to_be_apportioned(self, request):
# redirect_to = urlresolvers.reverse('admin:repanier_bankaccount_changelist', )
# return HttpResponseRedirect(redirect_to)
def get_actions(self, request):
actions = super(BankAccountAdmin, self).get_actions(request)
if 'delete_selected' in actions:
......@@ -304,3 +318,6 @@ class BankAccountAdmin(ImportExportMixin, admin.ModelAdmin):
"""
return [f for f in (XLS, XLSX_OPENPYXL_1_8_6) if f().can_import()]
# class Media:
# js = ('js/expenses_to_be_apportioned.js',)
......@@ -142,7 +142,7 @@ class CustomerResource(resources.ModelResource):
email = fields.Field(attribute='user', default="ask.it@to.me", widget=OneToOneWidget(User, 'email'), readonly=False)
phone1 = fields.Field(attribute='phone1', default="1234", widget=CharWidget(), readonly=False)
phone2 = fields.Field(attribute='phone2', widget=CharWidget(), readonly=False)
date_balance = fields.Field(attribute='get_admin_date_balance', widget=DateWidgetExcel(), readonly=True)
date_balance = fields.Field(attribute='get_admin_date_balance', widget=CharWidget(), 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)
......@@ -163,6 +163,7 @@ class CustomerResource(resources.ModelResource):
delivery_point = fields.Field(attribute='delivery_point',
widget=TranslatedForeignKeyWidget(LUT_DeliveryPoint, field='short_name'))
valid_email = fields.Field(attribute='valid_email', widget=DecimalBooleanWidget(), readonly=True)
date_joined = fields.Field(attribute='get_admin_date_joined', widget=CharWidget(), readonly=True)
def before_save_instance(self, instance, using_transactions, dry_run):
"""
......@@ -286,14 +287,6 @@ class CustomerWithUserDataAdmin(ImportExportMixin, admin.ModelAdmin):
get_email.short_description = _("email")
get_email.admin_order_field = 'user__email'
def get_date_joined(self, customer):
if customer.user is not None:
return customer.user.date_joined.strftime(settings.DJANGO_SETTINGS_DATE)
else:
return EMPTY_STRING
get_date_joined.short_description = _("date joined")
def get_last_login(self, customer):
if customer.user is not None and customer.user.last_login is not None:
return customer.user.last_login.strftime(settings.DJANGO_SETTINGS_DATE)
......@@ -356,7 +349,7 @@ class CustomerWithUserDataAdmin(ImportExportMixin, admin.ModelAdmin):
'bank_account1',
'bank_account2',
'get_last_login',
'get_date_joined',
'get_admin_date_joined',
'get_last_membership_fee',
'get_last_membership_fee_date',
'get_participation',
......@@ -374,20 +367,20 @@ class CustomerWithUserDataAdmin(ImportExportMixin, admin.ModelAdmin):
return [
'get_admin_date_balance', 'get_admin_balance',
'represent_this_buyinggroup', 'get_last_login',
'get_date_joined', 'get_participation', 'get_purchase',
'get_admin_date_joined', 'get_participation', 'get_purchase',
'get_last_membership_fee', 'get_last_membership_fee_date'
]
else:
return [
'get_admin_date_balance', 'get_admin_balance',
'get_last_login',
'get_date_joined', 'get_participation', 'get_purchase',
'get_admin_date_joined', 'get_participation', 'get_purchase',
'get_last_membership_fee', 'get_last_membership_fee_date'
]
else:
return [
'represent_this_buyinggroup', 'get_last_login',
'get_date_joined', 'get_participation', 'get_purchase',
'get_admin_date_joined', 'get_participation', 'get_purchase',
'get_last_membership_fee', 'get_last_membership_fee_date'
]
......
......@@ -404,6 +404,7 @@ class PermanenceInPreparationAdmin(TranslatableAdmin):
context = TemplateContext({
'offer_description': mark_safe(offer_description),
'offer_detail' : offer_detail,
'offer_recent_detail': offer_detail,
'offer_producer' : offer_producer,
'permanence_link' : mark_safe('<a href="#">%s</a>' % permanence),
'signature' : mark_safe(
......
......@@ -521,7 +521,7 @@ class ProductAdmin(ImportExportMixin, TranslatableAdmin):
if hasattr(picture_field.widget, 'upload_to'):
picture_field.widget.upload_to = "%s%s%d" % ("product", os_sep, producer.id)
if producer.represent_this_buyinggroup:
order_unit_choices = LUT_PRODUCT_ORDER_UNIT
order_unit_choices = LUT_PRODUCT_ORDER_UNIT_W_SUBSCRIPTION
order_unit_field.choices = order_unit_choices
if product is not None:
......@@ -570,9 +570,12 @@ class ProductAdmin(ImportExportMixin, TranslatableAdmin):
def get_queryset(self, request):
queryset = super(ProductAdmin, self).get_queryset(request)
return queryset.filter(is_box=False, is_membership_fee=False,
return queryset.filter(
is_box=False,
# is_membership_fee=False,
producer__is_active=True,
translations__language_code=translation.get_language())
translations__language_code=translation.get_language()
).exclude(order_unit=PRODUCT_ORDER_UNIT_MEMBERSHIP_FEE)
def get_import_formats(self):
"""
......
......@@ -108,8 +108,9 @@ PRODUCT_ORDER_UNIT_KG = '120'
PRODUCT_ORDER_UNIT_PC_KG = '140'
PRODUCT_ORDER_UNIT_LT = '150'
PRODUCT_ORDER_UNIT_DEPOSIT = '300'
PRODUCT_ORDER_UNIT_SUBSCRIPTION = '400'
PRODUCT_ORDER_UNIT_MEMBERSHIP_FEE = '400'
PRODUCT_ORDER_UNIT_TRANSPORTATION = '500'
PRODUCT_ORDER_UNIT_SUBSCRIPTION = '600'
LUT_PRODUCT_ORDER_UNIT = (
(PRODUCT_ORDER_UNIT_PC, _("bought per piece")),
......@@ -122,7 +123,7 @@ LUT_PRODUCT_ORDER_UNIT = (
(PRODUCT_ORDER_UNIT_DEPOSIT,
_('As a deposit, a bag : always add this product to preparation list when the customer has purchased something.')),
(PRODUCT_ORDER_UNIT_SUBSCRIPTION, _(
'As a subscription, common expense : add the minimal order quantity of this product to each customer of the group')),
'Subscription')),
(PRODUCT_ORDER_UNIT_TRANSPORTATION, _(
'As a transportation cost : add the minimal order quantity of this product to the basket representing the group.')),
)
......@@ -138,7 +139,7 @@ LUT_PRODUCT_ORDER_UNIT_REVERSE = (
(_('As a deposit, a bag : always add this product to preparation list when the customer has purchased something.'),
PRODUCT_ORDER_UNIT_DEPOSIT),
(_(
'As a subscription, common expense : add the minimal order quantity of this product to each customer of the group'),
'Subscription'),
PRODUCT_ORDER_UNIT_SUBSCRIPTION),
(_(
'As a transportation cost : add the minimal order quantity of this product to the basket representing the group.'),
......@@ -159,6 +160,20 @@ LUT_PRODUCT_ORDER_UNIT_WO_SUBSCRIPTION = (
'As a transportation cost : add the minimal order quantity of this product to the basket representing the group.')),
)
LUT_PRODUCT_ORDER_UNIT_W_SUBSCRIPTION = (
(PRODUCT_ORDER_UNIT_PC, _("bought per piece")),
(PRODUCT_ORDER_UNIT_PC_PRICE_KG, _("bought per piece (price /kg)")),
(PRODUCT_ORDER_UNIT_PC_PRICE_LT, _("bought per piece (price /l)")),
(PRODUCT_ORDER_UNIT_PC_PRICE_PC, _("bought per piece (price /pc)")),
(PRODUCT_ORDER_UNIT_KG, _("bought per kg")),
(PRODUCT_ORDER_UNIT_PC_KG, _("bought per piece, invoiced following the weight")),
(PRODUCT_ORDER_UNIT_LT, _("bought per l")),
(PRODUCT_ORDER_UNIT_DEPOSIT,
_('As a deposit, a bag : always add this product to preparation list when the customer has purchased something.')),
(PRODUCT_ORDER_UNIT_SUBSCRIPTION, _(
'Subscription')),
)
LUT_PRODUCER_PRODUCT_ORDER_UNIT = (
(PRODUCT_ORDER_UNIT_PC_PRICE_PC, _("Sold by piece")),
(PRODUCT_ORDER_UNIT_PC_PRICE_KG, _("Sold by weight")),
......@@ -230,7 +245,7 @@ LUT_ALL_VAT_REVERSE = (
)
BANK_NOT_LATEST_TOTAL = '100'
BANK_SUBSCRIPTION = '150'
BANK_MEMBERSHIP_FEE = '150'
BANK_COMPENSATION = '200' # BANK_COMPENSATION may occurs in previous release of Repanier
BANK_PROFIT = '210'
BANK_TAX = '220'
......@@ -240,7 +255,7 @@ BANK_LATEST_TOTAL = '400'
LUT_BANK_TOTAL = (
(BANK_NOT_LATEST_TOTAL, _('This is not the latest total')),
(BANK_SUBSCRIPTION, BANK_SUBSCRIPTION),
(BANK_MEMBERSHIP_FEE, BANK_MEMBERSHIP_FEE),
(BANK_PROFIT, BANK_PROFIT),
(BANK_TAX, BANK_TAX),
(BANK_CALCULATED_INVOICE, BANK_CALCULATED_INVOICE),
......
......@@ -127,12 +127,22 @@ def send_open_order(permanence_id):
)
for o in qs
),)
two_weeks_ago = timezone.now().date() - datetime.timedelta(days=14)
qs = qs.filter(product__is_updated_on__gte=two_weeks_ago)
offer_recent_detail = '<ul>%s</ul>' % ("".join('<li>%s, %s, %s</li>' % (
o.get_long_name(box_unicode=EMPTY_STRING),
o.producer.short_profile_name,
o.email_offer_price_with_vat,
)
for o in qs
),)
template = Template(offer_customer_mail)
context = TemplateContext({
'permanence_link' : mark_safe('<a href="http://%s%s">%s</a>' % (
settings.ALLOWED_HOSTS[0], reverse('order_view', args=(permanence.id,)), permanence)),
'offer_description': mark_safe(offer_description),
'offer_detail' : mark_safe(offer_detail),
'offer_recent_detail' : mark_safe(offer_recent_detail),
'offer_producer' : offer_producer,
'signature' : mark_safe(
'%s<br/>%s<br/>%s' % (signature, sender_function, REPANIER_SETTINGS_GROUP_NAME))
......
......@@ -5,7 +5,6 @@ import sys
from decimal import *
from django.conf import settings
from django.core.exceptions import ValidationError
from django.db import models
from django.db.models.expressions import BaseExpression, Expression
from django.forms import DecimalField, NumberInput
......
This diff is collapsed.
......@@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: repanier\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-04-14 13:41+0200\n"
"PO-Revision-Date: 2017-04-15 08:56+0100\n"
"POT-Creation-Date: 2017-04-21 12:29+0200\n"
"PO-Revision-Date: 2017-04-21 12:30+0100\n"
"Last-Translator: Patrick Colmant <pcolmant@gmail.com>\n"
"Language-Team: Patrick Colmant <pcolmant@gmail.com>\n"
"Language: fr\n"
......@@ -18,6 +18,10 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"X-Generator: Poedit 1.7.1\n"
#: static/js/expenses_to_be_apportioned.js:4
msgid "Expenses to be apportioned"
msgstr "Frais à répartir"
#: static/js/export_import_stock.js:4
msgid "Export stock"
msgstr "Exporter le stock"
......
......@@ -114,6 +114,7 @@ class Configuration(TranslatableModel):
<br />
Les produits suivants sont en offre :<br />
{{ offer_detail }}<br />
{{ offer_recent_detail }}<br />
<br />
{{ signature }}
""",
......@@ -377,13 +378,14 @@ def configuration_post_save(sender, **kwargs):
represent_this_buyinggroup=True
)
if producer_buyinggroup is not None:
membership_fee_product = product.Product.objects.filter(is_membership_fee=True, is_active=True).order_by(
'?').first()
membership_fee_product = product.Product.objects.filter(
order_unit=PRODUCT_ORDER_UNIT_MEMBERSHIP_FEE,
is_active=True
).order_by('?').first()
if membership_fee_product is None:
membership_fee_product = product.Product.objects.create(
producer_id=producer_buyinggroup.id,
is_membership_fee=True,
order_unit=PRODUCT_ORDER_UNIT_SUBSCRIPTION,
order_unit=PRODUCT_ORDER_UNIT_MEMBERSHIP_FEE,
vat_level=VAT_100
)
cur_language = translation.get_language()
......
......@@ -110,11 +110,20 @@ class Customer(models.Model):
preparation_order = models.IntegerField(null=True, blank=True, default=0)
def get_admin_date_balance(self):
return timezone.now().date()
return timezone.now().date().strftime(settings.DJANGO_SETTINGS_DATE)
get_admin_date_balance.short_description = (_("date_balance"))
get_admin_date_balance.allow_tags = False
def get_admin_date_joined(self):
if self.user is not None:
return self.user.date_joined.strftime(settings.DJANGO_SETTINGS_DATE)
else:
return EMPTY_STRING
get_admin_date_joined.short_description = _("date joined")
get_admin_date_joined.allow_tags = False
def get_admin_balance(self):
if self.id is not None:
return self.balance + self.get_bank_not_invoiced() - self.get_order_not_invoiced()
......@@ -190,7 +199,7 @@ class Customer(models.Model):
if self.id is not None:
last_membership_fee = purchase.Purchase.objects.filter(
customer_id=self.id,
offer_item__order_unit=PRODUCT_ORDER_UNIT_SUBSCRIPTION
offer_item__order_unit=PRODUCT_ORDER_UNIT_MEMBERSHIP_FEE
).order_by("-id")
if last_membership_fee.exists():
return last_membership_fee.first().selling_price
......@@ -203,7 +212,7 @@ class Customer(models.Model):
if self.id is not None:
last_membership_fee = purchase.Purchase.objects.filter(
customer_id=self.id,
offer_item__order_unit=PRODUCT_ORDER_UNIT_SUBSCRIPTION
offer_item__order_unit=PRODUCT_ORDER_UNIT_MEMBERSHIP_FEE
).order_by("-id").prefetch_related("customer_invoice")
if last_membership_fee.exists():
return last_membership_fee.first().customer_invoice.date_balance
......
......@@ -128,7 +128,7 @@ class OfferItem(TranslatableModel):
is_box = models.BooleanField(_("is_box"), default=False)
is_box_content = models.BooleanField(_("is_box_content"), default=False)
is_membership_fee = models.BooleanField(_("is_membership_fee"), default=False)
# is_membership_fee = models.BooleanField(_("is_membership_fee"), default=False)
may_order = models.BooleanField(_("may_order"), default=True)
is_active = models.BooleanField(_("is_active"), default=True)
limit_order_quantity_to_stock = models.BooleanField(_("limit maximum order qty of the group to stock qty"),
......
......@@ -128,7 +128,7 @@ class Product(TranslatableModel):
is_box = models.BooleanField(_("is_box"), default=False)
# is_mandatory = models.BooleanField(_("is_mandatory"), default=False)
is_membership_fee = models.BooleanField(_("is_membership_fee"), default=False)
# is_membership_fee = models.BooleanField(_("is_membership_fee"), default=False)
is_active = models.BooleanField(_("is_active"), default=True)
is_updated_on = models.DateTimeField(
_("is_updated_on"), auto_now=True, blank=True)
......@@ -308,7 +308,11 @@ def product_pre_save(sender, **kwargs):
elif product.order_unit not in [PRODUCT_ORDER_UNIT_PC_KG, PRODUCT_ORDER_UNIT_PC_PRICE_KG,
PRODUCT_ORDER_UNIT_PC_PRICE_LT, PRODUCT_ORDER_UNIT_PC_PRICE_PC]:
product.order_average_weight = DECIMAL_ZERO
if product.order_unit in [PRODUCT_ORDER_UNIT_DEPOSIT, PRODUCT_ORDER_UNIT_SUBSCRIPTION]:
if product.order_unit in [
PRODUCT_ORDER_UNIT_DEPOSIT,
PRODUCT_ORDER_UNIT_MEMBERSHIP_FEE,
PRODUCT_ORDER_UNIT_SUBSCRIPTION
]:
# No VAT on those products
product.vat_level = VAT_100
......@@ -327,7 +331,8 @@ def product_pre_save(sender, **kwargs):
product.limit_order_quantity_to_stock = False
if product.limit_order_quantity_to_stock:
product.customer_alert_order_quantity = min(999, product.stock)
elif product.order_unit == PRODUCT_ORDER_UNIT_SUBSCRIPTION:
product.customer_alert_order_quantity = LIMIT_ORDER_QTY_ITEM
if product.customer_increment_order_quantity <= DECIMAL_ZERO:
product.customer_increment_order_quantity = DECIMAL_ONE
if product.customer_minimum_order_quantity <= DECIMAL_ZERO:
......
(function($) {
$(document).ready(function($) {
if(location.pathname.indexOf('change') <= -1) {
$(".object-tools").prepend('<li><a href="./expenses_to_be_apportioned/' + location.search + '">' + gettext('Expenses to be apportioned')+ '</a></li>');
}
});
})(django.jQuery);
......@@ -322,14 +322,11 @@ def generate_invoice(permanence, payment_date):
producer_invoice=None
)
result_set = Purchase.objects.filter(
for membership_fee in Purchase.objects.filter(
permanence_id=permanence.id,
producer_id=producer_buyinggroup.id,
offer_item__order_unit=PRODUCT_ORDER_UNIT_SUBSCRIPTION
).order_by('?').aggregate(Sum('selling_price'))
if result_set["selling_price__sum"] is not None:
subscriptions = result_set["selling_price__sum"]
if subscriptions != DECIMAL_ZERO:
offer_item__order_unit=PRODUCT_ORDER_UNIT_MEMBERSHIP_FEE
).order_by('?').aggregate(Sum('selling_price')):
# --> This bank movement is not a real entry
# making this, it will not be counted into the customer_buyinggroup movements twice
# because Repanier will see it has already been counted into the customer_buyinggroup movements
......@@ -338,9 +335,9 @@ def generate_invoice(permanence, payment_date):
producer=None,
customer_id=customer_buyinggroup.id,
operation_date=payment_date,
operation_status=BANK_SUBSCRIPTION,
operation_comment=_("Subscriptions"),
bank_amount_in=subscriptions,
operation_status=BANK_MEMBERSHIP_FEE,
operation_comment="%s : %s" % (_("Membership fee"), membership_fee.customer),
bank_amount_in=membership_fee,
bank_amount_out=DECIMAL_ZERO,
customer_invoice_id=customer_invoice_buyinggroup.id,
producer_invoice=None
......@@ -362,7 +359,7 @@ def generate_invoice(permanence, payment_date):
producer=None,
customer_id=customer_buyinggroup.id,
operation_date=payment_date,
operation_status=BANK_SUBSCRIPTION,
operation_status=BANK_PROFIT,
operation_comment="%s : %s" % (_("Transport"), customer_invoice.customer.short_basket_name),
bank_amount_in=customer_invoice.delta_transport,
bank_amount_out=DECIMAL_ZERO,
......@@ -648,7 +645,7 @@ def cancel_invoice(permanence):
BANK_CALCULATED_INVOICE,
BANK_PROFIT,
BANK_TAX,
BANK_SUBSCRIPTION,
BANK_MEMBERSHIP_FEE,
BANK_COMPENSATION # BANK_COMPENSATION may occurs in previous release of Repanier
]
).order_by('?').delete()
......
This diff is collapsed.
......@@ -7,7 +7,6 @@
<div class="row">
<div class="panel panel-danger">
<div class="panel-heading">
{% trans "You need to log in" %}<br/><br/>
<a href="{% url "login_form" %}?next={% url 'order_delivery_view' permanence.id delivery_id %}" class="btn btn-primary">{% trans "Login me" %}</a>
</div>
</div>
......@@ -298,11 +297,9 @@
</ul>
</div>
{% endif %}
{% if display_all_product_button %}
<div class="btn-group">
<a href="{% url "order_delivery_view" permanence.id delivery_id %}?producer=all&departementforcustomer={{ departementforcustomer_id }}" class="btn btn-primary">{% trans "All" %}</a>
</div>
{% endif %}
<div class="btn-group">
<a href="{% url "basket_delivery_view" permanence.id delivery_id %}" class="btn btn-primary">
<span id="prepared_amount_visible_xs"></span></a>
......
......@@ -1229,6 +1229,7 @@ def my_order_confirmation(permanence, customer_invoice, is_basket=False,
href = urlresolvers.reverse(
'basket_view', args=(permanence.id,)
)
if customer_invoice.status == PERMANENCE_OPENED:
msg_confirmation1 = '<font color="red">%s</font><br/>' % _("An unconfirmed order will be canceled.")
msg_confirmation2 = _("Verify my order content before validating it.")
msg_html = """
......@@ -1405,11 +1406,9 @@ def clean_offer_item(permanence, queryset, reset_add_2_stock=False):
# The offer item may not be modified any more
return
getcontext().rounding = ROUND_HALF_UP
for offer_item in queryset.select_related("producer"):
for offer_item in queryset.select_related("producer", "product"):
product = offer_item.product
producer = offer_item.producer
if product.order_unit < PRODUCT_ORDER_UNIT_DEPOSIT:
offer_item.is_active = product.is_into_offer
offer_item.picture2 = product.picture2
offer_item.reference = product.reference
offer_item.department_for_customer_id = product.department_for_customer_id
......@@ -1452,7 +1451,7 @@ def clean_offer_item(permanence, queryset, reset_add_2_stock=False):
offer_item.customer_alert_order_quantity = product.customer_alert_order_quantity
offer_item.producer_order_by_quantity = product.producer_order_by_quantity
offer_item.is_box = product.is_box
offer_item.is_membership_fee = product.is_membership_fee
# offer_item.is_membership_fee = product.is_membership_fee
offer_item.save()
# Now got everything to calculate the sort order of the order display screen
......@@ -1471,7 +1470,7 @@ def clean_offer_item(permanence, queryset, reset_add_2_stock=False):
departementforcustomer_set = models.LUT_DepartmentForCustomer.objects.filter(
offeritem__permanence_id=permanence.id,
offeritem__order_unit__lt=PRODUCT_ORDER_UNIT_DEPOSIT) \
offeritem__may_order=True) \
.order_by("tree_id", "lft") \
.distinct("id", "tree_id", "lft")
if departementforcustomer_set:
......
......@@ -87,8 +87,6 @@ class OrderView(ListView):
def get_context_data(self, **kwargs):
context = super(OrderView, self).get_context_data(**kwargs)
context['permanence'] = self.permanence
if self.permanence.status == PERMANENCE_OPENED:
context['display_all_product_button'] = "Ok"
context['delivery_id'] = self.delivery_id
from repanier.apps import REPANIER_SETTINGS_DISPLAY_PRODUCER_ON_ORDER_FORM, REPANIER_SETTINGS_DISPLAY_ANONYMOUS_ORDER_FORM
if REPANIER_SETTINGS_DISPLAY_PRODUCER_ON_ORDER_FORM:
......
......@@ -63,22 +63,12 @@ def order_init_ajax(request):
if customer_invoice is None:
raise Http404
my_basket(customer_invoice.is_order_confirm_send, customer_invoice.get_total_price_with_tax(), to_json)
# if customer.balance.amount < 0:
# my_balance = _('My balance : <font color="red">%(balance)s</font> at %(date)s') % {
# 'balance': customer.balance,
# 'date' : customer.date_balance.strftime(settings.DJANGO_SETTINGS_DATE)}
# else:
# my_balance = _('My balance : <font color="green">%(balance)s</font> at %(date)s') % {
# 'balance': customer.balance,
# 'date' : customer.date_balance.strftime(settings.DJANGO_SETTINGS_DATE)}
# option_dict = {'id': "#my_balance", 'html': my_balance}
# to_json.append(option_dict)
basket = sboolean(request.GET.get('ba', False))
from repanier.apps import REPANIER_SETTINGS_CUSTOMERS_MUST_CONFIRM_ORDERS, \
REPANIER_SETTINGS_DISPLAY_PRODUCER_ON_ORDER_FORM, \
REPANIER_SETTINGS_MAX_WEEK_WO_PARTICIPATION
if basket or (REPANIER_SETTINGS_CUSTOMERS_MUST_CONFIRM_ORDERS
and customer_invoice.is_order_confirm_send):
# if basket or (REPANIER_SETTINGS_CUSTOMERS_MUST_CONFIRM_ORDERS
# and customer_invoice.is_order_confirm_send):
if customer_invoice.delivery is not None:
status = customer_invoice.delivery.status
else:
......@@ -99,14 +89,14 @@ def order_init_ajax(request):
basket_message=basket_message,
to_json=to_json
)
else:
if REPANIER_SETTINGS_CUSTOMERS_MUST_CONFIRM_ORDERS:
my_order_confirmation(
permanence=permanence,
customer_invoice=customer_invoice,
is_basket=basket,
to_json=to_json
)
# else:
# if REPANIER_SETTINGS_CUSTOMERS_MUST_CONFIRM_ORDERS:
# my_order_confirmation(
# permanence=permanence,
# customer_invoice=customer_invoice,
# is_basket=basket,
# to_json=to_json
# )
if customer.may_order:
if REPANIER_SETTINGS_DISPLAY_PRODUCER_ON_ORDER_FORM:
for producer in permanence.producers.all():
......
......@@ -53,9 +53,9 @@ class PreOrderView(DetailView):
offer_item_set = OfferItem.objects.filter(
Q(
producer_id=self.producer,
) |
Q(
stock__gt=DECIMAL_ZERO,
# ) |
# Q(
# stock__gt=DECIMAL_ZERO,
),
permanence_id=permanence_pre_opened.id,
translations__language_code=translation.get_language(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment