Deleting a product doesn't delete record in product_template table

Asked by James Wyson

Hi,

Using the products module, I created a single product category and a single product linked to this category. I want to delete the product category so I deleted the product linked to the category. When trying to delete the product category, the client informs me that I can't delete it because the categ_id of a record can't be null. I checked the tables and noticed that the even though I have already deleted the product, a record of it still exists in product_template table which is the reason I can't delete the product category. Is this a bug or was the module constructed this way to prevent complete deletion of a product?

I'm using version 5.0.7 of the web client and version 5.0.6 of the server.

Thanks in advance.

Question information

Language:
English Edit question
Status:
Answered
For:
Odoo Addons (MOVED TO GITHUB) Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Mantavya Gajjar (Open ERP) (mga) said :
#1

Hello James,

This is a not a bug this is a normal behaviour of the tiny for product, as per product template is main class in terms of the coding.
when we create any product a product templates is also created as according to the tiny specification define for product and product template as may be you can defined the various variant based on the template so this is the main purpose of the template.

Regards,
MGA

Revision history for this message
James Wyson (jmwyson) said :
#2

Hi,

Thanks for the quick reply. I noticed that the menu for Product Templates will only available after installing product_variant_multi module. Is there a way to delete a product template when I have only the product module installed? The only menus available under products are:

Configuration
  Products Categories
  Packaging
  Units of Measure
    Units of Measure Categories
    Units of Measure
  Prices Computations
    Prices Types
    Pricelists Types
Products by Category
Pricelists
  Pricelists
  Pricelist Versions
Products

As earlier stated, deleting a product by going to the products list (clicking the last available item in the above list) and deleting it from there still leaves a record in product_template.

Revision history for this message
Mantavya Gajjar (Open ERP) (mga) said :
#3

Hello,

"Product Templates will only available after installing product_variant_multi module" this is because the product_variant_multi module enables the Product Template menu actually Product Template is a Base Object for the Product and it comes from the Product module sit self.

Product is Inherits Product Template and use the properties of the Product Templates.

when you create an Product according to inheritance definition it create a 2 records
1. Product - store attributes which is specially defined in the product
2. Product Template - store attributes which is defined in Template

so, ow when we read Product it reads 2 Object
1. Product + 2. Product Template

Now, you are going to delete a Product, of course it will not delete the Product Template. and you can able to delete the Product because Category is not a field of Product Objects actually it comes from the Product Template. so if you want to Delete the Template first you have to delete all links to Template "in terms of database relations" but there is no special way to delete Product + Product Template if you delete Product

Regards,
MGA

Revision history for this message
mikel (mikel-martin) said :
#4

Then... which is the correct way for deleting a product category in openerp?

I get alway the message:

null value in column "categ_id" violates not-null constraint
CONTEXT: SQL statement "UPDATE ONLY "public"."product_template" SET "categ_id" = NULL WHERE $1 OPERATOR(pg_catalog.=) "categ_id""

Revision history for this message
vrsb (shipilov555) said :
#5

"which is the correct way for deleting a product category in openerp?"
You have to create window action related to model "product.template" and to view "product.template.product.tree".
Then create menu item linked with this window action.
After opening the list of templates you can delete them and then delete categories.

Can you help with this problem?

Provide an answer of your own, or ask James Wyson for more information if necessary.

To post a message you must log in.