forked from OCA/stock-logistics-warehouse
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move is_zone flag to stock.location picking_type M2o
Replace occurences of zone for routing operation
- Loading branch information
1 parent
63a5e32
commit 6a94a28
Showing
9 changed files
with
133 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from . import stock_location | ||
from . import stock_move | ||
from . import stock_picking_type | ||
from . import stock_quant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Copyright 2019 Camptocamp SA | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) | ||
from odoo import api, models, fields | ||
|
||
|
||
class StockLocation(models.Model): | ||
|
||
_inherit = 'stock.location' | ||
|
||
routing_operation_picking_type_id = fields.Many2one( | ||
'stock.picking.type', | ||
string='Routing operation', | ||
help="Change destination of the move line according to the" | ||
" default destination setup after reservation occurs", | ||
# TODO add domain ? | ||
) | ||
|
||
@api.multi | ||
def _find_picking_type_for_routing_operation(self): | ||
self.ensure_one() | ||
# First select all the parent locations and the matching | ||
# zones. In a second step, the zone matching the closest location | ||
# is searched in memory. This is to avoid doing an SQL query | ||
# for each location in the tree. | ||
tree = self.search( | ||
[('id', 'parent_of', self.id)], | ||
# the recordset will be ordered bottom location to top location | ||
order='parent_path desc' | ||
) | ||
picking_types = self.env['stock.picking.type'].search([ | ||
('routing_operation_location_ids', '!=', False), | ||
('default_location_src_id', 'in', tree.ids) | ||
]) | ||
# the first location is the current move line's source location, | ||
# then we climb up the tree of locations | ||
for location in tree: | ||
match = picking_types.filtered( | ||
lambda p: p.default_location_src_id == location | ||
) | ||
if match: | ||
# we can only have one match as we have a unique | ||
# constraint on is_zone + source location | ||
return match | ||
return self.env['stock.picking.type'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
* Joël Grand-Guillaume <[email protected]> | ||
* Guewen Baconnier <[email protected]> | ||
* Akim Juillerat <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<odoo> | ||
<record id="view_location_form_inherit" model="ir.ui.view"> | ||
<field name="name">stock.location.form.inherit</field> | ||
<field name="model">stock.location</field> | ||
<field name="inherit_id" ref="stock.view_location_form" /> | ||
<field name="arch" type="xml"> | ||
<field name="putaway_strategy_id" position="after"> | ||
<field name="routing_operation_picking_type_id" /> | ||
</field> | ||
</field> | ||
</record> | ||
</odoo> |