mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[ADD] stock_picking_procure_method: New module
This commit is contained in:
committed by
Cesar Andres Sanchez
parent
f13ff658c2
commit
4e2f8f3e07
1
stock_picking_procure_method/models/__init__.py
Normal file
1
stock_picking_procure_method/models/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import stock_picking
|
||||
43
stock_picking_procure_method/models/stock_picking.py
Normal file
43
stock_picking_procure_method/models/stock_picking.py
Normal file
@@ -0,0 +1,43 @@
|
||||
# Copyright 2018 Tecnativa - David Vidal
|
||||
# Copyright 2018 Tecnativa - Pedro M. Baeza
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class StockPicking(models.Model):
|
||||
_inherit = 'stock.picking'
|
||||
|
||||
procure_method = fields.Selection(
|
||||
selection='_selection_procure_method',
|
||||
compute='_compute_procure_method',
|
||||
inverse='_inverse_procure_method',
|
||||
string='Supply Method',
|
||||
help='By default, the system will take from the stock in the source '
|
||||
'location and passively wait for availability. The other '
|
||||
'possibility allows you to directly create a procurement on the '
|
||||
'source location (and thus ignore its current stock) to gather '
|
||||
'products. If we want to chain moves and have this one to wait '
|
||||
'for the previous, this second option should be chosen.',
|
||||
)
|
||||
|
||||
def _selection_procure_method(self):
|
||||
return self.env['stock.move'].fields_get(
|
||||
allfields=['procure_method'])['procure_method']['selection']
|
||||
|
||||
@api.depends('move_lines.procure_method')
|
||||
def _compute_procure_method(self):
|
||||
for picking in self:
|
||||
procure_method = False
|
||||
for move in picking.move_lines:
|
||||
if not procure_method:
|
||||
procure_method = move.procure_method
|
||||
elif procure_method != move.procure_method:
|
||||
procure_method = False
|
||||
break
|
||||
picking.procure_method = procure_method
|
||||
|
||||
def _inverse_procure_method(self):
|
||||
self.filtered('procure_method').mapped('move_lines').update({
|
||||
'procure_method': self.procure_method,
|
||||
})
|
||||
Reference in New Issue
Block a user