Skip to content

Commit

Permalink
donation: add unicity sql constraint on bank_statement_line_id
Browse files Browse the repository at this point in the history
  • Loading branch information
alexis-via committed Sep 14, 2021
1 parent 71c80da commit ca5d13f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions donation/models/donation.py
Expand Up @@ -244,6 +244,14 @@ def _compute_country_id(self):
copy=False,
)

_sql_constraints = [
(
"bank_statement_line_uniq",
"unique(bank_statement_line_id)",
"A donation already exists for this bank statement line.",
)
]

@api.model
def create(self, vals):
if "company_id" in vals:
Expand Down
2 changes: 1 addition & 1 deletion donation/views/donation.xml
Expand Up @@ -296,7 +296,7 @@
name="donation_id"
invisible="not context.get('donation_line_main_view')"
/>
<field name="product_id" context="{'default_donation': True}"/>
<field name="product_id" context="{'default_donation': True}" />
<field name="quantity" />
<field name="unit_price" />
<field
Expand Down

0 comments on commit ca5d13f

Please sign in to comment.