Same Attribute Instance on many Products

Description

1. Select T-Shirt attribute set on Product 1 and save
2. Create Attribute Instance for Product 1 and save
3. Select T-Shirt attribute set on Product 2 and save
4. Select Attribute Instance created in second step for Product 2 and save

Now is same attribute instance attached to two products. Try to select other Attribute Set on Product 1 > cant change it because there is a log with error:

Aug 04, 2015 8:12:47 AM org.compiere.util.CLogger saveError
SEVERE: DeleteErrorDependent - ERROR: update or delete on table "m_attributesetinstance" violates foreign key constraint "mattrsetinst_mproduct" on table "m_product"
Detail: Key (m_attributesetinstance_id)=(1103825) is still referenced from table "m_product".

The reason is that attribute instance is deleted when changing attribute set on product. I am wondering why should products share same attribute instances even if they are not instancable?

I suggest one simple change which should solve this conceptual (in my opinion) mistake
> modify Attribute Instance dialog to select exisitng attribute instances which are currently not attached to any products.

Environment

None

Attachments

1
  • 05 Aug 2015, 01:49 AM

Activity

Tomáš Švikruha August 5, 2015 at 9:46 AM

just tested your patch and have to admire your simple solution slightly smiling face thanks! I think you can commit it that patch.

Carlos Ruiz August 5, 2015 at 1:53 AM

Hi , I traced those lines deleting the old ASI to this commit:
https://github.com/adempiere/adempiere/commit/35e8b4
Corresponding to this adempiere ticket:
https://sourceforge.net/p/adempiere/bugs/2309/

Interestingly in that thread the situation arising here was foreseen, but not solved.

Now, I don't see a big issue about products sharing the same attribute set - that can be a possible scenario and maybe is preferable than duplicating the same values in several ASI records.

On my tests for this ticket I see several things failed (AS = Attribute Set, ASI = Attribute Set Instance)

  • creating a product and assigning an AS and ASI - on save the ASI was cleared without notice for the user

  • changing AS and trying to assign an ASI - the attribute dialog window shown the old AS

Attached a patch that I think solves these problems and the problem related here - it now checks if the ASI is used elsewhere before deleting it.

WDYT?

Regards,

Carlos Ruiz

Fixed

Details

Assignee

Reporter

Labels

Priority

Created August 4, 2015 at 6:16 AM
Updated October 1, 2015 at 5:02 PM
Resolved August 5, 2015 at 12:11 PM