This question has been flagged
1 Reply
5641 Views

Hi guys

Today I'm trying to build my own Odoo templates but I'm stuck on one thing.
I've started from the Quotation template code but I soon ran into some problems. With the Quotations template you can't make any productlines without a product name.
So now I'm wondering how I could add a product without a name. (in other words, unreferenced to a product)

Without using my Quotations template I can do this:
http://i.imgur.com/GvicVk9.png

But with the Quotation template I have to fill in a name. See this:
http://i.imgur.com/Od6pzMe.png

This is my code:
        template = self.browse(cr, uid, template)
        order_lines = template.order_line
        for line in order_lines: 
            vals = line_obj.product_id_change(cr, uid, [],
                pricelist = pricelist_id,
                product = line.product_id and line.product_id.id or False,
                qty = 0.0,
                uom = False,
                qty_uos = 0.0,
                uos = False,
                name = '',
                partner_id = partner_id,
                lang = False,
                update_tax = True,
                date_order = False,
                packaging = False,
                fiscal_position = fiscal_position,
                flag = False)
            vals['value']['discount'] = line.discount
            vals['value']['product_id'] = line.product_id and line.product_id.id or False
            name = line.name
            if name == "" or len(name) <= 0:
                vals['value']['name'] = "Unreferenced Products"
            else:
                vals['value']['name'] = line.name
            vals['value']['state'] = 'draft'
            vals['value']['product_uom_qty'] = line.product_uom_qty
            vals['value']['product_uom'] = line.product_uom and line.product_uom.id or False
            vals['value']['price_unit'] = line.price_unit
            vals['value']['tax_id'] = [(6, 0, [x.id for x in line.tax_id])]
            lines.append(vals['value'])
        result['order_line'] = lines

 

Could anybody please tell me how I could add lines to the templates / quotations without needing to supply anything in the field 'Product'?

Any information or help is much appreciated!
Yenthe

Avatar
Discard
Best Answer

Quotation is in fact order, so it is risky ro remove referential constraint on it, but you could try to remove it from order and then you can not fill it. I think better would be to create some special product like "quotation" and use it there with different description.

Best regards,

    Consultant Odoo

Avatar
Discard
Author

So your advise would be to not do this and make a product which you then can choose by default for this? By the way, if it is risky for referential constrains.. why is it then allowed on a quotation for example?