Skip to Content
Odoo Menu
  • Prisijungti
  • Išbandykite nemokamai
  • Programėlės
    Finansai
    • Apskaita
    • Pateikimas apmokėjimui
    • Sąnaudos
    • Skaičiuoklė (BI)
    • Dokumentai
    • Pasirašymas
    Pardavimai
    • CRM
    • Pardavimai
    • Kasų sistema - Parduotuvė
    • Kasų sistema - Restoranas
    • Prenumeratos
    • Nuoma
    Svetainės
    • Svetainių kūrėjimo įrankis
    • El. Prekyba
    • Internetinis Tinklaraštis
    • Forumas
    • Tiesioginis pokalbis
    • eMokymasis
    Tiekimo grandinė
    • Atsarga
    • Gamyba
    • PLM
    • Įsigijimai
    • Priežiūra
    • Kokybė
    Žmogaus ištekliai
    • Darbuotojai
    • Įdarbinimas
    • Atostogos
    • Įvertinimai
    • Rekomendacijos
    • Transporto priemonės
    Rinkodara
    • Socialinė rinkodara
    • Rinkodara el. paštu
    • SMS rinkodara
    • Renginiai
    • Rinkodaros automatizavimas
    • Apklausos
    Paslaugos
    • Projektas
    • Darbo laiko žiniaraščiai
    • Priežiūros tarnyba
    • Pagalbos tarnyba
    • Planavimas
    • Rezervacijos
    Produktyvumas
    • Diskucija
    • Patvirtinimai
    • IoT
    • VoIP
    • Žinių biblioteka
    • WhatsApp
    Trečiųjų šalių programos Odoo Studija Odoo debesijos platforma
  • Pramonės šakos
    Mažmeninė prekyba
    • Knygynas
    • Drabužių parduotuvė
    • Baldų parduotuvė
    • Maisto prekių parduotuvė
    • Techninės įrangos parduotuvė
    • Žaislų parduotuvė
    Food & Hospitality
    • Barai ir pub'ai
    • Restoranas
    • Greitasis maistas
    • Guest House
    • Gėrimų platintojas
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architektūros įmonė
    • Konstrukcija
    • Estate Managament
    • Sodininkauti
    • Turto savininkų asociacija
    Consulting
    • Accounting Firm
    • Odoo Partneris
    • Marketing Agency
    • Teisinė firma
    • Talentų paieška
    • Auditai & sertifikavimas
    Gamyba
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Įmonių dovanos
    Sveikata & Fitnesas
    • Sporto klubas
    • Akinių parduotuvė
    • Fitneso Centras
    • Sveikatos praktikai
    • Vaistinė
    • Kirpėjas
    Trades
    • Handyman
    • IT įranga ir palaikymas
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Aplinkos agentūra
    • Reklaminių stendų nuoma
    • Fotografavimas
    • Dviračių nuoma
    • Programinės įrangos perpardavėjas
    Browse all Industries
  • Bendrija
    Mokykitės
    • Mokomosios medžiagos
    • Dokumentacija
    • Sertifikatai
    • Mokymai
    • Internetinis Tinklaraštis
    • Tinklalaidės
    Skatinkite švietinimą
    • Švietimo programa
    • Scale Up! Verslo žaidimas
    • Aplankykite Odoo
    Gaukite programinę įrangą
    • Atsisiųsti
    • Palyginkite versijas
    • Leidimai
    Bendradarbiauti
    • Github
    • Forumas
    • Renginiai
    • Vertimai
    • Tapkite partneriu
    • Services for Partners
    • Registruokite jūsų apskaitos įmonę
    Gaukite paslaugas
    • Susiraskite partnerį
    • Susirask buhalterį
    • Susitikti su konsultantu
    • Diegimo paslaugos
    • Klientų rekomendavimas
    • Palaikymas
    • Atnaujinimai
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Gaukite demo
  • Kainodara
  • Pagalba

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

  • CRM
  • e-Commerce
  • Apskaita
  • Atsarga
  • PoS
  • Projektas
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
Pagalba

Hide journals, odoo 10 [SOLVED]

Prenumeruoti

Get notified when there's activity on this post

This question has been flagged
journalhide10.0
2 Replies
2776 Rodiniai
Portretas
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
Portretas
Atmesti
Portretas
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
Portretas
Atmesti
Learning_Odoo
Autorius

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
Autorius

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
Autorius

It's solved, thanks for your help!

Portretas
Learning_Odoo
Autorius 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
Portretas
Atmesti
Enjoying the discussion? Don't just read, join in!

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

Registracija
Related Posts Replies Rodiniai Veikla
[Odoo 10] How to create a journal through code (custom module)? Solved
journal sale.order 10 10.0
Portretas
Portretas
1
geg. 17
9570
How can you create journal sequences based on accounting posting dates? Solved
journal
Portretas
Portretas
2
birž. 22
3652
Can't reconcile bank statement line
10.0
Portretas
Portretas
Portretas
Portretas
4
bal. 20
10153
Can not close POS session in Odoo 10 Solved
accounting pos journal 10 10.0
Portretas
Portretas
3
gruod. 19
9967
how to use field from same model Solved
10.0
Portretas
Portretas
1
lapkr. 19
4742
Bendrija
  • Mokomosios medžiagos
  • Dokumentacija
  • Forumas
Atvirasis kodas
  • Atsisiųsti
  • Github
  • Runbot
  • Vertimai
Paslaugos
  • Odoo.sh talpinimas
  • Palaikymas
  • Atnaujinti
  • Pritaikytas programavimo kūrimas
  • Švietimas
  • Susirask buhalterį
  • Susiraskite partnerį
  • Tapkite partneriu
Apie mus
  • Mūsų įmonė
  • Prekės ženklo turtas
  • Susisiekite su mumis
  • Darbo pasiūlymai
  • Renginiai
  • Tinklalaidės
  • Internetinis Tinklaraštis
  • Klientai
  • Teisinis • Privatumas
  • Saugumas
الْعَرَبيّة 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 yra atvirojo kodo verslo programų rinkinys, kuris apima visas įmonės poreikius: CRM, El. Prekybą, Apskaitą, Atsargų, Kasų sistemą, Projektų valdymą ir kt.

Unikali Odoo vertės pasiūla – būti tuo pačiu metu labai lengvai naudojama ir visiškai integruota sistema.

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