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
    • Textil
    • Kov
    • Nábytek
    • Jídlo
    • Pivovar
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Transakce
    • Údržbář
    • Podpora IT & hardware
    • 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
    Procházet všechna odvětví
  • 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
    • Služby pro partnery
    • 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

button add in a view which is of another model

Odebírat

Get notified when there's activity on this post

This question has been flagged
button
1 Odpovědět
7533 Zobrazení
Avatar
omkar

Hi Friends.

I inherited a model hr.employee to my view and I added a button action,

But it is throwing error to me, that

ValueError: No such external ID currently defined in the system: hr_team.action_button_confirm

I added the button in the hr_team and written the function in the class hr_team.

But this is not working.

Here is my .py file

class hr_performancegoals(osv.osv): _name = "hr.performancegoals" _description = "Performance Goals"

def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
     if context is None:
        context = {}
     result = super(hr_performancegoals, self).fields_view_get(cr, uid, view_id,view_type, context, toolbar,submenu)
     data = result['arch']
     if uid == 1:
        L=[]
        ldata = data.split("\n")
        for var in ldata:
             if re.search("str_goals",var):
                 pass
             else:
                 L.append(var)
        reqdata =''.join(L)
        result['arch']=reqdata
     else:
        L=[]
        ldata = data.split("\n")
        for var in ldata:
             if re.search("strategic_goals",var):
                 pass
             else:
                 L.append(var)
        reqdata =''.join(L)
        result['arch']=reqdata
     return result


def _get_employee_id(self,cr,uid,ids,name,arg,context=None):
    if context.get('id',''):
        print "Sateesh testing Employee Id",context.get('id','')
        res = dict.fromkeys(ids,context.get('id',''))
        return res
    else:
        cr.execute("select id from resource_resource where user_id=%s"%context.get('uid',''))
        log_name = cr.dictfetchall()[0]
        res = dict.fromkeys(ids,log_name['id'])
        return res

def _get_objectives(self, cr, uid,context):
    L=[]
    if context.get('name_related','') :
       cr.execute ("select parent_id from hr_employee where name_related='%s'"%context.get('name_related',''))
       parent_id=cr.dictfetchall()[0]
       cr.execute("select objectives from hr_performancegoals where employee_id=%s"%int(parent_id['parent_id']))
       data = cr.dictfetchall()
       for i,values in enumerate(data):
         a=unicodedata.normalize('NFKD', values['objectives']).encode('ascii','ignore')
         L.append((a,a))
    else:
        if context.get('uid',''):
            user_id = int(context.get('uid',''))
            cr.execute("select id from resource_resource where user_id=%s"%user_id)
            log_name = cr.dictfetchall()[0]
            print "TEsting Log name Here :",log_name
            if log_name['id'] == 1:
                L=[]
            else:
                cr.execute ("select parent_id from hr_employee where id=%s"%log_name['id'])
                parent_id=cr.dictfetchall()[0]
                cr.execute("select objectives from hr_performancegoals where employee_id=%s"%parent_id['parent_id'])
                data = cr.dictfetchall()
                for i,values in enumerate(data):
                    a=unicodedata.normalize('NFKD', values['objectives']).encode('ascii','ignore')
                    L.append((a,a))
    return L

_columns = {
'employee_id': fields.function(_get_employee_id,method=True, type='many2one', relation="hr.employee", string="Employee",store=True),
'strategic_goals': fields.char('Strategic Goals'),
'str_goals': fields.selection(_get_objectives, type='selection', method=True, store=False, string="Strategic"),
'objectives' : fields.text('Objectives'),
'completion_date' : fields.date('Completion Date'),
'specific_actions_required_to_deliver_strategic_goal' : fields.text('Specific Actions Required To Deliver Strategic Goal'),
'status': fields.selection([('Yet To Start','Yet To Start'),
                           ('In Progress','In Progress'),
                           ('Invalid','Invalid'),
                           ('Completed','Completed'),
                           ('Closed','Closed'),],
                            'Status', required=True),
            }

class hr_team(osv.osv): # Instead of Act Win I want to call Function _name = "hr.team" _description = "Team Goals"

    # Function to overview the View
def action_button_confirm(self, cr, uid, ids, context=None):
    print "Here is the Context ::",context

    dummy, form_view = models_data.get_object_reference(cr, uid,  'hr_survey_relation', 'view_hr_performancegoals_form')
    dummy, tree_view = models_data.get_object_reference(cr, uid,  'hr_survey_relation', 'view_hr_performancegoals_form')

    return {
        'type': 'ir.actions.act_window',
        'domain': "[('employee_id','in',["+','.join(map(str,employee_list))+"])]",
        'name': 'Goals',
        'res_model': 'hr.performancegoals',
        'views': [(form_view or False, 'form'), (tree_view or False, 'tree')],
        'res_id': ids[0],
        'view_type': 'form',
        'view_mode': 'tree,form',
        'view_id': False,
    }

