Накладная добавил форму, перед редактированием шаблона

prod
Dmitriy Shesterkin 9 years ago
parent 68a012af47
commit 1535720a23
  1. 5
      src/docs/forms/base_forms.py
  2. 1
      src/docs/forms/faktura.py
  3. 23
      src/docs/forms/nakladn.py
  4. 25
      src/docs/models/nakladn.py
  5. 27
      src/docs/views/faktura.py
  6. 2
      src/docs/views/nakladn.py
  7. 49
      static/css/style.css
  8. 27
      templates/docs/nakladn/form.html
  9. 2
      templates/docs/parts/form_field_receiver.html
  10. 30
      templates/docs/stub_js.html

@ -49,7 +49,10 @@ class BaseModelForm(MyBaseModelForm):
f['plat_doc_date'].widget.attrs['class'] = 'has-datepicker'
if f.get('fix_doc_date'):
f['fix_doc_date'].widget.attrs['class'] = 'has-datepicker'
if f.get('transport_date'):
f['transport_date'].widget.attrs['class'] = 'has-datepicker'
if f.get('doc_reason_date'):
f['doc_reason_date'].widget.attrs['class'] = 'has-datepicker'
# Если в форме есть поле bank_account, настроить связь
# с BankAccount: чтобы можно было выбрать __только__
# расчетные счета данного пользователя. Также убрать

