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.

61 lines
1.8 KiB

2 years ago
  1. from odoo import models, fields, api
  2. class SocialMixin(models.AbstractModel):
  3. _name = "social.mixin"
  4. _description = "Social Mixin"
  5. social_facebook = fields.Char("Facebook Account")
  6. social_instagram = fields.Char("Instagram Account")
  7. social_twitter = fields.Char("Twitter Account")
  8. social_linkedin = fields.Char("LinkedIn Account")
  9. social_youtube = fields.Char("Youtube Account")
  10. social_github = fields.Char("GitHub Account")
  11. def open_twitter(self):
  12. self.ensure_one()
  13. return {
  14. "type": "ir.actions.act_url",
  15. "url": self.social_twitter or "https://www.twitter.com",
  16. "target": "new",
  17. }
  18. def open_facebook(self):
  19. self.ensure_one()
  20. return {
  21. "type": "ir.actions.act_url",
  22. "url": self.social_facebook or "https://www.facebook.com",
  23. "target": "new",
  24. }
  25. def open_github(self):
  26. self.ensure_one()
  27. return {
  28. "type": "ir.actions.act_url",
  29. "url": self.social_github or "https://www.github.com",
  30. "target": "new",
  31. }
  32. def open_linkedin(self):
  33. self.ensure_one()
  34. return {
  35. "type": "ir.actions.act_url",
  36. "url": self.social_linkedin or "https://www.linkedin.com",
  37. "target": "new",
  38. }
  39. def open_youtube(self):
  40. self.ensure_one()
  41. return {
  42. "type": "ir.actions.act_url",
  43. "url": self.social_youtube or "https://www.youtube.com",
  44. "target": "new",
  45. }
  46. def open_instagram(self):
  47. self.ensure_one()
  48. return {
  49. "type": "ir.actions.act_url",
  50. "url": self.social_instagram or "https://www.instagram.com",
  51. "target": "new",
  52. }