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
    • Textile
    • Kov
    • Nábytek
    • Jídlo
    • Brewery
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Transakce
    • Údržbář
    • IT hardware a podpora
    • 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
    Browse all Industries
  • 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
    • Services for Partners
    • 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

custom_function is not a valid action on...

Odebírat

Get notified when there's activity on this post

This question has been flagged
viewsviewinheritancebuttonsodoo
1 Odpovědět
7707 Zobrazení
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
Zrušit
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Nejlepší odpověď

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
Zrušit
Cristian Carbone
Autor

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
Autor

any help?

Cybrosys Techno Solutions Pvt.Ltd

Hi,
We have updated the answer, please check

Cristian Carbone
Autor

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!

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
[WITH SCREENSHOT] How can I add a button next to the "Create" button in the "Human Resources" -> "Employees" menu?
views inheritance buttons
Avatar
1
zář 15
3945
[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
čvn 23
3851
[ODOO 16CE] How to choose the form view used with Many2One or Many2Many (m2x) field? Vyřešeno
views view odoo odoo16features
Avatar
Avatar
1
čvn 23
3609
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
lis 21
3780
Add smart button to inherit form
inheritance buttons odoo smart
Avatar
Avatar
Avatar
2
kvě 21
7443
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