Skip to content

Commit

Permalink
stock_storage_type: add location smart buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
jbaudoux committed Aug 23, 2021
1 parent 459fe3d commit 8518d72
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
5 changes: 5 additions & 0 deletions stock_storage_type/models/stock_location_storage_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,8 @@ def _domain_location_storage_type(self, candidate_locations, quants, products):
("location_will_contain_lot_ids", "=", False),
]
return location_domain

def button_show_locations(self):
action = self.env.ref("stock.action_location_form").read()[0]
action["domain"] = [("allowed_location_storage_type_ids", "in", self.ids)]
return action
12 changes: 12 additions & 0 deletions stock_storage_type/models/stock_storage_location_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,15 @@ def _format_package_storage_type_message(self, last=False):
% self.location_id.name
)
return msg

def button_show_locations(self):
action = self.env.ref("stock.action_location_form").read()[0]
action["domain"] = [
("parent_path", "=ilike", "{}%".format(self.location_id.parent_path)),
(
"allowed_location_storage_type_ids",
"in",
self.package_storage_type_id.location_storage_type_ids.ids,
),
]
return action
9 changes: 9 additions & 0 deletions stock_storage_type/views/stock_location_storage_type.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@
<field name="arch" type="xml">
<form>
<sheet>
<div class="oe_button_box" name="button_box">
<button
string="Locations"
class="oe_stat_button"
icon="fa-th-list"
name="button_show_locations"
type="object"
/>
</div>
<div class="oe_title">
<label for="name" class="oe_edit_only" />
<h1>
Expand Down
5 changes: 5 additions & 0 deletions stock_storage_type/views/stock_storage_location_sequence.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
/>
<field name="location_id" />
<field name="location_putaway_strategy" />
<button
string="Show locations"
name="button_show_locations"
type="object"
/>
</tree>
</field>
</record>
Expand Down

0 comments on commit 8518d72

Please sign in to comment.