Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

Open Form View Without Tree View

Odoberať

Get notified when there's activity on this post

This question has been flagged
viewsformv17
3 Replies
4946 Zobrazenia
Avatar
Mohammad Ali Ben Hmida

Hello , 
I want to open the form view (from the menu item) to edit the company that the current user is authenticated.
that's mean the res.partner that equal to partner.parent_id 


I use odoo 17 

0
Avatar
Zrušiť
Dương Nguyễn

Your question seem odd, correct me if i'm wrong. You want the current user (the one who logged in) only be able to edit his/her company (res.partner) and can not edit any other company beside his/hers ?

Mohammad Ali Ben Hmida
Autor

Yes, but nott that only i want that he can do that from a button in menu item with an action to a form view (without open a tree view)

Avatar
Mohammad Ali Ben Hmida
Autor Best Answer

is had the error

0
Avatar
Zrušiť
Rithik Sandron

What error did you get? Give the stack trace and the your code

Mohammad Ali Ben Hmida
Autor

This is my code

<odoo>

<record id="view_company_form" model="ir.ui.view">
<field name="name">company_form</field>
<field name="model">res.partner</field>
<field name="arch" type='xml'>
<form>
<sheet>
<group>
<field name="name"></field>
<field name="description"></field>
</group>
</sheet>
</form>
</field>
</record>

<record id="update_portfolio_decription_action" model="ir.actions.server">
<field name="name">Open Company Form</field>
<field name="model_id" ref="res.partner"/>
<field name="binding_model_id" ref="res.partner"/>
<field name="binding_view_types">form</field>
<field name="view_id" ref="view_company_form"/>
<field name="state">code</field>
<field name="code">model.open_company_form()</field>
</record>

<menuitem
id="portfolio_decription_menu_item"
name="Portfolio Decription"
parent="portfolio_decription_root_menu"
action="update_portfolio_decription_action"
/>

</odoo>

@api.model
def open_company_form(self):
form_view_id = self.env.ref('base.view_company_form').id
return {
'type': 'ir.actions.act_window',
'name': 'Company Form',
'res_model': 'res.partner',
'res_id': self.env.user.partner_id.id,
'view_mode': 'form',
'view_id': form_view_id,
'target': 'current',
}

Avatar
Rithik Sandron
Best Answer

Hi,

Try this

Python:


from odoo import models, fields, api

class CustomModel(models.Model):
​_name = "custom.model"

@api.model
​​def open_company_form(self):
​form_view_id = ​self.env.ref('base.view_company_form').id
​ ​ ​return {
​ ​'type': 'ir.actions.act_window',
​ ​ ​'name': 'Company Form',
​ ​ ​'res_model': 'res.company',
​ ​ ​'res_id': self.env.company.id,
​ ​ ​'view_mode': 'form',
​ ​ ​'view_id': form_view_id,
​ ​ ​'target': 'current',​
​ ​}

XML code to call python method from menu item in comments.


Check this and let me know

0
Avatar
Zrušiť
Rithik Sandron

XML:

<record id="server_action_open_company_form" model="ir.actions.server">
<field name="name">Open Company Form</field>
<field name="model_id" ref="model_custom_model"/>
<field name="state">code</field>
<field name="code">action = model.open_company_form()</field>
</record>
​
​
<menuitem id="menu_server_action_open_company" action="server_action_open_company_form" sequence="5"/>

Mohammad Ali Ben Hmida
Autor

I had this error when I try your code
raise ParseError('while parsing %s:%s, somewhere inside\n%s' % (
odoo.tools.convert.ParseError: while parsing /mnt/...._view.xml:36, somewhere inside
<record id="server_action_open_company_form" model="ir.actions.server">
<field name="name">Open Company Form</field>
<field name="model_id" ref="model_custom_model"/>
<field name="state">code</field>
<field name="code">action = model.open_company_form()</field>
</record>

Rithik Sandron

Try this:
<record id="server_action_open_company_form" model="ir.actions.server">
<field name="name">Open Company Form</field>
<field name="model_id" ref="custom_module.model_custom_model"/>
<field name="binding_model_id" ref="custom_module.model_custom_model"/>
<feld name="binding_view_types">form</field>
<field name="state">code</field>
<field name="code">action = model.open_company_form()</field>
</record>

I have also updated my original answer.

Mohammad Ali Ben Hmida
Autor

not working

Avatar
Cybrosys Techno Solutions Pvt.Ltd
Best Answer

Hi,

Try like this
<record id="menu_partner_edit" model="ir.ui.menu">
    <field name="name">Edit Company</field>
    <field name="action" ref="action_partner_edit"/>
</record>

<record id="action_partner_edit" model="ir.actions.act_window">
    <field name="name">Edit Company</field>
<field name="res_model">res.partner</field>
    <field name="view_mode">form</field>
<field name="domain">[('parent_id', '=', env.user.company_id.partner_id.id)]</field>
</record>


Hope it helps

-1
Avatar
Zrušiť
Mohammad Ali Ben Hmida
Autor

it show me this error
"EvalError: Can not evaluate python expression: ([('parent_id', '=', env.user.company_id.partner_id.id)])
Error: Name 'env' is not defined"

Mohammad Ali Ben Hmida
Autor

up

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrácia
Related Posts Replies Zobrazenia Aktivita
Display model creation view of another model
views form
Avatar
Avatar
2
feb 23
2576
Why is my custom form view not being read by Odoo?
views form
Avatar
Avatar
2
sep 15
6396
When inherit view original view also changed ?
views form
Avatar
Avatar
1
mar 15
4566
add field in standard view but only see in a new menuitem Solved
views standard v17
Avatar
1
feb 24
2540
Dynamically add pages to notebook
views notebook v17
Avatar
0
jan 24
2565
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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