stock_usability: add/improve unreserve buttons
This commit is contained in:
@@ -91,21 +91,42 @@ 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()
|
||||
def button_do_unreserve(self):
|
||||
for move in self:
|
||||
move._do_unreserve()
|
||||
picking = move.picking_id
|
||||
if picking:
|
||||
product = move.product_id
|
||||
picking.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, product.uom_id.name))
|
||||
# Copied from do_unreserved of stock.picking
|
||||
picking.package_level_ids.filtered(lambda p: not p.move_ids).unlink()
|
||||
|
||||
|
||||
class StockMoveLine(models.Model):
|
||||
_inherit = 'stock.move.line'
|
||||
|
||||
def button_do_unreserve(self):
|
||||
for moveline in self:
|
||||
if moveline.state == 'cancel':
|
||||
continue
|
||||
elif moveline.state == 'done':
|
||||
raise UserError(_(
|
||||
"You cannot unreserve a move line in done state."))
|
||||
picking = moveline.move_id.picking_id
|
||||
if picking:
|
||||
product = moveline.product_id
|
||||
picking.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,
|
||||
moveline.product_qty, product.uom_id.name))
|
||||
# Copied from do_unreserved of stock.picking
|
||||
picking.package_level_ids.filtered(lambda p: not p.move_ids).unlink()
|
||||
moveline.unlink()
|
||||
|
||||
|
||||
class ProcurementGroup(models.Model):
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
<button name="action_cancel" type="object" position="attributes">
|
||||
<attribute name="confirm">Are you sure you want to cancel this picking?</attribute>
|
||||
</button>
|
||||
<!-- STOCK MOVE -->
|
||||
<!-- This sum is useful to check the 'number of items' to transfer... -->
|
||||
<xpath expr="//field[@name='move_ids_without_package']/tree/field[@name='product_uom_qty']" position="attributes">
|
||||
<attribute name="sum">1</attribute>
|
||||
@@ -33,6 +34,13 @@
|
||||
<field name="location_id" groups="stock.group_stock_multi_locations"/>
|
||||
<field name="location_dest_id" groups="stock.group_stock_multi_locations"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='move_ids_without_package']/tree/button[@name='action_show_details']" position="after">
|
||||
<button type="object" name="button_do_unreserve" string="Unreserve"
|
||||
groups="stock.group_stock_user"
|
||||
states="partially_available,assigned"
|
||||
icon="fa-ban"/>
|
||||
</xpath>
|
||||
<!-- STOCK MOVE LINE -->
|
||||
<xpath expr="//field[@name='move_line_ids_without_package']/tree/field[@name='location_id']" position="attributes">
|
||||
<attribute name="attrs">{}</attribute>
|
||||
</xpath>
|
||||
@@ -174,12 +182,12 @@
|
||||
<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"
|
||||
attrs="{'invisible': [('reserved_quant_ids', '=', [])]}"/>
|
||||
states="partially_available,assigned"/>
|
||||
</field>
|
||||
<!--
|
||||
<field name="group_id" position="replace"/>
|
||||
<group name="moved_quants_grp" position="after">
|
||||
<notebook colspan="2">
|
||||
@@ -208,6 +216,7 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!--
|
||||
<record id="view_move_picking_tree" model="ir.ui.view">
|
||||
<field name="name">stock_usability.src_location.in.picking.form</field>
|
||||
<field name="model">stock.move</field>
|
||||
@@ -219,16 +228,16 @@
|
||||
<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"
|
||||
attrs="{'invisible': [('reserved_quant_ids', '=', [])]}"
|
||||
states="partially_available,assigned"
|
||||
icon="fa-ban"/>
|
||||
<field name="reserved_quant_ids" invisible="1"/>
|
||||
</field> -->
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
-->
|
||||
|
||||
|
||||
<!-- By default, stock.move have:
|
||||
_order = 'picking_id, sequence, id'
|
||||
@@ -244,6 +253,12 @@
|
||||
<tree position="attributes">
|
||||
<attribute name="default_order">date desc, picking_id, sequence</attribute>
|
||||
</tree>
|
||||
<field name="state" position="after">
|
||||
<button type="object" name="button_do_unreserve" string="Unreserve"
|
||||
groups="stock.group_stock_user"
|
||||
states="partially_available,assigned"
|
||||
icon="fa-ban"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -258,6 +273,12 @@
|
||||
<field name="qty_done" position="attributes">
|
||||
<attribute name="sum">1</attribute>
|
||||
</field>
|
||||
<field name="state" position="after">
|
||||
<button type="object" name="button_do_unreserve" string="Unreserve"
|
||||
groups="stock.group_stock_user"
|
||||
states="partially_available,assigned"
|
||||
icon="fa-ban"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user