Skip to content

Commit

Permalink
fixup! [MIG] member_card: Migration to 14.0
Browse files Browse the repository at this point in the history
Signed-off-by: Carmen Bianca BAKKER <[email protected]>
  • Loading branch information
carmenbianca committed Sep 29, 2023
1 parent 6f7ccc2 commit 05ed8db
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion member_card/models/partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,31 @@
class Partner(models.Model):
_inherit = "res.partner"

barcode = fields.Char(compute="_compute_bar_code", store=True)
barcode = fields.Char(
compute="_compute_bar_code",
# It makes no sense to keep this field company-dependent in this module.
# Partners typically have no company. We could add a company field to
# member.card and check it against the env's company to compute the
# correct barcode. This would work, but means we can't use `store=True`
# on this field.
company_dependent=False,
store=True,
)
member_card_ids = fields.One2many("member.card", "partner_id")

member_card_to_be_printed = fields.Boolean("Print Member card?")
last_printed = fields.Datetime("Last printed on")

# TODO: Remove after https://github.com/odoo/odoo/issues/137141 is resolved.
@api.constrains("barcode")
def _check_barcode_unicity(self):
for partner in self:
super(Partner, partner)._check_barcode_unicity()
return

@api.depends(
"member_card_ids",
"member_card_ids.barcode",
)
def _compute_bar_code(self):
for partner in self:
Expand Down

0 comments on commit 05ed8db

Please sign in to comment.