Zum Inhalt springen
Odoo Menü
  • Anmelden
  • Jetzt gratis testen
  • Apps
    Finanzen
    • Buchhaltung
    • Rechnungsstellung
    • Spesenabrechnung
    • Tabellenkalkulation (BI)
    • Dokumente
    • E-Signatur
    Vertrieb
    • CRM
    • Vertrieb
    • Kassensystem – Shop
    • Kassensystem – Restaurant
    • Abonnements
    • Vermietung
    Websites
    • Website-Builder
    • E-Commerce
    • Blog
    • Forum
    • Livechat
    • E-Learning
    Lieferkette
    • Lager
    • Fertigung
    • PLM
    • Einkauf
    • Wartung
    • Qualität
    Personalwesen
    • Mitarbeiter
    • Personalbeschaffung
    • Abwesenheiten
    • Mitarbeiterbeurteilung
    • Personalempfehlungen
    • Fuhrpark
    Marketing-
    • Social Marketing
    • E-Mail-Marketing
    • SMS-Marketing
    • Veranstaltungen
    • Marketing-Automatisierung
    • Umfragen
    Dienstleistungen
    • Projekte
    • Zeiterfassung
    • Außendienst
    • Kundendienst
    • Planung
    • Termine
    Produktivität
    • Dialog
    • Genehmigungen
    • IoT
    • VoIP
    • Wissensdatenbank
    • WhatsApp
    Apps von Drittanbietern Odoo Studio Odoo Cloud-Plattform
  • Branchen
    Einzelhandel
    • Buchladen
    • Kleidergeschäft
    • Möbelhaus
    • Lebensmittelgeschäft
    • Baumarkt
    • Spielwarengeschäft
    Essen & Gastgewerbe
    • Bar und Kneipe
    • Restaurant
    • Fast Food
    • Gästehaus
    • Getränkehändler
    • Hotel
    Immobilien
    • Immobilienagentur
    • Architekturbüro
    • Baugewerbe
    • Immobilienverwaltung
    • Gartenarbeit
    • Eigentümervereinigung
    Beratung
    • Buchhaltungsfirma
    • Odoo-Partner
    • Marketingagentur
    • Anwaltskanzlei
    • Talentakquise
    • Prüfung & Zertifizierung
    Fertigung
    • Textil
    • Metall
    • Möbel
    • Speisen
    • Brauerei
    • Firmengeschenke
    Gesundheit & Fitness
    • Sportklub
    • Brillengeschäft
    • Fitnessstudio
    • Therapeut
    • Apotheke
    • Friseursalon
    Handel
    • Handyman
    • IT-Hardware & -Support
    • Solarenergiesysteme
    • Schuster
    • Reinigungsdienstleistungen
    • HLK-Dienstleistungen
    Sonstiges
    • Gemeinnützige Organisation
    • Umweltschutzagentur
    • Plakatwandvermietung
    • Fotostudio
    • Fahrrad-Leasing
    • Software-Händler
    Alle Branchen ansehen
  • Community
    Lernen
    • Tutorials
    • Dokumentation
    • Zertifizierungen
    • Schulung
    • Blog
    • Podcast
    Bildung fördern
    • Bildungsprogramm
    • Scale-Up! Planspiel
    • Odoo besuchen
    Software anfragen
    • Herunterladen
    • Editionen vergleichen
    • Releases
    Zusammenarbeiten
    • Github
    • Forum
    • Veranstaltungen
    • Übersetzungen
    • Partner werden
    • Dienstleistungen für Partner
    • Buchhaltungsfirma registrieren
    Services anfragen
    • Partner finden
    • Buchhalter finden
    • Einen Experten treffen
    • Implementierungsservices
    • Kundenreferenzen
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Eine Demo erhalten
  • Preiskalkulation
  • Hilfe

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

  • CRM
  • e-Commerce
  • Buchhaltung
  • Lager
  • PoS
  • Projekte
  • MRP
All apps
Sie müssen registriert sein, um mit der Community zu interagieren.
Alle Beiträge Personen Abzeichen
Stichwörter (Alle anzeigen)
odoo accounting v14 pos v15
Über dieses Forum
Sie müssen registriert sein, um mit der Community zu interagieren.
Alle Beiträge Personen Abzeichen
Stichwörter (Alle anzeigen)
odoo accounting v14 pos v15
Über dieses Forum
Hilfe

How to create a new openerp field through function?

Abonnieren

Erhalten Sie eine Benachrichtigung, wenn es eine Aktivität zu diesem Beitrag gibt

Diese Frage wurde gekennzeichnet
2 Antworten
5564 Ansichten
Avatar
arsalan

I wanted to know if I want to create a new field then how this can be done. How to set the xml and other details .I think I will have to set them and return the field. But is there any specific function to create new field ? . I have no idea .

Please help Thanks

0
Avatar
Verwerfen
Jagdish Panchal

You want to add dynamic field ?

arsalan
Autor

first I want to add a new field then I will think a way to add dynamic ones . I f you know any of these plz help

arsalan
Autor

my field is not being displayed

Avatar
Jagdish Panchal
Beste Antwort

Hi

This will help you https://accounts.openerp.com/forum/Help-1/question/47546

Refer below code