@ -59,7 +59,6 @@ class FakturaForm(BaseModelForm):
class FakturaAdminForm(FakturaForm):
"""Форма редактирования фактуры - для админки."""
class Meta(FakturaForm.Meta):
# fields = None
exclude = ()
_textarea = forms.Textarea(attrs={'cols': 80, 'rows': 3})
widgets = {

@ -1,7 +1,9 @@
# -*- coding: utf-8 -*-
import autocomplete_light
from django import forms
from commons.forms import MyBaseModelForm
from customer.models import Client
from .base_forms import BaseModelForm
from ..models import Nakladn, NakladnItem
@ -9,6 +11,20 @@ from ..models import Nakladn, NakladnItem
class NakladnForm(BaseModelForm):
"""Форма редактирования накладной."""
sender = forms.ModelChoiceField(
Client.objects.all(),
label='клиент',
required=False,
widget=autocomplete_light.ChoiceWidget('ACClient')
)
receiver = forms.ModelChoiceField(
Client.objects.all(),
label='клиент',
required=False,
widget=autocomplete_light.ChoiceWidget('ACClient')
)
adjust_client_fields = []
class Meta:
model = Nakladn
fields = (
@ -18,9 +34,16 @@ class NakladnForm(BaseModelForm):
'client',
'invoice',
'doc_reason',
'doc_reason_num',
'doc_reason_date',
'nds_value',
'nds_method',
'doc_text',
'transport',
'transport_date',
'transport_num',
'sender',
'receiver',
)
_radioselect = forms.RadioSelect
_textarea = forms.Textarea(attrs={'cols': 80, 'rows': 3})

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from django.db import models
from customer.models import Client
from docs.models.base_models import BaseInvoiceModel, BaseItemInvoiceModel
from docs.models.mixins import SignedStatusFieldMixin, InvoiceFieldMixin
from docs.models.linked_docs_mixin import LinkedDocsMixin
@ -9,6 +10,30 @@ from docs.models.linked_docs_mixin import LinkedDocsMixin
class Nakladn(BaseInvoiceModel, SignedStatusFieldMixin, InvoiceFieldMixin, LinkedDocsMixin):
"""Накладная торг12."""
doc_reason = models.CharField('Основание', max_length=256, blank=True, default='')
doc_reason_num = models.PositiveIntegerField('Номер основания', blank=True, null=True)
doc_reason_date = models.DateField('Дата основания', blank=True, null=True)
transport = models.BooleanField('Есть транспортная накладная', default=False)
transport_num = models.PositiveIntegerField(
'Номер транспортной накладной',
blank=True,
null=True
)
transport_date = models.DateField('Дата транспортной накладной', blank=True, null=True)
user_is_sender = models.BooleanField('пользователь - отправитель', default=False)
sender = models.ForeignKey(
Client,
related_name='sender_nakladn',
blank=True,
null=True,
verbose_name='Отправитель'
)
receiver = models.ForeignKey(
Client,
related_name='receiver_nakladn',
blank=True,
null=True,
verbose_name='Получатель'
)
class Meta(BaseInvoiceModel.Meta):
verbose_name = 'Накладная'

@ -27,6 +27,7 @@ class FakturaViews(BaseItemsViews, AddByInvoiceMethodMixin):
# префикс формы табличной части
ITEM_FORM_PREFIX = 'faktura_items'
# фильтры
FILTERSET_CLASS = FakturaFilterSet # фильтры
# по какому полю суммировать табличную часть документа при показе списком
@ -47,25 +48,25 @@ class FakturaViews(BaseItemsViews, AddByInvoiceMethodMixin):
# для генерации pdf/xls
PDF_TEMPLATE = 'docs/faktura/as_pdf.html'
XLS_TEMPLATE = 'faktura.xls'
FILENAME = u'Счёт-фактура № %s, %s' # без расширения
FILENAME = 'Счёт-фактура № %s, %s' # без расширения
# --- грамматика для вывода наименований в шаблонах
PADEJI = {
'imenit': u'счёт-фактура', # кто? что?
'rodit': u'счёта-фактуры', # кого? чего?
'dateln': u'счёту-фактуре', # кому? чему?
'vinit': u'счёт-фактуру', # кого? что?
'tvorit': u'счётом-фактурой', # кем? чем?
'predlojn': u'счёте-фактуре', # о ком? о чём?
'imenit': 'счёт-фактура', # кто? что?
'rodit': 'счёта-фактуры', # кого? чего?
'dateln': 'счёту-фактуре', # кому? чему?
'vinit': 'счёт-фактуру', # кого? что?
'tvorit': 'счётом-фактурой', # кем? чем?
'predlojn': 'счёте-фактуре', # о ком? о чём?
}
PADEJI_MNOJ = {
'imenit': u'счета-фактуры', # кто? что?
'rodit': u'счетов-фактур', # кого? чего?
'dateln': u'счетам-фактурам', # кому? чему?
'vinit': u'счета-фактуры', # кого? что?
'tvorit': u'счетами-фактурами', # кем? чем?
'predlojn': u'счетах-фактурах', # о ком? о чём?
'imenit': 'счета-фактуры', # кто? что?
'rodit': 'счетов-фактур', # кого? чего?
'dateln': 'счетам-фактурам', # кому? чему?
'vinit': 'счета-фактуры', # кого? что?
'tvorit': 'счетами-фактурами', # кем? чем?
'predlojn': 'счетах-фактурах', # о ком? о чём?
}
def prepare(self, obj, obj_items, export_to=None):

@ -48,7 +48,7 @@ class NakladnViews(BaseItemsViews, AddByInvoiceMethodMixin):
# для генерации pdf/xls
PDF_TEMPLATE = 'docs/nakladn/as_pdf.html'
XLS_TEMPLATE = 'nakladn.xls'
FILENAME = u'Накладная № %s, %s' # без расширения
FILENAME = 'Накладная № %s, %s' # без расширения
MAYBE_SIGNED = True
# --- грамматика для вывода наименований в шаблонах

@ -440,12 +440,17 @@ a.delete { vertical-align: top; }
#id_nds_value{padding-left: 2px;margin-left: 0;height: 36px;font-size: 25px;}
#id_doc_num, #id_doc_date {padding-left: 2px;margin-left: 0;height: 36px;width: 155px;}
.doc-form #doc_date,
.doc-form #doc_mesto, .doc-form #end_date,
.doc-form #doc_expire_date, .doc-form #dover_doc_date, .doc-form #dover_passport_num, .doc-form #plat_doc_date
{ margin-left: 10px; }
.doc-form #doc_mesto,
.doc-form #end_date,
.doc-form #doc_expire_date,
.doc-form #dover_doc_date,
.doc-form #dover_passport_num,
.doc-form #plat_doc_date { margin-left: 10px; }
.doc-form #client .hilight {font-size:25px;}
.doc-form #client .deck {font-size:25px;}
.doc-form #sender .deck {font-size:25px;}
.doc-form #receiver .deck {font-size:25px;}
.doc-form #saldo_debit input { margin-left: 12px; }
.doc-form #saldo_credit input { margin-left: 5px; }
.doc-form #saldo_debit .errorlist, .doc-form #saldo_credit .errorlist { margin-left: 83px; }
@ -460,9 +465,10 @@ a.delete { vertical-align: top; }
.doc-form #id_dover_passport_date {}
.doc-form #dover_name .help-text,
.doc-form #dover_name .errorlist, .doc-form #dover_passport_ser .errorlist,
.doc-form #dover_passport_org .errorlist, .doc-form #dover_passport_date .errorlist
{ margin-left: 168px;margin-top: -10px; }
.doc-form #dover_name .errorlist,
.doc-form #dover_passport_ser .errorlist,
.doc-form #dover_passport_org .errorlist,
.doc-form #dover_passport_date .errorlist { margin-left: 168px;margin-top: -10px; }
.doc-form select#id_bank_account {width: 410px;height: 40px;font-size: 25px;margin-left: 0;padding-left: 2px;}
.doc-form select#id_client { width: 370px; }
@ -878,7 +884,8 @@ input[type=number] {
.fixes__wrapper,
.avance__wrapper,
.government__wrapper {
.government__wrapper,
.transport__wrapper {
padding-bottom: 7px;
font-size: 15px;
}
@ -925,7 +932,8 @@ input[type=number] {
#fixes,
#avance,
#government {
#government,
#transport {
cursor: pointer;
font-style: normal;
}
@ -1151,9 +1159,32 @@ input[type=number] {
}
#id_doc_reason {
width: 570px;
width: 325px;
}
#id_government_description {
width: 325px;
}
.bank-account__invoice {
margin-left: -15px;
}
#doc_reason_num {
margin-left: -268px;
}
#id_transport_num,
#id_doc_reason_num {
margin-right: 10px;
width: 155px;
}
#id_transport_date,
#id_doc_reason_date {
width: 155px;
}
#doc_reason_date {
margin-left: -96px;
}