_columns = {
'id':fields.char('Employee ID'),
'name_related':fields.char('EMPLOYEE NAME', require=True),
'department_id':fields.char('Department'),
'work_location': fields.char('Office Location', size=32),
'job_id':fields.char('Role/Designation', required=True),
             }

.. Xml file

    <record model="ir.ui.view" id="view_hr_performancegoals_form">
        <field name="name">hr.performancegoals.form</field>
        <field name="model">hr.performancegoals</field>
        <field name="arch" type="xml">
            <form string="Goals" version="7.0">
            <sheet>
             <notebook>
               <page string="Add New Goals">
               <group>
               <field name="employee_id" invisible="1"/>
               </group>
                    <group col="4">
                        <field name="str_goals" context="{'employee_id':employee_id}"/>
                        <field name="strategic_goals" />
                        <field name="objectives"/>
                        <field name="completion_date"/>
                        <field name="specific_actions_required_to_deliver_strategic_goal"/>
                        <field name="status"/>
                    </group>
                </page>
              </notebook>
              </sheet>
            </form>
        </field>
    </record>

    <record model="ir.ui.view" id="view_hr_performancegoals_tree">
        <field name="name">hr.performancegoals.form</field>
        <field name="model">hr.performancegoals</field>
        <field name="arch" type="xml">
            <tree string="Goals" editable="bottom" >
                <field name="employee_id" invisible="1"/>
                <field name="str_goals" context="{'employee_id':employee_id}"/>
                <field name="strategic_goals"/>
                <field name="objectives"/>
                <field name="completion_date"/>
                <field name="specific_actions_required_to_deliver_strategic_goal"/>
                <field name="status"/>
            </tree>
        </field>
</record>

<record id="hr_performancegoals_action" model="ir.actions.act_window"> <field name="name">Goals</field> <field name="res_model">hr.performancegoals</field> <field name="view_type">form</field> <field name="view_mode">tree,form</field> <field name="view_id" ref="view_hr_performancegoals_tree"/> </record> <menuitem parent="hr_evaluation.menu_eval_hr" id="hr_performancegoals" name="Goals" action="hr_performancegoals_action"/>

<record model="ir.ui.view" id="view_hr_team_form"> <field name="name">hr.team.form</field> <field name="model">hr.employee</field> <field name="arch" type="xml"> <notebook position="inside"> <page string="Team"> <group col="4"> <field name="id" invisible="1"/> <field name="name_related"/> <field name="department_id"/> <field name="work_location"/> <field name="job_id"/> <button name="hr_team.action_button_confirm" type="action" string="Assign Goals" class="oe_link oe_edit_only" icon="STOCK_DIRECTORY_MENU" context="{'id':id,'name_related':name_related}"/> </group> </page> </notebook> </field> </record>

    <record model="ir.ui.view" id="view_hr_team_tree">
        <field name="name">hr.team.tree</field>
        <field name="model">hr.employee</field>
        <field name="type">tree</field>
        <field name="arch" type="xml">
            <tree string="Team" editable="bottom" >
                        <field name="id" invisible="1"/>
                        <field name="name_related"/>
                        <field name="department_id"/>
                        <field name="work_location"/>
                        <field name="job_id"/>
                        <button name="hr_team.action_button_confirm" type="action" string="Assign Goals" class="oe_link oe_edit_only" icon="STOCK_DIRECTORY_MENU" context="{'id':id,'name_related':name_related}"/>
            </tree>
        </field>
    </record>

    <record id="hr_team_action" model="ir.actions.act_window">
        <field name="name">Team</field>
        <field name="res_model">hr.employee</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
        <field name="view_id" ref="view_hr_team_tree"/>
    </record>
0
Avatar
Zrušit
Avatar
Sajad KK
Nejlepší odpověď

hr.team should inherit hr.employee

and button should be defined like below

<button name="action_button_confirm" type="object" string="Assign Goals" class="oe_link oe_edit_only" icon="STOCK_DIRECTORY_MENU" context="{'id':id,'name_related':name_related}"/>

note type and name

and you should specify model hr.team instead of hr.employee for hr_team form and tree view

0
Avatar
Zrušit
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
Opening new window with button in OpenERP Vyřešeno
button
Avatar
Avatar
1
led 24
15296
button in systray
button
Avatar
Avatar
2
bře 18
5929
how can i restict auto data saving while clicking on custom button in odoo10?
button
Avatar
0
led 18
4197
Modify / override button action in header of form ?
button
Avatar
Avatar
2
úno 24
27046
Send eMail template through code
button
Avatar
3
úno 25
57863
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