تخطي للذهاب إلى المحتوى
أودو القائمة
  • تسجيل الدخول
  • جرب مجاناً
  • التطبيقات
    المالية
    • المحاسبة
    • فوترة
    • النفقات
    • جدول البيانات (BI)
    • المستندات
    • توقيع إلكتروني
    المبيعات
    • إدارة علاقات العملاء
    • المبيعات
    • نقطة البيع للمتاجر
    • نقطة البيع للمطاعم
    • الاشتراكات
    • تأجير
    المواقع الإلكترونية
    • أداة بناء المواقع الإلكترونية
    • متاجر إلكترونية
    • مدونة
    • المنتدى
    • دردشة مباشرة
    • التعليم الإلكتروني
    سلسلة التوريد
    • المستودعات
    • التصنيع
    • إدارة دورة حياة المنتج
    • المشتريات
    • الصيانة
    • الجودة
    الموارد البشرية
    • موظفون
    • التوظيف
    • إجازة عمل
    • التقييمات
    • الإحالات
    • تطبيق الأسطول
    التسويق
    • التسويق الإجتماعي
    • التسويق عبر البريد الإلكتروني
    • التسويق عبر الرسائل النصية
    • فعاليات
    • أتمتة التسويق
    • الاستطلاعات
    الخدمات
    • المشاريع
    • الجداول الزمنية
    • الخدمة الميدانية
    • مكتب المساعدة
    • التخطيط
    • مواعيد
    اﻹنتاجية
    • مناقشة
    • الموافقات
    • إنترنت الأشياء "IoT"
    • بروتوكول ربط المحادثات الصوتية عبر الإنترنت
    • المعرفة
    • WhatsApp
    التطبيقات الخارجية ستوديو أودو منصة أودو السحابية
  • قطاعات الأعمال
    البيع بالتجزئة
    • متجر كتب
    • متجر ملابس
    • متجر أثاث
    • متجر بقالة
    • متجر معدات
    • متجر ألعاب
    الطعام والضيافة
    • بار وحانة
    • المطعم
    • مطعم للوجبات السريعة
    • نزل للضيوف
    • موزّع مشروبات
    • فندق
    العقارات
    • وكالة عقارات
    • شركة هندسة معمارية
    • البناء
    • إدارة العقارات
    • العناية بالحدائق
    • اتحاد مُلاّك العقارات
    استشارة
    • مؤسسة محاسبية
    • شريك أودو
    • وكالة تسويقية
    • منشأة قانونية
    • استقطاب المواهب
    • التدقيق والتوثيق
    التصنيع
    • الأقمشة
    • معدني
    • الأثاث
    • الطعام
    • مصنع خمور
    • هدايا الشركات
    الصحة واللياقة البدنية
    • نادي رياضي
    • متجر نظارات
    • مركز لياقة بدنية
    • الممارسون الصحيون
    • صيدلية
    • صالون تصفيف الشعر
    التجارة
    • عامل صيانة
    • الأجهزة والمعدات التقنية ودعمها
    • أنظمة الطاقة الشمسية
    • صانع أحذية
    • خدمات التنظيف
    • خدمات التكييف (HVAC)
    غير ذلك
    • منظمة غير ربحية
    • وكالة بيئية
    • تأجير لوحات إعلانية
    • تصوير
    • تأجير دراجات
    • بائع وسيط للبرمجيات
    تصفح كافة قطاعات الأعمال
  • مجتمع أودو
    تعلم
    • دروس
    • التوثيق
    • شهادات
    • التدريب
    • مدونة
    • بودكاست
    قم بتعزيز التعليم
    • برنامج تعليم
    • Scale UP! لعبة الأعمال
    • قم بزيارة أودو
    احصل على البرنامج
    • تحميل
    • قارنْ الإصدارات
    • إطلاق
    تعاون
    • جيت هاب "Github"
    • المنتدى
    • فعاليات
    • الترجمات
    • كنْ شريكاً
    • خدمات الشركاء
    • سجل مكتب المحاسبة الخاص بك
    احصل على الخدمات
    • اعثر على شريك
    • اعثر على محاسب
    • قابل أحد مرشدي الأعمال
    • خدمات التنفيذ
    • مراجع العملاء
    • الدعم
    • الترقيات
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    الحصول على عرض توضيحي
  • الأسعار
  • المساعدة

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

  • إدارة علاقات العملاء
  • e-Commerce
  • المحاسبة
  • المخزون
  • PoS
  • المشروع
  • MRP