@ -5,22 +5,31 @@
{% block form_content %}
<div class="block" style="border-bottom: 1px solid #777; padding: 0 20px 15px 0; margin-top: 0;">
{% include 'docs/parts/form_field.html' with field=form.doc_num id="doc_num" classes="left" label="Номер" required="True" no_clear_after="True" %}
{% include 'docs/parts/form_field.html' with field=form.doc_date id="doc_date" classes="left" label="Дата создания" required="True" %}
</div>
{% include 'docs/parts/form_field.html' with field=form.doc_date id="doc_date" classes="left" label="Дата создания" required="True" no_clear_after="True" %}
<div class="block" style="border-bottom: 1px solid #777; padding: 0 20px 5px 0;">
{% if user.profile.bank_accounts.count > 1 %}
{% include 'docs/parts/form_field.html' with field=form.bank_account id="bank_account" classes="field" label="Расчётный счёт" %}
{% include 'docs/parts/form_field.html' with field=form.bank_account id="bank_account" classes="left bank-account__invoice" label="Расчётный счёт" %}
{% else %}
{% include 'docs/parts/form_field.html' with field=form.bank_account id="bank_account" classes="field hidden" label="Расчётный счёт" %}
{% include 'docs/parts/form_field.html' with field=form.bank_account id="bank_account" classes="left bank-account__invoice" label="Расчётный счёт" %}
{% endif %}
{% include 'docs/parts/form_field_client.html' with field=form.client required="True" is_ajax="True" %}
{% include 'docs/parts/form_field.html' with field=form.invoice id="invoice" classes="field hidden" label="Создать накладную по счёту" %}
<div class="transport__wrapper"><label id="transport" for="id_transport">{{ form.transport }} Есть транспортная накладная</label></div>
<div id='transport_block' class="block{% if not form.transport.value %} hidden{% endif %}">
{% include 'docs/parts/form_field.html' with field=form.transport_num id="transport_num" classes="left" label="Номер" required="True" no_clear_after="True" %}
{% include 'docs/parts/form_field.html' with field=form.transport_date id="transport_date" classes="left" label="Дата" required="True" no_clear_after="True" %}
<div class="clear"></div>
</div>
{% include 'docs/parts/form_field.html' with field=form.doc_reason id="doc_reason" classes="left" label="Основание" no_clear_after="True" help='Например "Договор №25 от 01.01.2017" или "Заказ-наряд №23 от 01.01.2017".<br/>Можно написать "Счёт №25 от 01.01.2017", если в этом счёте указаны основные условия поставки и он заменяет договор.' %}
{% include 'docs/parts/form_field.html' with field=form.doc_reason_num id="doc_reason_num" classes="left" label="Номер" no_clear_after="True" %}
{% include 'docs/parts/form_field.html' with field=form.doc_reason_date id="doc_reason_date" classes="left" label="Дата" no_clear_after="True" %}
<div class="clear"></div>
</div>
<div class="block" style="border-bottom: 1px solid #777; padding: 0 20px 5px 0;">
{% include 'docs/parts/form_field.html' with field=form.doc_reason id="doc_reason" classes="field" label="Основание" help='Например "Договор №25 от 01.01.2017" или "Заказ-наряд №23 от 01.01.2017".<br/>Можно написать "Счёт №25 от 01.01.2017", если в этом счёте указаны основные условия поставки и он заменяет договор.' %}
{% include 'docs/parts/form_field_client.html' with field=form.client required="True" is_ajax="True" label="Плательщик" %}
{% include 'docs/parts/form_field.html' with field=form.invoice id="invoice" classes="field hidden" label="Создать накладную по счёту" %}
{% include 'docs/parts/form_field_sender.html' with field=form.sender id="sender" type="sender" %}
{% include 'docs/parts/form_field_receiver.html' with field=form.receiver id="receiver" type="receiver" %}
</div>
<div class="block" style="border-bottom: 1px solid #777; padding: 0 20px 15px 0;">

