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.

84 lines
2.2 KiB

  1. # Copyright 2020 Coop IT Easy SCRL fs
  2. # Robin Keunen <robin@coopiteasy.be>
  3. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
  4. from odoo import api, fields, models
  5. class EMCBinding(models.AbstractModel):
  6. _name = "emc.binding"
  7. _description = "EMC Binding (abstract)"
  8. backend_id = fields.Many2one(
  9. comodel_name="emc.backend", string="EMC Backend", ondelete="restrict"
  10. )
  11. external_id = fields.Integer(string="ID in Platform", index=True)
  12. # internal_id = fields.Many2one # implement in concrete class
  13. @api.model
  14. def search_binding(self, backend, external_id):
  15. return self.search(
  16. [
  17. ("backend_id", "=", backend.id),
  18. ("external_id", "=", external_id),
  19. ]
  20. )
  21. class SubscriptionRequestBinding(models.Model):
  22. _name = "emc.binding.subscription.request"
  23. _inherit = "emc.binding"
  24. internal_id = fields.Many2one(
  25. comodel_name="subscription.request",
  26. string="Internal ID",
  27. required=True,
  28. )
  29. class ProductTemplateBinding(models.Model):
  30. _name = "emc.binding.product.template"
  31. _inherit = "emc.binding"
  32. internal_id = fields.Many2one(
  33. comodel_name="product.template",
  34. string="Internal ID",
  35. domain="[('is_share', '=', True)]",
  36. required=True,
  37. )
  38. class AccountInvoiceBinding(models.Model):
  39. _name = "emc.binding.account.invoice"
  40. _inherit = "emc.binding"
  41. internal_id = fields.Many2one(
  42. comodel_name="account.invoice", string="Internal ID", required=True
  43. )
  44. class AccountPaymentBinding(models.Model):
  45. _name = "emc.binding.account.payment"
  46. _inherit = "emc.binding"
  47. internal_id = fields.Many2one(
  48. comodel_name="account.payment", string="Internal ID", required=True
  49. )
  50. class AccountJournalBinding(models.Model):
  51. _name = "emc.binding.account.journal"
  52. _inherit = "emc.binding"
  53. internal_id = fields.Many2one(
  54. comodel_name="account.journal", string="Internal ID", required=True
  55. )
  56. class AccountAccountBinding(models.Model):
  57. _name = "emc.binding.account.account"
  58. _inherit = "emc.binding"
  59. internal_id = fields.Many2one(
  60. comodel_name="account.account", string="Internal ID", required=True
  61. )