Changing product on production lots must be forbidden

Bug #1073106 reported by Numérigraphe
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Committed
Low
OpenERP Publisher's Warranty Team

Bug Description

When modifying a production lot (aka serial number in trunk), there is no check to assert that the changes are consistent with the existing data.
So users are allowed to change the product even though stock moves have been recorded using this prodlot.
But this makes it impossible to move the existing stock, or even to make an inventory of it or to scrap it.

So, users should just not be allowed to change the product.
Ideally, the field should become read-only as soon as there has been a stock move recorded.
If that's not feasible, OpenERP should at least raise a clean error message, and advice them to use another method. For example: "You cannot change this Production Lot because Stock Moves refer to it. You may want to create a new Production Lot and make an inventory to remove the current stock of this Production Lot, and create a stock of the new Production Lot."

Lionel Sausin.

Tags: maintenance

Related branches

Revision history for this message
Numérigraphe (numerigraphe) wrote :

This can be easily verified on v6.0. By browsing the trunk code I suppose this also affects it and v6.1.
Lionel.

Revision history for this message
Numérigraphe (numerigraphe) wrote :

I suggest you take the same approach as in Bug #707287 : overload write() and raise an error if users try to change the product.
It's OK if you don't bother checking whether the lot has stock moves attached or whatever - keep it simple.
Lionel.

description: updated
tags: added: data-integrity
tags: added: maintenance
removed: data-integrity
Changed in openobject-addons:
assignee: nobody → OpenERP Publisher's Warranty Team (openerp-opw)
Changed in openobject-addons:
status: New → Confirmed
importance: Undecided → Low
Changed in openobject-addons:
status: Confirmed → In Progress
Revision history for this message
Rifakat Husen (OpenERP) (rha-openerp) wrote :

Hello Lionel,

Thanks for reporting it. I think override write() is better solution, but we still need check
for moves too, if no moves associated with the lot then product can be changed else forbidden.

Making product as read only for stable 6.0 doesn't work. I tried when there is any stock move then
product should become read only but that doesn't work, so will go for write(). attrs works perfectly
for trunk so I will propose that solution for trunk.

Appreciated your efforts!
Thanks,
Rifakat Haradwala

Revision history for this message
Numérigraphe (numerigraphe) wrote :

Dear Rifakat Haradwala,

Actually I just realized we need to override write() anyway, or else wrong data can be injected through webservices (XML-RPC, netrpc, json...).
So write() is a good solution, and readonly is "nice to have" in trunk *in addition* to write().

Also, for the sake of consistency, if you use attrs in trunk for serial numbers, would you please be so kind as also use them on products and UoMs to enhance the solution of Bug #707287 ?

Thanks for your support.

Lionel.

Revision history for this message
Numérigraphe (numerigraphe) wrote :

One more thing: please let me correct myself: the field should be read-only as soon as the record is created.
As I noted on another bug, I doubt we can find a generic way to know if the serial number's product is safe to change or not : there may be custom addons that depend on it, in addition to the standard Stock Moves.
I hope this is clear enough, just tell me if it isn't.
Lionel

Revision history for this message
Rifakat Husen (OpenERP) (rha-openerp) wrote :

Hello Lionel,

I have fixed this bug over 6.0 and trunk,

lp:~openerp-dev/openobject-addons/6.0-opw-581494-rha
Revision 5366, Revision ID: <email address hidden>

lp:~openerp-dev/openobject-addons/trunk-opw-581494-rha
Revision 7955, Revision ID: <email address hidden>

Please let me know if you face any problem.

Thanks,
Rifakat Haradwala

Changed in openobject-addons:
status: In Progress → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.