@ -1,2 +1,2 @@
{% include 'docs/parts/form_client_choices.html' with client_group="receiver_group" id="receiver_choices" classes="field" label2='Грузополучатель - стороннее лицо (не покупатель)' default=receiver_choice %}
{% include 'docs/parts/form_field_client.html' with field=form.receiver id="receiver" classes="field" label=' ' type="receiver" %}
{% include 'docs/parts/form_field_client.html' with field=form.receiver id="receiver" classes="field" label=" " type="receiver" %}

@ -2,8 +2,6 @@
<script type="text/javascript">
$(document).ready(function() {
{# console.log('-----','stab js');#}
$('tr.plat_form').formset({
prefix: '{{ pformset.prefix }}',
formCssClass: 'plat_dynamic-form'
@ -58,6 +56,10 @@
senderBlock = $('#id_sender'),
receiverBlock = $('#id_receiver');
console.log('----', client_block);
console.log('----', senderBlock);
console.log('----', receiverBlock);
// прячем кнопку добавить контрагента если он уже есть в документе
if (client_block.val()){
check_vis(add_block);
@ -170,11 +172,11 @@
$last_row.find('.price input').val(price);
$last_row.find('.total_price input').val(total_price);
// TODO: need ajax function on backend
$.get('/my/docs/ajax_get_pair/Measure/name/code/' + units + '/', function(data){
if (data['val']) {
$last_row.find('.units_kod input').val(data['val']);
}
});
{# $.get('/my/docs/ajax_get_pair/Measure/name/code/' + units + '/', function(data){#}
{# if (data['val']) {#}
{# $last_row.find('.units_kod input').val(data['val']);#}
{# }#}
{# });#}
})
})
} else {
@ -187,6 +189,7 @@
console.log(client_type);
var sender_val = $('input:checkbox[name=' + client_type + '_group]:checked', '#doc-form').val();
console.log('-----------', sender_val );
if (sender_val == 'another') {
$('#' + client_type).show()
} else {
@ -226,6 +229,13 @@
$('#avance_block').hide();
}
if ($('#id_transport').is(':checked')){
$('#transport_block').show();
} else {
$('#transport_block').hide();
}
$('#id_fixes').change(function(){
$('#fix_block').toggle();
$('#id_fix_doc_num').val('1');
@ -243,6 +253,12 @@
$('#id_government_description').val('');
});
$('#id_transport').change(function(){
$('#transport_block').toggle();
$('#transport_num').val('');
$('#transport_date').val('');
});
function displayInvoiceBlock(visibly) {
var invoiceBlock = $('#invoice');

Loading…
Cancel
Save