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.

32 lines
931 B

5 years ago
5 years ago
  1. # Copyright 2018 ACSONE SA/NV
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  3. from odoo import api, fields, models
  4. class ProductTemplate(models.Model):
  5. _inherit = 'product.template'
  6. qty_type = fields.Selection(
  7. selection=[
  8. ('fixed', 'Fixed quantity'),
  9. ('variable', 'Variable quantity'),
  10. ],
  11. required=False,
  12. default='fixed',
  13. string="Qty. type",
  14. )
  15. qty_formula_id = fields.Many2one(
  16. comodel_name="contract.line.qty.formula", string="Qty. formula"
  17. )
  18. @api.onchange('is_contract')
  19. def _change_is_contract(self):
  20. """ Clear the relation to contract_template_id when downgrading
  21. product from contract
  22. """
  23. res = super(ProductTemplate, self)._change_is_contract()
  24. if not self.is_contract:
  25. self.qty_type = False
  26. self.qty_formula_id = False
  27. return res