Add direct access to re-ordering rules from stock location
This commit is contained in:
@@ -49,6 +49,20 @@ class StockLocationRoute(models.Model):
|
|||||||
class StockWarehouseOrderpoint(models.Model):
|
class StockWarehouseOrderpoint(models.Model):
|
||||||
_inherit = 'stock.warehouse.orderpoint'
|
_inherit = 'stock.warehouse.orderpoint'
|
||||||
|
|
||||||
|
# This is for the button shortcut "reordering rules" on
|
||||||
|
# stock.location form view, so that the location_id has the
|
||||||
|
# good value, not the default stock location of the first WH of the company
|
||||||
|
@api.model
|
||||||
|
def default_get(self, fields):
|
||||||
|
res = {}
|
||||||
|
if self._context.get('default_location_id'):
|
||||||
|
location = self.env['stock.location'].browse(
|
||||||
|
self._context['default_location_id'])
|
||||||
|
wh = location.get_warehouse()
|
||||||
|
if location and wh:
|
||||||
|
self = self.with_context(default_warehouse_id=wh.id)
|
||||||
|
return super(StockWarehouseOrderpoint, self).default_get(fields)
|
||||||
|
|
||||||
# This SQL constraint blocks the use of the "active" field
|
# This SQL constraint blocks the use of the "active" field
|
||||||
# but I think it's not very useful to have such an "active" field
|
# but I think it's not very useful to have such an "active" field
|
||||||
# on orderpoints ; when you think the order point is bad, you update
|
# on orderpoints ; when you think the order point is bad, you update
|
||||||
|
|||||||
@@ -205,6 +205,25 @@
|
|||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record id="location_open_orderpoint" model="ir.actions.act_window">
|
||||||
|
<field name="name">Reordering Rules</field>
|
||||||
|
<field name="res_model">stock.warehouse.orderpoint</field>
|
||||||
|
<field name="context">{'default_location_id': active_id, 'search_default_location_id': active_id}</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="view_location_form" model="ir.ui.view">
|
||||||
|
<field name="name">stock.usability.stock.location.form</field>
|
||||||
|
<field name="model">stock.location</field>
|
||||||
|
<field name="inherit_id" ref="stock.view_location_form"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<button class="oe_stat_button" icon="fa-filter" position="after">
|
||||||
|
<button type="action" name="%(location_open_orderpoint)d"
|
||||||
|
string="Reordering Rules"
|
||||||
|
class="oe_stat_button" icon="fa-refresh"/>
|
||||||
|
</button>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
<record id="view_stock_quant_tree" model="ir.ui.view">
|
<record id="view_stock_quant_tree" model="ir.ui.view">
|
||||||
<field name="name">stock.usability.quant.tree</field>
|
<field name="name">stock.usability.quant.tree</field>
|
||||||
<field name="model">stock.quant</field>
|
<field name="model">stock.quant</field>
|
||||||
|
|||||||
Reference in New Issue
Block a user