Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Aplikacije
    Finance
    • Knjigovodstvo
    • Obračun
    • Stroški
    • Spreadsheet (BI)
    • Dokumenti
    • Podpisovanje
    Prodaja
    • CRM
    • Prodaja
    • POS Shop
    • POS Restaurant
    • Naročnine
    • Najem
    Spletne strani
    • Website Builder
    • Spletna trgovina
    • Blog
    • Forum
    • Pogovor v živo
    • eUčenje
    Dobavna veriga
    • Zaloga
    • Proizvodnja
    • PLM
    • Nabava
    • Vzdrževanje
    • Kakovost
    Kadri
    • Kadri
    • Kadrovanje
    • Odsotnost
    • Ocenjevanja
    • Priporočila
    • Vozni park
    Marketing
    • Družbeno Trženje
    • Email Marketing
    • SMS Marketing
    • Dogodki
    • Avtomatizacija trženja
    • Ankete
    Storitve
    • Projekt
    • Časovnice
    • Storitve na terenu
    • Služba za pomoč
    • Načrtovanje
    • Termini
    Produktivnost
    • Razprave
    • Odobritve
    • IoT
    • Voip
    • Znanje
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industrije
    Trgovina na drobno
    • Book Store
    • Trgovina z oblačili
    • Trgovina s pohištvom
    • Grocery Store
    • Trgovina s strojno opremo računalnikov
    • Trgovina z igračami
    Food & Hospitality
    • Bar and Pub
    • Restavracija
    • Hitra hrana
    • Guest House
    • Beverage Distributor
    • Hotel
    Nepremičnine
    • Real Estate Agency
    • Arhitekturno podjetje
    • Gradbeništvo
    • Estate Management
    • Vrtnarjenje
    • Združenje lastnikov nepremičnin
    Svetovanje
    • Računovodsko podjetje
    • Odoo Partner
    • Marketinška agencija
    • Law firm
    • Pridobivanje talentov
    • Audit & Certification
    Proizvodnja
    • Tekstil
    • Metal
    • Pohištvo
    • Hrana
    • Brewery
    • Poslovna darila
    Health & Fitness
    • Športni klub
    • Trgovina z očali
    • Fitnes center
    • Wellness Practitioners
    • Lekarna
    • Frizerski salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Sistemi sončne energije
    • Izdelovalec čevljev
    • Čistilne storitve
    • HVAC Services
    Ostali
    • Neprofitna organizacija
    • Agencija za okolje
    • Najem oglasnih panojev
    • Fotografija
    • Najem koles
    • Prodajalec programske opreme
    Browse all Industries
  • Skupnost
    Learn
    • Tutorials
    • Dokumentacija
    • Certifikati
    • Šolanje
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Prenesi
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Dogodki
    • Prevodi
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Sklici kupca
    • Podpora
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Določanje cen
  • Pomoč

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

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

Hide journals, odoo 10 [SOLVED]

Naroči se

Get notified when there's activity on this post

This question has been flagged
journalhide10.0
2 Odgovori
2806 Prikazi
Avatar
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
Avatar
Opusti
Avatar
shubham shiroya
Best Answer

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
Avatar
Opusti
Learning_Odoo
Avtor

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
Avtor

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
Avtor

It's solved, thanks for your help!

Avatar
Learning_Odoo
Avtor Best Answer

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
Avatar
Opusti
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Prijavi
Related Posts Odgovori Prikazi Aktivnost
[Odoo 10] How to create a journal through code (custom module)? Solved
journal sale.order 10 10.0
Avatar
Avatar
1
maj 17
9606
How can you create journal sequences based on accounting posting dates? Solved
journal
Avatar
Avatar
2
jun. 22
3663
Can't reconcile bank statement line
10.0
Avatar
Avatar
Avatar
Avatar
4
apr. 20
10170
Can not close POS session in Odoo 10 Solved
accounting pos journal 10 10.0
Avatar
Avatar
3
dec. 19
9981
how to use field from same model Solved
10.0
Avatar
Avatar
1
nov. 19
4758
Community
  • Tutorials
  • Dokumentacija
  • Forum
Open Source
  • Prenesi
  • Github
  • Runbot
  • Prevodi
Services
  • Odoo.sh Hosting
  • Podpora
  • Nadgradnja
  • Custom Developments
  • Izobraževanje
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Sredstva blagovne znamke
  • Kontakt
  • Zaposlitve
  • Dogodki
  • Podcast
  • Blog
  • Stranke
  • Pravno • Zasebnost
  • Varnost
الْعَرَبيّة 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 is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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