All apps
يجب أن تكون مسجلاً حتى تتفاعل مع المجتمع.
كافة المنشورات الأفراد الشارات
علامات التصنيف (عرض الكل)
odoo accounting v14 pos v15
حول هذا المنتدى
يجب أن تكون مسجلاً حتى تتفاعل مع المجتمع.
كافة المنشورات الأفراد الشارات
علامات التصنيف (عرض الكل)
odoo accounting v14 pos v15
حول هذا المنتدى
المساعدة

How to add a field conditional to tree view of customer?

اشتراك

تسلم الإشعارات عندما يكون هناك نشاط في هذا المنشور

لقد تم الإبلاغ عن هذا السؤال
treeviewviewres.partnerhideinherit
4 الردود
40156 أدوات العرض
الصورة الرمزية
Anabela Damas

Hi,

I've added a supplier number and a customer number, and now I need to add this number in the tree view but I just want that the "Supplier number " appears if there is a partner is a supplier or in the view. I'll try to explain with images.

In this case when a partner is both(supplier and a costumer), it's ok to look like this: both

In this case I didn't want to show the Supplier Number: image description

And in this case I didn't want to show the Client Number: image description

I'm using this code:

<record id="view_partner_tree_inherit" model="ir.ui.view">
    <field name="name">res.partner.tree.inherit</field>
    <field name="model">res.partner</field>
    <field name="inherit_id" ref="base.view_partner_tree" />
    <field name="arch" type="xml">
    <xpath expr="/tree/field[@name='name']" position="after">
        <field name="supplier" invisible="1"/>
        <field name="customer" invisible="1"/>
        <field name="n_client" attrs="{'invisible':[('customer','!=',True)]}"/>
        <field name="n_supplier" attrs="{'invisible':[('supplier','!=',True)]}"/>
        </xpath>
    </field>
</record>

Someone know how to hide the columns depending on if it is a Suppliers tree view or a Customers tree view ?

Thanks

2
الصورة الرمزية
إهمال
الصورة الرمزية
vim24
أفضل إجابة

Having just scoured the internet looking for an answer to a similar problem myself I can tell you how I finally got something similar working:

Instinct told me to try the

attrs="{'invisible':[('customer','!=',True)]}"

approach too. But, I believe attrs don't work to stop the column name itself from appearing in a tree view (works only on the values of each row).

Instead, you need to overwrite the fields_view_get method from within your res_partner python code, which will allow you to change the viability of each column by checking the context. In my case I was looking at Supplier vs Customer invoices, so I checked for the context 'type' being 'out_invoice'/'in_invoice'. In your case I believe customers vs suppliers are given a context value, something like "default_customer" and "default_supplier".

Anyway, in the end you want to remove the attrs element from you xml view and then add something like this to the python code:

  from lxml import etree

  def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False):

    if context is None:
        context = {}

    res = super(res_partner,self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu)

    doc = etree.XML(res['arch'])

    if view_type == 'tree':
        if context.get('default_customer', '0') in ('1'):
            for node in doc.xpath("//field[@name='n_supplier']"):
                doc.remove(node)
        if context.get('default_supplier', '0') in ('1'):
            for node in doc.xpath("//field[@name='n_client']"):
                doc.remove(node)

        res['arch'] = etree.tostring(doc)
    return res

I can't guarantee this will work straight off as I havn't tested it for your case, you might need to tweak some values above. Nor can I guarantee this is the best way to achieve this. But I can say very similar code is working perfectly for me in my situation.

Hope that helps :)

2
الصورة الرمزية
إهمال
الصورة الرمزية
Mohamad Chamra
أفضل إجابة

in tree view, you should use  column_invisible instead of invisible:

attrs="{'column_invisible ':[('customer','!=',True)]}"


1
الصورة الرمزية
إهمال
Andres Brigard

Thanks, worked great in Odoo 12

