Skip to Content
Menu
This question has been flagged
3 Replies
507 Views

We are new to Odoo and would like to remove the manufacturer number from the product master in the product description. How can I do this?


Thank you

Avatar
Discard
Author Best Answer

Okay, I think my description was a bit wrong.

I would like to change the description (per product line) in Sales - Order. The manufacturer number, which is stored in the product, is currently placed in front of the product description. The customer should not see this number in the offer, order confirmation and invoice.


Sorry for the confusion

Avatar
Discard

I understood. Yes, you can refer to what I answered below. The Step 2 as i mentioned will remove the code number from the production description both in sale order and report/invoice .

Just note : Change for removing the code number from production description will only be validated for new orders thereafter, no effect on the existing records (just because the product description is a compute field, already stored in the database)

Best Answer

Hi Stefan:

I guess you want to remove the code before product name in the combo,  whick presented in order line、quote report etc. As you look into the model files of product.template  and product.product, you will find the combo is generated by the function ' name_get() ' depending on 'name' (which is the product master name) and 'default_code'(which is the exact part you want to remove). So you need to overwrite it by inheritting the 2 models mentioned above:



1、inherit model 'product.template':

class ProductTemplate(models.Model):
    _inherit = 'product.template'

    def name_get(self):
        return [(template.id, template.name) for template in self]


2、revise model 'product.product'

    It's a bit complex, coz there additionally defined a local function '_name_get() ' inside 'name_get()' to handle the basic name combo . The quick way is to comment the following 3 lines in source code:

        def _name_get(d):
            name = d.get('name', '')
            # code = self._context.get('display_default_code', True) and d.get('default_code', False) or False
            # if code:
            #     name = '[%s] %s' % (code,name)
            return (d['id'], name)

For safety and compliance purpose, we'd better overwriting the function 'name_get()' .

An alternative solution for step 2 above,  is to add a context in action:

in 'developper mode' -> click the debug icon -> select 'edit action' -> go to the field 'context', add value :   {'display_default_code': False}


Please note :  Step 2 will ONLY take effect on new records created afterwards.  You need to modify manually the ones in existing records, because they are compute fields which has been computed and stored in the database already.

Avatar
Discard
Best Answer

Hello Stefan Wuerfel ,

I hope this message finds you well.


You can use xpath position="replace" to remove the manufacturer number field from the view.


Here is the screenshot for your reference.


Thank you.

Avatar
Discard

This is incorrect, moreover there is no such field named 'manufacturer_number' in product module.