Skip to content

Commit

Permalink
holdings: attach serials to non-serials documents
Browse files Browse the repository at this point in the history
* Allows to:
    * Attach holdings of serial type to any type of document.
    * Attach holdings of standard type to document of type journal.
    * Attach items of standard type to holdings of type serial.
* Closes #1612.

Co-Authored-by: Aly Badr <aly.badr@rero.ch>
  • Loading branch information
Aly Badr committed Jan 27, 2021
1 parent fe2e70b commit 0f407f6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
9 changes: 3 additions & 6 deletions rero_ils/modules/holdings/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,6 @@ def extended_validation(self, **kwargs):
frequency the next_expected_date should be given.
:return: False if
- document type is not journal and holding type is serial.
- document type is journal and holding type is not serial.
- document type is ebook and holding type is not electronic.
- document type is not ebook and holding type is electronic.
- holding type is serial and the next_expected_date
Expand All @@ -157,10 +155,9 @@ def extended_validation(self, **kwargs):
is_electronic = self.holdings_type == 'electronic'
is_issuance = \
document.get('issuance', {}).get('main_type') == 'rdami:1003'
if (is_serial and not is_issuance) \
or (document.harvested ^ is_electronic):
msg = _('Holding is not attached to the correct document type.'
' document: {pid}')
if (document.harvested ^ is_electronic):
msg = _('Electronic Holding is not attached to the correct \
document type. document: {pid}')
return _(msg.format(pid=document_pid))
# the enumeration and chronology optional fields are only allowed for
# serial holdings
Expand Down
2 changes: 0 additions & 2 deletions rero_ils/modules/items/api/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ def extended_validation(self, **kwargs):
if not holding:
return _('Holding does not exist: {pid}.'.format(pid=holding_pid))
is_serial = holding.holdings_type == 'serial'
if is_serial and self.get('type') == 'standard':
return _('Standard item can not attached to a journal.')
issue = self.get('issue', {})
if issue and self.get('type') == 'standard':
return _('Standard item can not have a issue field.')
Expand Down

0 comments on commit 0f407f6

Please sign in to comment.