Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Jídlo a pohostinství
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Penzion
    • Distributor nápojů
    • Hotel
    Nemovitost
    • Realitní kancelář
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Poradenství
    • Účetní firma
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textil
    • Kov
    • Nábytek
    • Jídlo
    • Pivovar
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Transakce
    • Údržbář
    • Podpora IT & hardware
    • Systémy solární energie
    • Výrobce obuvi
    • Úklidové služby
    • Služby HVAC
    Ostatní
    • Nezisková organizace
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Procházet všechna odvětví
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Služby pro partnery
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

Inherit partner_id from account.payment with different domain. How to do it?

Odebírat

Get notified when there's activity on this post

This question has been flagged
inheritancepaymentsodoo12.0
2 Odpovědi
6788 Zobrazení
Avatar
Paulo Matos

Hello everyone,

I am working with Odoo 12 and having a problem on setting a domain on a form view for the account.payments model.

What I need to do is to show only users (partner_id) that has the field "parent_id" = False under partner_id field.

I have successfully tried on the account.invoice and changed the xml for the form view to:

       <record id="mymodule_form_view_account_invoice" model="ir.ui.view">
           <field name="name">Account Invoice Hide Children Partners</field>
           <field name="model">account.invoice</field>
           <field name="inherit_id" ref="account.invoice_form"/>
           <field name="arch" type="xml">
                <xpath expr="//field[@name='partner_id']" position="replace">
                       <field string="Customer" name="partner_id" widget="res_partner_many2one" context="{'search_default_customer':1, 'show_address': 1, 'default_is_company': True, 'show_vat': True}" options="{"always_reload": True, "no_quick_create": True}" domain="[('customer', '=', True),('parent_id', '=', False)]" required="1"/>
                </xpath>
          </field>
      </record>

I was able to hide partners with "parent_id" using the domain:

       domain="[('customer', '=', True),('parent_id', '=', False)]" required="1"

Tried to do the same for the account.payment model and was unable to achieve what I want.

I can see that on the account.payment form view there's a "partner_id" field and tried to:

       <field name="partner_id" domain="[('parent_id', '=', False)]" attrs="{'required': [('state', '=', 'draft'), ('payment_type', 'in', ('inbound', 'outbound'))], 'invisible': [('payment_type', 'not in', ('inbound', 'outbound'))], 'readonly': [('state', '!=', 'draft')]}" context="{'default_is_company': True, 'default_supplier': payment_type == 'outbound', 'default_customer': payment_type == 'inbound'}"/>

...and it does not work.

Using debug mode with mouse over the field, I can see that the domain is applied but it simple does not work.

Then, I have noticed that, in fact there is no "partner_id" on the account.payment form. This field in on the "account.abstract.payment" abstract model that is shared among models which allows to register payments.

Since I cannot find any related xml id for this model for changing the partner_id default values, I have tried to directly (for testing purposes) change the field definition to:

      _name = "account.abstract.payment"
      ....
      ....
      partner_id = fields.Many2one('res.partner', string='Partner', domain=lambda self: [("parent_id", "=", "False")])

Even adding the domain above on the field definition, I am unable to achieve what I need.

Can anyone help me please?

Thank you all in advance

Best regards

PM

0
Avatar
Zrušit
Avatar
Avinash Nk
Nejlepší odpověď

Hello Paulo Matos,

Like the way you expected, this problem is not because of that

This is happening because there is an onchange function in account.payment model that returns the domain of the partner_id.

So even if you put some domains in XML, it overrides by that function.

This onchange function is work when you change the partner_type field. so it will always execute when you create a new record.

So better you have to override that function.

Like this.


@api.onchange('partner_type')
def _onchange_partner_type(self):
self.ensure_one()
# Set partner_id domain
if self.partner_type:
return {'domain': {'partner_id': [(self.partner_type, '=', True), ('parent_id', '=', False)]}}



Code is not tested. I hope it will work.

Anyway, I think you get some idea about this.


Edited Part:

----

This code is for inheriting the function instead of the override.

@api.onchange('partner_type')
def _onchange_partner_type(self):
res = super(YourClass, self)._onchange_partner_type()
if 'domain' in res:
if 'partner_id' in res['domain']:
res['domain']['partner_id'].append(('parent_id', '=', False))
else:
res['domain']['partner_id'] = [('parent_id', '=', False)]
return res
else:
return {'domain': {'partner_id': [('parent_id', '=', False)]}}


-----

Thanks & Regards

Avinash N K


1
Avatar
Zrušit
Paulo Matos
Autor

@Avinash,

Thank you very much for your help and time.

The code itself did not work but with your help I get an idea of what the problem is.

Thank you very very much

Best regards

PM

Avinash Nk

Hi EuroGold,

I update some code for you. check if it helps you.

Thanks

Paulo Matos
Autor

@Avinash,,

Thank you once again.

Your code worked exactly as expected.

Thank you very much once again

Best regards

PM

Avatar
Arturo Velázquez
Nejlepší odpověď

Hello Avinash & Paulo.

I'm facing the same issue, I am unable to change the domain of partner_id field on account.payments model.  I see Avinash posted the solution to this problem, but I don't know how and where to put the code for inherit the onchange function.  Can someone put me in the right direction?  Best regards

0
Avatar
Zrušit
Enjoying the discussion? Don't just read, join in!

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

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
Inherit a method without copy/paste full original code Vyřešeno
inheritance odoo12.0
Avatar
Avatar
1
zář 19
4533
How to inherit view and add widget in Odoo 12CE ? Vyřešeno
form inheritance odoo12.0
Avatar
1
srp 23
6663
how to use model inheritance on the existing Product model to add some field for my new module ? Vyřešeno
inheritance product.product Module odoo12.0
Avatar
Avatar
Avatar
4
dub 19
9300
Expected singleton: hr.emp.travel.location(62, 63)
odoo12.0
Avatar
Avatar
Avatar
2
říj 25
1981
When registering payment, i get "can't create a new payment without an outstanding payments/receipts account set"
payments
Avatar
Avatar
1
dub 25
2982
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 je balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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