Bug 34142

Summary: Add column sub_location to items table
Product: Koha Reporter: Emmi Takkinen <emmi.takkinen>
Component: DatabaseAssignee: Emmi Takkinen <emmi.takkinen>
Status: Needs Signoff --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: ahennig, lucas, philip.orr
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Bug 34142: Add new column sub_location to (deleted)items
Bug 34142: DO NOT PUSH! Schema changes
Bug 34142: Add new column sub_location to (deleted)items
DO NOT PUSH! Schema changes
Bug 34142: Add new column sub_location to (deleted)items
DO NOT PUSH! Schema changes
DO NOT PUSH! Schema changes
Bug 34142: Add new column sub_location to (deleted)items
DO NOT PUSH! Schema changes
Bug 34142: Add new column sub_location to (deleted)items

Description Emmi Takkinen 2023-06-28 10:29:00 UTC
We should add new column sub_location to items and deleteditems table. This can be used to indicate e.g. if item has some other more specific location than permanent location.
Comment 1 Katrin Fischer 2023-06-30 20:44:09 UTC
Can you explain how sub_location, location and permanent_location would relate to each other?
Comment 2 Emmi Takkinen 2023-07-04 06:27:21 UTC
(In reply to Katrin Fischer from comment #1)
> Can you explain how sub_location, location and permanent_location would
> relate to each other?

For example, some of our libraries use it to mark new material. They're located in e.g. adult section so location and permanent_location are marked as "A". But they also have sub_location "NEW" so they are shelved into a specific place. Or items have sub_location "EXHIBIT" so librarians know where to look for them.
Comment 3 Katrin Fischer 2023-07-04 07:29:53 UTC
Hm, I think this sounds a bit like the temporary location idea that has been discussed in 

Bug 14962 - Temp Shelving Location
Bug 31168 - Temporary Item Locations

as New would be temporary. I think some libraries have resolved this by mapping permanent_location to a subfield to make it visible in the items editor. They control them manually then.
Comment 4 Emmi Takkinen 2023-07-04 08:38:41 UTC
(In reply to Katrin Fischer from comment #3)
> Hm, I think this sounds a bit like the temporary location idea that has been
> discussed in 
> 
> Bug 14962 - Temp Shelving Location
> Bug 31168 - Temporary Item Locations
> 
> as New would be temporary. I think some libraries have resolved this by
> mapping permanent_location to a subfield to make it visible in the items
> editor. They control them manually then.

Yeah some of the locations are temporary. Some other cases might be that library has a sublocation in their storage for specific items. Or then item has shorter loan time and is shelved separately. So those sublocations are more permanent and might never change, but they are not quite the same as permanent location.
Comment 5 Emmi Takkinen 2023-10-18 06:31:16 UTC
Created attachment 157299 [details] [review]
Bug 34142: Add new column sub_location to (deleted)items

Add new column sub_location to items and deleteditems table.
Column can be used to indicate e.g. if item has some other
more specific location than permanent location.

To test:
1) Add new authorized value for sublocation e.g. "SUBLOC"
and add some values to it.
2) Add new 952 subfield e.g. S to MARC framework and link
your new authorized value "SUBLOC" to it.
3) Link subfield to items.sub_location field in "Koha to MARC
mapping" (add 952,S).
4) Find a record and attempt to add new item to it.
=> Note that new subfield S is now displayed on item form
and dropdown selector contains values added to "SUBLOC".
=> Saving should be successfull.
=> After saving confirm that sublocation is displayed in
its own column in items listing above item form and that
sublocation is displayed with correct description.
5) Attempt to modify item.
=> Confirm that sublocation is displayed and it's correct.
6) Attempt to delete item.
=> Deleting should be successfull.

Sponsored-by: Koha-Suomi Oy
Comment 6 Emmi Takkinen 2023-10-18 06:32:40 UTC
Created attachment 157300 [details] [review]
Bug 34142: DO NOT PUSH! Schema changes
Comment 7 Owen Leonard 2023-10-18 11:58:33 UTC
I see the new column in the items table but when I save an item with the new field nothing shows up in items.sub_location. I only see the data in more_subfields_xml.

