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.

38 lines
1.4 KiB

  1. # Copyright 2019 Tecnativa - David Vidal
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  3. from odoo import fields, models
  4. class ResPartner(models.Model):
  5. _inherit = "res.partner"
  6. customer_global_discount_ids = fields.Many2many(
  7. comodel_name="global.discount",
  8. relation="customer_global_discount_rel",
  9. column1="partner_id",
  10. column2="global_discount_id",
  11. string="Sale Global Discounts",
  12. domain=[("discount_scope", "=", "sale")],
  13. )
  14. supplier_global_discount_ids = fields.Many2many(
  15. comodel_name="global.discount",
  16. relation="supplier_global_discount_rel",
  17. column1="partner_id",
  18. column2="global_discount_id",
  19. string="Purchase Global Discounts",
  20. domain=[("discount_scope", "=", "purchase")],
  21. )
  22. # HACK: Looks like UI doesn't behave well with Many2many fields and
  23. # negative groups when the same field is shown. In this case, we want to
  24. # show the readonly version to any not in the global discount group.
  25. # TODO: Check in future versions if it's fixed
  26. customer_global_discount_ids_readonly = fields.Many2many(
  27. string="Sale Global Discounts (readonly)",
  28. related="customer_global_discount_ids",
  29. readonly=True,
  30. )
  31. supplier_global_discount_ids_readonly = fields.Many2many(
  32. string="Purchase Global Discounts (readonly)",
  33. related="supplier_global_discount_ids",
  34. readonly=True,
  35. )