Skip to Content
Odoo Menu
  • Prisijungti
  • Išbandykite nemokamai
  • Programėlės
    Finansai
    • Apskaita
    • Pateikimas apmokėjimui
    • Sąnaudos
    • Skaičiuoklė (BI)
    • Dokumentai
    • Pasirašymas
    Pardavimai
    • CRM
    • Pardavimai
    • Kasų sistema - Parduotuvė
    • Kasų sistema - Restoranas
    • Prenumeratos
    • Nuoma
    Svetainės
    • Svetainių kūrėjimo įrankis
    • El. Prekyba
    • Internetinis Tinklaraštis
    • Forumas
    • Tiesioginis pokalbis
    • eMokymasis
    Tiekimo grandinė
    • Atsarga
    • Gamyba
    • PLM
    • Įsigijimai
    • Priežiūra
    • Kokybė
    Žmogaus ištekliai
    • Darbuotojai
    • Įdarbinimas
    • Atostogos
    • Įvertinimai
    • Rekomendacijos
    • Transporto priemonės
    Rinkodara
    • Socialinė rinkodara
    • Rinkodara el. paštu
    • SMS rinkodara
    • Renginiai
    • Rinkodaros automatizavimas
    • Apklausos
    Paslaugos
    • Projektas
    • Darbo laiko žiniaraščiai
    • Priežiūros tarnyba
    • Pagalbos tarnyba
    • Planavimas
    • Rezervacijos
    Produktyvumas
    • Diskucija
    • Patvirtinimai
    • IoT
    • VoIP
    • Žinių biblioteka
    • WhatsApp
    Trečiųjų šalių programos Odoo Studija Odoo debesijos platforma
  • Pramonės šakos
    Mažmeninė prekyba
    • Knygynas
    • Drabužių parduotuvė
    • Baldų parduotuvė
    • Maisto prekių parduotuvė
    • Techninės įrangos parduotuvė
    • Žaislų parduotuvė
    Food & Hospitality
    • Barai ir pub'ai
    • Restoranas
    • Greitasis maistas
    • Guest House
    • Gėrimų platintojas
    • Hotel
    Nekilnojamasis turtas
    • Real Estate Agency
    • Architektūros įmonė
    • Konstrukcija
    • Estate Managament
    • Sodininkauti
    • Turto savininkų asociacija
    Konsultavimas
    • Accounting Firm
    • Odoo Partneris
    • Marketing Agency
    • Teisinė firma
    • Talentų paieška
    • Auditai & sertifikavimas
    Gamyba
    • Textile
    • Metal
    • Furnitures
    • Maistas
    • Brewery
    • Įmonių dovanos
    Sveikata & Fitnesas
    • Sporto klubas
    • Akinių parduotuvė
    • Fitneso Centras
    • Sveikatos praktikai
    • Vaistinė
    • Kirpėjas
    Trades
    • Handyman
    • IT įranga ir palaikymas
    • Saulės energijos sistemos
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Kiti
    • Nonprofit Organization
    • Aplinkos agentūra
    • Reklaminių stendų nuoma
    • Fotografavimas
    • Dviračių nuoma
    • Programinės įrangos perpardavėjas
    Browse all Industries
  • Bendrija
    Mokykitės
    • Mokomosios medžiagos
    • Dokumentacija
    • Sertifikatai
    • Mokymai
    • Internetinis Tinklaraštis
    • Tinklalaidės
    Skatinkite švietinimą
    • Švietimo programa
    • Scale Up! Verslo žaidimas
    • Aplankykite Odoo
    Gaukite programinę įrangą
    • Atsisiųsti
    • Palyginkite versijas
    • Leidimai
    Bendradarbiauti
    • Github
    • Forumas
    • Renginiai
    • Vertimai
    • Tapkite partneriu
    • Services for Partners
    • Registruokite jūsų apskaitos įmonę
    Gaukite paslaugas
    • Susiraskite partnerį
    • Susirask buhalterį
    • Susitikti su konsultantu
    • Diegimo paslaugos
    • Klientų rekomendavimas
    • Palaikymas
    • Atnaujinimai
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Gaukite demo
  • Kainodara
  • Pagalba

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

  • CRM
  • e-Commerce
  • Apskaita
  • Atsarga
  • PoS
  • Projektas
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
Pagalba

How to inherit and modify "Name" in Sale Order lines

Prenumeruoti

Get notified when there's activity on this post

This question has been flagged
inheritancesale.order.line
6 Replies
19524 Rodiniai
Portretas
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
Portretas
Atmesti
Portretas
Cyrare
Best Answer

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
Portretas
Atmesti
Santi
Autorius

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

Santi
Autorius

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

Portretas
Simplify it!
Best Answer

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
Portretas
Atmesti
Santi
Autorius

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
Autorius

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
Autorius

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
Autorius

...any other suggestions?

Portretas
tansadio
Best Answer
0
Portretas
Atmesti
Portretas
Miguel Machado
Best Answer

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

0
Portretas
Atmesti
Portretas
Santi
Autorius Best Answer

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
Portretas
Atmesti
Miguel Machado

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

Portretas
tansadio
Best Answer

 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
Portretas
Atmesti
Enjoying the discussion? Don't just read, join in!

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

Registracija
Related Posts Replies Rodiniai Veikla
odoo16 sale
sales inheritance sale.order.line
Portretas
Portretas
1
kov. 23
2504
How to make a field from Sale Order form Line Item invisible by inheriting view_order_form in my custom module? Solved
views inheritance sale.order.line
Portretas
Portretas
2
kov. 15
5509
Can't inherit base.view_partner_form of res.partner
inheritance
Portretas
Portretas
Portretas
Portretas
Portretas
4
vas. 25
4149
How to add a sequence a field? Solved
sale.order.line
Portretas
Portretas
Portretas
2
gruod. 24
22202
add product upon saving sales order
sale.order.line
Portretas
0
rugs. 24
1507
Bendrija
  • Mokomosios medžiagos
  • Dokumentacija
  • Forumas
Atvirasis kodas
  • Atsisiųsti
  • Github
  • Runbot
  • Vertimai
Paslaugos
  • Odoo.sh talpinimas
  • Palaikymas
  • Atnaujinti
  • Pritaikytas programavimo kūrimas
  • Švietimas
  • Susirask buhalterį
  • Susiraskite partnerį
  • Tapkite partneriu
Apie mus
  • Mūsų įmonė
  • Prekės ženklo turtas
  • Susisiekite su mumis
  • Darbo pasiūlymai
  • Renginiai
  • Tinklalaidės
  • Internetinis Tinklaraštis
  • Klientai
  • Teisinis • Privatumas
  • Saugumas
الْعَرَبيّة 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 yra atvirojo kodo verslo programų rinkinys, kuris apima visas įmonės poreikius: CRM, El. Prekybą, Apskaitą, Atsargų, Kasų sistemą, Projektų valdymą ir kt.

Unikali Odoo vertės pasiūla – būti tuo pačiu metu labai lengvai naudojama ir visiškai integruota sistema.

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