Перейти к содержимому
Odoo Меню
  • Войти
  • Попробовать бесплатно
  • Модули
    Финансы
    • Бухгалтерия
    • Выставление счетов
    • Расходы
    • Таблицы
    • Документооборот
    • Подпись
    Продажи
    • CRM
    • Продажи
    • POS Магазин
    • POS Ресторан
    • Подписки
    • Аренда
    Вебсайты
    • Конструктор вебсайтов
    • eCommerce
    • Блог
    • Форум
    • Онлайн-чат
    • Электронное обучение
    Логистика
    • Склад
    • Производство
    • PLM
    • Закупки
    • Обслуживание
    • Качество
    Отдел кадров
    • Сотрудники
    • Подбор персонала
    • Отпуска
    • Оценка персонала
    • Реферальная программа
    • Автопарк
    Маркетинг
    • SMM
    • E-mail рассылки
    • СМС рассылки
    • Мероприятия
    • Автоматизация маркетинга
    • Опросы
    Услуги
    • Проекты
    • Табели
    • Выездной сервис
    • Поддержка
    • Планирование
    • Встречи
    Продуктивность
    • Обсуждения
    • Согласование
    • IoT
    • VoIP-телефония
    • Knowledge
    • WhatsApp
    Сторонние приложения Модуль Студия Odoo Платформа Odoo Cloud
  • Индустрии
    Розничная торговля
    • Книжный магазин
    • Магазин одежды
    • Мебельный магазин
    • Продуктовый магазин
    • Строительный магазин
    • Магазин игрушек
    Гостинично-ресторанный бизнес
    • Бар и паб
    • Ресторан
    • Фастфуд
    • Гостевой дом
    • Дистрибьютор напитков
    • Отель
    Недвижимость
    • Агентство недвижимости
    • Архитектурное бюро
    • Строительство
    • Управление недвижимостью
    • Ландшафтный дизайн
    • Товарищество собственников жилья
    Консалтинг
    • Бухгалтерская фирма
    • Партнер Odoo
    • Маркетинговое агентство
    • Юридическая фирма
    • Подбор персонала
    • Аудиторское бюро
    Производство
    • Текстиль
    • Металл
    • Мебель
    • Продукты питания
    • Пивоварня
    • Корпоративные сувениры
    Здоровье и фитнес
    • Спортивный комплекс
    • Магазин оптики
    • Фитнес-клуб
    • Велнес-центр
    • Аптека
    • Салон красоты
    Услуги
    • Специалист по бытовым услугам
    • Продажа и обслуживание IT-оборудования
    • Солнечные энергосистемы
    • Производство обуви
    • Клининг
    • Системы ОВКВ
    Прочее
    • Некоммерческая организация
    • Консалтинг в сфере устойчивого развития
    • Аренда рекламных щитов
    • Бизнес по фотосъемке
    • Прокат велосипедов
    • Реселлер программного обеспечения
    Все индустрии
  • Community
    Обучение
    • Видео уроки
    • Документация
    • Сертификация
    • Тренинг
    • Блог
    • Подкаст
    Образование и развитие
    • Образовательная программа
    • Деловая игра Scale Up!
    • Экскурсия в офис Odoo
    ПО
    • Скачать
    • Сравнить версии
    • Релизы
    Сотрудничество
    • Github
    • Форум
    • Мероприятия
    • Перевод
    • Стать партнером
    • Услуги для партнеров
    • Зарегистрировать бухгалтерскую фирму
    Услуги
    • Найти партнера
    • Найти бухгалтера
    • Встреча с экспертом
    • Услуги по внедрению
    • Отзывы клиентов
    • Поддержка
    • Обновления
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Заказать демонстрацию
  • Цены
  • Поддержка

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Бухгалтерия
  • Склад
  • PoS
  • Проекты
  • MRP
All apps
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Все посты Люди Значки
Теги (Смотреть все)
odoo accounting v14 pos v15
Об этом форуме
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Все посты Люди Значки
Теги (Смотреть все)
odoo accounting v14 pos v15
Об этом форуме
Помощь

How can I add custom fields to the sale order print template?

Подписаться

Получайте уведомления о появлении активности в этом посте

Этот вопрос был отмечен
v8printsale.order
3 Ответы
13620 Представления
Аватар
Peter Nietz

We have added some extra fields to the model sale.order.line. The values in these fields are needed for some automatic calculations we do in our modules. Our code looks similar to this (minimal example):

class sale_order_line(models.Model):
    _inherit = 'sale.order.line'
    myfield1 = fields.Char(string='License key', required=False)
    myfield2 = fields.Date(string='Start date', required=False)

However we need to show these values on the printed sale order as well. Therefore we tried to extend the sale order template to include these values right behind the name field. This looks like follows:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <template id="my_report_saleorder_document" inherit_id="sale.report_saleorder_document">
            <xpath expr="//span[@t-field='l.name']" position="after">
                <span t-field="l.myfield1"/>
                <span t-field="l.myfield2"/>
            </xpath>
        </template>
    </data>
