Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
2 Відповіді
1975 Переглядів


Hi all,

i want to create an ir.actions.server action to open a form with a new record after login

for testing purpose i coded a function in my class  

class kskassenbuch(models.Model): 
_name = 'ks_sale.kskassenbuch'


@api.model    
def serveraction(self):        
​raise Warning(_('Test action!'))


and in xml:

           how can i post xml code? my code is not displayed after saving this post


record id="action_new_kassenbuch" model="ir.actions.server

field name="name">Kassenbuch_Actionfield name="type">ir.actions.server

field name="model_id" ref="model_ks_sale_kskassenbuch"
field name="binding_model_id" ref="model_ks_sale_kskassenbuch"
field name="code">records.serveraction()

record

(i could not post xml code here, so i wrote the xml lines without brackets, sorry)


after running this code i always get the error:

 ValueError: : "'NoneType' object has no attribute 'serveraction'" while evaluating 'records.serveraction()'

for me it looks that the class is bind in the action, but i dont know what i've made wrong.

thx for any help


Аватар
Відмінити
Найкраща відповідь

Hi,

You can add the following xml code,

<record id="action_new_kassenbuch" model="ir.actions.server">
<field name="name">assenbuch_Action</field>
<field name="model_id" ref="module_name.model_ks_sale_kskassenbuch"/>

        <field name="binding_model_id" ref="module_name.model_ks_sale_kskassenbuch"/>
        <field name="state">code</field>
        <field name="code">action = model.serveraction()</field>
    </record>


For more details, refer to the blog:
https://www.cybrosys.com/blog/type-of-actions-in-odoo-16-erp

Hope it helps

Аватар
Відмінити
Автор

hi Cybrosys,
thanks for your answer.
your code is working. i call this ir.actions.server at the home_action i give to the user after login.
i put a logging in the function and i see that serveraction() is called.
but then i get a blank page.
i want to run my custom code and then redirect to a menu e.g. to the pipeline.
i dont know how to realize a call to crm_lead
thx for helping

Автор Найкраща відповідь

i solved it by adding  from odoo import _ in the .py file

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
1
лист. 23
6
0
лист. 23
1722
3
серп. 25
2370
1
трав. 25
2563
1
квіт. 25
3520