Bug 37265 - Consideration of UniqueItemFields setting when receiving items in an order.
Summary: Consideration of UniqueItemFields setting when receiving items in an order.
Status: Pushed to main
Alias: None
Product: Koha
Classification: Unclassified
Component: Acquisitions (show other bugs)
Version: Main
Hardware: All All
: P5 - low trivial
Assignee: Michal Dudzik
QA Contact: Lucas Gass (lukeg)
URL:
Keywords: Sandbox
Depends on:
Blocks:
 
Reported: 2024-07-05 16:26 UTC by Michal Dudzik
Modified: 2024-10-02 09:56 UTC (History)
3 users (show)

See Also:
Change sponsored?: Sponsored
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
24.11.00
Circulation function:


Attachments
Add UniqueItemFields in orderreceive (474 bytes, patch)
2024-07-05 16:33 UTC, Michal Dudzik
Details | Diff | Splinter Review
Add UniqueItemFields in orderreceive (1.63 KB, patch)
2024-07-08 15:29 UTC, Michal Dudzik
Details | Diff | Splinter Review
Bug 37265: Consideration of UniqueItemFields setting when receiving items in an order (1.63 KB, patch)
2024-07-08 16:53 UTC, Michal Dudzik
Details | Diff | Splinter Review
Bug 37265: Consideration of UniqueItemFields setting when receiving items in an order (1.63 KB, patch)
2024-07-08 16:55 UTC, Michal Dudzik
Details | Diff | Splinter Review
Bug 37265: Consideration of UniqueItemFields setting when receiving items in an order (1.67 KB, patch)
2024-07-09 09:55 UTC, David Nind
Details | Diff | Splinter Review
Bug 37265: Consideration of UniqueItemFields setting when receiving items in an order (1.72 KB, patch)
2024-09-24 19:22 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Michal Dudzik 2024-07-05 16:26:05 UTC
When using the Koha acquisition module to receive items (basket receiving an order), Koha does not consideration of UniqueItemFields setting. The problem is that you can accidentally attach 3 items to an order with the same values.
Comment 1 Michal Dudzik 2024-07-05 16:33:37 UTC
Created attachment 168559 [details] [review]
Add UniqueItemFields in orderreceive

Test plan:

1)	Set preferences UniqueItemFields: Public note (itemnotes)
2)	Go to acquisition module
3)	Create a basket with option Create items when: receiving an order
4)	Add order to basket example from From a new (empty) record with Quantity: 3 or more
5)	Close Basket
6)	Receiving an order
7)	Add Public note: TEST and receive first item (Add item)
8)	You will see that next item have the same Public note
9)	Apply this patch and repeat step 7

Sponsored-by: kohawbibliotece.pl
Comment 2 David Nind 2024-07-07 21:18:48 UTC
Thanks for the patch Michal!

I had a go at testing (using the koha-testing-docker development environment).

I could replicate the problem that you identified (and by manually making the change in the patch, I can confirm that it fixes the problem you identified).

Issue applying the patch
~~~~~~~~~~~~~~~~~~~~~~~~

However, I had an issue applying the patch. I don't know what this means or how to fix it:

git bz apply 37265

Bug 37265 - Consideration of UniqueItemFields setting when receiving items in an order.

168559 - Add UniqueItemFields in orderreceive

