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

Sale order line - get value of a product on "add an item"

By
Daouda Diop
on 8/17/16, 5:08 AM 241 views

Hi,


I created a field in product.template and in the sales order lines.

I would like that when click on add an item and choose a product in field product_id, my new field in the sales order lines take the value the same field but in the product template.

If I use a related field and change the value of the field in sale order line, it also change the value in the product template. And I want it to not change.

Can you help me ? :(

Thanks

0
Daouda Diop
On 8/17/16, 6:17 AM

class coef(models.Model):

    _inherit='sale.order.line'

    coefficient=fields.Float(string="Coefficient UB (%)", require = True)

    # fonction permettant de transmettre les valeurs du champs coefficient des devis vers les factures

    def _prepare_order_line_invoice_line(self, cr, uid, line, account_id=False, context=None):

        ret = super(coef, self)._prepare_order_line_invoice_line(cr, uid, line, account_id=False, context=context)

        if line.product_id:

            if line.coefficient:

                ret['coefficient'] = line.coefficient

        return ret

    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').browse(cr, uid, product)

    return super(coef, 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)


Sorry for the quality

0
madan
On 8/17/16, 6:15 AM

could you please paste the code here?

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: 8/17/16, 5:08 AM
Seen: 241 times
Last updated: 8/17/16, 6:17 AM