Rifakat (OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-opw-581494-rha into
lp:openobject-addons.
Requested reviews:
OpenERP Core Team (openerp)
Related bugs:
Bug #1073106 in OpenERP Addons: "Changing product on production lots must be
forbidden"
https://bugs.launchpad.net/openobject-addons/+bug/1073106
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-opw-581494-rha/+merge/133057
Hello,
It is possible to change product on Production Lot while stock move
is also refers to it. We should not let any user change the product if
stock move is associated.
I have put attrs on product, it becomes readonly when there is any stock move
refers to Production Lot. Also overrided write(), so that it can't be changed
through any webservice.
Thanks for your review.
Regards,
Rifakat Haradwala
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-opw-581494-rha/+merge/133057
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/trunk-opw-581494-rha.
=== modified file 'stock/stock.py'
--- stock/stock.py 2012-10-30 04:49:18 +0000
+++ stock/stock.py 2012-11-06 12:53:30 +0000
@@ -1555,6 +1555,16 @@
_sql_constraints = [
('name_ref_uniq', 'unique (name, ref)', 'The combination of serial number and internal reference must be unique !'),
]
+
+ def write(self, cr, uid, ids, vals, context=None):
+ if 'product_id' in vals:
+ for production_lot in self.browse(cr, uid, ids, context=context):
+ if production_lot.move_ids and vals['product_id'] != production_lot.product_id.id:
+ raise osv.except_osv(_('Warning!'), _('You can not change product in this Production Lot because \
+stock moves refers to it. \
+Please create a new Production Lot for your product!'))
+ return super(stock_production_lot, self).write(cr, uid, ids, vals, context=context)
+
def action_traceability(self, cr, uid, ids, context=None):
""" It traces the information of a product
@param self: The object pointer.
=== modified file 'stock/stock_view.xml'
--- stock/stock_view.xml 2012-10-30 04:49:18 +0000
+++ stock/stock_view.xml 2012-11-06 12:53:30 +0000
@@ -348,7 +348,7 @@
</div>
<group>
<group>
- <field name="product_id"/>
+ <field name="product_id" attrs="{'readonly': [('move_ids', '!=', False)]}"/>
<field name="prefix"/>
<field name="ref"/>
</group>
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp