Commit e58a1675 authored by Patrick's avatar Patrick

Refactoring

parent d841fa2b
......@@ -262,7 +262,6 @@ class UserDataForm(forms.ModelForm):
username=username, email=email, password=uuid.uuid1().hex,
first_name=first_name, last_name=last_name)
self.user = user
read_only = self.read_only
return self.instance
......@@ -487,7 +486,7 @@ class ProductAdmin(ReadOnlyAdmin):
else:
producer_id = None
department_for_customer_id = None
is_actif_value = None
is_active_value = None
is_into_offer_value = None
preserved_filters = request.GET.get('_changelist_filters', None)
if preserved_filters:
......@@ -497,7 +496,7 @@ class ProductAdmin(ReadOnlyAdmin):
if 'department_for_customer' in param:
department_for_customer_id = param['department_for_customer']
if 'is_active__exact' in param:
is_actif_value = param['is_active__exact']
is_active_value = param['is_active__exact']
if 'is_into_offer__exact' in param:
is_into_offer_value = param['is_into_offer__exact']
is_active = form.base_fields["is_active"]
......@@ -516,8 +515,8 @@ class ProductAdmin(ReadOnlyAdmin):
)
else:
department_for_customer.queryset = LUT_DepartmentForCustomer.objects.filter(is_active=True)
if is_actif_value:
if is_actif_value == '0':
if is_active_value:
if is_active_value == '0':
is_active.initial = False
else:
is_active.initial = True
......
......@@ -5,7 +5,6 @@ from django.contrib.auth.models import User
class RepanierCustomBackend(ModelBackend):
def authenticate(self, **credentials):
user_or_none = None
try:
user_or_none = super(RepanierCustomBackend, self).authenticate(**credentials)
if user_or_none and not user_or_none.is_superuser:
......@@ -29,7 +28,6 @@ class RepanierCustomBackend(ModelBackend):
return user_or_none
def get_user(self, user_id):
user_or_none = None
try:
user_or_none = User.objects.get(pk=user_id)
if user_or_none and not user_or_none.is_superuser:
......
......@@ -13,16 +13,12 @@ from const import *
class RepanierToolbar(CMSToolbar):
def populate(self):
admin_menu = self.toolbar.get_or_create_menu(ADMIN_MENU_IDENTIFIER, _('Manage'))
# _('Administration')
position = admin_menu.get_alphabetical_insert_position(
_('Parameters'),
SubMenu
)
if not position:
position = admin_menu.find_first(
Break,
identifier=ADMINISTRATION_BREAK
) + 1
# TODO : Check this part of the code
position = 0
admin_menu.add_break('custom-break', position=position)
office_menu = admin_menu.get_or_create_menu(
......
......@@ -20,8 +20,6 @@ def send(permanence_id, current_site_name):
sender_function = ""
signature = ""
cc_email_staff = []
staff_composition = ""
first_staff = True
for staff in Staff.objects.filter(is_active=True, is_external_group=False):
cc_email_staff.append(staff.user.email)
if staff.is_reply_to_invoice_email:
......@@ -45,9 +43,9 @@ def send(permanence_id, current_site_name):
permanence=permanence_id).order_by()
for producer in producer_set:
if producer.email.upper().find("NO-SPAM.WS") < 0:
long_profile_name = producer.long_profile_name if producer.long_profile_name != None else producer.short_profile_name
long_profile_name = producer.long_profile_name if producer.long_profile_name is not None else producer.short_profile_name
wb = xslx_invoice.export(permanence=permanence, producer=producer, wb=None, sheet_name=long_profile_name)
if wb != None:
if wb is not None:
invoices_url = 'http://' + settings.ALLOWED_HOSTS[0] + urlresolvers.reverse(
'invoicep_uuid_view',
args=(0, producer.uuid )
......@@ -88,9 +86,9 @@ def send(permanence_id, current_site_name):
customer_set = Customer.objects.filter(
purchase__permanence=permanence_id, represent_this_buyinggroup=False).order_by().distinct()
for customer in customer_set:
long_basket_name = customer.long_basket_name if customer.long_basket_name != None else customer.short_basket_name
long_basket_name = customer.long_basket_name if customer.long_basket_name is not None else customer.short_basket_name
wb = xslx_invoice.export(permanence=permanence, customer=customer, wb=None, sheet_name=long_basket_name)
if wb != None:
if wb is not None:
html_content = unicode(_('Dear')) + " " + long_basket_name + ",<br/><br/>" + unicode(_('Your invoice of')) + \
" " + unicode(permanence) + " " + unicode(
_("is now available in attachment")) + ".<br/>" + permanence.invoice_description + \
......@@ -118,7 +116,7 @@ def send(permanence_id, current_site_name):
# Report to the staff
wb = xslx_invoice.export(permanence=permanence, wb=None, sheet_name=current_site_name)
if wb != None:
if wb is not None:
html_content = unicode(_('Dear staff member')) + ",<br/><br/>" + unicode(_('The invoices of')) + \
" " + unicode(permanence) + " " + unicode(
_("are now available in attachment")) + ".<br/>" + permanence.invoice_description + \
......
......@@ -67,8 +67,8 @@ def send(permanence_id, current_site_name):
for producer in producer_set:
if producer.email.upper().find("NO-SPAM.WS") < 0:
wb = xslx_order.export_producer(permanence=permanence, producer=producer, wb=None)
if wb != None:
long_profile_name = producer.long_profile_name if producer.long_profile_name != None else producer.short_profile_name
if wb is not None:
long_profile_name = producer.long_profile_name if producer.long_profile_name is not None else producer.short_profile_name
html_content = unicode(_('Dear')) + " " + long_profile_name + ",<br/><br/>" + unicode(
_('In attachment, you will find the detail of our order for the')) + \
" " + unicode(permanence) + ".<br/><br/>" + unicode(
......@@ -101,8 +101,8 @@ def send(permanence_id, current_site_name):
purchase__permanence=permanence_id, represent_this_buyinggroup=False).order_by().distinct()
for customer in customer_set:
wb = xslx_order.export_customer(permanence=permanence, customer=customer, wb=None)
if wb != None:
long_basket_name = customer.long_basket_name if customer.long_basket_name != None else customer.short_baskrt_name
if wb is not None:
long_basket_name = customer.long_basket_name if customer.long_basket_name is not None else customer.short_baskrt_name
html_content = unicode(_('Dear')) + " " + long_basket_name + ",<br/><br/>" + unicode(
_('In attachment, you will find the detail of your order for the')) + \
" " + unicode(permanence) + ".<br/><br/>" + unicode(
......@@ -131,7 +131,7 @@ def send(permanence_id, current_site_name):
email.send()
wb = xslx_order.export(permanence=permanence, wb=None)
if wb != None:
if wb is not None:
to_email_board = []
for permanenceboard in PermanenceBoard.objects.filter(
permanence=permanence_id).order_by():
......
This diff is collapsed.
......@@ -9,9 +9,9 @@ from django.utils.translation import ugettext_lazy as _
from django.core.urlresolvers import reverse
from const import *
from repanier.models import Permanence
from repanier.models import CustomerInvoice
from repanier.models import PermanenceBoard
from models import Permanence
from models import CustomerInvoice
from models import PermanenceBoard
class PermanenceMenu(Menu):
......@@ -69,7 +69,7 @@ class PermanenceMenu(Menu):
for permanence in Permanence.objects.filter(status=PERMANENCE_OPENED).order_by('distribution_date'):
if first_pass and separator:
node = NavigationNode(
('------'),
'------',
"/",
id=submenu_id, parent_id=master_id,
visible=True
......@@ -91,7 +91,7 @@ class PermanenceMenu(Menu):
for permanence in Permanence.objects.filter(status=PERMANENCE_SEND).order_by('-distribution_date'):
if first_pass and separator:
node = NavigationNode(
('------'),
'------',
"/",
id=submenu_id, parent_id=master_id,
visible=True
......@@ -114,7 +114,7 @@ class PermanenceMenu(Menu):
if last_customer_invoice:
if separator:
node = NavigationNode(
('------'),
'------',
"/",
id=submenu_id, parent_id=master_id,
visible=True
......@@ -141,7 +141,6 @@ class PermanenceMenu(Menu):
)
nodes.append(node)
# for node in nodes:
# logging.debug('Node before : %s' % node.get_menu_title())
# for attr in (x for x in dir(node) if not x.startswith('__')):
......
......@@ -129,10 +129,10 @@ class LUT(models.Model):
objects = LUTManager()
def natural_key(self):
return (self.short_name)
return self.short_name
def __unicode__(self):
return u'%s' % (self.short_name)
return u'%s' % self.short_name
class Meta:
abstract = True
......@@ -188,7 +188,7 @@ class Producer(models.Model):
price_list_multiplier = models.DecimalField(
_("price_list_multiplier"),
help_text=_('This multiplier is applied to each price automatically imported/pushed.'),
help_text=_("This multiplier is applied to each price automatically imported/pushed."),
default=0, max_digits=4, decimal_places=2)
vat_level = models.CharField(
max_length=3,
......@@ -196,8 +196,8 @@ class Producer(models.Model):
default=VAT_400,
verbose_name=_("Default vat or compensation"),
help_text=_(
'When the vendor is in agricultural'
' regime select the correct compensation %. In the other cases select the correct vat %'))
"When the vendor is in agricultural"
" regime select the correct compensation %. In the other cases select the correct vat %"))
date_balance = models.DateField(
_("date_balance"), default=datetime.date.today)
......@@ -283,7 +283,7 @@ class Producer(models.Model):
get_last_invoice.allow_tags = True
def __unicode__(self):
return u'%s' % (self.short_profile_name)
return u'%s' % self.short_profile_name
class Meta:
verbose_name = _("producer")
......@@ -475,7 +475,6 @@ class Staff(models.Model):
@receiver(post_save, sender=Staff)
def staff_post_save(sender, **kwargs):
staff = kwargs['instance']
created = kwargs['created']
if staff.id is not None:
user = staff.user
user.groups.clear()
......
......@@ -26,7 +26,6 @@ import thread
def generate(request, permanence_id, permanence_distribution_date, permanence_unicode, current_site_name,
producers_to_be_paid_set):
validation_passed = True
something_to_put_into_the_invoice = False
bank_account = BankAccount.objects.filter(operation_status=BANK_LATEST_TOTAL).order_by().first()
if bank_account:
# try:
......@@ -113,15 +112,12 @@ def generate(request, permanence_id, permanence_distribution_date, permanence_un
# Calculate new current balance : Purchases
# Changed in Django 1.6.3:
# It is now an error to execute a query with select_for_update() in autocommit mode. With earlier releases in the 1.6 series it was a no-op.
# It is now an error to execute a query with select_for_update() in autocommit mode. With earlier releases in the 1.6 series it was a no-op.
for purchase in Purchase.objects.select_for_update().filter(
permanence=permanence_id,
).order_by():
a_total_price = 0
a_total_vat = 0
a_total_compensation = 0
a_total_deposit = purchase.unit_deposit * purchase.quantity_deposit
if purchase.invoiced_price_with_compensation:
a_total_price = purchase.price_with_compensation + a_total_deposit
......@@ -138,7 +134,7 @@ def generate(request, permanence_id, permanence_distribution_date, permanence_un
a_total_vat = (purchase.price_with_vat * DECIMAL_0_21).quantize(THREE_DECIMALS)
a_total_compensation = 0
if purchase.is_recorded_on_customer_invoice == None:
if purchase.is_recorded_on_customer_invoice is None:
if purchase.producer.id == producer_buyinggroup_id:
# When the producer represent the buying group, generate a compensation movement
customerinvoice = CustomerInvoice.objects.get(
......@@ -174,7 +170,7 @@ def generate(request, permanence_id, permanence_distribution_date, permanence_un
balance=F('balance') - a_total_price
)
purchase.is_recorded_on_customer_invoice_id = customerinvoice.id
if purchase.is_recorded_on_producer_invoice == None:
if purchase.is_recorded_on_producer_invoice is None:
producerinvoice = ProducerInvoice.objects.get(
producer=purchase.producer,
permanence=permanence_id,
......@@ -217,7 +213,7 @@ def generate(request, permanence_id, permanence_distribution_date, permanence_un
customer=bank_account.customer,
permanence=permanence_id,
).order_by().first()
if customerinvoice == None:
if customerinvoice is None:
customerinvoice = CustomerInvoice.objects.create(
customer=bank_account.customer,
permanence_id=permanence_id,
......@@ -259,7 +255,7 @@ def generate(request, permanence_id, permanence_distribution_date, permanence_un
producer=bank_account.producer,
permanence=permanence_id,
).order_by().first()
if producerinvoice == None:
if producerinvoice is None:
producerinvoice = ProducerInvoice.objects.create(
producer=bank_account.producer,
permanence_id=permanence_id,
......@@ -309,7 +305,7 @@ def generate(request, permanence_id, permanence_distribution_date, permanence_un
is_recorded_on_customer_invoice=None,
is_recorded_on_producer_invoice=None
)
# except Exception, e:
# except Exception, e:
# validation_passed = False
if validation_passed:
......@@ -382,7 +378,7 @@ def admin_generate(request, producers_to_be_paid_set=Producer.objects.none(), pe
user_message = _("You can only generate invoices when the permanence status is 'send'.")
user_message_level = messages.WARNING
permanence = Permanence.objects.filter(id=permanence_id).order_by().first()
if permanence != None:
if permanence is not None:
current_site = get_current_site(request)
if permanence.status == PERMANENCE_SEND:
generate(request, permanence.id, permanence.distribution_date, permanence.__unicode__(), current_site.name,
......
......@@ -123,7 +123,7 @@ def admin_open_and_send(request, queryset):
user_message_level = messages.WARNING
else:
user_message = _("Action refused by the system. Please, retry in %d minutes.") % (
31 - (int(timediff.total_seconds()) / 60))
31 - (int(timediff.total_seconds()) / 60))
user_message_level = messages.WARNING
return user_message, user_message_level
......@@ -211,7 +211,7 @@ def admin_close_and_send(request, queryset):
user_message_level = messages.WARNING
else:
user_message = _("Action refused by the system. Please, retry in %d minutes.") % (
31 - (int(timediff.total_seconds()) / 60))
31 - (int(timediff.total_seconds()) / 60))
user_message_level = messages.WARNING
return user_message, user_message_level
......@@ -20,7 +20,7 @@ def admin_generate_bank_account_movement(request, queryset, permanence_distribut
if bank_account.operation_date > operation_date:
operation_date = bank_account.operation_date
bank_latest_total_id = bank_account.id
if bank_latest_total_id != None:
if bank_latest_total_id is not None:
counter = 0
counter_max = 0
for producer in queryset:
......@@ -56,7 +56,7 @@ def admin_generate_bank_account_movement(request, queryset, permanence_distribut
bank_account = BankAccount.objects.filter(producer_id=producer.id, operation_date=operation_date,
operation_comment=msg).order_by("-id").first()
if bank_account:
if bank_account.is_recorded_on_producer_invoice == None:
if bank_account.is_recorded_on_producer_invoice is None:
bank_account.bank_amount_in = 0
bank_account.bank_amount_out += delta
bank_account.operation_comment = msg
......
......@@ -10,7 +10,6 @@ from repanier.models import Purchase
def admin_delete(request, queryset):
user_message = _("The status of this permanence prohibit you to delete the purchases.")
user_message_level = messages.ERROR
is_something_deleted = False
for permanence in queryset.filter(status=PERMANENCE_SEND)[:1]:
Purchase.objects.filter(permanence_id=permanence.id).delete()
OfferItem.objects.filter(permanence_id=permanence.id).delete()
......
# -*- coding: utf-8 -*-
from django.conf import settings
from django import template
from django.contrib.auth.models import User
from django.utils.translation import ugettext as _
from django.utils.formats import number_format
from repanier.const import *
from repanier.tools import *
from repanier.models import OfferItem
from repanier.models import Purchase
......@@ -49,7 +44,6 @@ def repanier_select_qty(context, *args, **kwargs):
q_step = offer_item.product.customer_increment_order_quantity
# The q_min cannot be 0. In this case try to replace q_min by q_step.
# In last ressort by q_alert.
# result = '<select name="value" id="offer_item' + str(offer_item.id) + '" onchange="order_ajax(' + str(offer_item.id) + ')" data-refresh="'+ str(offer_item.limit_to_alert_order_quantity) + '" class="form-control">'
result = '<select name="value" id="offer_item' + str(offer_item.id) + '" onchange="order_ajax(' + str(
offer_item.id) + ')" class="form-control">'
q_order_is_displayed = False
......@@ -61,13 +55,12 @@ def repanier_select_qty(context, *args, **kwargs):
q_min = q_alert
q_step = q_alert
if (q_min <= 0 and offer_item.permanence.status == PERMANENCE_OPENED) or (q_order <= 0):
q_order_is_displayed = True
result += '<option value="0" selected>---</option>'
else:
q_select_id = 0
q_valid = q_min
q_counter = 0 # Limit to avoid too long selection list
while q_valid <= q_alert and q_counter <= 20 and q_order_is_displayed == False:
while q_valid <= q_alert and q_counter <= 20 and not q_order_is_displayed:
q_select_id += 1
q_counter += 1
if q_order <= q_valid:
......@@ -86,9 +79,9 @@ def repanier_select_qty(context, *args, **kwargs):
# 1; 2; 3; 4 ... q_min = 1; q_step = 1
# 0,125; 0,175; 0,225 ... q_min = 0,125; q_step = 0,50
q_valid = q_valid + q_step
if q_order_is_displayed == False:
if not q_order_is_displayed:
# An custom order_qty > q_alert
q_select_id = q_select_id + 1
q_select_id += 1
qty_display = get_qty_display(
q_order,
q_average_weight,
......@@ -104,8 +97,8 @@ def repanier_select_qty(context, *args, **kwargs):
else:
result = "N/A3"
# except:
# # user.customer doesn't exist -> the user is not a customer.
# result = "N/A2"
# # user.customer doesn't exist -> the user is not a customer.
# result = "N/A2"
return result
......
......@@ -6,10 +6,10 @@ from django.conf import settings
from django.utils.formats import number_format
from django.db import transaction
from repanier.models import Purchase
from repanier.models import Customer
from repanier.models import OfferItem
from repanier.models import CustomerOrder
from models import Purchase
from models import Customer
from models import OfferItem
from models import CustomerOrder
LENGTH_BY_PREFIX = [
(0xC0, 2), # first byte mask, total codepoint length
......@@ -34,24 +34,18 @@ def codepoint_length(first_byte):
def cap_to_bytes_length(unicode_text, byte_limit):
utf8_bytes = unicode_text.encode('UTF-8', 'replace')
cut_index = 0
previous_cut_index = cut_index
while cut_index < len(utf8_bytes):
step = codepoint_length(ord(utf8_bytes[cut_index]))
if cut_index + step > byte_limit:
# can't go a whole codepoint further, time to cut
return utf8_bytes[:cut_index] + '...'
else:
previous_cut_index = cut_index
previuos_step = step
cprevious = utf8_bytes[cut_index]
cut_index += step
# ccurrent = utf8_bytes[cut_index]
# length limit is longer than our bytes strung, so no cutting
return utf8_bytes
def cap(s, l):
if s != None:
if s is not None:
if not isinstance(s, basestring):
s = str(s)
if isinstance(s, unicode):
......@@ -64,7 +58,6 @@ def cap(s, l):
def get_invoice_unit(order_unit=PRODUCT_ORDER_UNIT_LOOSE_PC, qty=0):
unit = None
if order_unit in [PRODUCT_ORDER_UNIT_LOOSE_KG, PRODUCT_ORDER_UNIT_NAMED_KG, PRODUCT_ORDER_UNIT_LOOSE_PC_KG,
PRODUCT_ORDER_UNIT_NAMED_PC_KG]:
unit = unicode(_("/ Kg"))
......@@ -79,16 +72,10 @@ def get_invoice_unit(order_unit=PRODUCT_ORDER_UNIT_LOOSE_PC, qty=0):
def get_customer_unit(order_unit=PRODUCT_ORDER_UNIT_LOOSE_PC, qty=0):
unit = None
if order_unit in [PRODUCT_ORDER_UNIT_LOOSE_KG, PRODUCT_ORDER_UNIT_NAMED_KG]:
unit = unicode(_("/ Kg"))
elif order_unit == PRODUCT_ORDER_UNIT_LOOSE_LT:
unit = unicode(_("/ L"))
# elif order_unit == PRODUCT_ORDER_UNIT_LOOSE_BT_LT:
# if qty < 2:
# unit = unicode(_("/ piece"))
# else:
# unit = unicode(_("/ pieces"))
else:
if qty < 2:
unit = unicode(_("/ piece"))
......@@ -99,7 +86,6 @@ def get_customer_unit(order_unit=PRODUCT_ORDER_UNIT_LOOSE_PC, qty=0):
def get_producer_unit(order_unit=PRODUCT_ORDER_UNIT_LOOSE_PC, qty=0):
# Used when producing the orders send to the producers.
unit = None
if order_unit in [PRODUCT_ORDER_UNIT_LOOSE_KG, PRODUCT_ORDER_UNIT_NAMED_KG]:
unit = unicode(_("/ Kg"))
elif order_unit == PRODUCT_ORDER_UNIT_LOOSE_LT:
......@@ -114,7 +100,6 @@ def get_producer_unit(order_unit=PRODUCT_ORDER_UNIT_LOOSE_PC, qty=0):
def get_preparator_unit(order_unit=PRODUCT_ORDER_UNIT_LOOSE_PC, qty=0):
# Used when producing the preparation list.
unit = None
if order_unit in [PRODUCT_ORDER_UNIT_LOOSE_PC, PRODUCT_ORDER_UNIT_NAMED_PC, PRODUCT_ORDER_UNIT_DEPOSIT]:
unit = unicode(_("Piece(s) :"))
elif order_unit in [PRODUCT_ORDER_UNIT_NAMED_KG, PRODUCT_ORDER_UNIT_NAMED_PC_KG]:
......@@ -193,7 +178,7 @@ def get_qty_display(qty=0, order_average_weight=0, order_unit=PRODUCT_ORDER_UNIT
def get_user_order_amount(permanence, user=None):
a_total_price_with_tax = 0
if user != None:
if user is not None:
customer_order_set = CustomerOrder.objects.filter(
permanence_id=permanence.id,
customer__user=user)[:1]
......@@ -204,7 +189,7 @@ def get_user_order_amount(permanence, user=None):
def get_order_amount(permanence, customer=None):
a_total_price_with_tax = 0
if customer != None:
if customer is not None:
customer_order_set = CustomerOrder.objects.filter(
permanence_id=permanence.id,
customer_id=customer.id)[:1]
......@@ -234,7 +219,6 @@ def save_order_amount(permanence_id, customer_id, a_total_price_with_tax):
def save_order_delta_amount(permanence_id, customer_id,
a_previous_total_price_with_tax,
a_total_price_with_tax):
a_new_total_price_with_tax = 0
customer_order_set = CustomerOrder.objects.filter(
permanence_id=permanence_id,
customer_id=customer_id)[:1]
......@@ -258,15 +242,14 @@ def save_order_delta_amount(permanence_id, customer_id,
def recalculate_order_amount(permanence_id, customer_id=None, send_to_producer=False):
customer_save_id = None
a_total_price_with_tax = 0
purchase_set = Purchase.objects.none()
if customer_id == None:
if customer_id is None:
purchase_set = Purchase.objects.filter(permanence_id=permanence_id).order_by('customer')
else:
purchase_set = Purchase.objects.filter(permanence_id=permanence_id, customer_id=customer_id).order_by()
for purchase in purchase_set:
distribution_date = purchase.permanence.distribution_date
if customer_save_id != purchase.customer.id:
if customer_save_id != None:
if customer_save_id is not None:
save_order_amount(permanence_id, customer_save_id, a_total_price_with_tax)
a_total_price_with_tax = 0
customer_save_id = purchase.customer.id
......@@ -317,7 +300,7 @@ def recalculate_order_amount(permanence_id, customer_id=None, send_to_producer=F
else:
a_total_price_with_tax += purchase.price_with_vat
if customer_save_id != None:
if customer_save_id is not None:
save_order_amount(permanence_id, customer_save_id, a_total_price_with_tax)
......@@ -355,21 +338,19 @@ def update_or_create_purchase(user=None, customer=None, p_offer_item_id=None, p_
# when the status is PERMANENCE_WAIT_FOR_SEND
if (offer_item.permanence.status == PERMANENCE_OPENED) or close_orders:
# The offer_item belong to a open permanence
q_order = 0
purchase = Purchase.objects.filter(
offer_item_id=offer_item.id,
permanence_id=offer_item.permanence_id,
customer_id=customer.id).order_by().first()
a_previous_total_price_with_tax = 0
q_previous_order = 0
if purchase != None:
if purchase is not None:
q_previous_order = purchase.quantity
if purchase.invoiced_price_with_compensation:
a_previous_total_price_with_tax = purchase.price_with_compensation
else:
a_previous_total_price_with_tax = purchase.price_with_vat
q_min = offer_item.product.customer_minimum_order_quantity
q_alert = 0
if offer_item.limit_to_alert_order_quantity:
offer_item.customer_alert_order_quantity += q_previous_order
q_alert = offer_item.customer_alert_order_quantity
......
......@@ -22,18 +22,18 @@ from django.shortcuts import render_to_response
from django.shortcuts import get_object_or_404
from django.template import RequestContext
from repanier.models import LUT_DepartmentForCustomer
from repanier.models import OfferItem
from repanier.models import Permanence
from repanier.models import Producer
from repanier.models import ProducerInvoice
from repanier.models import Purchase
from repanier.models import Customer
from repanier.models import CustomerInvoice
from repanier.models import Staff
from repanier.models import BankAccount
from repanier.models import PermanenceBoard
from repanier.forms import ContactForm
from models import LUT_DepartmentForCustomer
from models import OfferItem
from models import Permanence
from models import Producer
from models import ProducerInvoice
from models import Purchase
from models import Customer
from models import CustomerInvoice
from models import Staff
from models import BankAccount
from models import PermanenceBoard
from forms import ContactForm
import logging
......@@ -109,7 +109,6 @@ def ajax_order_select(request):
if request.method == 'GET':
# construct a list which will contain all of the data for the response
to_json = []
p_offer_item_id = None
if 'offer_item' in request.GET:
p_offer_item_id = request.GET['offer_item']
user = request.user
......@@ -133,7 +132,7 @@ def ajax_order_select(request):
q_alert = offer_item.customer_alert_order_quantity + q_order if offer_item.limit_to_alert_order_quantity else offer_item.customer_alert_order_quantity