Commit 491ebf51 authored by Patrick's avatar Patrick

Add contract to producers

parent 42df4d20
......@@ -214,6 +214,7 @@ INSTALLED_APPS = (
'rest_framework',
'easy_select2',
'djng',
'recurrence'
)
# https://docs.djangoproject.com/fr/1.9/ref/middleware/
......
......@@ -241,6 +241,7 @@ class ContractAdmin(TranslatableAdmin):
def get_fieldsets(self, request, contract=None):
fields_basic = [
('long_name', 'picture2'),
'recurrences',
('calculated_stock', 'calculated_customer_contract_price', 'calculated_contract_deposit'),
('stock', 'customer_unit_price', 'unit_deposit'),
]
......
......@@ -328,10 +328,17 @@ class ProducerAdmin(ImportExportMixin, admin.ModelAdmin):
else:
return ('__str__', 'get_products', 'phone1', 'email')
else:
if repanier.apps.REPANIER_SETTINGS_INVOICE:
return ('__str__', 'get_products', 'get_contracts', 'get_balance', 'phone1', 'email')
if settings.DJANGO_SETTINGS_DEBUG:
# TODO : Contracts are in development. So they are only availalble in DEBUG mode
if repanier.apps.REPANIER_SETTINGS_INVOICE:
return ('__str__', 'get_products', 'get_contracts', 'get_balance', 'phone1', 'email')
else:
return ('__str__', 'get_products', 'get_contracts', 'phone1', 'email')
else:
return ('__str__', 'get_products', 'get_contracts', 'phone1', 'email')
if repanier.apps.REPANIER_SETTINGS_INVOICE:
return ('__str__', 'get_products', 'get_balance', 'phone1', 'email')
else:
return ('__str__', 'get_products', 'phone1', 'email')
def get_fieldsets(self, request, producer=None):
fields_basic = [
......
This diff is collapsed.
# -*- coding: utf-8
from __future__ import unicode_literals
from recurrence.fields import RecurrenceField
from django.core.validators import MinValueValidator
from django.db import models
from django.db.models import Sum
......@@ -17,6 +18,7 @@ from repanier.models.product import Product, product_pre_save
@python_2_unicode_compatible
class Contract(Product):
recurrences = RecurrenceField()
def get_calculated_stock(self):
# stock : max_digits=9, decimal_places=3 => 1000000 > max(stock)
......@@ -35,21 +37,20 @@ class Contract(Product):
return stock
def get_calculated_price(self):
result_set = ContractContent.objects.filter(box_id=self.id).aggregate(
result_set = ContractContent.objects.filter(contract_id=self.id).aggregate(
Sum('calculated_customer_content_price'),
Sum('calculated_content_deposit')
)
box_price = result_set["calculated_customer_content_price__sum"] \
contract_price = result_set["calculated_customer_content_price__sum"] \
if result_set["calculated_customer_content_price__sum"] is not None else DECIMAL_ZERO
box_deposit = result_set["calculated_content_deposit__sum"] \
contract_deposit = result_set["calculated_content_deposit__sum"] \
if result_set["calculated_content_deposit__sum"] is not None else DECIMAL_ZERO
return box_price, box_deposit
return contract_price, contract_deposit
class Meta:
proxy = True
verbose_name = _("box")
verbose_name_plural = _("boxes")
verbose_name = _("contract")
verbose_name_plural = _("contracts")
def __str__(self):
return '%s' % self.long_name
......@@ -66,7 +67,7 @@ def contract_pre_save(sender, **kwargs):
contract.producer_unit_price = contract.customer_unit_price
contract.producer_vat = contract.customer_vat
contract.limit_order_quantity_to_stock = True
# ! Important to initialise all fields of the box. Remember : a box is a product.
# ! Important to initialise all fields of the contract. Remember : a contract is a product.
product_pre_save(sender, **kwargs)
......
......@@ -10,6 +10,7 @@
{#<link rel="stylesheet" href="{% static "css/custom.css" %}">#}
{% block extrastyle %}{% endblock %}
{% if LANGUAGE_BIDI %}<link rel="stylesheet" type="text/css" href="{% block stylesheet_rtl %}{% static "admin/css/rtl.css" %}{% endblock %}" />{% endif %}
<script type="text/javascript" src="{% url 'javascript-catalog' %}"></script>
{% block extrahead %}{% endblock %}
<style type="text/css">
{# vvvvvvvvv django cms admin style 1.2.6 #}
......@@ -95,7 +96,6 @@ div, span, ul {line-height: inherit !important;}
</style>
{% block blockbots %}<meta name="robots" content="NONE,NOARCHIVE" />{% endblock %}
<script type="text/javascript" src="{% url 'javascript-catalog' %}"></script>
</head>
<body class="{% if is_popup %}popup {% endif %}{% block bodyclass %}{% endblock %}"
data-admin-utc-offset="{% now "Z" %}">
......
......@@ -3,7 +3,7 @@
{% block extrastyle %}
{{ block.super }}
<script type="text/javascript" src="{{ jsi18n_url }}"></script>
{# <script type="text/javascript" src="{{ jsi18n_url }}"></script>#}
{% endblock %}
{% block search %}{% endblock %}
......
{% extends "admin/base_site.html" %}
{% load cms_tags menu_tags compress i18n l10n static %}
{% block content %}
<link rel="stylesheet" href="{% static "bootstrap/css/bootstrap.css" %}">
<link rel="stylesheet" href="{% static "css/custom.css" %}">
<h4>{{ sub_title }}</h4>
<p></p>
<form action="" method="post">{% csrf_token %}
<h6>{{ box }}</h6>
<div class="submit-row">
<button type="submit" name="cancel" value="cancel"><h6>{% trans "No, cancel the action" %}</h6></button>
<button type="submit" name="apply" value="apply" class="default"><h6>{% trans "Yes, I'm sure" %}</h6></button>
</div>
<input type="hidden" name="{{ action_checkbox_name }}" value="{{ product.id|unlocalize }}"/>
<input type="hidden" name="action" value="{{ action }}"/>
</form>
{% endblock %}
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