1
votes

I have added a custom field in opportunity and same field in quotation and I want to add value in that custom field in opportunity and pass that values to Quotation in same field.

In odoo 8 it was done by overriding makeOrder method but now in odoo 10 I have no idea how to do it. Someone please help me about it. Thanks!
3
I don't understand it. So you create a new field, and you want to see its value, is it? Have you any relation between the the model? If yes, you should use relation field. May it solve your problem?Döme
yes there is a relational field opportunity_ id in sale.order and I have done it by onchange. Thank you so much for suggestionTahir Noor

3 Answers

2
votes

When you write your field definitions, you can solve it. It will be change on the fly, if you set 'store' property to True, then it will write it to the db, so this will equivalent with your solution. If I know well, my way is faster, and this is the right way. More transparent code management.

opportunity_id = fields.Many2One('opportunity', string='Opportunity')
x_description = fields.Text(related='opportunity_id.x_description', store=True)
1
votes

thank you it also the thing I have struggled for few weeks. Mine is below (to transfer a value commission set under "res.company" to be used in model "sale.order": ( I didn't known "company_it" is fields of relationship)

class YourCompany(models.Model):
    _inherit = "res.company"

    company_commission =  fields.Float( default =15.00)
    commission_ids = fields.One2many( 'sale.order', 'company_id', 
        string="Commission_ids")

class SaleOrder(models.Model):
    _inherit = "sale.order"
    company_id = fields.Many2one('res.company', string='company_id', 
          required=True)
    company_commission = 
                fields.Float(related='company_id.company_commission', 
         string="Comm", store = True)
0
votes

I found this solution, It is working well for me.

@api.onchange('opportunity_id')
    def _get_description(self):
        if self.opportunity_id.id:
            self.x_description = self.opportunity_id.x_description