Перейти к содержимому
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
Об этом форуме
Помощь

One2many field issue openerpv7

Подписаться

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

Этот вопрос был отмечен
1 Ответить
3456 Представления
Аватар
TEIMI Yassine

On account.voucher I added a one2many field like this : 

'bls_to_pay': fields.one2many('stock.picking.out','bl_id','BLS to pay'),

I added a many2one field on both stock.picking.out and stock.picking like this : 

'bl_id': fields.many2one('account.voucher','BLs to pay'),

On stock.picking.out, I have a field "num_bl", that I added by inheritance. and so as to add a field into stock.picking.out, you have also to add it on stock.picking as well, and that's what I did.

The probleme is when I try to display the field on the one2many tree, it prints on log the following error : 

Can't find field num_bl on the following view parts composing the view of object model account.voucher, either you wrongly customzed the view, or some modules bringing those views are not compatible with your current data model.

All of this knowing that I tried with other fields of stock.picking, wich have been created initially with the model, and not added by inheritance and it worked, the problem is just with the field "num_bl", wich have been added by inheritance ( custome  module ).

Here is an example, working for date field of stock.picking : http://prntscr.com/5euiix

Why this behaviour occurs ?

1
Аватар
Отменить
Ivan

The error message indicates that you tried to create a view for account.voucher model that contains num_bl field. As you have stated this field is in the stock.picking. Maybe you can post your view here so that it can be analyzed further.

Ivan

Also you might want to post the definition of num_bl field as well complete with the class.

Аватар
TEIMI Yassine
Автор Лучший ответ

Hi Ivan, 

Here after the object inheritance made, so as to add the field 'num_bl' :

Module name : add_num_bl

Path : add_num_bl/stock.py

from openerp.osv import fields, orm

class StockPicking(orm.Model):

    _inherit = 'stock.picking'
    _name = 'stock.picking'
    _columns = {
        'num_bl': fields.char('Numero BL',size=64),
        'bl_id': many2one('account.voucher','BLs to Pay', ondelete='cascade'),

    }
    _sql_constraints = [
        ('bl_uniq','unique(num_bl)','Numero BL est unique, veuillez verifier. !')]


class StockPickingOut(orm.Model):

    _inherit = 'stock.picking.out'
    _name = 'stock.picking.out'
    _columns = {
        'num_bl': fields.char('Numero BL',size=64),

        'bl_id': many2one('account.voucher','BLs to Pay', ondelete='cascade'),

    }


Stock_view.xml :

 

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record id="view_bl_custom_form" model="ir.ui.view">
            <field name="name">picking.custom.form</field>
            <field name="model">stock.picking.out</field>
            <field name="inherit_id" ref="stock.view_picking_out_form"/>
            <field name="arch" type="xml">
                <xpath expr="//form/sheet/group/group/field[@name='origin']" position="after">
                    <field name="num_bl"/>
                </xpath>
        </field>
        </record>
        <record id="view_bl_custom_tree" model="ir.ui.view">
            <field name="name">picking.custom.tree</field>
            <field name="model">stock.picking.out</field>
            <field name="inherit_id" ref="stock.view_picking_out_tree"/>
            <field name="arch" type="xml">
                <xpath expr="//tree/field[@name='partner_id']" position="after">
                    <field name="num_bl"/>
                </xpath>
            </field>
        </record>

    </data>
</openerp>


I created another custom module to :


1. Customize voucher_sales_purchase_view.xml, by creating another view, and ignoring the old one, I didn't pass by inheritance because I needed to redefine the view ( a lot of radical changes ).
2. Add the one2many field : "bls_to_pay".

Module name : account_payment_bl

Path : account_payment_bl/account_voucher.py

from openerp.osv import fields, orm

class AccountVoucher(orm.Model):

    _inherit = 'account.voucher'
    _name = 'account.voucher'
    _columns = {
        'bls_to_pay': fields.one2many('stock.picking.out','bl_id','BLS to pay'),
    }

voucher_sales_purchase_view.xml :

I just posted the view that interests us the most in this question.

