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.

30 lines
832 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(
  8. "product.product",
  9. string="Product")
  10. name = fields.Char(
  11. string="Description",
  12. required=True)
  13. agreement_id = fields.Many2one(
  14. "agreement",
  15. string="Agreement",
  16. ondelete="cascade")
  17. qty = fields.Float(string="Quantity")
  18. uom_id = fields.Many2one(
  19. "uom.uom",
  20. string="Unit of Measure",
  21. required=True)
  22. @api.onchange("product_id")
  23. def _onchange_product_id(self):
  24. self.name = self.product_id.name
  25. self.uom_id = self.product_id.uom_id.id