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
742 B

  1. from odoo import api, models
  2. class SubscriptionRequest(models.Model):
  3. _inherit = "subscription.request"
  4. _majority = 18
  5. def get_eater_vals(self, partner, share_product_id):
  6. vals = {}
  7. eater = share_product_id.eater
  8. if partner.is_company or partner.age < self._majority:
  9. eater = "eater"
  10. vals["eater"] = eater
  11. return vals
  12. @api.multi
  13. def validate_subscription_request(self):
  14. self.ensure_one()
  15. invoice = super(
  16. SubscriptionRequest, self
  17. ).validate_subscription_request()[0]
  18. partner = invoice.partner_id
  19. vals = self.get_eater_vals(partner, self.share_product_id)
  20. partner.write(vals)
  21. return invoice