الصورة الرمزية
Tintumon
أفضل إجابة

For other view like "form view" it works fine

attrs="{'invisible':[('customer','!=',True)]}"

If you use this attrs in Tree view it just hide the data/content which shown in that column. Not the complete column.


So I just tried using this instead of above code:

invisible = "context.get('customer') != True"

And it helped me to hide the complete column from Tree view.

1
الصورة الرمزية
إهمال
الصورة الرمزية
Gustavo
أفضل إجابة

Using the attrs XML attributes to set the invisible attribute of an element is not working. In fact, this attrs will only show or hide the content of the tree view, not the entire column. After searching for some solutions from google, i found this one is working. As an example, i add two new fields on invoice model (called ref_partner_id and sales_inv) and it will shows on the invoice tree view only if the type is out_invoice (supplier invoice):

<field name=”ref_partner_id” string=”Customer (name)” invisible=”context.get(‘type’) == ‘out_invoice’ “/>
<field name=”sales_inv”  invisible=”context.get(‘type’) == ‘out_invoice’ “/>

This will work because we got the context variable that inform us the type of invoices currently being displayed on the tree. This comes from the account module (account_invoice_view.xml), for example on the action_invoice_tree2:

<record id=”action_invoice_tree2″ model=”ir.actions.act_window”>
<field name=”name”>Supplier Invoices</field>
<field name=”res_model”>account.invoice</field>
<field name=”view_type”>form</field>
<field name=”view_mode”>tree,form,calendar,graph</field>
<field eval=”False” name=”view_id”/>
<field name=”domain”>[('type','=','in_invoice')]</field>
    <field name=”context”>{‘default_type’: ‘in_invoice’, ‘type’: ‘in_invoice’, ‘journal_type’: ‘purchase’}</field>
</record>

Source: http://vitraining.com/show-hide-columns-in-openerp-tree-view-xml/

0
الصورة الرمزية
إهمال
هل أعجبك النقاش؟ لا تكن مستمعاً فقط. شاركنا!

أنشئ حساباً اليوم لتستمتع بالخصائص الحصرية، وتفاعل مع مجتمعنا الرائع!

تسجيل
المنشورات ذات الصلة الردود أدوات العرض النشاط
Creating new view from a old view تم الحل
view res.partner inherit
الصورة الرمزية
الصورة الرمزية
11
يناير 24
14467
inherit res.partner view
view res.partner inherit
الصورة الرمزية
الصورة الرمزية
1
مارس 15
12025
Hide the misc group in res.partner view in sale & purchases page
view res.partner hide group odoo18
الصورة الرمزية
الصورة الرمزية
1
مايو 25
1526
How to inherit list (tree) view? تم الحل
treeview inherit
الصورة الرمزية
الصورة الرمزية
الصورة الرمزية
3
يناير 24
16007
Why is my Custom TreeView showing only one record, instead of a list of records? تم الحل
treeview view
الصورة الرمزية
الصورة الرمزية
2
مايو 18
4892
المجتمع
  • دروس
  • التوثيق
  • المنتدى
مصدر مفتوح
  • تحميل
  • جيت هاب "Github"
  • المشغل الآلي رنبوت
  • الترجمات
خدماتنا
  • استضافة أودو إس إتش
  • الدعم
  • الترقية
  • التطويرات المخصصة
  • التعليم
  • اعثر على محاسب
  • اعثر على شريك
  • كنْ شريكاً
معلومات عنا
  • شركتنا
  • أصول العلامة التجارية
  • اتصلْ بنا
  • الوظائف
  • فعاليات
  • بودكاست
  • مدونة
  • عملاء
  • قانوني • الخصوصية
  • الحماية
الْعَرَبيّة 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

أودو هو عبارة عن مجموعة من تطبيقات الأعمال مفتوحة المصدر التي تغطي جميع احتياجات شركتك، مثل: إدارة علاقات العملاء والتجارة الإلكترونية والمحاسبة والمخزون ونقاط البيع وإدارة المشاريع وما إلى ذلك.

ما يجعل من أودو مميزاً هو هدفه بأن يكون سهل الاستخدام للغاية ومتكاملاً تمامًا في الوقت ذاته.

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