İç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

custom_function is not a valid action on...

Abone Ol

Get notified when there's activity on this post

Bu soru işaretlendi
viewsviewinheritancebuttonsodoo
1 Cevapla
7695 Görünümler
Avatar
Cristian Carbone

Hi,

I'm inheriting the Sale Order view and adding a button in it. What I'm trying to achieve is calling a method in my .py model but Odoo is looking for it in the sale.order one. 

This is my .py model: https://pastebin.com/aiKGLMdE


This is the view: https://pastebin.com/ypn75Nvd


This is the error: https://pastebin.com/LEwtc9aw


Any help is appreciated, thanks in advance
 (PS: I'm usign Odoo.sh)

1
Avatar
Vazgeç
Avatar
Cybrosys Techno Solutions Pvt.Ltd
En İyi Yanıt

Hi,

Please go through the Odoo documentation:

https://www.odoo.com/documentation/15.0/developer/reference/backend/orm.html#classical-inheritance

You are creating a new class through Classical inheritance(Prototype inheritance). You can't inherit the existing view in this case(You are supposed to use the new class instead of sale.order). So, create a new view for your new model.

Example

If you check the fields in 'sale.order', you can see these fields:

transaction_ids = fields.Many2many('payment.transaction',
'sale_order_transaction_rel',
'sale_order_id', 'transaction_id',
string='Transactions', copy=False,
readonly=True)
authorized_transaction_ids = fields.Many2many(
string="Authorized Transactions", comodel_name='payment.transaction',
compute='_compute_authorized_transaction_ids', readonly=True, copy=False)

The authorized_transaction_ids is a computed field which depends on the transaction_ids field. So, changing the field will cause another error. The tag_ids field is also there.

During development, if you are not intending to update any field, then please use a different name for the new fields to avoid unnecessary errors and to not break existing workflows!

Now, you are supposed to add 3 fields in 'sale.order' and a button in its form view. I have refactored the code here(please make the changes as per your requirement). I think you are adding the customization through the module "custom_addon"(based on the path in the error message.)

custom_addon/models/sale_order.py

from odoo import fields, models

class SaleOrder(models.Model):
_inherit = 'sale.order'

field_1 = fields.Char(string="Field One", required=True)
sale_order_transaction_ids = fields.Many2many(
'sale.order.transaction', 'sale_order_transaction_sale_order_rel',
'sale_order_id', 'sale_order_transaction_id',
string='Sale Order Transactions')
sale_order_tag_ids = fields.Many2many(
'sale.order.tag', 'sale_order_tag_sale_order_rel', 'sale_order_id',
'sale_order_tag_id', string='Sale Order Tags')

def action_test_function(self):
print("Test Print")
return

custom_addon/views/sale_order_views.xml

<?xml version="1.0" encoding="utf-8"?>


<odoo>


    <record id="sale_order_view_form" model="ir.ui.view">


        <field name="name">sale.order.view.form.inherit.custom_addon</field>


        <field name="model">sale.order</field>


        <field name="inherit_id" ref="sale.view_order_form"/>


        <field name="arch" type="xml">


            <xpath expr="/form/sheet/group/group[1]" position="inside">


                <button name="action_test_function" string="Test" type="object"


                        class="btn-primary"/>


            </xpath>


        </field>


    </record>


</odoo>


Ensure that you have added the python files and directories in the respective __init__.py files, added the xml files in the __manifest__.py, and added "sale_management" module in the depends list.

Regards

1
Avatar
Vazgeç
Cristian Carbone
Üretici

i'm trying to add a new button linked to a new function in a existing view, according to documentation I should avoid "_name" parameter if I want to add a new element or function, but still not works

Cristian Carbone
Üretici

any help?

Cybrosys Techno Solutions Pvt.Ltd

Hi,
We have updated the answer, please check

Cristian Carbone
Üretici

i struggled for days to look for a solution, and this finally worked, thank you so much! have a great day!

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
[WITH SCREENSHOT] How can I add a button next to the "Create" button in the "Human Resources" -> "Employees" menu?
views inheritance buttons
Avatar
1
Eyl 15
3937
[ODOO 16CE] How to choose the form used when clicking on 'Add a line' in a tree view?
views view odoo odoo16features
Avatar
Avatar
2
Haz 23
3844
[ODOO 16CE] How to choose the form view used with Many2One or Many2Many (m2x) field? Çözüldü
views view odoo odoo16features
Avatar
Avatar
1
Haz 23
3601
I want to use res_partner view to another menu action with fields (not all) in res_partner
views inheritance res.partner odoo
Avatar
Avatar
1
Kas 21
3779
Add smart button to inherit form
inheritance buttons odoo smart
Avatar
Avatar
Avatar
2
May 21
7428
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