</openerp>

Unfortunately this extended template seems to have no effect. Odoo still uses the standard template and our custom fields are not shown. How can we tell Odoo to use the modified template?

 

EDIT: In the meantime we investigated a little more on the inner workings of sale order printing. It seems to be the case that Odoo has a template 'sale.report_saleorder' which in turn includes the template 'sale.report_saleorder_document':

<template id="report_saleorder">
    <t t-call="report.html_container">
        <t t-foreach="doc_ids" t-as="doc_id">
            <t t-raw="translate_doc(doc_id, doc_model, 'partner_id.lang', 'sale.report_saleorder_document')"/>
        </t>
    </t>
</template>

Our inherited version of the included template of course has a different ID 'mymodule.my_report_saleorder_document'. Maybe the problem is that the "master template" still includes the old version of the "inner template" instead of our new inherited version? But this would mean that there are two different types of "inheritance" in Odoo? Also the module sale_layout seems to do it the same way we do it? We are confused...

 

0
Аватар
Отменить
Аватар
Muhammad Hassan
Лучший ответ

I applied same logic but my field value is not displaying and parent view can not be located error occurs

0
Аватар
Отменить
Аватар
Zbik
Лучший ответ
  1. Probably you need a record:

    'depends': [ 'sale' ],

in your module, in __openerp__.py

2. You change

myfield1 = fields.Char()
myfield2 = fields.Date()

by

myfield1 = fields.Char('FOO NAME')
myfield2 = fields.Date('FOO DATE NAME')

3. Probably the values in these fields are empty and therefore do not see them in report

0
Аватар
Отменить
Peter Nietz
Автор

We already have that in our module: "depends" : [ "base", "web", "account", "sale" ]

Zbik

You have installed sale_layout module?

Peter Nietz
Автор

No, we did not have sale_layout installed. We have catched up with that now, but apparently it does not make any difference whether it is installed or not.

Zbik

Answer updated

Peter Nietz
Автор

Okay, apparently we reduced the code too much to provide a minimal example. We have changed the example code above to be closer to our actual production code. We also added another thought above.

Zbik

You code works without any problem in my test system.

Zbik

You inherit sale.order in other custom module? Eg. if sale_layout is installed he would replace a part of the report template (this with your code).

Аватар
Ankit H Gandhi(AHG)
Лучший ответ

Hello Peter Nietz,

Use below code may be help you.

<template id="my_report_saleorder_document" inherit_id="sale.report_saleorder_document">
                <xpath expr="//table[@class='table table-condensed']/thead/tr/th[1]" position="after">
                       <th>License key</th>
                       <th>Start date</th>
                </xpath>
                <xpath expr="//table[@class='table table-condensed']/tbody[@class='sale_tbody']/tr/td[1]" position="after">
                       <td><span t-field="l.myfield1"/></td>              
                       <td><span t-field="l.myfield2"/></td>
                </xpath>
        </template>

if you find this answer helpful, please give me a thumbs up vote

Regards,

Ankit H Gandhi

0
Аватар
Отменить
Не оставайтесь в стороне – присоединяйтесь к обсуждению!

Создайте аккаунт сегодня, чтобы получить доступ к эксклюзивным функциям и стать частью нашего замечательного сообщества!

Регистрация
Похожие посты Ответы Просмотры Активность
Create a print view for a tree view
v8 print
Аватар
Аватар
1
июл. 15
9790
Email template is failed to render ? [SOLVED] Решено
v8 sale.order email_template
Аватар
Аватар
Аватар
Аватар
4
янв. 19
33119
How to modify count total amount in sale order? [SOLVED] Решено
v8 sale.order override
Аватар
Аватар
Аватар
3
янв. 18
10034
Where is it possible to view the "Warning message" as defined in product form?
message v8 sale.order
Аватар
0
мая 16
4507
v8: Error when print BoM
v8 print bom
Аватар
0
мар. 15
4754
Сообщество
  • Видео уроки
  • Документация
  • Форум
Открытый исходный код
  • Скачать
  • Github
  • Runbot
  • Перевод
Услуги
  • Хостинг Odoo.sh
  • Поддержка
  • Обновление
  • Индивидуальные решения по доработке
  • Образование
  • Найти бухгалтера
  • Найти партнера
  • Стать партнером
О нас
  • Наша компания
  • Активы бренда
  • Cвяжитесь с нами
  • Вакансии
  • Мероприятия
  • Подкаст
  • Блог
  • Клиенты
  • Правовые документы • Конфиденциальность
  • Безопасность
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo – это набор бизнес-модулей с открытым исходным кодом, который закроет все потребности вашей компании: CRM, E-commerce, Бухгалтерия, Склад, POS, управление проектами и др.

Odoo сочетает в себе простоту использования и полную интеграцию всех бизнес-процессов в одной системе.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now