0
votes

I am trying to delete the part number(default_code) from the description but I can't get it to work, is there a way to delete ir or hide it?

Quotation Report

1
You should inherit the qweb report and modify it - Kiran

1 Answers

1
votes

Hi and welcome to stackoverflow.

First, you can add show your image in your question, you don't need to reference in a link.

Second, you have to know that the exact line where the default_code is add to the product's name is in this line, and override it is not an option because it would affect the entire functionality of Odoo not just for reports.

Third, you are trying to modify the product's description but not the name, in this sense you have two option to solve your problem:

  1. Change the product's description manualy when you add a new line order line. Or
  2. To do automatically do the point 1. you need to override the function product_id_change that fill the order line when you select a product to remove the default_code surrounded for the brackets, to achieve that use the code below:

Update: add imports

    import re

    class SaleOrderLine(models.Model):
        _inherit = 'sale.order.line'

        @api.multi
        @api.onchange('product_id')
        def product_id_change(self):
            #call the super to maintain the proper flow
            super(SaleOrderLine, self).product_id_change()
            if not self.product_id:
                return {'domain': {'product_uom': []}}
            else:
                vals = {}
                #if the super already assigned a name
                if self.name:
                    regex_pattern = r'\[\w+\] '
                    #count is the maximum number of pattern occurrences
                    rename = re.sub(regex_pattern, '', self.name, count=1, flags=re.IGNORECASE)
                    vals['name'] = rename
                    self.update(vals)

Now the report doesn't have [default_code]. You should take a look the original function for better understanding.

I hope this answer can be helpful for you.