def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
    if context is None:
        context = {}
    wiz_id = self.pool.get('ir.actions.act_window').search(cr, uid, [("name","=","analytic.plan.create.model.action")], context=context)
    res = super(account_analytic_plan_instance,self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu)
    journal_obj = self.pool.get('account.journal')
    analytic_plan_obj = self.pool.get('account.analytic.plan')
    if (res['type']=='form'):
        plan_id = False
        if context.get('journal_id', False):
            plan_id = journal_obj.browse(cr, uid, int(context['journal_id']), context=context).plan_id
        elif context.get('plan_id', False):
            plan_id = analytic_plan_obj.browse(cr, uid, int(context['plan_id']), context=context)

        if plan_id:
            i=1
            res['arch'] = """<form string="%s">
<field name="name"/>
<field name="code"/>
<field name="journal_id"/>
<button name="%d" string="Save This Distribution as a Model" type="action" colspan="2"/>
"""% (tools.to_xml(plan_id.name), wiz_id[0])
            for line in plan_id.plan_ids:
                res['arch']+="""
                <field name="account%d_ids" string="%s" nolabel="1" colspan="4">
                <tree string="%s" editable="bottom">
                    <field name="rate"/>
                    <field name="analytic_account_id" domain="[('parent_id','child_of',[%d])]" groups="analytic.group_analytic_accounting"/>
                </tree>
            </field>
            <newline/>"""%(i,tools.to_xml(line.name),tools.to_xml(line.name),line.root_analytic_id and line.root_analytic_id.id or 0)
                i+=1
            res['arch'] += "</form>"
            doc = etree.fromstring(res['arch'].encode('utf8'))
            xarch, xfields = self._view_look_dom_arch(cr, uid, doc, view_id, context=context)
            res['arch'] = xarch
            res['fields'] = xfields
        return res
    else:
        return res
0
Avatar
Verwerfen
arsalan
Autor

I tried that .But I was unable to get that solution . I think fields_view_get will up grade the already created fields . I want to create fields not upgrade.

Jagdish Panchal

using fields_view_get get you can add dynamic filed. can u paste your code here ?

arsalan
Autor

have u created dynamic fields before?

Jagdish Panchal

yes ? i have

arsalan
Autor

def fields_view_get(self, cr, uid, view_id, view_type='form', context=None,toolbar=False,submenu=False): result = super(deg_form, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar,submenu) moves_fields=result['fields'] moves_fields.update({ "name" : {'string': 'MyNewName','type': 'char'}}) moves_fields.update({ "data_type" : {'string': 'MyTYPE','type': 'char'}})
moves_fields.update({ "father_name" : {'string': 'MyNewName','type': 'char'}}) # school_obj = self.pool.get('deg.form') result['fields'] = moves_fields # if vi

arsalan
Autor

above here is my function

arsalan
Autor

<button name="fields_view_get" string="CREATE FIELD" type="object" /> And this is button which will call fields_view_get to create fields

arsalan
Autor

can u make me realize whats wrong here

Jagdish Panchal

@arsalan: fields view get call when view load, you want create in button click. So in your case i can't help you.

arsalan
Autor

is there some way I could do this , by any function . If I can return field

arsalan
Autor

hello jack?

Jagdish Panchal

Sorry i have no idea..

arsalan
Autor

ok tell me how can I create fields with fields_view_get function

Jagdish Panchal

I have update ans check try it.

arsalan
Autor

can we give name, data_type etc of our choice or not?

Jagdish Panchal

yes you can type:'Any tyep' , string:'name of field'

arsalan
Autor

but here u have not used my class n objects , I am having problems understanding it. How could I import it in my module

arsalan
Autor

u have used account.journal , journal_id , account_analytic_plan etc . can u explain a bit

arsalan
Autor

because I will have to make changes according to my class.

Jagdish Panchal

There is lost of example in openerp addons module.

arsalan
Autor

ur code is complaining "xml view error". May be u have missed something. Please check

Jagdish Panchal

This code is given in openerp addons>>account_analytic_plans>>account_analytic_plans.py line no : 170 to 210, pls refer this

arsalan
Autor

just tell me how it works if u know. because I really need to understand this to code it

arsalan
Autor

can u code a simple function n edit the one that I sent u . It will be much easier for me to understand the flow of fields_view_get because ur function has an xml issue

Jagdish Panchal

show your code will give solution.

arsalan
Autor

I sent u my code before .Pls do make changes in it

arsalan
Autor

xml issue, because u have not given the xml issue

Avatar
ayman mohammed adam
Beste Antwort

def fields_view_get(self, cr, uid, view_id, view_type='form', context=None,toolbar=False,submenu=False): result = super(deg_form, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar,submenu) moves_fields=result['fields'] moves_fields.update({ "name" : {'string': 'MyNewName','type': 'char', 'size': 10}) moves_fields.update({ "data_type" : {'string': 'MyTYPE','type': 'char', 'size': 10}) moves_fields.update({ "father_name" : {'string': 'MyNewName','type': 'char', 'size': 10})

0
Avatar
Verwerfen
Diskutieren Sie gerne? Treten Sie bei, statt nur zu lesen!

Erstellen Sie heute ein Konto, um exklusive Funktionen zu nutzen und mit unserer tollen Community zu interagieren!

Registrieren
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Herunterladen
  • Github
  • Runbot
  • Übersetzungen
Dienstleistungen
  • Odoo.sh-Hosting
  • Support
  • Upgrade
  • Individuelle Entwicklungen
  • Bildung
  • Buchhalter finden
  • Partner finden
  • Partner werden
Über uns
  • Unsere Firma
  • Markenwerte
  • Kontakt
  • Karriere
  • Veranstaltungen
  • Podcast
  • Blog
  • Kunden
  • Rechtliches • Datenschutz
  • Sicherheit
الْعَرَبيّة 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 ist eine Suite von Open-Source-Betriebsanwendungen, die alle Bedürfnisse Ihres Unternehmens abdecken: CRM, E-Commerce, Buchhaltung, Lager, Kassensystem, Projektmanagement etc.

Das einzigartige Wertversprechen von Odoo ist, dass es gleichzeitig sehr einfach zu bedienen und voll integriert ist.

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