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

How to open a new form when i click in a button?

Abone Ol

Get notified when there's activity on this post

Bu soru işaretlendi
20 Cevaplar
77678 Görünümler
Avatar
Arunagiri K

I want to create button field . If i click a button it will show a new form . Please tell anyone how to create it  

Here is my code

myform.py

import time
from lxml import etree
import openerp.addons.decimal_precision as dp
import openerp.exceptions

from openerp import netsvc
from openerp import pooler
from openerp.osv import fields, osv, orm
from openerp.tools.translate import _

 

class my_form(osv.osv):
            _name = "my.form"
            _description = 'Formview Module'
            _columns = {
               'name': fields.char('Name', size=64),
               'project': fields.char('Project', size=64),
               'image': fields.binary('Image'),
               'file':fields.binary('attach file')
 #~ def create_field(self, cr, uid, ids, context=None):              
}
my_form()

class my_form2(osv.osv):
        _name="my.form2"
        _description="new form"
        _columns={
          'add':fields.char('Address',size=64)
          }
my_form2()

myform_view.xml

<openerp>
    <data>
        <record model="ir.ui.view" id="from_view_form">
        <field name="name">form.view.form</field>
        <field name="model">my.form</field>
        <field name="arch" type="xml">
            <form string="Form" version="7.0">
                <group>
                    <field name="name" />
                    <field name="project" />
                    <button name="%(create_field)d" string="Create Field" type="action" />
                </group>
            </form>
        </field>
    </record>
        <record model="ir.ui.view" id="from_view_form2">
        <field name="name">form.view.form</field>
        <field name="model">my.form</field>
        <field name="arch" type="xml">
            <form string="Form" version="7.0">
               <group>
                   <field name="name"/>
               </group>
            </form>
        </field>
    </record>

         <record model="ir.ui.view" id="from_view_tree">
        <field name="name">form.view.tree</field>
        <field name="model">my.form</field>
        <field name="arch" type="xml">
            <tree string="Form">
                <field name="name" />
            </tree>
        </field>
    </record>    
        
        <record model='ir.actions.act_window' id='%(create_field)d'>
        <field name="name">Form</field>
        <field name="res_model">my.form</field>
        <field name="view_type">form</field>
        <field name="view_mode">form</field>
        <field name="context">{}</field>
        <field name="help" type="html">
            <p class="oe_view_nocontent_create">
                Click to create a new record.
            </p>
            <p>This is a test class developed to learn Openerp.</p>
        </field>
    </record>
    
    
        <record model='ir.actions.act_window' id='form_view_action'>
        <field name="name">Form</field>
        <field name="res_model">my.form</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
        <field name="context">{}</field>
        <field name="help" type="html">
            <p class="oe_view_nocontent_create">
                Click to create a new record.
            </p>
            <p>This is a test class developed to learn Openerp.</p>
        </field>
    </record>

         <menuitem id="myform_ID" name="myforms" />

         <menuitem id="myform_menu_ID" name="myform" parent="myform_ID"  />

         <menuitem id="myform_menu2_ID" name="myform" parent="myform_menu_ID"  action='form_view_action' />

        
        
        
    </data>
    
    </openerp>

 

 

3
Avatar
Vazgeç
Arunagiri K
Üretici