Even after manually adding data to items.sub_location, I don't see the information appearing in circ/returns.tt. On the detail page I see the authorized value code instead of the description.

Should sub-location appear in every place where location appears? (if so please see Bug 35059)

Should sub-location only display when a location is defined?

Shouldn't the new column in the table have the same capacity as items.location? The new one is varchar(10) instead of item.location's varchar(80)
Comment 8 Emmi Takkinen 2023-11-24 07:57:40 UTC
(In reply to Owen Leonard from comment #7)
> I see the new column in the items table but when I save an item with the new
> field nothing shows up in items.sub_location. I only see the data in
> more_subfields_xml.
> 
> Even after manually adding data to items.sub_location, I don't see the
> information appearing in circ/returns.tt. On the detail page I see the
> authorized value code instead of the description.
It's hard to say what is going on here. I installed patches from a scratch and everything works as expected when adding new item. But I don't see it on detail page or in returns page. 

> Should sub-location appear in every place where location appears? (if so
> please see Bug 35059)
It could, I'll add it after I fix those other pages.

> Should sub-location only display when a location is defined?
I think it should be displayed even if location is not defined.

> Shouldn't the new column in the table have the same capacity as
> items.location? The new one is varchar(10) instead of item.location's
> varchar(80)
I don't see why not.
Comment 9 Emmi Takkinen 2023-11-24 12:18:49 UTC
Created attachment 159236 [details] [review]
Bug 34142: Add new column sub_location to (deleted)items

Add new column sub_location to items and deleteditems table.
Column can be used to indicate e.g. if item has some other
more specific location than permanent location.

To test:
1) Add new authorized value for sublocation e.g. "SUBLOC"
and add some values to it.
2) Add new 952 subfield e.g. S to MARC framework and link
your new authorized value "SUBLOC" to it.
3) Link subfield to items.sub_location field in "Koha to MARC
mapping" (add 952,S).
4) Find a record and attempt to add new item to it.
=> Note that new subfield S is now displayed on item form
and dropdown selector contains values added to "SUBLOC".
=> Saving should be successfull.
=> After saving confirm that sublocation is displayed in
its own column in items listing above item form and that
sublocation is displayed with correct description.
5) Attempt to modify item.
=> Confirm that sublocation is displayed and it's correct.
6) Attempt to delete item.
=> Deleting should be successfull.

Also confirm that sub location is displayed on these pages:
1) detail.pl
2) moredetail.pl
3. returns.pl

Sponsored-by: Koha-Suomi Oy
Comment 10 Emmi Takkinen 2023-11-24 12:19:15 UTC
Created attachment 159237 [details] [review]
DO NOT PUSH! Schema changes
Comment 11 Emmi Takkinen 2023-12-05 08:08:24 UTC
Now I'm facing the same problem as Owen. Update runs as it should, but column isn't added to database.
Comment 12 Emmi Takkinen 2023-12-05 08:10:40 UTC
(In reply to Emmi Takkinen from comment #11)
> Now I'm facing the same problem as Owen. Update runs as it should, but
> column isn't added to database.

My bad, for some reason column was already in the table but in wrong place.
Comment 13 Philip Orr 2024-04-12 08:55:14 UTC
Failed to merge for me when trying to apply the patch. Needs to be rebased.
Comment 14 Emmi Takkinen 2024-04-15 11:12:26 UTC
Created attachment 164875 [details] [review]
Bug 34142: Add new column sub_location to (deleted)items

Add new column sub_location to items and deleteditems table.
Column can be used to indicate e.g. if item has some other
more specific location than permanent location.

To test:
1) Add new authorized value for sublocation e.g. "SUBLOC"
and add some values to it.
2) Add new 952 subfield e.g. S to MARC framework and link
your new authorized value "SUBLOC" to it.
3) Link subfield to items.sub_location field in "Koha to MARC
mapping" (add 952,S).
4) Find a record and attempt to add new item to it.
=> Note that new subfield S is now displayed on item form
and dropdown selector contains values added to "SUBLOC".
=> Saving should be successfull.
=> After saving confirm that sublocation is displayed in
its own column in items listing above item form and that
sublocation is displayed with correct description.
5) Attempt to modify item.
=> Confirm that sublocation is displayed and it's correct.
6) Attempt to delete item.
=> Deleting should be successfull.

