<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <template id="report_order">
            <t t-call="web.basic_layout">
                <t t-foreach="docs" t-as="o">
                    <!-- Multicompany -->
                    <t t-if="o and 'company_id' in o">
                        <t t-set="company" t-value="o.company_id"></t>
                    </t>
                    <t t-if="not o or not 'company_id' in o">
                        <t t-set="company" t-value="res_company"></t>
                    </t>
                    <t t-set="context" t-value="o._context"></t>

                    <div class="page">

                        <STYLE TYPE="text/css">
                            body { background: #ffffff; margin: 0; font-family: Arial; font-size: 8pt; font-style:
                            normal; }
                            tr.R0{ height: 15px; }
                            tr.R0 td.R0C1{ text-align: center; vertical-align: medium; }
                            tr.R0 td.R16C19{ font-family: Arial; font-size: 9pt; font-style: normal; vertical-align:
                            top; border-left: #000000 1px solid; border-top: #000000 1px solid; border-bottom: #000000
                            1px solid; border-right: #000000 1px solid; }
                            tr.R0 td.R16C22{ font-family: Arial; font-size: 9pt; font-style: normal; vertical-align:
                            top; border-left: #000000 1px solid; border-top: #ffffff 0px none; border-bottom: #000000
                            1px solid; border-right: #000000 1px solid; }
                            tr.R0 td.R17C1{ border-left: #000000 1px solid; border-bottom: #000000 1px solid;
                            border-right: #000000 1px solid; }
                            tr.R0 td.R19C1{ font-family: Arial; font-size: 9pt; font-style: normal; vertical-align: top;
                            border-left: #000000 1px solid; border-top: #000000 1px solid; }
                            tr.R0 td.R21C1{ font-family: Arial; font-size: 8pt; font-style: normal; vertical-align:
                            medium; border-left: #000000 1px solid; border-top: #ffffff 0px none; border-bottom: #000000
                            1px solid; }
                            tr.R0 td.R24C1{ font-family: Arial; font-size: 14pt; font-style: normal; font-weight: bold;
                            vertical-align: medium; }
                            tr.R0 td.R37C1{ text-align: center; vertical-align: top; overflow: hidden;border-left:
                            #000000 2px solid; border-top: #000000 1px solid; }
                            tr.R0 td.R37C2{ vertical-align: top; border-left: #000000 1px solid; border-top: #000000 1px
                            solid; }
                            tr.R0 td.R37C4{ text-align: right; vertical-align: top; border-left: #000000 1px solid;
                            border-top: #000000 1px solid; }
                            tr.R0 td.R37C5{ vertical-align: top; border-left: #000000 1px solid; border-top: #000000 1px
                            solid; }
                            tr.R0 td.R37C7{ text-align: right; vertical-align: top; border-left: #000000 1px solid;
                            border-top: #000000 1px solid; border-right: #000000 2px solid; }
                            tr.R15{ height: 17px; }
                            tr.R15 td.R15C1{ font-family: Arial; font-size: 9pt; font-style: normal; vertical-align:
                            top; border-left: #000000 1px solid; border-top: #000000 1px solid; border-right: #000000
                            1px solid; }
                            tr.R15 td.R15C19{ font-family: Arial; font-size: 9pt; font-style: normal; vertical-align:
                            medium; border-left: #000000 1px solid; border-top: #000000 1px solid; border-bottom:
                            #000000 1px solid; border-right: #000000 1px solid; }
                            tr.R15 td.R15C22{ font-family: Arial; font-size: 9pt; font-style: normal; vertical-align:
                            medium; border-left: #000000 1px solid; border-top: #000000 1px solid; border-bottom:
                            #ffffff 0px none; border-right: #000000 1px solid; }
                            tr.R15 td.R18C1{ font-family: Arial; font-size: 9pt; font-style: normal; vertical-align:
                            medium; border-left: #000000 1px solid; border-top: #000000 1px solid; }
                            tr.R15 td.R18C19{ font-family: Arial; font-size: 9pt; font-style: normal; vertical-align:
                            top; border-left: #000000 1px solid; border-top: #000000 1px solid; border-bottom: #000000
                            1px solid; border-right: #000000 1px solid; }
                            tr.R15 td.R18C3{ font-family: Arial; font-size: 9pt; font-style: normal; vertical-align:
                            medium; border-top: #000000 1px solid; border-right: #000000 1px solid; }
                            tr.R15 td.R29C1{ font-family: Arial; font-size: 9pt; font-style: normal; vertical-align:
                            top; }
                            tr.R15 td.R29C5{ font-family: Arial; font-size: 9pt; font-style: normal; font-weight: bold;
                            vertical-align: top; }
                            tr.R15 td.R35C1{ font-family: Arial; font-size: 9pt; font-style: normal; font-weight: bold;
                            text-align: center; vertical-align: medium; border-left: #000000 2px solid; border-top:
                            #000000 2px solid; }
                            tr.R15 td.R35C2{ font-family: Arial; font-size: 9pt; font-style: normal; font-weight: bold;
                            text-align: center; vertical-align: medium; border-left: #000000 1px solid; border-top:
                            #000000 2px solid; }
                            tr.R15 td.R35C7{ font-family: Arial; font-size: 9pt; font-style: normal; font-weight: bold;
                            text-align: center; vertical-align: medium; border-left: #000000 1px solid; border-top:
                            #000000 2px solid; border-right: #000000 2px solid; }
                            tr.R15 td.R40C6{ font-family: Arial; font-size: 9pt; font-style: normal; font-weight: bold;
                            text-align: right; vertical-align: top; }
                            tr.R15 td.R46C1{ font-family: Arial; font-size: 9pt; font-style: normal; }
                            tr.R15 td.R51C1{ font-family: Arial; font-size: 9pt; font-style: normal; font-weight: bold;
                            }
                            tr.R15 td.R51C10{ text-align: right; border-bottom: #000000 1px solid; }
                            tr.R15 td.R51C6,tr.R15 td.R51C6I,tr.R15 td.R51C6S{ border-bottom: #000000 1px solid; }
                            tr.R15 td.R51C6I,tr.R15 td.R51C6S { overflow: visible; }
                            tr.R15 td.R51C6I span,tr.R15 td.R51C6S span { position: relative; }
                            tr.R15 td.R51C6I span img { position: absolute; width: 100px; top: -40px; }
                            tr.R15 td.R51C6S span img { position: absolute; width: 140px; top: -80px; left: -100px; }
                            tr.R26{ height: 9px; }
                            tr.R26 td.R26C1{ border-bottom: #000000 2px solid; }
                            tr.R26 td.R39C1{ border-top: #000000 2px solid; }
                            table {table-layout: fixed; padding: 0px; padding-left: 2px; vertical-align:bottom;
                            border-collapse:collapse;width: 100%; font-family: Arial; font-size: 8pt; font-style:
                            normal; }
                            td { padding: 0px; padding-left: 2px; overflow:hidden; }
                            .cu_space15 { width:100%;height:15px;overflow:hidden; }
                            .cu_space44 { width:100%;height:44px;overflow:hidden; }
                            .cu_space104 { width:100%;height:104px;overflow:hidden; }
                            .cu_space31 { width:100%;height:31px;overflow:hidden; }
                            .cu_wspace { white-space:nowrap; }
                            .cu_space29 { width:100%;height:29px;overflow:hidden; }
                            .cu_space61 { width:100%;height:61px;overflow:hidden; }
                            .cu_space9 { width:100%;height:9px;overflow:hidden; }
                            tbody, table, tr, td, th{border: none;}
                        </STYLE>

                        <TABLE CELLSPACING="0">
                            <COL WIDTH="13%"/>
                            <COL WIDTH="13%"/>
                            <COL WIDTH="13%"/>
                            <COL WIDTH="13%"/>
                            <COL WIDTH="12%"/>
                            <COL WIDTH="12%"/>
                            <COL WIDTH="12%"/>
                            <COL WIDTH="12%"/>
                            <TR CLASS="R0">
                                <TD CLASS="R0C1" COLSPAN="8"> <DIV class="cu_space44"><![CDATA[&nbsp;]]></DIV></TD>
                            </TR>
                            <TR CLASS="R0">
                                <TD CLASS="R0C1" COLSPAN="8"> <DIV class="cu_space44">Внимание! Оплата данного счета означает согласие с условиями поставки товара.</DIV></TD>
                            </TR>
                            <TR CLASS="R0">
                                <TD CLASS="R0C1" COLSPAN="8"> <DIV class="cu_space44"><![CDATA[&nbsp;]]></DIV></TD>
                            </TR>
                            <TR CLASS="R15">
                                <TD CLASS="R15C1" COLSPAN="4" ROWSPAN="2">
                                    <DIV class="cu_space31" t-esc="(company.partner_id.bank_ids and company.partner_id.bank_ids[0].bank_name or '')+' '+(company.partner_id.bank_ids and company.partner_id.bank_ids[0].bank_id.city or '')"></DIV>
                                </TD>
                                <TD CLASS="R15C19">
                                    <SPAN class="cu_wspace">БИК</SPAN>
                                </TD>
                                <TD CLASS="R15C22" COLSPAN="3">
                                    <SPAN class="cu_wspace" t-esc="company.partner_id.bank_ids and company.partner_id.bank_ids[0].bank_bic or ''"></SPAN>
                                </TD>
                                <TD></TD>
                            </TR>
                            <TR CLASS="R0">
                                <TD CLASS="R16C19" ROWSPAN="2">
                                    <DIV class="cu_space29"><SPAN class="cu_wspace">Сч. №</SPAN></DIV>
                                </TD>
                                <TD CLASS="R16C22" COLSPAN="3" ROWSPAN="2">
                                    <DIV class="cu_space29">
                                        <SPAN class="cu_wspace" t-esc="company.partner_id.bank_ids and company.partner_id.bank_ids[0].bank_id.corr_acc or ''"></SPAN>
                                    </DIV>
                                </TD>
                            </TR>
                            <TR CLASS="R0">
                                <TD CLASS="R17C1" COLSPAN="4">
                                    <SPAN class="cu_wspace">Банк получателя</SPAN>
                                </TD>
                            </TR>
                            <TR CLASS="R15">
                                <TD CLASS="R18C1" COLSPAN="1"><SPAN class="cu_wspace">ИНН</SPAN></TD>
                                <TD CLASS="R18C3" COLSPAN="1"><SPAN class="cu_wspace" t-esc="company.inn or ''"></SPAN></TD>
                                <TD CLASS="R18C1" COLSPAN="1"><SPAN class="cu_wspace">КПП</SPAN></TD>
                                <TD CLASS="R18C3" COLSPAN="1"><SPAN class="cu_wspace" t-esc="company.kpp or ''"></SPAN></TD>
                                <TD CLASS="R18C19" ROWSPAN="4">
                                    <DIV class="cu_space61"><SPAN class="cu_wspace">Сч. №</SPAN></DIV>
                                </TD>
                                <TD CLASS="R18C19" COLSPAN="3" ROWSPAN="4">
                                    <DIV class="cu_space61">
                                        <SPAN class="cu_wspace" t-esc="company.partner_id.bank_ids and company.partner_id.bank_ids[0].acc_number or ''"></SPAN>
                                    </DIV>
                                </TD>
                            </TR>
                            <TR CLASS="R0">
                                <TD CLASS="R19C1" COLSPAN="4" ROWSPAN="2"><DIV class="cu_space29" t-esc="company.name or ''"></DIV></TD>
                            </TR>
                            <TR CLASS="R0">
                                <TD><![CDATA[&nbsp;]]></TD>
                            </TR>
                            <TR CLASS="R0">
                                <TD CLASS="R21C1" COLSPAN="4"><SPAN class="cu_wspace">Получатель</SPAN></TD>
                            </TR>
                            <TR CLASS="R0">
                                <TD COLSPAN="8"><![CDATA[&nbsp;]]></TD>
                            </TR>
                            <TR CLASS="R0">
                                <TD COLSPAN="8"><![CDATA[&nbsp;]]></TD>
                            </TR>
                            <TR CLASS="R0">
                                <TD CLASS="R24C1" COLSPAN="8" ROWSPAN="2">
                                    <DIV class="cu_space29">
                                        <SPAN class="cu_wspace">
                                            <t t-esc="'Комм. предложение' if o.state in ['draft','sent'] else 'Счет на оплату'"/>
                                            <t t-esc="' № '"/>
                                            <t t-esc="helper.numer(o.name)"/>
                                            <t t-esc="' от '"/>
                                            <t t-esc="helper.ru_date2(o.date_order)"/>
                                        </SPAN>
                                    </DIV>
                                </TD>
                            </TR>
                            <TR CLASS="R0">
                                <TD COLSPAN="8"><![CDATA[&nbsp;]]></TD>
                            </TR>
                            <TR CLASS="R26">
                                <TD CLASS="R26C1" COLSPAN="8"> <DIV class="cu_space9"> <SPAN><![CDATA[&nbsp;]]></SPAN></DIV></TD>
                            </TR>
                            <TR CLASS="R0">
                                <TD COLSPAN="8"><![CDATA[&nbsp;]]></TD>
                            </TR>
                            <TR CLASS="R15">
                                <TD CLASS="R29C1" COLSPAN="1">
                                    <SPAN class="cu_wspace">Поставщик:</SPAN>
                                </TD>
                                <TD CLASS="R29C5" COLSPAN="7">
                                    <t t-esc="helper.representation(company)"/>
                                </TD>
                            </TR>
                            <TR CLASS="R0">
                                <TD COLSPAN="8"><![CDATA[&nbsp;]]></TD>
                            </TR>
                            <TR CLASS="R15">
                                <TD CLASS="R29C1" COLSPAN="1">
                                    <SPAN class="cu_wspace">Покупатель:</SPAN>
                                </TD>
                                <TD CLASS="R29C5" COLSPAN="7">
                                    <t t-esc="helper.representation(o.partner_id.parent_id) if o.partner_id.parent_id else helper.representation(o.partner_id) "/>
                                </TD>
                                <TD></TD>
                            </TR>
                            <TR CLASS="R0">
                                <TD COLSPAN="8"><![CDATA[&nbsp;]]></TD>
                            </TR>
                            <TR CLASS="R15">

                                <TD CLASS="R35C1"> <SPAN class="cu_wspace">№</SPAN></TD>
                                <TD CLASS="R35C2" COLSPAN="3"><SPAN class="cu_wspace">Товары (работы, услуги)</SPAN></TD>
                                <TD CLASS="R35C2"><SPAN class="cu_wspace">Кол-во</SPAN></TD>
                                <TD CLASS="R35C2"><SPAN class="cu_wspace">Ед.</SPAN></TD>
                                <TD CLASS="R35C2"><SPAN class="cu_wspace">Цена</SPAN></TD>
                                <TD CLASS="R35C7"><SPAN class="cu_wspace">Сумма</SPAN></TD>
                            </TR>

                            <tr CLASS="R0"
                                t-foreach="o.order_line.filtered(lambda s: 'аванс' not in s.name.lower() and 'депозит' not in s.name.lower())"
                                t-as="line">
                                <TD CLASS="R37C1"><SPAN class="cu_wspace"><t t-esc="line_index+1"/></SPAN></TD>
                                <TD CLASS="R37C2" COLSPAN="3"><t t-esc="line.name or ''"/></TD>
                                <TD CLASS="R37C4"><SPAN class="cu_wspace"><t t-esc="line.product_uom_qty or ''"/></SPAN></TD>
                                <TD CLASS="R37C5"><SPAN class="cu_wspace"><t t-esc="line.product_uom_id.name or ''"/></SPAN></TD>
                                <TD CLASS="R37C4"><SPAN class="cu_wspace"><t t-esc="line.price_unit or ''"/></SPAN></TD>
                                <TD CLASS="R37C7"><SPAN class="cu_wspace"><t t-esc="(('%.2f')%(line.price_unit*line.product_uom_qty)).replace('.',',') or ''"/></SPAN></TD>
                            </tr>
                            <TR CLASS="R26">
                                <TD COLSPAN="8" CLASS="R39C1"><![CDATA[&nbsp;]]></TD>
                            </TR>
                            <TR CLASS="R15">
                               <t t-if="o.amount_tax and float(o.amount_tax) > 0">
                                   <TD CLASS="R40C6" COLSPAN="7"><SPAN class="cu_wspace">Сумма НДС: <!-- TO DO: [НДС]: --></SPAN></TD>
                                <TD CLASS="R40C6"><SPAN class="cu_wspace"><t t-esc="(('%.2f')%(o.amount_tax)).replace('.',',') or '0,00'"/></SPAN></TD>
                                </t>
                                <t t-else="">
                                      <TD CLASS="R40C6" COLSPAN="7"><SPAN class="cu_wspace">НДС:</SPAN></TD>
                                                            <TD CLASS="R40C6"><SPAN class="cu_wspace">Без НДС</SPAN></TD>
                                </t>
                                                        </TR>
                            <TR CLASS="R15">
                                <TD CLASS="R40C6" COLSPAN="7"><SPAN class="cu_wspace">Итого:</SPAN></TD>
                                <TD CLASS="R40C6"><SPAN class="cu_wspace"><t t-esc="(('%.2f')%(o.amount_total)).replace('.',',') or '0,00'"/></SPAN></TD>
                            </TR>
                            <TR CLASS="R0">
                                <TD COLSPAN="8"><![CDATA[&nbsp;]]></TD>
                            </TR>
                            <TR CLASS="R15">
                                <TD CLASS="R46C1" COLSPAN="8">
                                    <SPAN class="cu_wspace">Всего наименований <t
                                            t-esc="o.order_line and len(o.order_line) or '0' "/>, на сумму
                                        <t t-esc="o.amount_total or '0,00'"/>
                                        руб.
                                    </SPAN>
                                </TD>
                            </TR>
                            <TR CLASS="R15">
                                <TD CLASS="R29C5" COLSPAN="8">
                                    <t t-esc="helper.rubles(o.amount_total).capitalize()"/>
                                </TD>
                            </TR>
                            <TR CLASS="R15">
                                <TD CLASS="R29C5" COLSPAN="8">Условия оплаты:
                                    <t t-esc="o.payment_term_id.name"/>
                                </TD>
                            </TR>
                            <TR CLASS="R0">
                                <TD COLSPAN="8"><![CDATA[&nbsp;]]></TD>
                            </TR>
                            <TR CLASS="R26">
                                <TD CLASS="R26C1" COLSPAN="8"> <DIV class="cu_space9"> <SPAN><![CDATA[&nbsp;]]></SPAN></DIV></TD>
                            </TR>
                            <TR CLASS="R0">
                                <TD COLSPAN="8"><![CDATA[&nbsp;]]></TD>
                            </TR>
                            <TR CLASS="R0">
                                <TD COLSPAN="8"><![CDATA[&nbsp;]]></TD>
                            </TR>
                            <TR CLASS="R15">
                                <TD CLASS="R51C1" COLSPAN="1">
                                    <SPAN class="cu_wspace">Руководитель</SPAN>
                                </TD>
                                <TD CLASS="R51C10" COLSPAN="1">
                                    <t t-esc="helper.initials(company.chief_id.name)"/>
                                </TD>
                                <TD CLASS="R51C6I">
                                    <SPAN>
                                        <t t-raw="company.print_facsimile and (company.print_anywhere or context.get('mark_so_as_sent', False)) and helper.img(company.chief_id.facsimile) or ''"/>
                                    </SPAN>
                                </TD>
                                <TD CLASS="R51C6S">
                                    <SPAN>
                                        <t t-raw="company.print_stamp and (company.print_anywhere or context.get('mark_so_as_sent', False)) and helper.img(company.stamp) or ''"/>
                                    </SPAN>
                                </TD>

                                <TD CLASS="R51C1" COLSPAN="1">
                                    <SPAN class="cu_wspace">Бухгалтер</SPAN>
                                </TD>
                                <TD CLASS="R51C10" COLSPAN="1">
                                    <t t-esc="helper.initials(company.accountant_id.name)"/>
                                </TD>
                                <TD CLASS="R51C6I">
                                    <SPAN>
                                        <t t-raw="company.print_facsimile and (company.print_anywhere or context.get('mark_so_as_sent', False)) and helper.img(company.accountant_id.facsimile) or ''"/>
                                    </SPAN>
                                </TD>

                            </TR>
                        </TABLE>


                    </div>
                </t>
            </t>
        </template>
    </data>
</openerp>