import time from lxml import etree import openerp.addons.decimal_precision as dp import openerp.exceptions from openerp import netsvc from openerp import pooler from openerp.osv import fields, osv, orm from openerp.tools.translate import _ class my_form(osv.osv): _name = "my.form" _description = 'Formview Module' _columns = { 'name': fields.char('Name', size=64), 'project': fields.char('Project', size=64), 'image': fields.binary('Image'), 'file':fields.binary('attach file') #~ def create_field(self, cr, uid, ids, context=None): } my_form() class my_form2(osv.osv): _name="my.form2" _description="new form" _columns={ 'add':fields.char('Address',size=64) } my_form2()

Arunagiri K
Üretici

i try myself but its not working please tell me ef create_field(self,cr, uid, ids,create_field, context={}): if not ids: return False if context is None: context={} model_data_pool = self.pool.get('ir.model.data') view = model_data_pool.get_object(cr, uid, 'my_form2', 'view_copy_multiple', context=context) return{ 'name': _("Copy multiple records"), 'type': 'ir.actions.act_window', 'view_mode': 'form', 'view_id': [view.id], 'view_type': 'form', 'res_model': 'my.form', 'nodestroy': True, 'target': 'new', 'context': context, 'res_id': ids, }

Avatar
Indrabhan Bhamare
En İyi Yanıt

Hello May be this will help you.

You can define object type button and return action.

example.py and example.xml

    @api.multi
def method_name(self):
view_id = self.env.ref('modul_name._id_of_form_view').id
context = self._context.copy()
return {
'name':'form_name',
'view_type':'form',
'view_mode':'tree',
'views' : [(view_id,'form')],
'res_model':'model_name',
'view_id':view_id,
'type':'ir.actions.act_window',
'res_id':self.id,
'target':'new',
'context':context,
}

<button name="method_name" string="open_form" type="object"/> 
8
Avatar
Vazgeç
Avatar
Tangaraj
En İyi Yanıt

Hi

Try like this ...

<button type="action" string="submit" name= "%(module_name.form_action_id)d" class="oe_highlight"/>

which form u want open,put ur id mentioned in  above line( form_action-id),,, <record model="ir.ui.view" id="......."


3
Avatar
Vazgeç
Avatar
Emipro Technologies Pvt. Ltd.
En İyi Yanıt

Hi,

<button name="%(create_field)d" string="Create Field" type="action" />

Button with type "action" is like above will call the action with ID="create_field". So, you have to make one action with ID = "create_field".

But you have created action with ID = "%(create_field)d" is not good. please change it with ID = "create_field"

I hope this will help you. If you have still any issue then let me know.

Or 

You can put the button type="object" and make one function into python with same name as button name.

in your case :

<button name="create_field" string="Create Field" type="object" />

In your python code put the function as like below.

def create_field(self, cr, uid, ids, context=None):

        return {
            'name': _('My Form'),
            'view_type': 'form',
            'view_mode': 'form',
            'res_model': 'my.form',
            'view_id': False,
            'type': 'ir.actions.act_window',
        }

It will open one window to create record of the model 'my.form'. If you want to open window to create 'my.form2' then just replate 'res_model' value with 'my.form2'.

thats it.

 

3
Avatar
Vazgeç
Arunagiri K
Üretici

I already try that one but its not working . Any changes in function for action of button in python file if you know please tell me

Emipro Technologies Pvt. Ltd.

Then you have to take button type="object" and then return the form view from that button click function. When you take type="object" then system will call the function of python as same name of that button.

Arunagiri K
Üretici

Hi i change type ="object" but i got an error like this AttributeError: 'my.form' object has no attribute 'create_field'

Arunagiri K
Üretici

Thats the thing i asked how to write a function i don't know i'm new to openerp if you tell about that it will helpfull to me . This is my test project only i just want to learn please help me

Emipro Technologies Pvt. Ltd.

Hello, I have update my answer please have a look on it.

Arunagiri K
Üretici

def create_field(self,cr, uid, ids,create_field, context={}): if not ids: return False if context is None: context={} model_data_pool = self.pool.get('ir.model.data') view = model_data_pool.get_object(cr, uid, 'my_form2', 'view_copy_multiple', context=context) return{ 'name': _("Copy multiple records"), 'type': 'ir.actions.act_window', 'view_mode': 'form', 'view_id': [view.id], 'view_type': 'form', 'res_model': 'my.form', 'nodestroy': True, 'target': 'new', 'context': context, 'res_id': ids, }

Arunagiri K
Üretici

Hi i follow your code instructions i'm working odoo 8 i had an error again here is the error message : AccessError The requested operation cannot be completed due to security restrictions. Please contact your system administrator. (Document type: ir.actions.actions, Operation: read)

Emipro Technologies Pvt. Ltd.

For that you have to make sure that user have an access rights for the model ir.actions.actions. Thats it. you can also give access rights to a particular model via setting => Technical => Security => Access control List.

Arunagiri K
Üretici

Hi i change the Access control list till i got an error please give me any suggestion

Avatar
Chandni Gandhi
En İyi Yanıt

Hi,

Refer this site, it might be help u.

http://www.odooclass.com/shop/product/how-to-create-custom-smart-buttons-in-odoo-8-24


Creating Smart Buttons in Odoo

1. Add required fields to the model so you can store your calculations

voucher_count = fields.Integer(compute='_voucher_count', string='# of Vouchers')

account_voucher_ids = fields.One2many('account.voucher', 'partner_id', 'Voucher History')

2. Create a custom view template and use the interhit id that matches the external id of the form 

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

<field name="name">view.res.partner.form.crm.inherited2</field> <field name="model">res.partner</field> <field name="priority" eval="200"/> <field name="inherit_id" ref="base.view_partner_form"/>

3. Use xpath in the template to tell the Odoo framework where to place your button

<xpath expr="//div[@name='buttons']" position="inside">

4. Add your Odoo smart button code to the view

<button class="oe_inline oe_stat_button" type="action" name="%(pay_view_voucher_tree)d" attrs="{'invisible': [('customer', '=', False)]}" icon="fa-usd"> <field string="Payments" name="voucher_count" widget="statinfo"/> </button>

5. Create a python function to calcuate the functional field (voucher_count)

@api.one @api.depends('account_voucher_ids','account_voucher_ids.state')

def _voucher_count(self):

        vouchers = self.env['account.voucher'].search([('partner_id', '=', self.id)])

        self.voucher_count = len(vouchers)


6. . Create a view for the action to display your results (payments in this case) when the user clicks the button

<record model="ir.actions.act_window" id="pay_view_voucher_tree">

<field name="name">Payments</field>

<field name="res_model">account.voucher</field>

<field name="view_type">form</field>

<field name="view_mode">tree,form,graph</field>

<field name="context">{'search_default_partner_id': active_id}</field>

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

          <tree string="Payments">

               <field name="date"/> <field name="number"/> <field name="reference"/> <field name="partner_id"/>

                <field name="type" invisible="context.get('visible', True)"/> <field name="amount" sum="Total Amount"/> <field name="state"/>

         </tree>

  </field>

</record>

If you found this as correct, please mark this as correct. Thanks.

0
Avatar
Vazgeç
Purnendu Singh

Your answer is not relevant to this question! He simply want a button which will open a form view. Say for example our sale order line set as editable top. And we want to put a new button on sale order line which will popup sale order line form view in which we can edit things.

Avatar
Kirubanidhi Rajarathinam
En İyi Yanıt

In odoo 9 , 

We apply for this way


<button string="Library details" type="object"

class="oe_highlight oe_right" name="library_method" icon="fa-fire" >

</button>

@api.multi

def library_method(self):

print self._context

course_form = self.env.ref('college.return_form', False)

return {

'name': 'New Course',

'type': 'ir.actions.act_window',

'res_model': 'college.return',

'view_type': 'form',

'view_mode': 'tree,form',

'target': 'self',

'views': [(course_form.id, 'form')],

'view_id': 'course_form.id',

'flags': {'action_buttons': True},

}

0
Avatar
Vazgeç
ANSU MARY JACOB

hey how to visible a tab while clicking a button , the condition where 2 boolean field is true

Kirubanidhi Rajarathinam
Create a new wizard form. 

Check the existing code by using 



api.multi
def method_name(self):
view_id = self.env.ref('modul_name._id_of_form_view').id
context = self._context.copy()
return {
'name':'form_name',
'view_type':'form',
'view_mode':'tree',
'views' : [(view_id,'form')],
'res_model':'model_name',
'view_id':view_id,
'type':'ir.actions.act_window',
'res_id':self.id,
'target':'new',
'context':context,
}



On Tue, 2 Nov, 2021, 6:08 pm ANSU MARY JACOB, <ansu@zbeanztech.com> wrote:

hey how to visible a tab while clicking a button , the condition where 2 boolean field is true

Sent by Odoo S.A. using Odoo.

Avatar
Jose Angel Inda Herrera
En İyi Yanıt

I agree with Arunagiri, that is the way to resolve your problem and, in the action dict definition, you push also the 'target' property to show modal dialog

0
Avatar
Vazgeç
Arunagiri K
Üretici

You know about the module if you let me know please ................!!!!

Avatar
Jacky
En İyi Yanıt

Question is not clear. Give an example. I think you can make it through a wizard.

0
Avatar
Vazgeç
Arunagiri K
Üretici

i add a button in my module i want to new form when i click a button

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