İçereği Atla
Odoo Menü
  • Portal
  • Ücretsiz deneyin
  • Uygulamalar
    Finans
    • Muhasebe
    • Faturalama
    • Masraf Yönetimi
    • Elektronik Çizelge (BI)
    • Belgeler
    • İmza
    Satış
    • Müşteri İlişkileri Yönetimi (CRM)
    • Satış
    • Satış Noktası Mağaza
    • Satış Noktası Restoran
    • Abonelikler
    • Kiralama
    Web Sitesi
    • Web Sitesi Oluşturucu
    • eTicaret
    • Blog
    • Forum
    • Canlı Sohbet
    • eÖğrenme
    Tedarik Zinciri
    • Envanter
    • Üretim
    • Ürün Yaşam Döngüsü Yönetimi
    • Satın Alma
    • Bakım
    • Kalite
    İnsan Kaynakları
    • Çalışanlar
    • İşe Alım
    • İzin
    • Değerlendirme
    • Referans
    • Filo Yönetimi
    Pazarlama
    • Sosyal Medyada Pazarlama
    • E-posta ile Pazarlama
    • SMS ile Pazarlama
    • Etkinlikler
    • Pazarlama Otomasyonu
    • Anket
    Hizmetler
    • Proje Yönetimi
    • Çalışma Çizelgeleri
    • Saha Hizmeti
    • Yardım Masası
    • Planlama
    • Randevular
    Verimlilik
    • Sohbet
    • Onay
    • Nesnelerin İnterneti
    • VoIP
    • Bilgi Bankası
    • WhatsApp
    Üçüncü taraf uygulamalar Odoo Stüdyo Odoo Bulut Platformu
  • Sektörler
    Perakende satış
    • Kitapçı
    • Giyim Mağazası
    • Mobilya Mağazası
    • Gıda Marketi
    • Hırdavat Dükkanı
    • Oyuncak Dükkanı
    Gıda ve Konaklama
    • Bar ve Pub
    • Restoran
    • Fast Food Restoranı
    • Konuk Evi
    • İçecek Distribütörü
    • Otel
    Gayrimenkul
    • Emlak Acentesi
    • Mimarlık Firması
    • İnşaat
    • Emlak Yönetimi
    • Bahçe Tasarımı
    • Mülk Sahipleri Derneği
    Uzmanlık
    • Muhasebe Firması
    • Odoo Partner
    • Pazarlama Ajansı
    • Hukuk Firması
    • Yetenek Kazanımı
    • Denetim ve Belgelendirme
    Üretim
    • Tekstil
    • Metal
    • Mobilyalar
    • Gıda
    • Bira fabrikası
    • Kurumsal Hediye
    Sağlık ve Spor
    • Spor Kulübü
    • Optik Mağazası
    • Fitness Merkezi
    • Sağlıklı Yaşam Merkezi
    • Eczane
    • Kuaför Salonu
    Ticaret
    • Tamirci
    • BT Donanım & Destek
    • Güneş Enerjisi Sistemleri
    • Ayakkabı İmalatçısı
    • Temizlik Hizmetleri
    • HVAC Hizmetleri
    Diğerleri
    • Kar Amacı Gütmeyen Kuruluş
    • Çevre Ajansı
    • Reklam Panosu Kiralama
    • Fotoğrafçılık
    • Bisiklet Kiralama
    • Yazılım Bayisi
    Tüm Sektörlere Göz Atın
  • Topluluk
    Öğrenim
    • Eğitim Araçları
    • Dokümantasyon
    • Sertifikasyonlar
    • Eğitim Etkinlikleri
    • Blog
    • Podcast
    Eğitim ve Gelişim
    • Eğitim Programı
    • Scale Up! İşletme Oyunu
    • Odoo'yu Ziyaret Edin
    Yazılım
    • İndirin
    • Sürümleri Kıyaslayın
    • Sürümler
    İş Birliği
    • Github
    • Forum
    • Etkinlikler
    • Çeviriler
    • Partner Olun
    • Partnerler için Hizmetler
    • Muhasebe Firmanızı Kaydettirin
    Hizmetler
    • Partner Bulun
    • Muhasebeci Bulun
    • Bir danışmanla görüşün
    • Kurulum Hizmetleri
    • Müşteri Referansları
    • Destek
    • Sürüm Yükseltme
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Demo randevusu alın
  • Fiyatlandırma
  • Yardım

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

  • Müşteri İlişkileri Yönetimi
  • e-Commerce
  • Muhasebe
  • Envanter
  • PoS
  • Proje Yönetimi
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiketler (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiketler (View all)
odoo accounting v14 pos v15
About this forum
Yardım

Odoo14 Action Server Error - Unable to call fields of current model in context correctly

Abone Ol

Get notified when there's activity on this post

Bu soru işaretlendi
xmlwindow_actionserver_actionsv14
1 Cevapla
2896 Görünümler
Avatar
Kahina

I am facing an issue while trying to define an action server in Odoo14. The objective is to call a Python method that returns a window action because I need to access fields in the current model and pass them to the context. Unfortunately, directly using a window action with a context that calls fields doesn't seem to be working as expected. Below is the code snippet I am using:


XML Code: 

<odoo>

<record id="action_add_supplier_payment_bank_statement_line_new" model="ir.actions.server">

    <field name="name">Créer un paiement</field>

    <field name="model_id" ref="account.model_account_bank_statement_line"/>

    <field name="binding_model_id" ref="account.model_account_bank_statement_line"/>

    <field name="state">code</field>

    <field name="binding_view_types">list</field>

    <field name="code">action = model.action_payment_bank_statement_line()</field>

</record>

</odoo>



Python Method:

def action_payment_bank_statement_line(self):
        action_ref = 'account.view_account_payment_form'
        print(action_ref)
        action = self.env['ir.actions.act_window']._for_xml_id(action_ref)
        action['context'] = {
            'default_payment_type': 'outbound',
            'default_partner_type': 'customer',
            'default_ref': self.payment_ref,
            'default_amount': self.amount,
            'default_date': datetime.strptime(self.date, '%Y-%m-%d')
        }
        action['view_mode'] = 'form'
        action['target'] = 'new'
        return action

However, I'm encountering the following error when I click on action button:

result = request.dispatch()
  File "/opt/odoo14/odoo/odoo/http.py", line 696, in dispatch
    result = self._call_function(**self.params)
  File "/opt/odoo14/odoo/odoo/http.py", line 370, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/opt/odoo14/odoo/odoo/service/model.py", line 94, in wrapper
    return f(dbname, *args, **kwargs)
  File "/opt/odoo14/odoo/odoo/http.py", line 358, in checked_call
    result = self.endpoint(*a, **kw)
  File "/opt/odoo14/odoo/odoo/http.py", line 919, in __call__
    return self.method(*args, **kw)
  File "/opt/odoo14/odoo/odoo/http.py", line 544, in response_wrap
    response = f(*args, **kw)
  File "/opt/odoo14/odoo/addons/web/controllers/main.py", line 1728, in run
    result = action.run()
  File "/opt/odoo14/odoo/odoo/addons/base/models/ir_actions.py", line 632, in run
    res = runner(run_self, eval_context=eval_context)
  File "/opt/odoo14/odoo/addons/website/models/ir_actions.py", line 61, in _run_action_code_multi
    res = super(ServerAction, self)._run_action_code_multi(eval_context)
  File "/opt/odoo14/odoo/odoo/addons/base/models/ir_actions.py", line 501, in _run_action_code_multi
    safe_eval(self.code.strip(), eval_context, mode="exec", nocopy=True)  # nocopy allows to return 'action'
  File "/opt/odoo14/odoo/odoo/tools/safe_eval.py", line 347, in safe_eval
    raise ValueError('%s: "%s" while evaluating\n%r' % (ustr(type(e)), ustr(e), expr))
Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/odoo14/odoo/odoo/http.py", line 652, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/opt/odoo14/odoo/odoo/http.py", line 317, in _handle_exception
    raise exception.with_traceback(None) from new_cause
ValueError: : "" while evaluating
'action = record.action_payment_bank_statement_line()'


I would appreciate any assistance in identifying and correcting the issue in the code, or any alternative suggestions for defining the action server correctly.

0
Avatar
Vazgeç
Avatar
Kahina
Üretici En İyi Yanıt

The issue was with how the action values were returned into python method. Here is the updated code: 
 


def action_payment_bank_statement_line(self):
        view_id = self.env.ref('account.view_account_payment_form').id
        ctx = {
                      'default_payment_type': 'inbound',
                      'default_partner_type': 'customer',
                      'default_ref': self.payment_ref,
                      'default_amount': self.amount,
                      'default_date': datetime.strptime(str(self.date), '%Y-%m-%d').date()
              }
        return {'type': 'ir.actions.act_window',
                'res_model': 'account.payment',
                'target': 'new',
                'view_mode': 'form',
                'views': [[view_id, 'form']],
                'context': ctx
        }


        

 


0
Avatar
Vazgeç
Enjoying the discussion? Don't just read, join in!

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

Üye Ol
İlgili Gönderiler Cevaplar Görünümler Aktivite
Odoo14 Action Server Error - Unable to Call Python Method Correctly
window_action server_actions v14
Avatar
0
Oca 24
95
Add button at header in tree view using xpath Çözüldü
xml v14
Avatar
Avatar
1
Eyl 24
3185
XML showing both result of t-if and t-else
xml v14
Avatar
Avatar
1
May 23
3821
how to access key value from nested dictionary in xml qweb report odoo14?
xml v14
Avatar
Avatar
1
Eyl 21
6370
Which addons have examples of python server actions (preferably stored in XML data files)?
xml server_actions
Avatar
Avatar
1
Mar 15
9017
Topluluk
  • Eğitim Araçları
  • Dokümantasyon
  • Forum
Açık Kaynak
  • İndirin
  • Github
  • Runbot
  • Çeviriler
Hizmetler
  • Odoo.sh Hosting
  • Destek
  • Sürüm Yükseltme
  • Özel Geliştirmeler
  • Eğitim
  • Muhasebeci Bulun
  • Partner Bulun
  • Partner Olun
Hakkında
  • Şirketimiz
  • Pazarlama Gereçleri
  • İletişim
  • Kariyer
  • Etkinlikler
  • Podcast
  • Blog
  • Müşteriler
  • Hukuki • Gizlilik
  • Güvenlik
الْعَرَبيّة 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, müşteri ilişkileri yönetimi, eTicaret, muhasebe, envanter, satış noktası, proje yönetimi gibi şirketinizin tüm ihtiyaçlarını karşılayan bir açık kaynak işletme uygulamaları paketidir.

Odoo’nun eşsiz değer önermesi, aynı anda hem kullanımının çok kolay olup hem de tamamen entegre olmasıdır.

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