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.

16 lines
561 B

  1. from odoo import api, fields, models, _
  2. class ProductTemplate(models.Model):
  3. _inherit = 'product.template'
  4. @api.onchange('sale_ok')
  5. def _onchange_sale_ok(self):
  6. """ Maintains the value of `available_in_pos` when unchecking `sale_ok`,
  7. by storing its value before calling parent's method,
  8. then assigning the stored value.
  9. """
  10. was_available = self.available_in_pos
  11. super(ProductTemplate, self)._onchange_sale_ok()
  12. if not self.sale_ok:
  13. self.available_in_pos = was_available