<!-- Voucher on delivery order : Form view-->
    <record model="ir.ui.view" id="view_encaissement_sur_bl_form">
        <field name="name">account.encaissement.surbl.form</field>
            <field name="model">account.voucher</field>
            <field name="arch" type="xml">
                <form string="Encaissement sur BL" version="7.0">
                <header invisible="context.get('line_type', False)">
                    <button name="proforma_voucher" string="Validate" states="draft" class="oe_highlight"/>
                    <button name="cancel_voucher" string="Annuler Encaissement" states="draft,proforma"/>
                    <button name="cancel_voucher" string="Annuler Operation" type="object" states="posted" confirm="Are you sure to unreconcile and cancel this record ?"/>
                    <button name="action_cancel_draft" type="object" states="cancel" string="Set to Draft"/>
                    <field name="state" widget="statusbar" statusbar_visible="draft,posted" statusbar_colors='{"proforma":"blue"}'/>
                </header>
                <sheet>
                    <h1 attrs="{'invisible': [('number','=',False)]}"><field name="number"/></h1>
                    <group invisible="context.get('line_type', False)">
                        <group>
                            <field name="partner_id" domain="[('customer','=',True)]" required="1" string="Customer" context="{'search_default_customer': 1}"/>
                            <field name="currency_id" invisible="1"/>
                            <field name="amount" class="oe_inline"
                                string="Paid Amount"
                                widget="monetary" options="{'currency_field': 'currency_id'}"/>
                            <field name="journal_id"
                                domain="[('type','in',['bank', 'cash'])]"
                                widget="selection"
                                on_change="onchange_journal(journal_id, line_cr_ids, False, partner_id, date, amount, type, company_id, context)"
                                string="Payment Method"/>
                        </group>
                        <group>
                            <field name="date" on_change="onchange_date(date, currency_id, payment_rate_currency_id, amount, company_id, context)"/>
                            <field name="reference" string="Payment Ref" placeholder="e.g. 003/10"/>
                            <field name="name" colspan="2" placeholder="e.g. Invoice SAJ/0042"/>
                            <field name="company_id" widget="selection" groups="base.group_multi_company"/>

                            <field name="account_id"
                                widget="selection"
                                invisible="True"/>
                            <field name="pre_line" invisible="1"/>
                            <field name="type" invisible="True"/>
                        </group>
                    </group>
                    <notebook>
                        <page string="Payment Information" groups="base.group_user">
                            <label for="line_cr_ids" invisible="context.get('line_type', False)"/>
                            <field name="line_cr_ids" context="{'journal_id':journal_id, 'type':type, 'partner_id':partner_id}" on_change="onchange_line_ids(line_dr_ids, line_cr_ids, amount, currency_id, type, context)">
                                <tree string="Invoices and outstanding transactions" editable="bottom" colors="gray:amount==0">
                                    <field name="move_line_id" context="{'journal_id':parent.journal_id, 'partner_id':parent.partner_id}"
                                           domain="[('account_id.type','in',('receivable','payable')), ('reconcile_id','=', False), ('partner_id','=',parent.partner_id)]"                                 required="1" groups="account.group_account_user"/>
                                    <field name="account_id"  groups="base.group_no_one" domain="[('type','=','receivable')]"/>
                                    <field name="date_original" readonly="1"/>
                                    <field name="date_due" readonly="1"/>
                                    <field name="amount_original" readonly="1"/>
                                    <field name="amount_unreconciled" readonly="1" groups="account.group_account_user"/>
                                    <field name="reconcile" on_change="onchange_reconcile(reconcile, amount, amount_unreconciled, context)" groups="account.group_account_user"/>
                                    <field name="amount" sum="Total Allocation" on_change="onchange_amount(amount, amount_unreconciled, context)" string="Allocation"/>
                                </tree>
                            </field>
                            <label for="line_dr_ids" attrs="{'invisible': [('pre_line','=',False)]}"/>
                            <field name="line_dr_ids" attrs="{'invisible': [('pre_line','=',False)]}" context="{'journal_id':journal_id, 'partner_id':partner_id}" on_change="onchange_line_ids(line_dr_ids, line_cr_ids, amount, currency_id, type, context)">
                                <tree string="Credits" editable="bottom" colors="gray:amount==0">
                                    <field name="move_line_id" context="{'journal_id':parent.journal_id, 'partner_id':parent.partner_id}"
                                        on_change="onchange_move_line_id(move_line_id)"
                                        domain="[('account_id.type','in',('receivable','payable')), ('reconcile_id','=', False), ('partner_id','=',parent.partner_id)]"
                                        required="1"/>
                                    <field name="account_id"  groups="base.group_no_one" domain="[('type','=','receivable')]"/>
                                    <field name="date_original" readonly="1"/>
                                    <field name="date_due" readonly="1"/>
                                    <field name="amount_original" readonly="1"/>
                                    <field name="amount_unreconciled" readonly="1"/>
                                    <field name="reconcile" on_change="onchange_reconcile(reconcile, amount, amount_unreconciled, context)"/>
                                    <field name="amount" sum="Total Allocation" on_change="onchange_amount(amount, amount_unreconciled, context)" string="Allocation"/>
                                </tree>
                            </field>
                            <group col="3">
                                <group>
                                    <field name="narration" colspan="2" nolabel="1"/>
                                </group>
                                <group col="4" attrs="{'invisible':[('is_multi_currency','=',False)]}">
                                    <field name="is_multi_currency" invisible="1"/>
                        <label for="payment_rate" colspan="1"/>
                                   <div>
                                        <field name="payment_rate" required="1" class="oe_inline" on_change="onchange_amount(amount, payment_rate, partner_id, journal_id, currency_id, type, date, payment_rate_currency_id, company_id, context)"/>
                                        <field name="payment_rate_currency_id" class="oe_inline" on_change="onchange_payment_rate_currency(currency_id, payment_rate, payment_rate_currency_id, date, amount, company_id, context)" groups="base.group_multi_currency"/>
                                    </div>
                                    <field name="currency_help_label" colspan="2" nolabel="1" class="oe_grey"/>
                                    <field name="paid_amount_in_company_currency" colspan="4" invisible="1"/>
                                </group>
                                <group>
                                    <field name="writeoff_amount" widget="monetary" options="{'currency_field': 'currency_id'}"/>
                                    <field name="payment_option" required="1" attrs="{'invisible':[('writeoff_amount','=',0)]}"/>
                                    <field name="writeoff_acc_id" attrs="{'invisible':['|', ('payment_option','!=','with_writeoff'), ('writeoff_amount','=',0)], 'required':[('payment_option','=','with_writeoff')]}" domain="[('type','=','other')]"/>
                                    <field name="comment"
                                           attrs="{'invisible':['|', ('payment_option','!=','with_writeoff'), ('writeoff_amount','=',0)]}"/>
                                    <field name="analytic_id"
                                           groups="analytic.group_analytic_accounting"
                                           attrs="{'invisible':['|', ('payment_option','!=','with_writeoff'), ('writeoff_amount','=',0)]}"/>
                                </group>
                            </group>
                        </page>
                        <page string="bls">            
                            <field name="bls_to_pay" readonly="1">
                                <tree string="BLs to pay">
                                    <field name="num_bl"/>
                                    <field name="date"/>
                                    <field name="origin"/>                                  
                                </tree>
                            </field>
                        </page>

                        <page string="Journal Items" attrs="{'invisible': [('state','!=','posted')]}">
                            <group col="4">
                                <field name="period_id"/>
                                <field name="audit"/>
                            </group>
                            <field name="move_ids" readonly="1">
                                <tree string="Journal Items">
                                    <field name="move_id"/>
                                    <field name="ref"/>
                                    <field name="date"/>
                                    <field name="statement_id"/>
                                    <field name="partner_id"/>
                                    <field name="account_id"/>
                                    <field name="name"/>
                                    <field name="debit"/>
                                    <field name="credit"/>
                                    <field name="state"/>
                                    <field name="reconcile_id"/>
                                    <field name="amount_currency"/>
                                    <field name="currency_id" groups="base.group_multi_currency"/>
                                </tree>
                            </field>
                        </page>
                    </notebook>
                    </sheet>
                    <div class="oe_chatter" invisible="context.get('line_type', False)">
                        <field name="message_follower_ids" widget="mail_followers"/>
                        <field name="message_ids" widget="mail_thread"/>
                    </div>
                </form>
            </field>
        </record>

I made the page that I want to add in bold and itallic.

0
Аватар
Отменить
Ivan

Have you tried setting the model to stock.picking instead of stock.picking.out when defining the bls_to_pay field? So: 'bls_to_pay': fields.one2many('stock.picking','bl_id','BLS to pay'). Inheritance for stock.picking is particularly unique as all 3 models (stock.picking, stock.picking.in, stock.picking.out) share the same table. The only one truly linked to the table is stock.picking, which is the base model.

TEIMI Yassine
Автор

Yes i've tried this, same result ...

TEIMI Yassine
Автор

And when I add the fields direclty on the objects : stock.picking and stock.picking.out, without passing by inheritance, it works, and everything looks fine ...

Ivan

And module account_payment_bl depends on module add_num_bl?

TEIMI Yassine
Автор

No I didn't make any dependency between them, account_payment_bl depends on account_voucher, because it extends it.

Ivan

You should because account_payment_bl uses 'bl_id' field of stock.picking which is created by add_num_bl. So, in a way account_payment_bl can only work if add_num_bl is there and installed. Dependency also affects how the sequence inheritance will be called.

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

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

Регистрация
Сообщество
  • Видео уроки
  • Документация
  • Форум
Открытый исходный код
  • Скачать
  • 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