mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[ADD] cron which lift the reservation with an passed validity date
This commit is contained in:
@@ -5,5 +5,22 @@
|
||||
<field name="name">Reservation Stock</field>
|
||||
<field name="location_id" ref="stock.stock_location_company"/>
|
||||
</record>
|
||||
|
||||
|
||||
<!-- Release the stock.reservation when the validity date has
|
||||
passed -->
|
||||
<record forcecreate="True" id="ir_cron_release_stock_reservation" model="ir.cron">
|
||||
<field name="name">Release the stock reservation having a passed validity date</field>
|
||||
<field eval="True" name="active" />
|
||||
<field name="user_id" ref="base.user_root" />
|
||||
<field name="interval_number">1</field>
|
||||
<field name="interval_type">days</field>
|
||||
<field name="numbercall">-1</field>
|
||||
<field eval="False" name="doall" />
|
||||
<field name="model">stock.reservation</field>
|
||||
<field name="function">release_validity_exceeded</field>
|
||||
<field name="args">()</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
@@ -37,7 +37,7 @@ class stock_reservation(orm.Model):
|
||||
readonly=True,
|
||||
ondelete='cascade',
|
||||
select=1),
|
||||
'date_validity': fields.datetime('Validity Date'),
|
||||
'date_validity': fields.date('Validity Date'),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
@@ -77,6 +77,16 @@ class stock_reservation(orm.Model):
|
||||
move_obj.action_cancel(cr, uid, move_ids, context=context)
|
||||
return True
|
||||
|
||||
def release_validity_exceeded(self, cr, uid, ids=None, context=None):
|
||||
""" Release all the reservation having an exceeded validity date """
|
||||
domain = [('date_validity', '<', fields.date.today()),
|
||||
('state', '=', 'done')]
|
||||
if ids:
|
||||
domain.append(('id', 'in', ids))
|
||||
reserv_ids = self.search(cr, uid, domain, context=context)
|
||||
self.release(cr, uid, reserv_ids, context=context)
|
||||
return True
|
||||
|
||||
def unlink(self, cr, uid, ids, context=None):
|
||||
""" Release the reservation before the unlink """
|
||||
self.release(cr, uid, ids, context=context)
|
||||
|
||||
@@ -128,8 +128,7 @@
|
||||
|
||||
<menuitem action="action_stock_reservation"
|
||||
id="menu_action_stock_reservation"
|
||||
parent="stock.menu_stock_products_moves"
|
||||
sequence="10"
|
||||
groups="stock.group_locations"/>
|
||||
parent="stock.menu_stock_inventory_control"
|
||||
sequence="30"/>
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
Reference in New Issue
Block a user