İçereği Atla
Odoo Menü
  • Portal
  • Ücretsiz deneyin
  • Uygulamalar
    Finans
    • Muhasebe
    • Faturalama
    • Masraf Yönetimi
    • Elektronik Çizelge (BI)
    • Belgeler
    • İmza
    Satış
    • Müşteri İlişkileri Yönetimi (CRM)
    • Satış
    • Satış Noktası Mağaza
    • Satış Noktası Restoran
    • Abonelikler
    • Kiralama
    Web Sitesi
    • Web Sitesi Oluşturucu
    • eTicaret
    • Blog
    • Forum
    • Canlı Sohbet
    • eÖğrenme
    Tedarik Zinciri
    • Envanter
    • Üretim
    • Ürün Yaşam Döngüsü Yönetimi
    • Satın Alma
    • Bakım
    • Kalite
    İnsan Kaynakları
    • Çalışanlar
    • İşe Alım
    • İzin
    • Değerlendirme
    • Referans
    • Filo Yönetimi
    Pazarlama
    • Sosyal Medyada Pazarlama
    • E-posta ile Pazarlama
    • SMS ile Pazarlama
    • Etkinlikler
    • Pazarlama Otomasyonu
    • Anket
    Hizmetler
    • Proje Yönetimi
    • Çalışma Çizelgeleri
    • Saha Hizmeti
    • Yardım Masası
    • Planlama
    • Randevular
    Verimlilik
    • Sohbet
    • Onay
    • Nesnelerin İnterneti
    • VoIP
    • Bilgi Bankası
    • WhatsApp
    Üçüncü taraf uygulamalar Odoo Stüdyo Odoo Bulut Platformu
  • Sektörler
    Perakende satış
    • Kitapçı
    • Giyim Mağazası
    • Mobilya Mağazası
    • Gıda Marketi
    • Hırdavat Dükkanı
    • Oyuncak Dükkanı
    Gıda ve Konaklama
    • Bar ve Pub
    • Restoran
    • Fast Food Restoranı
    • Konuk Evi
    • İçecek Distribütörü
    • Otel
    Gayrimenkul
    • Emlak Acentesi
    • Mimarlık Firması
    • İnşaat
    • Emlak Yönetimi
    • Bahçe Tasarımı
    • Mülk Sahipleri Derneği
    Uzmanlık
    • Muhasebe Firması
    • Odoo Partner
    • Pazarlama Ajansı
    • Hukuk Firması
    • Yetenek Kazanımı
    • Denetim ve Belgelendirme
    Üretim
    • Tekstil
    • Metal
    • Mobilyalar
    • Gıda
    • Bira fabrikası
    • Kurumsal Hediye
    Sağlık ve Spor
    • Spor Kulübü
    • Optik Mağazası
    • Fitness Merkezi
    • Sağlıklı Yaşam Merkezi
    • Eczane
    • Kuaför Salonu
    Ticaret
    • Tamirci
    • BT Donanım & Destek
    • Güneş Enerjisi Sistemleri
    • Ayakkabı İmalatçısı
    • Temizlik Hizmetleri
    • HVAC Hizmetleri
    Diğerleri
    • Kar Amacı Gütmeyen Kuruluş
    • Çevre Ajansı
    • Reklam Panosu Kiralama
    • Fotoğrafçılık
    • Bisiklet Kiralama
    • Yazılım Bayisi
    Tüm Sektörlere Göz Atın
  • Topluluk
    Öğrenim
    • Eğitim Araçları
    • Dokümantasyon
    • Sertifikasyonlar
    • Eğitim Etkinlikleri
    • Blog
    • Podcast
    Eğitim ve Gelişim
    • Eğitim Programı
    • Scale Up! İşletme Oyunu
    • Odoo'yu Ziyaret Edin
    Yazılım
    • İndirin
    • Sürümleri Kıyaslayın
    • Sürümler
    İş Birliği
    • Github
    • Forum
    • Etkinlikler
    • Çeviriler
    • Partner Olun
    • Partnerler için Hizmetler
    • Muhasebe Firmanızı Kaydettirin
    Hizmetler
    • Partner Bulun
    • Muhasebeci Bulun
    • Bir danışmanla görüşün
    • Kurulum Hizmetleri
    • Müşteri Referansları
    • Destek
    • Sürüm Yükseltme
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Demo randevusu alın
  • Fiyatlandırma
  • Yardım

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

  • Müşteri İlişkileri Yönetimi
  • e-Commerce
  • Muhasebe
  • Envanter
  • PoS
  • Proje Yönetimi
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiketler (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiketler (View all)
odoo accounting v14 pos v15
About this forum
Yardım

How to add a page in a product.product form view ?

Abone Ol

Get notified when there's activity on this post

Bu soru işaretlendi
11 Cevaplar
11418 Görünümler
Avatar
MIADI

Hello, I try to add a page in the product.product form view after the page "Notes" to insert a treeview of a table that I've created.

I tried this in XML :

<?xml version="1.0" encoding="utf-8"?>

<openerp>

    <data>   

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

            <field name="model">miadi.poidsconditionnement</field>

            <field name="name">view.inherit.variantes.conditionnement.form</field>

            <field name="inherit_id" ref="product.product_template_form_view"/>

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

                     <xpath expr="//page[@name='notes']" position="after">

                           <page name="miadi_variantes_conditionnement" string="Packaging">

                                   <tree string="Packaging" editable="bottom">

                                           <field name="nb_articles" />

                                   </tree>

                           </page>

                     </xpath>

            </field>

        </record>

    </data>

</openerp>


But it gives me this error :

ParseError: "Erreur lors de la validation de la contrainte

Le champ `message_follower_ids` n'existe pas

Why I have this error ?

Is the code is good ?

Please help me

Thanks for answers


Odoo 10

0
Avatar
Vazgeç
Avatar
Niyas Raphy (Walnut Software Solutions)
En İyi Yanıt

Hi Miadi,

To add a field to the product.product model first you have to inherit that model and has to define that model, like this

class ProductProduct(models.Model):
_inherit = 'product.product'

test_field = fields.One2many('test.model', 'connect_test_model', string='Packaging')


class TestModel(models.Model):
_name = 'test.template'

connect_test_model = fields.Many2one('product.template', string="Connect")
customer_id = fields.Char(string="Passenger")
age = fields.Integer(string="Age")

Then in the XML,

<record model="ir.ui.view" id="view_variantes_conditionnement_form">
<field name="model">product.template</field>
<field name="name">view.inherit.variantes.conditionnement.form</field>
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml">
<xpath expr="//page[@name='notes']" position="after">
<page name="miadi_variantes_conditionnement" string="Packaging">
<field name="test_field" >
<tree editable="bottom">
<field name="customer_id"/>
<field name="age"/>
</tree>
</field>
</page>
</xpath>
</field>
</record>

Thank You

1
Avatar
Vazgeç
MIADI
Üretici

hi Niyas, thanks for answer.

What I want to do is to display this view (please check this picture : https://www.hostingpics.net/viewer.php?id=947270Capturetreeview2.png) in a page in a product view.

This view is created by the python code below.

So, right now, my python code is only this (with good indentation):

class miadi_poidsConditionnement(models.Model):

_name = 'miadi.poidsconditionnement'

conditionnement_id = fields.Many2one('miadi.packaging', 'Packaging', default='', required=True)

produit_id = fields.Many2one('product.product', 'Product', default='', required=True, ondelete='cascade')

nb_articles = fields.Integer(string='Number of products', default=0)

poids = fields.Float(string='Packaging Weight', default=0)

_sql_constraints = [

('uniq_id', 'unique(produit_id, conditionnement_id)', 'A product already exists with this packaging !'),

]

@api.multi

@api.model

def chargement_ratio(self):

productRatio = self.env['miadi.poidsconditionnement']

conditionnements = self._cr.execute("SELECT id FROM miadi_packaging")

query_cond = self.env.cr.dictfetchall()

#produits = self._cr.execute("SELECT id FROM product_product WHERE active=True")

produits = self._cr.execute("SELECT id FROM product_product")

query_prod = self.env.cr.dictfetchall()

for conditionnements in query_cond:

nom_conditionnement = conditionnements['id']

for produits in query_prod:

product = produits['id']

if_exist = self._cr.execute("SELECT * FROM miadi_poidsConditionnement WHERE conditionnement_id=%s AND produit_id=%s", (nom_conditionnement, product))

exist = self.env.cr.dictfetchall()

if exist:

if_actif = self._cr.execute("SELECT active FROM product_product WHERE id=%s", (product,))

state_actif = self.env.cr.dictfetchone()

actif = state_actif['active']

if actif == False:

productRatio.search([('produit_id', '=', product), ('conditionnement_id', '=', nom_conditionnement)]).unlink()

if not exist:

if_actif = self._cr.execute("SELECT active FROM product_product WHERE id=%s", (product,))

state_actif = self.env.cr.dictfetchone()

actif = state_actif['active']

if actif == True:

Ratio = productRatio.create({'conditionnement_id': nom_conditionnement, 'produit_id': product})

return {'name': _('Weight/number Ratio'), 'view_type': 'form', 'view_mode': 'tree', 'view_id': self.env.ref('miadi_packaging.miadi_poidsConditionnement_tree').id, 'res_model': 'miadi.poidsconditionnement', 'type': 'ir.actions.act_window', 'target': 'current',}

Niyas Raphy (Walnut Software Solutions)

I just updated my answer please check it

MIADI
Üretici

Thanks, but my tree view is returned by my python function (given in my last comment), so how to do ?

MIADI
Üretici

Your answer seems works with my first post but in this post, I gave an example.

My treeview is return by a python function,so how can I add this tree view in a page ?

MIADI
Üretici

and I want to add this treeview in a variant product, so it's in the product.product table

Niyas Raphy (Walnut Software Solutions)

miadi, you want to add a new page in product right ? there you dont need to return a tree view like this, first check my updated answer and see whether its working or not ? after that we can add a tree view in the new page

MIADI
Üretici

I try your answer and the page is display with nothing inside.

Now, what I have to do ?

MIADI
Üretici

I you want the context to understand what I want check this :

I've a table (miadi.poidsconditionnement) and when I click on the menuitem of this table, I have a treeview that is return by a python function. In this treeview, there is some records with different products (from product.product).

And what I want is to display this table in a treeview in a page with some records but only for the product where I am.

I hope you will help you to a good help for me.

Niyas Raphy (Walnut Software Solutions)

Updated the answer please check it, if i add it here the indentation wont be good

MIADI
Üretici

Can you update your answer with my fields please ? Because I don't understand good...

Check my answer to see my codes.

Avatar
MIADI
Üretici En İyi Yanıt

Codes :

class miadi_packaging(models.Model):
_name = 'miadi.packaging'
_rec_name = 'conditionnement_id'
_order = 'conditionnement_id asc'
conditionnement_id = fields.Char(string='Code', size=4, default='', required=True)
conditionnement_nom = fields.Char(string='Packaging Name', default='', required=True)
nb_articles = fields.Integer(string='Number of products', default=0, required=True)
poids = fields.Float(string='Weight', default=0, required=True)
type = fields.Many2one('miadi.packaging.type', 'Type of Packaging', default='', required=True)
_sql_constraints = [
('uniq_id', 'unique(conditionnement_id)', 'A packaging already exists with this ID. It must be unique !'),
('uniq_name', 'unique(conditionnement_nom)', 'A packaging already exists with this name. It must be unique !'),
]
class miadi_poidsConditionnement(models.Model):
_name = 'miadi.poidsconditionnement'
conditionnement_id = fields.Many2one('miadi.packaging', 'Packaging', default='', required=True)
produit_id = fields.Many2one('product.product', 'Product', default='', required=True, ondelete='cascade')
nb_articles = fields.Integer(string='Number of products', default=0)
poids = fields.Float(string='Packaging Weight', default=0)

_sql_constraints = [
('uniq_id', 'unique(produit_id, conditionnement_id)', 'A product already exists with this packaging !'),
]

@api.multi
@api.model
def chargement_ratio(self):
productRatio = self.env['miadi.poidsconditionnement']
conditionnements = self._cr.execute("SELECT id FROM miadi_packaging")
query_cond = self.env.cr.dictfetchall()
produits = self._cr.execute("SELECT id FROM product_product")
query_prod = self.env.cr.dictfetchall()
for conditionnements in query_cond:
nom_conditionnement = conditionnements['id']
for produits in query_prod:
product = produits['id']
if_exist = self._cr.execute("SELECT * FROM miadi_poidsConditionnement WHERE conditionnement_id=%s AND produit_id=%s", (nom_conditionnement, product))
exist = self.env.cr.dictfetchall()
if exist:
if_actif = self._cr.execute("SELECT active FROM product_product WHERE id=%s", (product,))
state_actif = self.env.cr.dictfetchone()
actif = state_actif['active']
if actif == False:
productRatio.search([('produit_id', '=', product), ('conditionnement_id', '=', nom_conditionnement)]).unlink()
if not exist:
if_actif = self._cr.execute("SELECT active FROM product_product WHERE id=%s", (product,))
state_actif = self.env.cr.dictfetchone()
actif = state_actif['active']
if actif == True:
Ratio = productRatio.create({'conditionnement_id': nom_conditionnement, 'produit_id': product})
return {'name': _('Weight/number Ratio'), 'view_type': 'form', 'view_mode': 'tree', 'view_id': self.env.ref('miadi_packaging.miadi_poidsConditionnement_tree').id, 'res_model': 'miadi.poidsconditionnement', 'type': 'ir.actions.act_window', 'target': 'current',}

class ProductProduct(models.Model):
    _inherit = 'product.template'
    packaging_quantity = fields.Char(string="kkkkk")
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="miadi_poidsConditionnement_form" model="ir.ui.view">
<field name="name">miadi.poidsconditionnement.form</field>
<field name="model">miadi.poidsconditionnement</field>
<field name="arch" type="xml">
<form string="Weight/number ratio">  
<group col="4">
<field name="produit_id" />
<field name="conditionnement_id" />
<field name="nb_articles" />
<field name="poids" />
</group>
</form>
</field>
</record>

<record id="miadi_poidsConditionnement_tree" model="ir.ui.view">
<field name="name">miadi.poidsconditionnement.tree</field>
<field name="model">miadi.poidsconditionnement</field>
<field name="arch" type="xml">
<tree string="Weight/number ratio" editable="top">
<field name="produit_id" ref="product.product.attribute_value_ids" />
<field name="conditionnement_id" ref="miadi.packaging.conditionnement_id" />
<field name="nb_articles" />
<field name="poids" />
</tree>
</field>
</record>

<record model="ir.ui.view" id="miadi_poidsConditionnement_search">
<field name="name">miadi.poidsconditionnement.search</field>
<field name="model">miadi.poidsconditionnement</field>
<field name="arch" type="xml">
<search string="Weight/number ratio">
<field name="produit_id" />
<group expand="0" string="Group by">
<filter string="Product" domain="[]" context="{'group_by':'produit_id'}"/>
<filter string="Packaging" domain="[]" context="{'group_by':'conditionnement_id'}"/>
</group>
</search>
</field>
</record>

<record model="ir.actions.act_window" id="action_miadi_poidsConditionnement">
<field name="name">Weight/number ratio</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">miadi.poidsconditionnement</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="miadi_poidsConditionnement_tree"/>
<field name="help" type="html">
<p class="oe_view_nocontent_create">Click here to create a weight/number ratio.</p>
</field>
</record>

<record id="action_chargement_ratio" model="ir.actions.server">
<field name="name">Chargement Ratio</field>
<field name="type">ir.actions.server</field>
<field name="model_id" ref="model_miadi_poidsconditionnement"/>
<field name="code">action = env['miadi.poidsconditionnement'].chargement_ratio()</field>
</record>

<menuitem name="Weight/number ratio" id="menu_miadi_poidsConditionnement" parent="menu_miadi_packaging" sequence="15" action="action_chargement_ratio" />

 

</data>
</openerp>
<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record model="ir.ui.view" id="view_variantes_conditionnement_form">
            <field name="model">product.template</field>
            <field name="name">view.inherit.variantes.conditionnement.form</field>
            <field name="inherit_id" ref="product.product_template_form_view"/>
            <field name="arch" type="xml">
                <xpath expr="//page[@name='notes']" position="after">
                    <page name="miadi_variantes_conditionnement" string="Packaging"> <tree string="Packaging" editable="bottom"> <field name="packaging_quantity" /> </tree> </page>
                </xpath>
            </field>
        </record>
    </data>
</openerp>


I've a table (miadi.poidsconditionnement) which gives a treeview with some records taking products (from product.product) and packaging (from miadi.packaging).

When I go to the form view of a product variant, I want to display in the created page, all records from the miadi.poidsconditionnement table for the product where I am. (Or, if it's possible, I want to execute a function with SQL queries and this function returns a treeview that will be display in the created page)

Do you understand ? If yes, can you help me to edit my code ?

Thank you

0
Avatar
Vazgeç
Niyas Raphy (Walnut Software Solutions)

you just add a my sample code as in the last updation, then tell me in which all places you need which field and values

MIADI
Üretici

i copy/paste your code and it says this when I click on a product variant :

Désolé, vous n'êtes pas autorisé à accéder à ce document. Contactez l'administrateur système si vous pensez qu'il s'agit d'une erreur.

(Modèle de document: test.model)

MIADI
Üretici

The message in english :

Sorry, you are not allowed to access this document. Contact the system administrator if you think this is an error.

(Document template: test.model)

MIADI
Üretici

Ok, i fix the error.

It works, I have the packaging page with, inside, Passenger and Age fields.

MIADI
Üretici

Now, what I want is to display some records of my miadi.poidsconditionnement table but I want only records for the product selected.

Thank you

MIADI
Üretici

I updated my answer, check it and try to help me please

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

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

Üye Ol
Topluluk
  • Eğitim Araçları
  • Dokümantasyon
  • Forum
Açık Kaynak
  • İndirin
  • Github
  • Runbot
  • Çeviriler
Hizmetler
  • Odoo.sh Hosting
  • Destek
  • Sürüm Yükseltme
  • Özel Geliştirmeler
  • Eğitim
  • Muhasebeci Bulun
  • Partner Bulun
  • Partner Olun
Hakkında
  • Şirketimiz
  • Pazarlama Gereçleri
  • İletişim
  • Kariyer
  • Etkinlikler
  • Podcast
  • Blog
  • Müşteriler
  • Hukuki • Gizlilik
  • Güvenlik
الْعَرَبيّة 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, müşteri ilişkileri yönetimi, eTicaret, muhasebe, envanter, satış noktası, proje yönetimi gibi şirketinizin tüm ihtiyaçlarını karşılayan bir açık kaynak işletme uygulamaları paketidir.

Odoo’nun eşsiz değer önermesi, aynı anda hem kullanımının çok kolay olup hem de tamamen entegre olmasıdır.

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