Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Aplikacije
    Finance
    • Knjigovodstvo
    • Obračun
    • Stroški
    • Spreadsheet (BI)
    • Dokumenti
    • Podpisovanje
    Prodaja
    • CRM
    • Prodaja
    • POS Shop
    • POS Restaurant
    • Naročnine
    • Najem
    Spletne strani
    • Website Builder
    • Spletna trgovina
    • Blog
    • Forum
    • Pogovor v živo
    • eUčenje
    Dobavna veriga
    • Zaloga
    • Proizvodnja
    • PLM
    • Nabava
    • Vzdrževanje
    • Kakovost
    Kadri
    • Kadri
    • Kadrovanje
    • Odsotnost
    • Ocenjevanja
    • Priporočila
    • Vozni park
    Marketing
    • Družbeno Trženje
    • Email Marketing
    • SMS Marketing
    • Dogodki
    • Avtomatizacija trženja
    • Ankete
    Storitve
    • Projekt
    • Časovnice
    • Storitve na terenu
    • Služba za pomoč
    • Načrtovanje
    • Termini
    Produktivnost
    • Razprave
    • Odobritve
    • IoT
    • Voip
    • Znanje
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industrije
    Trgovina na drobno
    • Book Store
    • Trgovina z oblačili
    • Trgovina s pohištvom
    • Grocery Store
    • Trgovina s strojno opremo računalnikov
    • Trgovina z igračami
    Food & Hospitality
    • Bar and Pub
    • Restavracija
    • Hitra hrana
    • Guest House
    • Beverage Distributor
    • Hotel
    Nepremičnine
    • Real Estate Agency
    • Arhitekturno podjetje
    • Gradbeništvo
    • Estate Management
    • Vrtnarjenje
    • Združenje lastnikov nepremičnin
    Svetovanje
    • Računovodsko podjetje
    • Odoo Partner
    • Marketinška agencija
    • Law firm
    • Pridobivanje talentov
    • Audit & Certification
    Proizvodnja
    • Tekstil
    • Metal
    • Pohištvo
    • Hrana
    • Brewery
    • Poslovna darila
    Health & Fitness
    • Športni klub
    • Trgovina z očali
    • Fitnes center
    • Wellness Practitioners
    • Lekarna
    • Frizerski salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Sistemi sončne energije
    • Izdelovalec čevljev
    • Čistilne storitve
    • HVAC Services
    Ostali
    • Neprofitna organizacija
    • Agencija za okolje
    • Najem oglasnih panojev
    • Fotografija
    • Najem koles
    • Prodajalec programske opreme
    Browse all Industries
  • Skupnost
    Learn
    • Tutorials
    • Dokumentacija
    • Certifikati
    • Šolanje
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Prenesi
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Dogodki
    • Prevodi
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Sklici kupca
    • Podpora
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Določanje cen
  • Pomoč

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

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

Form view could not be loaded in odoo 10

Naroči se

Get notified when there's activity on this post

This question has been flagged
pythonxmlpopupodoo10
2 Odgovori
7789 Prikazi
Avatar
Silviaa

Hi,

I have a button, when i click this button it  shows a form in popup. But when i click it  will shows an error "Form could not be loaded"

My Code:

In Python,

class AccountInvoice(models.Model):

    _inherit = "account.invoice"


    def attach_documents(self):

        return {

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

            'view_type': 'form',

            'view_mode': 'form',

            'res_model': 'upload.file',

            'res_id': self.id,

            'target': 'new',

            'context': {'default_invoice_id': self.id}

        }

class UploadFile(models.Model):

    _name = "upload.file"

    attachment_ids = fields.Many2many(

                        'ir.attachment',

                        string='Attachments',

                        help='Attachments are linked to a document through model / res_id')


In XML,

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

<field name="name">account.invoice.supplier.tree.inherit</field>

<field name="model">account.invoice</field>

<field name="inherit_id" ref="account.invoice_supplier_tree" />

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

<xpath expr="field[@name='state']" position="after">