Also confirm that sub location is displayed on these pages:
1) detail.pl
2) moredetail.pl
3. returns.pl

Sponsored-by: Koha-Suomi Oy
Comment 15 Emmi Takkinen 2024-04-15 11:13:01 UTC
Created attachment 164876 [details] [review]
DO NOT PUSH! Schema changes
Comment 16 Emmi Takkinen 2024-04-15 11:14:30 UTC
Created attachment 164877 [details] [review]
DO NOT PUSH! Schema changes
Comment 17 HKS3 Tadeusz Sośnierz 2024-06-14 13:52:09 UTC
Created attachment 167714 [details] [review]
Bug 34142: Add new column sub_location to (deleted)items

Add new column sub_location to items and deleteditems table.
Column can be used to indicate e.g. if item has some other
more specific location than permanent location.

To test:
1) Add new authorized value for sublocation e.g. "SUBLOC"
and add some values to it.
2) Add new 952 subfield e.g. S to MARC framework and link
your new authorized value "SUBLOC" to it.
3) Link subfield to items.sub_location field in "Koha to MARC
mapping" (add 952,S).
4) Find a record and attempt to add new item to it.
=> Note that new subfield S is now displayed on item form
and dropdown selector contains values added to "SUBLOC".
=> Saving should be successfull.
=> After saving confirm that sublocation is displayed in
its own column in items listing above item form and that
sublocation is displayed with correct description.
5) Attempt to modify item.
=> Confirm that sublocation is displayed and it's correct.
6) Attempt to delete item.
=> Deleting should be successfull.

Also confirm that sub location is displayed on these pages:
1) detail.pl
2) moredetail.pl
3. returns.pl

Sponsored-by: Koha-Suomi Oy
Signed-off-by: Tadeusz „tadzik” Sośnierz <tadeusz@sosnierz.com>
Comment 18 Lucas Gass (lukeg) 2024-09-24 16:21:16 UTC
This no longer applies cleanly. 

If you add a column to the holdings/other holdings table I think it needs to accounted for in columns_settings.yml so it can be properly hidden via Table Settings. Setting to FQA for that.
Comment 19 Emmi Takkinen 2024-09-27 12:10:03 UTC
Created attachment 172103 [details] [review]
DO NOT PUSH! Schema changes
Comment 20 Emmi Takkinen 2024-09-27 12:10:34 UTC
Created attachment 172104 [details] [review]
Bug 34142: Add new column sub_location to (deleted)items

Add new column sub_location to items and deleteditems table.
Column can be used to indicate e.g. if item has some other
more specific location than permanent location.

To test:
1) Add new authorized value for sublocation e.g. "SUBLOC"
and add some values to it.
2) Add new 952 subfield e.g. S to MARC framework and link
your new authorized value "SUBLOC" to it.
3) Link subfield to items.sub_location field in "Koha to MARC
mapping" (add 952,S).
4) Find a record and attempt to add new item to it.
=> Note that new subfield S is now displayed on item form
and dropdown selector contains values added to "SUBLOC".
=> Saving should be successfull.
=> After saving confirm that sublocation is displayed in
its own column in items listing above item form and that
sublocation is displayed with correct description.
5) Attempt to modify item.
=> Confirm that sublocation is displayed and it's correct.
6) Attempt to delete item.
=> Deleting should be successfull.

Also confirm that sub location is displayed on these pages:
1) detail.pl
2) moredetail.pl
3. returns.pl

Sponsored-by: Koha-Suomi Oy
Signed-off-by: Tadeusz „tadzik” Sośnierz <tadeusz@sosnierz.com>
Comment 21 Emmi Takkinen 2024-09-27 12:13:03 UTC
(In reply to Lucas Gass from comment #18)
> This no longer applies cleanly. 
> 
> If you add a column to the holdings/other holdings table I think it needs to
> accounted for in columns_settings.yml so it can be properly hidden via Table
> Settings. Setting to FQA for that.

Rebased patches against current master.

Sublocation isn't added to its own column in those tables. It's added in the same column as home library (same as permanent location), so I don't think there is need to include to the columns_settings.yml.