mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[12.0][ADD] stock_request_submit
This commit is contained in:
2
stock_request_submit/models/__init__.py
Normal file
2
stock_request_submit/models/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from . import stock_request
|
||||
from . import stock_request_order
|
||||
36
stock_request_submit/models/stock_request.py
Normal file
36
stock_request_submit/models/stock_request.py
Normal file
@@ -0,0 +1,36 @@
|
||||
# Copyright 2019 Open Source Integrators
|
||||
# Copyright 2019 Eficent Business and IT Consulting Services, S.L.
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
||||
from odoo import api, fields, models
|
||||
|
||||
REQUEST_STATES = [
|
||||
('draft', 'Draft'),
|
||||
('submitted', 'Submitted'),
|
||||
('open', 'In progress'),
|
||||
('done', 'Done'),
|
||||
('cancel', 'Cancelled')]
|
||||
|
||||
|
||||
class StockRequest(models.Model):
|
||||
_inherit = 'stock.request'
|
||||
|
||||
state = fields.Selection(selection=REQUEST_STATES, string='Status',
|
||||
copy=False, default='draft', index=True,
|
||||
readonly=True, track_visibility='onchange',
|
||||
)
|
||||
route_id = fields.Many2one(states={'draft': [('readonly', False)],
|
||||
'submitted': [('readonly', False)]},
|
||||
readonly=True)
|
||||
|
||||
@api.multi
|
||||
def action_submit(self):
|
||||
self._action_submit()
|
||||
|
||||
@api.multi
|
||||
def _action_submit(self):
|
||||
self.state = 'submitted'
|
||||
|
||||
def _skip_procurement(self):
|
||||
return super(StockRequest, self)._skip_procurement() and \
|
||||
self.state != 'submitted' or \
|
||||
self.product_id.type not in ('consu', 'product')
|
||||
27
stock_request_submit/models/stock_request_order.py
Normal file
27
stock_request_submit/models/stock_request_order.py
Normal file
@@ -0,0 +1,27 @@
|
||||
# Copyright 2019 Open Source Integrators
|
||||
# Copyright 2019 Eficent Business and IT Consulting Services, S.L.
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
||||
from odoo import api, fields, models
|
||||
|
||||
REQUEST_STATES = [
|
||||
('draft', 'Draft'),
|
||||
('submitted', 'Submitted'),
|
||||
('open', 'In progress'),
|
||||
('done', 'Done'),
|
||||
('cancel', 'Cancelled')]
|
||||
|
||||
|
||||
class StockRequestOrder(models.Model):
|
||||
_inherit = 'stock.request.order'
|
||||
|
||||
state = fields.Selection(selection=REQUEST_STATES, string='Status',
|
||||
copy=False, default='draft', index=True,
|
||||
readonly=True, track_visibility='onchange',
|
||||
)
|
||||
|
||||
@api.multi
|
||||
def action_submit(self):
|
||||
for line in self.stock_request_ids:
|
||||
line.action_submit()
|
||||
self.state = 'submitted'
|
||||
return True
|
||||
Reference in New Issue
Block a user