Files
contract/agreement_legal/models/agreement_line.py
2021-05-14 16:14:03 +02:00

25 lines
815 B
Python

# Copyright (C) 2018 - TODAY, Pavlov Media
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
class AgreementLine(models.Model):
_name = "agreement.line"
_description = "Agreement Lines"
product_id = fields.Many2one(comodel_name="product.product", string="Product")
name = fields.Char(string="Description", required=True)
agreement_id = fields.Many2one(
comodel_name="agreement", string="Agreement", ondelete="cascade"
)
qty = fields.Float(string="Quantity")
uom_id = fields.Many2one(
comodel_name="uom.uom", string="Unit of Measure", required=True
)
@api.onchange("product_id")
def _onchange_product_id(self):
self.name = self.product_id.name
self.uom_id = self.product_id.uom_id.id