<button name="attach_documents" string="Attach" type="object"

icon="fa fa-paperclip" class="fa-paperclip" />

</xpath>

</field>

</record>


can anyone help me to resolve this issue.

0
Avatar
Opusti
Avatar
Hilar Andikkadavath
Best Answer

change your action varsas :-

optionally you can add views as a tuple like

tree = self.env.ref('yourmodel.tree_view_id')

form = self.env.ref('yourmodel.form_view_id')

return {

            'model': 'ir.actions.act_window',

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

            'view_type': 'form',

            'view_mode': 'tree,form',

            'views': [(tree, 'tree'), (form, 'form')],

            'res_model': 'upload.file',

            'res_id': self.id,

            'target': 'new',

            'context': {'default_invoice_id': self.id}

        }

1
Avatar
Opusti
Silviaa
Avtor

Hi Hilar,

I have changed my code but it still shows an error 'Form view could not be loaded'

form = self.env.ref('skit_attachment.upload_file_form').id

return {

'model': 'ir.actions.act_window',

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

'view_type': 'form',

'view_mode': 'form',

'views': [(form, 'form')],

'res_model': 'upload.file',

'res_id': self.id,

'create': False,

'target': 'new',

'context': {'default_invoice_id': self.id, 'default_res_id': self.id}

}

Mohammed Ajmal

view_id = self.env.ref('skit_attachment.upload_file_form').id

return {

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

'view_type': 'form',

'view_mode': 'form',

'view_id': view_id,

'res_model': 'upload.file',

'res_id': self.id,

'create': False,

'target': 'new',

'context': {'default_invoice_id': self.id, 'default_res_id': self.id}

}

Silviaa
Avtor

Hi Mohammed,

I also tried your code modifications, but still i got the same error

I dont know what to do..

In this issue if i remove the 'res_id:self.id' form will open, otherwise it shows an error..

But i need res_id because i want to display the uploaded documents for each row

Avatar
Synodica Solutions Pvt. Ltd.
Best Answer

Hi,Problem :

You're passing res_id=self.id, but self refers to the account.invoice record. However, in the action res_model='uplod.file', the res_id is from account.invoice, which doesn't match the uplod.file model. There might be a mismatch as the res_id doesn't exist in the 'upload.file' model.Solution :
You need to first create record of upload.file after you can use it in res_id. we can do like this.

class AccountInvoice(models.Model):
  _inherit = "account.invoice"  def attach_documents(self):
    upload_file = self.env['upload.file'].create({
     # your values
    })
    return {
      'type': 'ir.actions.act_window',
      'view_type': 'form',
      'view_mode': 'form',
      'res_model': 'upload.file',
      'res_id': upload_file.id,
      'target': 'new',
      'context': {'default_invoice_id': self.id}
    }

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

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

Prijavi
Related Posts Odgovori Prikazi Aktivnost
How can i get parent form value in one2many form view or pop up form view ?? Solved
python xml odoo10
Avatar
Avatar
Avatar
2
okt. 22
10701
change field color depending on its value (condition)
python xml odoo10
Avatar
Avatar
Avatar
2
nov. 19
11735
Inherit Customers Form View
python xml odoo10
Avatar
0
avg. 18
3240
ODOO10: How to close Popup based on python
python popup odoo10
Avatar
0
nov. 17
5321
How to add a new column in Purchase Order invoice Solved
python xml odoo10
Avatar
Avatar
1
maj 17
8389
Community
  • Tutorials
  • Dokumentacija
  • Forum
Open Source
  • Prenesi
  • Github
  • Runbot
  • Prevodi
Services
  • Odoo.sh Hosting
  • Podpora
  • Nadgradnja
  • Custom Developments
  • Izobraževanje
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Sredstva blagovne znamke
  • Kontakt
  • Zaposlitve
  • Dogodki
  • Podcast
  • Blog
  • Stranke
  • Pravno • Zasebnost
  • Varnost
الْعَرَبيّة 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 is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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