Add unreserve buttons on moves + log in chatter
This commit is contained in:
@@ -31,6 +31,13 @@ class StockPicking(models.Model):
|
||||
pick.message_post(_("Using <b>Force Availability</b>!"))
|
||||
return res
|
||||
|
||||
@api.multi
|
||||
def do_unreserve(self):
|
||||
res = super(StockPicking, self).do_unreserve()
|
||||
for pick in self:
|
||||
pick.message_post(_("Picking <b>unreserved</b>."))
|
||||
return res
|
||||
|
||||
|
||||
class StockLocation(models.Model):
|
||||
_inherit = 'stock.location'
|
||||
@@ -115,6 +122,22 @@ class StockMove(models.Model):
|
||||
res.append((line.id, name))
|
||||
return res
|
||||
|
||||
def button_do_unreserve(self):
|
||||
for move in self:
|
||||
move.do_unreserve()
|
||||
if move.picking_id:
|
||||
product = move.product_id
|
||||
self.picking_id.message_post(_(
|
||||
"Product <a href=# data-oe-model=product.product "
|
||||
"data-oe-id=%d>%s</a> qty %s %s <b>unreserved</b>")
|
||||
% (product.id, product.display_name,
|
||||
move.product_qty, move.product_id.uom_id.name))
|
||||
ops = self.env['stock.pack.operation']
|
||||
for smol in move.linked_move_operation_ids:
|
||||
if smol.operation_id:
|
||||
ops += smol.operation_id
|
||||
ops.unlink()
|
||||
|
||||
|
||||
class StockIncoterms(models.Model):
|
||||
_inherit = 'stock.incoterms'
|
||||
|
||||
@@ -114,14 +114,11 @@
|
||||
<field name="model">stock.move</field>
|
||||
<field name="inherit_id" ref="stock.view_move_form" />
|
||||
<field name="arch" type="xml">
|
||||
<!-- There are no button any more on that view...
|
||||
so probably not a good idea to add one
|
||||
<button name="force_assign" position="after">
|
||||
<button type="object" name="do_unreserve" string="Unreserve"
|
||||
<field name="state" position="before">
|
||||
<button type="object" name="button_do_unreserve" string="Unreserve"
|
||||
groups="stock.group_stock_user"
|
||||
states="confirmed,assigned"/>
|
||||
</button>
|
||||
-->
|
||||
</field>
|
||||
<field name="picking_id" position="after">
|
||||
<field name="inventory_id" readonly="1"/>
|
||||
</field>
|
||||
@@ -152,6 +149,11 @@
|
||||
<field name="model">stock.move</field>
|
||||
<field name="inherit_id" ref="stock.view_move_picking_form" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="state" position="before">
|
||||
<button type="object" name="button_do_unreserve" string="Unreserve"
|
||||
groups="stock.group_stock_user"
|
||||
states="confirmed,assigned"/>
|
||||
</field>
|
||||
<field name="group_id" position="replace"/> <!-- in stock, this field has invisible="1" re-add it below as visible -->
|
||||
<group name="moved_quants_grp" position="after">
|
||||
<notebook colspan="2">
|
||||
@@ -187,6 +189,12 @@
|
||||
<field name="location_dest_id" position="attributes">
|
||||
<attribute name="invisible">0</attribute>
|
||||
</field>
|
||||
<field name="state" position="after">
|
||||
<button type="object" name="button_do_unreserve" string="Unreserve"
|
||||
groups="stock.group_stock_user"
|
||||
states="confirmed,assigned"
|
||||
icon="fa-ban"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user