تخطي للذهاب إلى المحتوى
أودو القائمة
  • تسجيل الدخول
  • جرب مجاناً
  • التطبيقات
    المالية
    • المحاسبة
    • فوترة
    • النفقات
    • جدول البيانات (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
حول هذا المنتدى
المساعدة

[SOLVED] Related field in a form - works on edit, but not create

اشتراك

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

لقد تم الإبلاغ عن هذا السؤال
fieldcreaterelatededit
2 الردود
15625 أدوات العرض
الصورة الرمزية
Peter Alabaster

Hi, I have created a related field on the product.template form in hope to duplicate the field and have it placed somewhere else.

In the _columns{} section of a class, I have added :

'default_code_duplicate' : fields.related('product_variant_ids', 'default_code', type='char', string='SKU:'),

And in the view I have added:           

           <field name="arch" type="xml">
                <div name="options" position="inside">
                    <div>
                        <label for="default_code_duplicate"/>
                        <field name="default_code_duplicate"/>
                    </div>
                </div>
            </field>

The field shows up fine and i thought it was working correctly until I created a new record and inputted data to this field. The data dissapears on 'Save'. When I click edit, then enter again in the same field, and click save - the data stays.

Could this be something to do with the fact it is a temporary record when you click create, and not written to the database yet?

Is this the correct way to go about this? I don't actually need to duplicate the field, but simply move it - but i didn't know how to do that - so I went about doing it this way.

Thanks

 

0
الصورة الرمزية
إهمال
الصورة الرمزية
Bruno PLANCHER
أفضل إجابة

Hello Peter Alabaster,

No, using a related field is not the correct way to "move" a field on a view.

First, related field are not meant to be written when creating a new record (as you saw it on your tests, the create() method remove the related fields from the written fields).

Then, you can move a field by directly overriding the view (you have to create a new view on xml file, and add the field inherit_id to reference the product view).

Moving a field can be dangerous, as other modules can override the same view. One of the correct way to do this could be (IMHO), to set the priority field of your view as higher as possible (so that your view will be the last one to override the original view).

To sum'up, you could create a new view to remove the original field and relocate it where you want to move it, for example: 

        <record id="view_product_peter_alabaster_inherit" model="ir.ui.view">
            <field name="name">product.product.peter.alabaster.inherit</field>
            <field name="model">product.product</field>
            <field name="priority">99</field>
            <field name="inherit_id" ref="product.product_view_you_want_inherit"/>
            <field name="arch" type="xml">
                <-- remove the orinial location of default_code and its label -->
                <field name="default_code" position="replace"/>
                <label for="default_code" position="replace"/>
                <!-- relocate the field under the options field -->
                <field name="options" position="inside">
                    <div>
                        <label for="default_code"/>
                        <field name="default_code"/>
                    </div>
                </field>
        </record>

 

Hope it helps you,

Regards

1
الصورة الرمزية
إهمال
الصورة الرمزية
Peter Alabaster
الكاتب أفضل إجابة

Sorry I can't reply to your comment. Thankyou for the answer! It is very helpful. I think i must have tried this before though.

The product template form is all messed up - default_code is in a different form inherit to the position i want it to go.
 

The Inherit id where i want the field to go is:
<field name="inherit_id" ref="product.product_template_form_view"/>

 

Whereas the field I want to move is in:
product.template.product.form
product.template
product.product_template_only_form_view

 

Error details:
Element '<field name="default_code">' cannot be located in parent view

 

I tried this and got no errors, but the internal reference is showing twice, and the second field (the new one) is blank

        <record id="view_product_supplier_inherit" model="ir.ui.view">
            <field name="name">product.template.supplier.form.inherit</field>
            <field name="model">product.template</field>

            <field name="priority">99</field>
            <field name="inherit_id" ref="product.product_template_only_form_view"/>
            <field name="arch" type="xml">
                <field name="default_code" position="replace"/>
                <label for="default_code" position="replace"/>
            </field>

            <field name="priority">99</field>
            <field name="inherit_id" ref="product.product_template_form_view"/>
            <field name="arch" type="xml">
                <div name="options" position="inside">
                    <div>
                        <label for="default_code"/>
                        <field name="default_code"/>
                    </div>
                </div>
            </field>
        </record>

 

 

:: EDIT ::

In response to your comment - yes I have tried that, and get 'not located in parent view' error. I have tried this:

        <record id="view_product_template_form" model="ir.ui.view">
            <field name="name">product.template.inherit</field>
            <field name="model">product.template</field>
            <field name="priority">99</field>
            <field name="inherit_id" ref="product.product_template_form_view"/>
            <field name="arch" type="xml">
                <xpath expr="//page[@string='Information']" position="inside">                   
                    <label for="default_code" position="replace"/>
                    <field name="default_code" position="replace"/>
                </xpath>
                <div name="options" position="inside">
                    <div>
                        <label for="default_code"/>
                        <field name="default_code"/>
                    </div>
                </div>
            </field>
        </record>

And the original still shows up, the duplicated field shows too though, which is a start, but unfortunately, neither stay updated when entering values (enter value, save, leave form, return to form, value not there).

Also - with the latest xml i posted (above) neither fields show a tooltip when developer mode is activated and the mouse is hovered over them.

0
الصورة الرمزية
إهمال
Bruno PLANCHER

have you tried to inherit from product.product_template_form_view instead of product.product_template_only_form_view ?

Peter Alabaster
الكاتب

d

هل أعجبك النقاش؟ لا تكن مستمعاً فقط. شاركنا!

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

تسجيل
المنشورات ذات الصلة الردود أدوات العرض النشاط
Auto Load Customer Invoice Address
invoice field related
الصورة الرمزية
0
يونيو 15
4103
Field acting like Textbox
field edit textbox
الصورة الرمزية
0
مارس 15
4564
How do I create a related field? تم الحل
field related bom
الصورة الرمزية
الصورة الرمزية
1
يناير 24
15652
How to edit field in the page ".../my" تم الحل
field edit remove v17
الصورة الرمزية
الصورة الرمزية
2
فبراير 24
2556
Field editing after create a form تم الحل
fields form create edit
الصورة الرمزية
الصورة الرمزية
1
أغسطس 23
2802
المجتمع
  • دروس
  • التوثيق
  • المنتدى
مصدر مفتوح
  • تحميل
  • جيت هاب "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