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

How to create a new row in a table ?

Odoberať

Get notified when there's activity on this post

This question has been flagged
environmentpostgresqlodoo8.0
2 Replies
8745 Zobrazenia
Avatar
Salma

Hello ! please can someone tell me how to create a new row in a table and fill it with the computed fields

class ProductImpo(models.Model):

      _name = 'product.impo'

      id = fields.Integer(string="ID", compute='_compute_id',Store=True)

      Serial_No = fields.Char(string="N° de série", compute='_compute_serial_no')

      @api.multi

      def _compute_id(self):

            i=0

            for record in self:

                       i=i+1

                      record.id=i

       @api.multi

      def _compute_serial_no(self):

               i=-1

               for record in self:

                        i=i+1

                       record.Serial_No=result.Stock_Vehicule[i].Serial_No

Should I use :

product_impo = self.env['product.impo']

product_impo.sudo().write({'id':self.id,  'Serial_No': self.Serial_No  })
If yes so where I must put it ??
PS: The table product_impo in PostgreSQL is empty that's why when I display the tree view I obtain it empty so how to create a new row in the table ?

 

0
Avatar
Zrušiť
Avatar
CatsandDogs
Best Answer

Use,

product_impo.sudo().create({'id':self.id,  'Serial_No': self.Serial_No  })

Note:

Don't use field name as 'id' because following fields are reserved in odoo.

id, create_date, create_uid. write_date, write_uid

0
Avatar
Zrušiť
Avatar
Salma
Autor Best Answer

Yes I have created a treeview : 

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

<field name="name">product.impo.tree</field>

<field name="model">product.impo</field>

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

<tree string="Disponibilité">

<field name="id"/>

<field name="VIN"/>

<field name="Serial_No"/>

</tree>

</field>

</record>
So it must be like this : 

class ProductImpo(models.Model):

_name = 'product.impo'

VIN = fields.Char(string="VIN", compute='_compute_vin')

Serial_No = fields.Char(string="N° de série", compute='_compute_vin')

@api.multi

def _compute_vin(self):

i=0

while i < taille:

self.VIN=result.Stock_Vehicule[i].VIN

self.Serial_No=result.Stock_Vehicule[i].Serial_No

impo = self.env['product.impo']

impo.sudo().create({'VIN': self.VIN, 'Serial_No': self.Serial_No})

i=i+1
Is that true ?


0
Avatar
Zrušiť
CatsandDogs

Did you create a view for the object "product.impo"?. If u have created, there is no need to write a function like you mentioned.

Salma
Autor

Yes I have created a tree view : product.impo.tree product.impo So just I need to do that ? : class ProductImpo(models.Model): _name = 'product.impo' VIN = fields.Char(string="VIN", compute='_compute_vin') Serial_No = fields.Char(string="N° de série", compute='_compute_vin') @api.multi def _compute_vin(self): i=0 while i

Salma
Autor

I will modifiy the previous answer

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
Repeated Serialization Errors("could not serialize access due to concurrent update") in Postgres Database Solved
postgresql odoo8.0
Avatar
Avatar
1
aug 24
34628
can't restore .sql database why? help ?? Solved
postgresql restore odoo8.0
Avatar
Avatar
Avatar
2
máj 16
5122
Invoices Analysis with pos_order included
database postgresql query odoo8.0
Avatar
0
máj 20
3638
How can export a DB odoo 8 without postgresql world? Lubuntu 14, for experts
postgresql databases linux odoo8.0
Avatar
0
apr 19
3991
Odoo 8 gets crashed from time to time
server postgresql crash odoo8.0
Avatar
0
aug 18
3954
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