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

Hide journals, odoo 10 [SOLVED]

Подписаться

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

Этот вопрос был отмечен
journalhide10.0
2 Ответы
2773 Представления
Аватар
Learning_Odoo

Hi, I have a boolean field in account.journal , and I have this function in account.payment:

@api.onchange('payment_type')
def _onchange_payment_type(self):
if not self.
invoice_ids:
# Set default partner type for the payment type
​if self.
payment_type == 'inbound':
​ ​self.
partner_type = 'customer'
# Set payment method domain
​res = self._onchange_journal()
​if not
res.get('domain', {}):
​ ​res['domain'] = {}
​res['domain']['journal_id'] = self.payment_type == 'inbound' and ​[('at_least_one_inbound', '=', True)] or []
​res['domain']['journal_id'].append(('type', 'in', ('bank', 'cash')))
​if self.
invoice_ids:
​ ​res['domain']['journal_id'].append(('ap_ar', '=', True))
​return
res


What this function does is that if I activate the boolean that is in account.journal in any of the journals (in this case for banks and cash), those journals will be hidden when registering a payment in customer invoices... but for some reason it is also applied when registering a payment in vendor invoices, when I only want the function to be applied to customer invoices...

What can I do so that the function does not apply to both customers and suppliers and that it only applies to customer invoices?

Odoo 10, thank you.

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

to modify the _onchange_payment_type function in Odoo 10 so that it only applies to customer invoices and not vendor invoices, you can make the following changes:

@api.onchange('payment_type')
def _onchange_payment_type(self):
if not self.invoice_ids:
# Set default partner type for the payment type
if self.payment_type == 'inbound':
self.partner_type = 'customer'
# Set payment method domain
res = self._onchange_journal()
if not res.get('domain', {}):
res['domain'] = {}
res['domain']['journal_id'] = [('type', 'in', ('bank', 'cash'))]
if self.invoice_ids:
res['domain']['journal_id'].append(('ap_ar', '=', True))
else:
# Reset journal domain for outbound payments (vendor invoices)
res = self._onchange_journal()
if not res.get('domain', {}):
res['domain'] = {}
res['domain']['journal_id'] = [('type', 'in', ('bank', 'cash'))]
return res


In the modified code, we introduce an else block after setting the default partner type for inbound payments. Inside the else block, we reset the journal domain by calling _onchange_journal() and assign a new domain that includes only the journals with type "bank" or "cash". This ensures that the journal domain is not modified for outbound payments (vendor invoices).

By making this change, the function will only apply the specific logic for customer invoices when the payment type is set to "inbound". For vendor invoices, the function will perform the default behavior without modifying the journal domain.


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

Hello, thanks for answering, apparently it doesn't work since I put the lines of code that are after the else and even so it continues to take the condition in both customer invoices and supplier invoices, here is my code:
@api.onchange('payment_type')
def _onchange_payment_type(self):
if not self.invoice_ids:
# Set default partner type for the payment type
if self.payment_type == 'inbound':
self.partner_type = 'customer'
# Set payment method domain
res = self._onchange_journal()
if not res.get('domain', {}):
res['domain'] = {}
res['domain']['journal_id'] = [('type', 'in', ('bank', 'cash'))]
if self.invoice_ids:
res['domain']['journal_id'].append(('ap_ar', '=', True))
else:
# Reset journal domain for outbound payments (vendor invoices)
res = self._onchange_journal()
if not res.get('domain', {}):
res['domain'] = {}
res['domain']['journal_id'] = [('type', 'in', ('bank', 'cash'))]
return res
It is supposed that only the journals should be hidden in customer invoices, all the journals should appear in supplier invoices, but it doesn't work.
Thank you!

shubham shiroya

try this way:
@api.onchange('payment_type')
def onchange_payment_type(self):
if not self.invoice_ids:
# Set default partner type for the payment type
if self.payment_type == 'inbound':
self.partner_type = 'customer'
# Set payment method domain
domain = [('type', 'in', ('bank', 'cash'))]
if self.invoice_ids:
domain.append(('ap_ar', '=', True))
return {'domain': {'journal_id': domain}}
return {}

In this code, we directly return the domain in the onchange_payment_type method based on the condition for customer invoices. If the payment type is 'inbound' (customer invoice), we set the domain to only include journals with types 'bank' or 'cash' and optionally with the 'ap_ar' field set to True. If the condition is not met, we return an empty dictionary to indicate no changes to the domain.

By using this approach, the function should apply the specific logic for customer invoices and not modify the journal domain for vendor invoices.

Learning_Odoo
Автор

It didn't work either, as it was missing to give the final touch to the if, the only thing I did in the if was to add that the type of payment was 'inbound' so that it could apply the domain, and that's how it already worked.... I don't know if it was OK, I show you my code:

@api.onchange('payment_type')
def _onchange_payment_type(self):
​if not self.invoice_ids:
​# Set default partner type for the payment type
​ ​if self.payment_type == 'inbound':
​ ​ ​self.partner_type = 'customer'
​# Set payment method domain
​domain = [('type', 'in', ('bank', 'cash'))]
​ ​if self.invoice_ids and self.payment_type == 'inbound':
​ ​ ​domain.append(('ap_ar', '=', True))
​ ​return {'domain': {'journal_id': domain}}
​ ​return {}

In this way it does work, since when I activate the boolean in any of the journals, it shows me in the customer invoices only the journals that have the checkbox activated, and in the supplier invoices this filter no longer applies to me, now it only applies to me the filter that shows me all the newspapers that are in the bank and cash.

Thank you!

Learning_Odoo
Автор

It's solved, thanks for your help!

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

It didn't work either, as it was missing to give the final touch to the if, the only thing I did in the if was to add that the type of payment was 'inbound' so that it could apply the domain, and that's how it already worked.... I don't know if it was OK, I show you my code:

@api.onchange('payment_type')
def _onchange_payment_type(self):
​if not self.invoice_ids:
​# Set default partner type for the payment type
​ ​if self.payment_type == 'inbound':
​ ​ ​self.partner_type = 'customer'
​# Set payment method domain
​domain = [('type', 'in', ('bank', 'cash'))]
​ ​if self.invoice_ids and self.payment_type == 'inbound':
​ ​ ​domain.append(('ap_ar', '=', True))
​ ​return {'domain': {'journal_id': domain}}
​ ​return {}

In this way it does work, since when I activate the boolean in any of the journals, it shows me in the customer invoices only the journals that have the checkbox activated, and in the supplier invoices this filter no longer applies to me, now it only applies to me the filter that shows me all the newspapers that are in the bank and cash.

Thank you!

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

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

Регистрация
Похожие посты Ответы Просмотры Активность
[Odoo 10] How to create a journal through code (custom module)? Решено
journal sale.order 10 10.0
Аватар
Аватар
1
мая 17
9569
How can you create journal sequences based on accounting posting dates? Решено
journal
Аватар
Аватар
2
июн. 22
3645
Can't reconcile bank statement line
10.0
Аватар
Аватар
Аватар
Аватар
4
апр. 20
10149
Can not close POS session in Odoo 10 Решено
accounting pos journal 10 10.0
Аватар
Аватар
3
дек. 19
9956
how to use field from same model Решено
10.0
Аватар
Аватар
1
нояб. 19
4720
Сообщество
  • Видео уроки
  • Документация
  • Форум
Открытый исходный код
  • Скачать
  • 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