Automatically fill One2many in Odoo


#T&C in each SO
class sale_order(models.Model):
    _inherit = "sale.order"
    
    #By default load the terms and conditions configured in the master T&C configuration
    @api.model
    def _default_so_tc(self):
        terms_obj = self.env['so.terms.config']
        terms = []
        termsids = terms_obj.search([])
        for rec in termsids:
            values = {}
            values['name'] = rec.name
            values['description'] = rec.description
            terms.append((0, 0, values))
        return terms

    terms = fields.One2many('sale.order.terms.conditions','order_id',string='Terms and Conditions',copy=True,default=_default_so_tc)
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s