stock_usability: add/improve unreserve buttons
This commit is contained in:
@@ -91,21 +91,42 @@ class StockMove(models.Model):
|
|||||||
res.append((line.id, name))
|
res.append((line.id, name))
|
||||||
return res
|
return res
|
||||||
|
|
||||||
# def button_do_unreserve(self):
|
def button_do_unreserve(self):
|
||||||
# for move in self:
|
for move in self:
|
||||||
# move.do_unreserve()
|
move._do_unreserve()
|
||||||
# if move.picking_id:
|
picking = move.picking_id
|
||||||
# product = move.product_id
|
if picking:
|
||||||
# self.picking_id.message_post(_(
|
product = move.product_id
|
||||||
# "Product <a href=# data-oe-model=product.product "
|
picking.message_post(_(
|
||||||
# "data-oe-id=%d>%s</a> qty %s %s <b>unreserved</b>")
|
"Product <a href=# data-oe-model=product.product "
|
||||||
# % (product.id, product.display_name,
|
"data-oe-id=%d>%s</a> qty %s %s <b>unreserved</b>")
|
||||||
# move.product_qty, move.product_id.uom_id.name))
|
% (product.id, product.display_name,
|
||||||
# ops = self.env['stock.pack.operation']
|
move.product_qty, product.uom_id.name))
|
||||||
# for smol in move.linked_move_operation_ids:
|
# Copied from do_unreserved of stock.picking
|
||||||
# if smol.operation_id:
|
picking.package_level_ids.filtered(lambda p: not p.move_ids).unlink()
|
||||||
# ops += smol.operation_id
|
|
||||||
# ops.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):
|
class ProcurementGroup(models.Model):
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
<button name="action_cancel" type="object" position="attributes">
|
<button name="action_cancel" type="object" position="attributes">
|
||||||
<attribute name="confirm">Are you sure you want to cancel this picking?</attribute>
|
<attribute name="confirm">Are you sure you want to cancel this picking?</attribute>
|
||||||
</button>
|
</button>
|
||||||
|
<!-- STOCK MOVE -->
|
||||||
<!-- This sum is useful to check the 'number of items' to transfer... -->
|
<!-- 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">
|
<xpath expr="//field[@name='move_ids_without_package']/tree/field[@name='product_uom_qty']" position="attributes">
|
||||||
<attribute name="sum">1</attribute>
|
<attribute name="sum">1</attribute>
|
||||||
@@ -33,6 +34,13 @@
|
|||||||
<field name="location_id" groups="stock.group_stock_multi_locations"/>
|
<field name="location_id" groups="stock.group_stock_multi_locations"/>
|
||||||
<field name="location_dest_id" groups="stock.group_stock_multi_locations"/>
|
<field name="location_dest_id" groups="stock.group_stock_multi_locations"/>
|
||||||
</xpath>
|
</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">
|
<xpath expr="//field[@name='move_line_ids_without_package']/tree/field[@name='location_id']" position="attributes">
|
||||||
<attribute name="attrs">{}</attribute>
|
<attribute name="attrs">{}</attribute>
|
||||||
</xpath>
|
</xpath>
|
||||||
@@ -174,12 +182,12 @@
|
|||||||
<field name="model">stock.move</field>
|
<field name="model">stock.move</field>
|
||||||
<field name="inherit_id" ref="stock.view_move_picking_form" />
|
<field name="inherit_id" ref="stock.view_move_picking_form" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<!--
|
|
||||||
<field name="state" position="before">
|
<field name="state" position="before">
|
||||||
<button type="object" name="button_do_unreserve" string="Unreserve"
|
<button type="object" name="button_do_unreserve" string="Unreserve"
|
||||||
groups="stock.group_stock_user"
|
groups="stock.group_stock_user"
|
||||||
attrs="{'invisible': [('reserved_quant_ids', '=', [])]}"/>
|
states="partially_available,assigned"/>
|
||||||
</field>
|
</field>
|
||||||
|
<!--
|
||||||
<field name="group_id" position="replace"/>
|
<field name="group_id" position="replace"/>
|
||||||
<group name="moved_quants_grp" position="after">
|
<group name="moved_quants_grp" position="after">
|
||||||
<notebook colspan="2">
|
<notebook colspan="2">
|
||||||
@@ -208,6 +216,7 @@
|
|||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<!--
|
||||||
<record id="view_move_picking_tree" model="ir.ui.view">
|
<record id="view_move_picking_tree" model="ir.ui.view">
|
||||||
<field name="name">stock_usability.src_location.in.picking.form</field>
|
<field name="name">stock_usability.src_location.in.picking.form</field>
|
||||||
<field name="model">stock.move</field>
|
<field name="model">stock.move</field>
|
||||||
@@ -219,16 +228,16 @@
|
|||||||
<field name="location_dest_id" position="attributes">
|
<field name="location_dest_id" position="attributes">
|
||||||
<attribute name="invisible">0</attribute>
|
<attribute name="invisible">0</attribute>
|
||||||
</field>
|
</field>
|
||||||
<!--
|
|
||||||
<field name="state" position="after">
|
<field name="state" position="after">
|
||||||
<button type="object" name="button_do_unreserve" string="Unreserve"
|
<button type="object" name="button_do_unreserve" string="Unreserve"
|
||||||
groups="stock.group_stock_user"
|
groups="stock.group_stock_user"
|
||||||
attrs="{'invisible': [('reserved_quant_ids', '=', [])]}"
|
states="partially_available,assigned"
|
||||||
icon="fa-ban"/>
|
icon="fa-ban"/>
|
||||||
<field name="reserved_quant_ids" invisible="1"/>
|
</field>
|
||||||
</field> -->
|
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
-->
|
||||||
|
|
||||||
|
|
||||||
<!-- By default, stock.move have:
|
<!-- By default, stock.move have:
|
||||||
_order = 'picking_id, sequence, id'
|
_order = 'picking_id, sequence, id'
|
||||||
@@ -244,6 +253,12 @@
|
|||||||
<tree position="attributes">
|
<tree position="attributes">
|
||||||
<attribute name="default_order">date desc, picking_id, sequence</attribute>
|
<attribute name="default_order">date desc, picking_id, sequence</attribute>
|
||||||
</tree>
|
</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>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
@@ -258,6 +273,12 @@
|
|||||||
<field name="qty_done" position="attributes">
|
<field name="qty_done" position="attributes">
|
||||||
<attribute name="sum">1</attribute>
|
<attribute name="sum">1</attribute>
|
||||||
</field>
|
</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>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user