<?xml version="1.0" encoding="UTF-8"?>
<odoo>
    <record id="paperformat_a4" model="report.paperformat">
        <field name="name">A4</field>
        <field name="default" eval="True"/>
        <field name="format">A4</field>
        <field name="page_height">0</field>
        <field name="page_width">0</field>
        <field name="orientation">Portrait</field>
        <field name="margin_top">15</field>
        <field name="margin_bottom">30</field>
        <field name="margin_left">7</field>
        <field name="margin_right">7</field>
        <field name="header_line" eval="False"/>
        <field name="header_spacing">10</field>
        <field name="dpi">90</field>
    </record>

    <record id="action_report_contract_customer" model="ir.actions.report">
       <field name="name">Договор</field>
       <field name="model">partner.contract.customer</field>
       <field name="report_type">qweb-pdf</field>
       <field name="report_name">l10n_ru_contract.report_contract_customer</field>
       <field name="report_file">l10n_ru_contract.report_contract_customer</field>
       <field name="print_report_name">'Договор - %s' % (object.name)</field>
       <field name="binding_model_id" ref="l10n_ru_contract.model_partner_contract_customer" />
       <field name="paperformat_id" ref="paperformat_a4" />
       <field name="binding_type">report</field>
    </record>

    <template id="report_contract_customer">
        <t t-call="web.basic_layout">
            <t t-foreach="docs" t-as="o">
                <t t-if="o and 'company_id' in o">
                    <t t-set="company" t-value="o.company_id"/>
                </t>
                <t t-if="not o or not 'company_id' in o">
                    <t t-set="company" t-value="res_company"/>
                </t>
                <t t-set="context" t-value="o._context"/>
                <div class="header">
                    <STYLE TYPE="text/css">
                        body {background: #ffffff; margin: 0; font-family: Times new roman; font-size: 12pt; font-style:
                        normal;}
                        tr.R0{height: 15px;}
                        tr.R0 td.R0C0{ font-family: Times new roman; font-size: 11pt; font-style: normal; text-align:
                        left; vertical-align: medium; font-weight: bold;}
                        tr.R0 td.R0C1{ font-family: Times new roman; font-size: 11pt; font-style: normal; text-align:
                        right; vertical-align: medium; font-weight: bold;}
                    </STYLE>
                    <table border="0" cellpadding="0" cellspacing="0" style="width:100%">
                        <tbody>
                            <tr class="R0">
                                <td class="R0C0">
                                    <t t-esc="o.company_id.name or ''"/>
                                </td>
                                <td class="R0C1">Договор
                                    <t t-esc="o.name or ''"/>
                                    от
                                    <t
                                            t-esc="o.date_start or ''"/>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <div class="page">
                    <STYLE TYPE="text/css">
                        body {background: #ffffff; margin: 0; font-family: Times new roman; font-size: 12pt; font-style:
                        normal;}
                        tr.R0{height: 15px;}
                        tr.R0 td.R0C0{ font-family: Times new roman; font-size: 11pt; font-style: normal; font-weight:
                        bold; text-align: center; vertical-align: medium;}
                        tr.R0 td.R0C1{ font-family: Times new roman; font-size: 11pt; font-style: normal; text-align:
                        left; vertical-align: medium;}
                        tr.R0 td.R0C2{ font-family: Times new roman; font-size: 11pt; font-style: normal; text-align:
                        right; vertical-align: medium;}
                        tr.R0 td.R0C3{ font-family: Times new roman; font-size: 12pt; font-style: normal; text-align:
                        justify; vertical-align: medium; margin: 40px;}
                        p.R0C4{ font-family: Times new roman; font-size: 12pt; font-style: normal; text-align: center;
                        vertical-align: medium; font-weight: bold;}
                        div.R0C5{ font-family: Times new roman; font-size: 12pt; font-style: normal; text-align:
                        justify; vertical-align: medium;}
                        tr.R0 td.R0C4{ font-family: Times new roman; font-size: 12pt; font-style: normal; text-align:
                        center; vertical-align: medium; font-weight: bold;}
                        tr.R0 td.R0C5{ font-family: Times new roman; font-size: 12pt; font-style: normal; text-align:
                        justify; vertical-align: medium;}
                        tr.R0 td.R0C6rtl{ font-family: Times new roman; font-size: 11pt; font-style: normal;
                        font-weight: bold; text-align: left; vertical-align: medium; border-left: #000000 1px solid;
                        border-top: #000000 1px solid; border-right: #000000 1px solid;}
                        tr.R0 td.R0C6rl{ font-family: Times new roman; font-size: 11pt; font-style: normal; font-weight:
                        bold; text-align: left; vertical-align: medium; border-left: #000000 1px solid; border-right:
                        #000000 1px solid}
                        tr.R0 td.R0C6r{ font-family: Times new roman; font-size: 11pt; font-style: normal; font-weight:
                        bold; text-align: left; vertical-align: medium; border-right: #000000 1px solid}
                        tr.R0 td.R0C6l{ font-family: Times new roman; font-size: 11pt; font-style: normal;
                        text-align: left; vertical-align: medium; border-left: #000000 1px solid;}
                        tr.R0 td.R0C6b{ font-family: Times new roman; font-size: 11pt; font-style: normal; font-weight:
                        bold; text-align: left; vertical-align: medium; border-top: #000000 1px solid;}
                        tr.R0 td.R0C6t{ font-family: Times new roman; font-size: 11pt; font-style: normal; font-weight:
                        bold; text-align: left; vertical-align: medium; border-top: #000000 1px solid;}
                        tr.R0 td.R0C6rbl{ font-family: Times new roman; font-size: 11pt; font-style: normal;
                        font-weight: bold; text-align: left; vertical-align: medium; border-left: #000000 1px solid;
                        border-right: #000000 1px solid; border-bottom: #000000 1px solid;}
                        tr.R0 td.R0C7rtl{ font-family: Times new roman; font-size: 11pt; font-style: normal; text-align:
                        left; vertical-align: medium; border-left: #000000 1px solid; border-top: #000000 1px solid;
                        border-right: #000000 1px solid;}
                        tr.R0 td.R0C7rl{ font-family: Times new roman; font-size: 11pt; font-style: normal; text-align:
                        left; vertical-align: medium; border-left: #000000 1px solid; border-right: #000000 1px solid;}
                        tr.R0 td.R0C7rbl{ font-family: Times new roman; font-size: 11pt; font-style: normal; text-align:
                        left; vertical-align: medium; border-left: #000000 1px solid; border-right: #000000 1px solid;
                        border-bottom: #000000 1px solid;}
                        tr.R0 td.R0C6tI{ font-family: Times new roman; font-size: 11pt; font-style: normal; font-weight:
                        bold; text-align: left; vertical-align: medium; border-bottom: #000000 1px solid;}
                        tr.R0 td.R0C6tI { overflow: visible; }
                        tr.R0 td.R0C6tI span { position: relative; }
                        tr.R0 td.R0C6tI span img { position: absolute; width: 100px; top: -30px; left: 80px; }
                        tr.R0 td.R0C6tS { overflow: visible; }
                        tr.R0 td.R0C6tS span { position: relative; }
                        tr.R0 td.R0C6tS span img { position: absolute; width: 140px; top: -40px; left: -200px; }
                    </STYLE>
                    <table border="0" cellpadding="0" cellspacing="0" style="width:100%; page-break-inside: auto;">
                        <tbody>
                            <tr class="R0">
                                <td class="R0C0" colspan="2">Договор №
                                    <t t-esc="o.name"/>
                                </td>
                            </tr>
                            <tr class="R0">
                                <td class="R0C0" colspan="2">на поставку продукции</td>
                            </tr>
                            <tr class="R0">
                                <td class="R0C1"></td>
                                <td class="R0C2"></td>
                            </tr>
                            <tr class="R0">
                                <td class="R0C1">
                                    <t t-esc="company.partner_id.city"/>
                                </td>
                                <td class="R0C2">
                                    <t t-esc="o.get_date_text(o.date_start)"/>
                                </td>
                            </tr>
                            <tr class="R0">
                                <td class="R0C1"></td>
                                <td class="R0C2"></td>
                            </tr>
                            <tr class="R0">
                                <td class="R0C3" colspan="2">
                                    <span>
                                        <t t-raw="o.contract_header or ''"/>
                                    </span>
                                </td>
                                <tr class="R0">
                                    <td class="R0C1"></td>
                                    <td class="R0C2"></td>
                                </tr>
                            </tr>
                            <!--t t-foreach="o.lines.sorted(key=lambda r: r.sequence, reverse=False)" t-as="line">
                              <tr class="R0">
                                <td  class="R0C4" colspan="2"><t t-esc="line.name"/></td>
                              </tr>
                              <tr class="R0">
                                <td  class="R0C5" colspan="2"><span><t t-raw="line.punct"/></span></td>
                              </tr>
                              <tr class="R0">
                                <td  class="R0C5" colspan="2"></td>
                              </tr>
                            </t-->
                        </tbody>
                    </table>
                    <t t-foreach="o.lines_ids.sorted(key=lambda r: r.sequence, reverse=False)" t-as="line">
                        <p class="R0C4">
                            <t t-esc="line.name or ''"/>
                        </p>
                        <div class="R0C5">
                            <span>
                                <t t-raw="line.punct or ''"/>
                            </span>
                        </div>
                    </t>
                    <table border="0" cellpadding="0" cellspacing="0" style="width:100%; page-break-inside: avoid;">
                        <COL WIDTH="5%"/>
                        <COL WIDTH="30%"/>
                        <COL WIDTH="15%"/>
                        <COL WIDTH="5%"/>
                        <COL WIDTH="30%"/>
                        <COL WIDTH="15%"/>
                        <tbody>
                            <tr class="R0">
                                <td class="R0C4" colspan="6">Реквизиты и подписи сторон.</td>
                            </tr>
                            <tr class="R0">
                                <td class="R0C1" colspan="6"></td>
                            </tr>
                            <tr class="R0">
                                <td class="R0C6rtl" colspan="3">Поставщик:</td>
                                <td class="R0C6rtl" colspan="3">Покупатель:</td>
                            </tr>
                            <tr class="R0">
                                <td class="R0C6rl" colspan="3">
                                    <t t-esc="o.company_id.name or ''"/>
                                </td>
                                <td class="R0C6rl" colspan="3">
                                    <t t-esc="o.partner_id.name or ''"/>
                                </td>
                            </tr>
                            <tr class="R0">
                                <td class="R0C6l" colspan="3">ИНН
                                    <t t-esc="o.company_id.inn or ''"/>
                                </td>
                                <td class="R0C7rl" colspan="3">ИНН
                                    <t t-esc="o.partner_id.inn or ''"/>
                                </td>
                            </tr>
                            <tr class="R0">
                                <td class="R0C6l" colspan="2">ОГРН
                                    <t t-esc="o.company_id.company_registry or ''"/>
                                </td>
                                <td class="R0C6r" rowspan="2">
                                    <t t-esc="o.director_name_company or ''"/>
                                </td>
                                <t t-if="o.partner_type in ['company', 'company_ip']">
                                    <td class="R0C7rl" colspan="3">ОГРН
                                        <t t-esc="o.partner_id.ogrn or ''"/>
                                    </td>
                                </t>
                                <t t-else="">
                                    <td class="R0C7rl" colspan="3">Паспорт
                                        <t t-esc="o.partner_id.passport or ''"/>
                                    </td>
                                </t>
                            </tr>
                            <tr class="R0">
                                <td class="R0C6l" colspan="3">КПП
                                    <t t-esc="o.company_id.kpp or ''"/>
                                </td>
                                <t t-if="o.partner_type == 'company'">
                                    <td class="R0C7rl" colspan="3">КПП
                                        <t t-esc="o.partner_id.kpp or ''"/>
                                    </td>
                                </t>
                                <t t-else="">
                                    <td class="R0C7rl" colspan="3"></td>
                                </t>
                            </tr>
                            <!--                            <tr class="R0">-->
                            <!--                                <td class="R0C6rl" colspan="3">Расчетный счет:</td>-->
                            <!--                                <td class="R0C6rl" colspan="3">Расчетный счет:</td>-->
                            <!--                            </tr>-->
                            <!--                            <tr class="R0">-->
                            <!--                                <td class="R0C6l" colspan="3">-->
                            <!--                                    <t t-raw="o.get_bank(o.company_id.partner_id) or ''"/>-->
                            <!--                                </td>-->
                            <!--                                <td class="R0C7rl" colspan="3">-->
                            <!--                                    <t t-raw="o.get_bank(o.partner_id) or ''"/>-->
                            <!--                                </td>-->
                            <!--                            </tr>-->
                            <!--                                                        <td class="R0C6tI">-->
                            <!--                                                            <SPAN>-->
                            <!--                                                                <t-->
                            <!--                                                                        t-raw="o.stamp and o.img(company.chief_id.facsimile) or ''"/>-->
                            <!--                                                            </SPAN>-->
                            <!--                                                        </td>-->
                            <tr class="R0">
                                <td class="R0C6rl" colspan="3">Юридический адрес:
                                </td>
                                <td class="R0C6rl" colspan="3">Юридический адрес:
                                </td>
                            </tr>
                            <tr class="R0">
                                <td class="R0C6l" colspan="3">
                                    <t t-esc="o.address(o.company_id) or ''"/>
                                </td>
                                <td class="R0C7rl" colspan="3">
                                    <t t-esc="o.address(o.partner_id) or ''"/>
                                </td>
                            </tr>
                            <tr class="R0">
                                <td class="R0C6rl" colspan="3"></td>
                                <td class="R0C6rl" colspan="3"></td>
                            </tr>
                            <tr class="R0">
                                <td class="R0C6rl" colspan="3"></td>
                                <td class="R0C6rl" colspan="3"></td>
                            </tr>
                            <tr class="R0">
                                <td class="R0C6rl" colspan="3"></td>
                                <td class="R0C6rl" colspan="3"></td>
                            </tr>
                            <tr class="R0">
                                <td class="R0C6rl" colspan="3"></td>
                                <td class="R0C6rl" colspan="3"></td>
                            </tr>
                            <tr class="R0">
                                <td class="R0C6rl" colspan="3"></td>
                                <td class="R0C6rl" colspan="3"></td>
                            </tr>
                            <tr class="R0">
                                <td class="R0C6l"></td>
                                <td class="R0C6tI">
                                    <SPAN>
                                        <t t-raw="o.stamp and o.img(o.company_id.chief_id.facsimile) or ''"/>
                                    </SPAN>
                                </td>
                                <td class="R0C6tS">
                                    <SPAN>
                                        <t t-raw="o.stamp and o.img(o.company_id.stamp) or ''"/>
                                    </SPAN>
                                </td>
                                <td class="R0C6rl" colspan="3"></td>
                            </tr>
                            <tr class="R0">
                                <td class="R0C6rl" colspan="3"></td>
                                <td class="R0C6l"></td>
                                <td class="R0C6b"></td>
                                <td class="R0C6r">
                                    <t t-esc="''"/>
                                </td>
                            </tr>
                            <tr class="R0">
                                <td class="R0C6rl" colspan="3"></td>
                                <td class="R0C6rl" colspan="3"></td>
                            </tr>
                            <tr class="R0">
                                <td class="R0C6rl" colspan="3"></td>
                                <td class="R0C6rl" colspan="3"></td>
                            </tr>
                            <tr class="R0">
                                <td class="R0C6rl" colspan="3"></td>
                                <td class="R0C6rl" colspan="3"></td>
                            </tr>
                            <tr class="R0">
                                <td class="R0C6rl" colspan="3"></td>
                                <td class="R0C6rl" colspan="3"></td>
                            </tr>
                            <tr class="R0">
                                <td class="R0C6rl" colspan="3"></td>
                                <td class="R0C6rl" colspan="3"></td>
                            </tr>
                            <tr class="R0">
                                <td class="R0C6rbl" colspan="3"></td>
                                <td class="R0C6rbl" colspan="3"></td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <div class="footer">
                    <STYLE TYPE="text/css">
                        body {background: #ffffff; margin: 0; font-family: Times new roman; font-size: 12pt; font-style:
                        normal;}
                        tr.R0{height: 30px;}
                        tr.R0 td.R0C0{ font-family: Times new roman; font-size: 11pt; font-style: normal; font-weight:
                        bold; text-align: left; vertical-align: bottom;}
                        tr.R0 td.R0C1{ font-family: Times new roman; font-size: 11pt; font-style: normal; font-weight:
                        bold; text-align: right; vertical-align: bottom;}
                        tr.R0 td.R0C6tI{ font-family: Times new roman; font-size: 11pt; font-style: normal; font-weight:
                        bold; text-align: left; vertical-align: top; border-bottom: #000000 1px solid;}
                        tr.R0 td.R0C6tI { overflow: visible; }
                        tr.R0 td.R0C6tI span { position: relative; }
                        tr.R0 td.R0C6tI span img { position: absolute; width: 100px; top: -5px; left: 5px;}
                    </STYLE>
                    <table border="0" cellpadding="0" cellspacing="0" style="width:100%">
                        <COL WIDTH="20%"/>
                        <COL WIDTH="20%"/>
                        <COL WIDTH="20%"/>
                        <COL WIDTH="20%"/>
                        <COL WIDTH="20%"/>
                        <tbody>
                            <tr class="R0">
                                <td class="R0C0">Подпись Исполнителя</td>
                                <td class="R0C6tI">
                                    <SPAN>
                                        <t
                                                t-raw="o.stamp and o.img(company.chief_id.facsimile) or ''"/>
                                    </SPAN>
                                </td>
                                <td class="R0C0"></td>
                                <td class="R0C1">Подпись Заказчика</td>
                                <td class="R0C6tI"></td>
                            </tr>
                        </tbody>
                    </table>
                    <div class="row">
                        <div class="col-xs-3 pull-right">
                            <small style="font-size:18px;">
                                <span>Страница</span>
                                <span class="page"/>
                                из
                                <span class="topage"/>
                            </small>
                        </div>
                    </div>
                </div>
            </t>
        </t>
    </template>
</odoo>
