تخطي للذهاب إلى المحتوى
أودو القائمة
  • تسجيل الدخول
  • جرب مجاناً
  • التطبيقات
    المالية
    • المحاسبة
    • فوترة
    • النفقات
    • جدول البيانات (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 inherit and modify "Name" in Sale Order lines

اشتراك

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

لقد تم الإبلاغ عن هذا السؤال
inheritancesale.order.line
6 الردود
19526 أدوات العرض
الصورة الرمزية
Santi

My goal is to make the "Description" (name) field in Sale Order lines to only show the products "Sales Description"(description_sale)....and NOT the products "Name"+"Sales Description" as per default.

I have already accomplished what I want by editing the "/addons/sale/sale.py" file directly:

by simply modifying this code in class sale_order_line:

    if product_obj.description_sale:
        result['name'] += '\n'+product_obj.description_sale

to

    if product_obj.description_sale:
        result['name'] = product_obj.description_sale

And now I want to add this modification to a module I have created with different modifications for my company so it survives future OpenERP updates. What is the correct way to inherit the class and modify that line of code from a custom module?

Thanks in advance for any help! ...i think it should be pretty easy for any experienced python programmer

Note1: My custom module is already up and running with other modifications, so I don't need help with that, I just need help with the python code necessary to accomplish my request above through inheritance. Note2: Before anyone recommends it to me, i'm aware there's already a module (sale_line_description) which accomplishes something similar, but INCORRECTLY....when the module is installed, when I add a product to the Sale Order line it does not use the product translation if it's a foreign partner.

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

Hi, Try this, it's work here :

 

from openerp.osv import fields, osv
from openerp.tools.translate import _

class sale_order_line(osv.osv):
    _inherit='sale.order.line'

    def product_id_change(self, cr, uid, ids, pricelist, product, qty=0,
        uom=False, qty_uos=0, uos=False, name='', partner_id=False,
        lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False, context=None):
        
        #Appeler la fonction native
        res = super(sale_order_line, self).product_id_change(cr, uid, ids, pricelist, product, qty,
            uom, qty_uos, uos, name, partner_id,
            lang, update_tax, date_order, packaging, fiscal_position, flag, context)
        
        product_obj = self.pool.get('product.product')
        partner_obj = self.pool.get('res.partner')
        partner = partner_obj.browse(cr, uid, partner_id)
        context_partner = {'lang': partner.lang, 'partner_id': partner_id}
        product_obj = product_obj.browse(cr, uid, product, context=context_partner)
        
        if not flag:
            if product_obj.description_sale:
                res['value']['name'] = product_obj.description_sale
        
        return res

sale_order_line()

1
الصورة الرمزية
إهمال
Santi
الكاتب

Thanks! this piece of code did the trick, finally!

Santi
الكاتب

Thanks! this piece of code did the trick, finally!

الصورة الرمزية
Simplify it!
أفضل إجابة

There is no way to modify only that line of code through inheritance, but you can override name doing this on your own module:

class sale_order_line(osv.osv)
    _inherit='sale.order.line'

def product_id_change(self, cr, uid, ids, pricelist, product, qty=0,
        uom=False, qty_uos=0, uos=False, name='', partner_id=False,
        lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False, context=None):

    res=super(sale_order_line, self).product_id_change(cr, uid, ids, pricelist, product, qty=qty,
        uom=uom, qty_uos=qty_uos, uos=uos, name=name, partner_id=partner_id,
        lang=lang, update_tax=update_tax, date_order=date_order, packaging=packaging, fiscal_position=fiscal_position, flag=flag, context=context)

    #Above lines are going to call the native function and 'res' is going to store the result, so you can change the value right there

    if not flag:
        res['value']['name'] = self.pool.get('product.product').name_get(cr, uid, [product_obj.id], context=context_partner)[0][1]
        if product_obj.description_sale:
            res['value']['name'] += product_obj.description_sale

    return res

Well I'm just doing the code that you've modified. But functions can be inherited like this.

Hope that this can help you

1
الصورة الرمزية
إهمال
Santi
الكاتب

Thanks for your quick answer Grover!

I've applied your suggested code (with two small corrections: class sale_order_line(osv.osv): and sale_order_line() ) and then restarted OpenERP server, but it doesn't change anything in the product description.

Santi
الكاتب

Can you take a second look at your code and see if there's anything wrong?

Simplify it!

you've to check your own module. If you can post it everything here. Maybe you didn't added 'sale' ro depends on __openerp__, or maybe you are not calling the file on __init__.py

Santi
الكاتب

OK, I've posted it below. Before I had it in a larger module together with other fixes and modifications, but I've decided to create a separate module just for this fix, to sort out any problems...

Santi
الكاتب

...any other suggestions?

الصورة الرمزية
tansadio
أفضل إجابة
0
الصورة الرمزية
إهمال
الصورة الرمزية
Miguel Machado
أفضل إجابة

im trying this module in v8, but dont work for me.

0
الصورة الرمزية
إهمال
الصورة الرمزية
Santi
الكاتب أفضل إجابة

These are the different components of the simple module and their code:

Code in __init__.py:

import ti_order_lines_description

Code in __openerp__.py:

{
    "name": 'Modifications for XXX',
    "version": '1.0',
    "description": """XXX""",
    "author": 'XXX',
    "website": 'XXX',
    "depends": [
        'base',
        'sale',
    ],
    "demo": [],
    "data": [],
    "installable": True,
    "active": True,
    "category" : "",
}

Code in ti_modifications.py:

from openerp.osv import fields, osv
from tools.translate import _


###Fix: Remove "Product Name" from Sale Order product lines

class sale_order_line(osv.osv):
    _inherit='sale.order.line'

def product_id_change(self, cr, uid, ids, pricelist, product, qty=0,
        uom=False, qty_uos=0, uos=False, name='', partner_id=False,
        lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False, context=None):

    res=super(sale_order_line, self).product_id_change(cr, uid, ids, pricelist, product, qty=qty,
        uom=uom, qty_uos=qty_uos, uos=uos, name=name, partner_id=partner_id,
        lang=lang, update_tax=update_tax, date_order=date_order, packaging=packaging, fiscal_position=fiscal_position, flag=flag, context=context)
   #Above lines are going to call the native function and 'res' is going to store the result, so you can change the value right there

    if not flag:
        res['value']['name'] = self.pool.get('product.product').name_get(cr, uid, [product_obj.id], context=context_partner)[0][1]
        if product_obj.description_sale:
            res['value']['name'] = product_obj.description_sale
    return res
sale_order_line()
0
الصورة الرمزية
إهمال
Miguel Machado

im trying this module in v8, but dont work for me.

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

 make the "Description" (name) field in Sale Order lines to only show the products "Sales Description"(description_sale)....and NOT the products "Name"+"Sales Description" as per default. I think this code can help you.

 

from openerp.osv import osv, fields
from openerp.tools.translate import _

class sale_order_line(osv.Model):
    _name = 'sale.order.line'
    _inherit ='sale.order.line'

    def product_id_change(self, cr, uid, ids, pricelist, product, qty=0, uom=False, qty_uos=0, uos=False, name='', partner_id=False, lang=False, update_tax=True,
            date_order=False, packaging=False, fiscal_position=False, flag=False, context=None):
            
        product_obj = self.pool.get('product.product')
        partner_obj = self.pool.get('res.partner')
        partner = partner_obj.browse(cr, uid, partner_id)
        lang = partner.lang
        context_partner = {'lang': lang, 'partner_id': partner_id}
        
        res=super(sale_order_line, self).product_id_change(cr, uid, ids, pricelist, product, qty=qty, uom=uom, qty_uos=qty_uos, uos=uos, name=name,
            partner_id=partner_id, lang=lang, update_tax=update_tax, date_order=date_order, packaging=packaging, fiscal_position=fiscal_position, flag=flag, context=context)

        #Above lines are going to call the native function and 'res' is going to store the result, so you can change the value right there
        

        product_obj = product_obj.browse(cr, uid, product, context=context_partner)
        
        if not flag:
            res['value']['name'] = self.pool.get('product.product').name_get(cr, uid, [product_obj.id], context=context_partner)[0][1]
            if product_obj.description_sale:
                res['value']['name'] = product_obj.description_sale
        
        return res
    
sale_order_line()

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

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

تسجيل
المنشورات ذات الصلة الردود أدوات العرض النشاط
odoo16 sale
sales inheritance sale.order.line
الصورة الرمزية
الصورة الرمزية
1
مارس 23
2504
How to make a field from Sale Order form Line Item invisible by inheriting view_order_form in my custom module? تم الحل
views inheritance sale.order.line
الصورة الرمزية
الصورة الرمزية
2
مارس 15
5509
Can't inherit base.view_partner_form of res.partner
inheritance
الصورة الرمزية
الصورة الرمزية
الصورة الرمزية
الصورة الرمزية
الصورة الرمزية
4
فبراير 25
4149
How to add a sequence a field? تم الحل
sale.order.line
الصورة الرمزية
الصورة الرمزية
الصورة الرمزية
2
ديسمبر 24
22202
add product upon saving sales order
sale.order.line
الصورة الرمزية
0
سبتمبر 24
1507
المجتمع
  • دروس
  • التوثيق
  • المنتدى
مصدر مفتوح
  • تحميل
  • جيت هاب "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