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

View extension and model inheritance

اشتراك

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

لقد تم الإبلاغ عن هذا السؤال
2 الردود
6858 أدوات العرض
الصورة الرمزية
Sebastián Seifert

Hi, 

I´m trying to create a base module with some other modules extending it, and adding more functionality to this base module.

In order to extend de base module, I´m using inheritance without changing the _name field, using only the field _inherit. (I´ll copy my code at the end).

To extend the views of the model I´m using extension inheritance.

Everything works fine the first time I install all modules, but when I try to update the base module, the server will throw and exception because it can´t find the fields from the subclases for the already extended view.

I´ve managed to make it work running an sql script that erase this views. But i would like not to do that, just get the base module updated clicking on the update button of the module. 

I´ll copy my code now.

class document(models.Model):
 
     _name = 'document_control_base.document'

       @api.model
     def _get_resources_list(self):
            model_obj = self.env['document_control_base.resource_type']
            return model_obj._get_resources_list()
        
       STATE_SELECTION = [('active', 'Vigente'),('to_expire', 'Proximo a vencer'),('expired', 'Vencido')]

      name = fields.Char("Nombre",readonly=True,store=True,compute='_compute_name')
  document_name_id = fields.Many2one("document_control_base.document_name","Nombre del documento")
document_condition_ids = fields.Many2many("document_control_base.document_condition", "document_condition_rel", "document_id", "condition_id", "Condiciones del documento")
res_partner_id = fields.Many2one("res.partner",string="Empresa/Recurso Externo")
...

class document(models.Model):
    _inherit = 'document_control_base.document'
    fleet_vehicle_id = fields.Many2one("fleet.vehicle",string="Vehiculo")

    @api.one
    @api.depends('file_name','res_partner_id','document_name_id','state','fleet_vehicle_id')
    def _compute_name(self):
        super(document, self)._compute_name()
    
    resid = self.fleet_vehicle_id.name if self.fleet_vehicle_id.name else ''
    self.name = resid.title() + self.name
...
<record id="document_control_base.document_form" model="ir.ui.view">
<field name="model">document_control_base.document</field>
<field name="arch" type="xml">
<form string="Documentos">
<sheet>
<label for="name" class="oe_edit_only" />
<h1>
<field name="name" class="oe_edit_only" />
</h1>
<group>
<field name="res_type" class="oe_edit_only oe_inline" widget="radio"/>
<field name="res_partner_id" domain="['|','&amp;','&amp;','&amp;',('is_company', '=', False),('parent_id', '!=', False),
('active', '=', True),('employee','=',False),'&amp;','&amp;','&amp;',('is_company', '=', True),('parent_id', '=', False),('active', '=', True),('employee','=',False)]"
attrs="{'invisible':[('res_type', '!=', 'res.partner')]}" class="oe_edit_only"/>
</group>
<group>
<group>
<field name="file_binary" filename="file_name" />
<field name="file_name" class="oe_inline oe_right" invisible="1" />
<field name="document_name_id" domain="[('res_type','=',res_type)]"/>
<field name="document_condition_ids" widget="many2many_tags" />
<field name="description" />
</group>
</group>
<group>
<field name="no_expiration" />
<field name="expiration_id"
attrs="{'invisible':[('no_expiration','=',True)]}"
context="{'form_view_ref': 'document_control_base.expiration_form','resources':'expirations','name':'Vencimiento:','res_partner_id':res_partner_id,'document_name_id':document_name_id}" />
<field name="in_renewal" />
<field name="state" readonly="1" class="oe_edit_only" />
</group>
</sheet>
</form>
</field>
</record>
....
<record model="ir.ui.view" id="document_control_base.document_form_fleet">
<field name="model">document_control_base.document</field>
<field name="inherit_id" ref="document_control_base.document_form" />
<field name="arch" type="xml">
<field name="res_partner_id" position="after">
<label for="fleet_vehicle_id" attrs="{'invisible':[('res_type', '!=', 'fleet.vehicle')]}" class="oe_edit_only" />
<field name="fleet_vehicle_id" attrs="{'invisible':[('res_type', '!=', 'fleet.vehicle')]}" class="oe_edit_only"/>
</field>
<field name="expiration_id" position="attributes">
<attribute name="context">{'form_view_ref': 'document_control_base.expiration_form','resources':'expirations','name':'Vencimiento:','res_partner_id':res_partner_id,'fleet_vehicle_id':fleet_vehicle_id,'document_name_id':document_name_id}</attribute><!-- <attribute name="context" add=" py.PY_setItem(py.evaluate(expr.first, context),'fleet_vehicle_id', fleet_vehicle_id)" separator=" "></attribute> -->
</field>
</field>
</record>
0
الصورة الرمزية
إهمال
Ameera PP

why using 2 classes here?

Sebastián Seifert
الكاتب

The first is from the base module. The second is from the extending module, there are several modules extending the base class. Fleet is only one. And their are installed separately. I can´t erase the answer. Sorry.

الصورة الرمزية
Sebastián Seifert
الكاتب أفضل إجابة

The first is from the base module. The second is from the extending module, there are several modules extending the base class. Fleet is only one. And their are installed separately. 

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

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

تسجيل
المجتمع
  • دروس
  • التوثيق
  • المنتدى
مصدر مفتوح
  • تحميل
  • جيت هاب "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