You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
816 B

  1. # Copyright (C) 2018 - TODAY, Pavlov Media
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  3. from odoo import api, fields, models
  4. class AgreementLine(models.Model):
  5. _name = 'agreement.line'
  6. _description = 'Agreement Lines'
  7. product_id = fields.Many2one('product.product', string='Product')
  8. name = fields.Char(string="Description", required=True)
  9. agreement_id = fields.Many2one('agreement', string="Agreement",
  10. ondelete="cascade")
  11. qty = fields.Float(string='Quantity')
  12. uom_id = fields.Many2one('product.uom', string='Unit of Measure',
  13. required=True)
  14. @api.onchange('product_id')
  15. def _onchange_product_id(self):
  16. self.name = self.product_id.name
  17. self.uom_id = self.product_id.uom_id.id