Skip to content

Commit

Permalink
[IMP] stock_removal_by_location_priority: refactor?
Browse files Browse the repository at this point in the history
  • Loading branch information
vib-adhoc authored and nicomacr committed Sep 12, 2023
1 parent 39341f1 commit 139e0b0
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 46 deletions.
2 changes: 1 addition & 1 deletion stock_removal_by_location_priority/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
'stock',
],
'data': [
'views/product_category_views.xml',
'data/stock_data.xml',
'views/stock_location_views.xml',
],
'demo': [
Expand Down
9 changes: 9 additions & 0 deletions stock_removal_by_location_priority/data/stock_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="removal_by_location_priority" model="product.removal">
<field name="name">By Location Priority</field>
<field name="method">priority</field>
</record>
</data>
</odoo>
1 change: 0 additions & 1 deletion stock_removal_by_location_priority/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
from . import stock_quant
from . import product_category
from . import stock_location
12 changes: 0 additions & 12 deletions stock_removal_by_location_priority/models/product_category.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
class StockLocation(models.Model):
_inherit = 'stock.location'

removal_strategy_method = fields.Char(related='removal_strategy_id.method')
removal_priority = fields.Integer(
default=10,
help='Priority used on stock removal if "Force removal by location "'
Expand Down
20 changes: 3 additions & 17 deletions stock_removal_by_location_priority/models/stock_quant.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,8 @@ class StockQuant(models.Model):
store=True,
)

@api.model
def _get_removal_strategy(self, product_id, location_id):
res = super()._get_removal_strategy(product_id, location_id)
if product_id.categ_id.removal_by_location_priority:
res = 'location_priority,%s' % res
return res

@api.model
def _get_removal_strategy_order(self, removal_strategy=None):
location_priority = False
if 'location_priority,' in removal_strategy:
removal_strategy = removal_strategy.replace(
'location_priority,', '')
location_priority = True
res = super()._get_removal_strategy_order(
removal_strategy=removal_strategy)
if location_priority:
res = 'removal_priority ASC, %s' % res
return res
if removal_strategy == 'priority':
return 'removal_priority ASC, id'
return super()._get_removal_strategy_order(removal_strategy)

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
<field name="inherit_id" ref="stock.view_location_form"/>
<field name="arch" type="xml">
<field name="removal_strategy_id" position="after">
<field name="removal_priority"/>
<field name="removal_strategy_method" invisible="1"/>
<field name="removal_priority" attrs="{'invisible': [('removal_strategy_method', '!=', 'priority')]}"/>
</field>
</field>
</record>
Expand Down

0 comments on commit 139e0b0

Please sign in to comment.