Apply? [(y)es, (n)o, (i)nteractive] y
Traceback (most recent call last):
  File "/usr/bin/git-bz", line 2834, in <module>
    applied = do_apply(bug_ref)
              ^^^^^^^^^^^^^^^^^
  File "/usr/bin/git-bz", line 1918, in do_apply
    users = bug.server.get_xmlrpc_proxy().User.get({'names': [patch.attacher]})['users']
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/xmlrpc/client.py", line 1122, in __call__
    return self.__send(self.__name, args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/xmlrpc/client.py", line 1464, in __request
    response = self.__transport.request(
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/xmlrpc/client.py", line 1166, in request
    return self.single_request(host, handler, request_body, verbose)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/xmlrpc/client.py", line 1178, in single_request
    http_conn = self.send_request(host, handler, request_body, verbose)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/bin/git-bz", line 1239, in send_request
    connection.putheader("Cookie", cookie)
    ^^^^^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'putheader'

I'm assuming that this means the patch is not in the required format that then development environment expects.

Feel free to post on this bug, or ask for help in the Development channel at https://chat.koha-community.org/

Koha development environment
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Most regular Koha developers use the koha-testing-docker development environment (https://gitlab.com/koha-community/koha-testing-docker) - if you need help setting that up, please ask in the Koha Community Chat > Development channel.

Commit message guidelines
~~~~~~~~~~~~~~~~~~~~~~~~~

Also, the commit message needs to follow the guidelines at https://wiki.koha-community.org/wiki/Commit_messages If I was authoring the patch, I would format it similar to this:

  Bug 37265: Use UniqueItemFields settings for fields when receiving orders

  When using the acquisition module and receiving orders (where items
  are created when receiving an order), Koha does not consider the 
  UniqueItemFields system preference settings for for fields when 
  adding items. The problem is that the unique field values are copied
  to the next items received in the order, when they shouldn't be.

  Test plan:
  1. Set preference UniqueItemFields: Public note (itemnotes)
  2. Go to the acquisition module.
  3. Create a basket with the option for "Create items when:" set to 
     "receiving an order".
  4. Add an order to the basket, for example: From a new (empty) 
     record with the Quantity set to 3 or more.
  5. Close the basket.
  6. Receive the order.
  7. Add a public note: TEST, and receive the first item (Add item).
  8. You will see that the next item has the same public note.
  9. Apply this patch and repeat step 7 - the public note is not 
     used for the next note.

  Sponsored-by: kohawbibliotece.pl

It can sometimes be a challenge getting a development environment setup, and I'd be happy to try and help you to get this to work (or alternatively, I can attach the patch to the bug in the format required). 

Changes to the bug information
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I've added you as the assignee for this bug, and set the version to main (the release maintainer for 24.05 will review this bug once it is pushed to main by the release manager (after the quality assurance step is completed), and decide whether it should be added to 24.05).
Comment 3 Katrin Fischer 2024-07-08 08:23:58 UTC
The file attached is just a diff file not a patch - missing the header lines with the commit message and the bug number - I think this explains the error from git bz. Please let us know if we can help!
Comment 4 Michal Dudzik 2024-07-08 15:29:08 UTC
Created attachment 168594 [details] [review]
Add UniqueItemFields in orderreceive

When using the Koha acquisition module to receive items (basket receiving
an order), Koha does not consideration of UniqueItemFields setting.
The problem is that you can accidentally attach 3 items to an order with the same values.

Test plan:
1. Set preference UniqueItemFields: Public note (itemnotes)
2. Go to the acquisition module.
3. Create a basket with the option for 'Create items when:' set to receiving an order.
4. Add an order to the basket, for example: From a new (empty) record with the Quantity set to 3 or more.
5. Close the basket.
6. Receive the order.
7. Add a public note: TEST, and receive the first item (Add item).
8. You will see that the next item has the same public note.
9. Apply this patch and repeat step 7 - the public note is not used for the next note.

Sponsored-by: kohawbibliotece.pl
Comment 5 Katrin Fischer 2024-07-08 15:33:01 UTC
This looks much better. Small but important:

Subject: [PATCH] Bug 37265 - Consideration of UniqueItemFields setting when
 receiving items in an order
Should be: Bug 37265: ... 

Another small thing: I think you created the patch manually and uploaded it here. Are you using koha-testing-docker? Have a look at git bz, it makes creating and handling the patch files with bugzilla much easier:
https://wiki.koha-community.org/wiki/Git_bz_configuration
Comment 6 Michal Dudzik 2024-07-08 16:53:06 UTC
Created attachment 168607 [details] [review]
Bug 37265: Consideration of UniqueItemFields setting when receiving items in an order

Bug 37265: Use UniqueItemFields settings for fields when receiving orders

When using the acquisition module and receiving orders (where items
are created when receiving an order), Koha does not consider the 
UniqueItemFields system preference settings for for fields when 
adding items. The problem is that the unique field values are copied
to the next items received in the order, when they shouldn't be.

Test plan:
1. Set preference UniqueItemFields: Public note (itemnotes)
2. Go to the acquisition module.
3. Create a basket with the option for "Create items when:" set to 
   "receiving an order".
4. Add an order to the basket, for example: From a new (empty) 
   record with the Quantity set to 3 or more.
5. Close the basket.
6. Receive the order.
7. Add a public note: TEST, and receive the first item (Add item).
8. You will see that the next item has the same public note.
9. Apply this patch and repeat step 7 - the public note is not 
   used for the next note.

Sponsored-by: kohawbibliotece.pl
Comment 7 Michal Dudzik 2024-07-08 16:55:46 UTC
Created attachment 168608 [details] [review]
Bug 37265: Consideration of UniqueItemFields setting when receiving items in an order

When using the acquisition module and receiving orders (where items
are created when receiving an order), Koha does not consider the 
UniqueItemFields system preference settings for for fields when 
adding items. The problem is that the unique field values are copied
to the next items received in the order, when they shouldn't be.

Test plan:
1. Set preference UniqueItemFields: Public note (itemnotes)
2. Go to the acquisition module.
3. Create a basket with the option for "Create items when:" set to 
   "receiving an order".
4. Add an order to the basket, for example: From a new (empty) 
   record with the Quantity set to 3 or more.
5. Close the basket.
6. Receive the order.
7. Add a public note: TEST, and receive the first item (Add item).
8. You will see that the next item has the same public note.
9. Apply this patch and repeat step 7 - the public note is not 
   used for the next note.

Sponsored-by: kohawbibliotece.pl
Comment 8 Michal Dudzik 2024-07-08 17:03:56 UTC
David, thank you for the information. They helped me a lot. I think I've already uploaded the patch according to community guidelines.
Comment 9 Michal Dudzik 2024-07-08 17:04:27 UTC
Katrin, thank you for your tips. I currently work locally. Next time I will use git-bz.
Comment 10 David Nind 2024-07-09 09:55:12 UTC
Created attachment 168638 [details] [review]
Bug 37265: Consideration of UniqueItemFields setting when receiving items in an order

When using the Koha acquisition module to receive items (basket receiving
an order), Koha does not consideration of UniqueItemFields setting.
The problem is that you can accidentally attach 3 items to an order with the same values.

Test plan:
1. Set preference UniqueItemFields: Public note (itemnotes)
2. Go to the acquisition module.
3. Create a basket with the option for 'Create items when:' set to receiving an order.
4. Add an order to the basket, for example: From a new (empty) record with the Quantity set to 3 or more.
5. Close the basket.
6. Receive the order.
7. Add a public note: TEST, and receive the first item (Add item).
8. You will see that the next item has the same public note.
9. Apply this patch and repeat step 7 - the public note is not used for the next note.

Sponsored-by: kohawbibliotece.pl
Signed-off-by: David Nind <david@davidnind.com>
Comment 11 David Nind 2024-07-09 09:57:30 UTC
Thanks Michal!

Good luck with h equality assurance (QA) stage.

There is a bit of a backlog at the moment for the QA Team (180), so it may take a while to get through.

David
Comment 12 Lucas Gass (lukeg) 2024-09-24 19:22:16 UTC
Created attachment 171949 [details] [review]
Bug 37265: Consideration of UniqueItemFields setting when receiving items in an order

When using the Koha acquisition module to receive items (basket receiving
an order), Koha does not consideration of UniqueItemFields setting.
The problem is that you can accidentally attach 3 items to an order with the same values.

Test plan:
1. Set preference UniqueItemFields: Public note (itemnotes)
2. Go to the acquisition module.
3. Create a basket with the option for 'Create items when:' set to receiving an order.
4. Add an order to the basket, for example: From a new (empty) record with the Quantity set to 3 or more.
5. Close the basket.
6. Receive the order.
7. Add a public note: TEST, and receive the first item (Add item).
8. You will see that the next item has the same public note.
9. Apply this patch and repeat step 7 - the public note is not used for the next note.

Sponsored-by: kohawbibliotece.pl
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 13 Martin Renvoize (ashimema) 2024-10-02 09:56:06 UTC
Thanks for all the hard work!

Pushed to main for the next 24.11.00 release as RM Assistant