Merge lp:~openerp-dev/openobject-addons/6.0-opw-581494-rha into lp:openobject-addons/6.0

Proposed by Rifakat Husen (OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/6.0-opw-581494-rha
Merge into: lp:openobject-addons/6.0
Diff against target: 20 lines (+10/-0)
1 file modified
stock/stock.py (+10/-0)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/6.0-opw-581494-rha
Reviewer Review Type Date Requested Status
Numérigraphe (community) Approve
Naresh(OpenERP) Pending
Review via email: mp+133053@code.launchpad.net

Description of the change

Hello,

Currently it is possible to change product on Production Lot where
stock move is associated with the lot. We should forbid the user
changing it.

Override write(), if the product is changed and any stock move refers to
it then it will raise warning.

Please review this fix.

Thanks,
Rifakat Haradwala

To post a comment you must log in.
Revision history for this message
Numérigraphe (numerigraphe) wrote :

I think write() should always refuse to change the product, even when no moves exist, other objects could relate to product_id and we have no way to know.
Lionel

review: Needs Fixing
5366. By Rifakat Husen (OpenERP)

[FIX] stock: remove checking for moves, always product can not be changed

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

right said, corrected the check, Thanks!

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

Unmerged revisions

5366. By Rifakat Husen (OpenERP)

[FIX] stock: remove checking for moves, always product can not be changed

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'stock/stock.py'
2--- stock/stock.py 2012-08-17 07:46:56 +0000
3+++ stock/stock.py 2012-11-07 06:30:30 +0000
4@@ -1432,6 +1432,16 @@
5 _sql_constraints = [
6 ('name_ref_uniq', 'unique (name, ref)', 'The combination of serial number and internal reference must be unique !'),
7 ]
8+
9+ def write(self, cr, uid, ids, vals, context=None):
10+ if 'product_id' in vals:
11+ for production_lot in self.browse(cr, uid, ids, context=context):
12+ if vals['product_id'] != production_lot.product_id.id:
13+ raise osv.except_osv(_('Warning!'), _('You can not change product in this Production Lot once \
14+any product has been assigned to it. \
15+Please create a new Production Lot for your product!'))
16+ return super(stock_production_lot, self).write(cr, uid, ids, vals, context=context)
17+
18 def action_traceability(self, cr, uid, ids, context=None):
19 """ It traces the information of a product
20 @param self: The object pointer.