Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Need to figure out how to have Product Field --> Internal Code and Description --> Product Name

By
Tim
on 10/1/16, 10:13 PM 172 views

Hello,

I have been trying to figure out in Odoo9 instead of having [4423]Apple iWatch White in both the Product and Description columns would like to have 4423 in the Product column and Apple iWatch White in the Description column.


I have look on the odoo forums and found threads that talk about how to remove the sku, but when i do that it removes it for both columns. This is not the results I need.

I have already treid to edit name_gate to:

def name_get(self, cr, user, ids, context=None):

  res = []
 if context is None:
  context = {}
 if isinstance(ids, (int, long)):
  ids = [ids]
 if not len(ids):
  return []
 for product in self.browse(cr, user, ids,context=context):
  res.append((product.id, product.name))
 return res

But this removes the internal code.

I appericate any help!


Thank you.


0

Bejaoui Souheil

--Bejaoui Souheil--
808
| 2 1 4
Sousse, Tunisia
--Bejaoui Souheil--

Odoo developer,  functional and technical consultant

souheil_bejaoui@hotmail.fr

Bejaoui Souheil
On 10/2/16, 5:53 AM

Hi,

If we take the sale order as example, you can see how the field description is set.

addons/sale/sale.py:759
@api.multi
@api.onchange('product_id')
def product_id_change(self):
[...]
    name = product.name_get()[0][1]
    if product.description_sale:
name += '\n' + product.description_sale
    vals['name'] = name
[...]

Overbidding  the get_name will give you always the same result in the two columns.

So, you have to override the onchange function to set whatever you want or simply define a value for  description_sale on your product

0
Tim
On 10/2/16, 1:35 PM

Hello,

Thank you for your reply.


In purchase.py

self.name = product_lang.display_name
if product_lang.description_purchase: self.name += '\n' + product_lang.description_purchase

So I would have to change self.name to equal product name. What is the product name variable?

EDIT: I created a new function and it works perfectly.

In sale.sy

name = product.name_get()[0][1]        
if product.description_sale: name += '\n' + product.description_sale

What are the [0][1] for? Also would I have to make another name_get() function in product.py?.
EDIT: I created a new function and it works perfectly.

Thank you


Welcome.

Bejaoui Souheil
on 10/3/16, 3:48 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 10/1/16, 10:13 PM
Seen: 172 times
Last updated: 10/2/16, 4:18 PM