mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[IMP] stock_request_submit: black, isort
This commit is contained in:
committed by
Patrick Wilson
parent
c63c40110b
commit
1f54d6088e
@@ -5,17 +5,13 @@
|
||||
{
|
||||
"name": "Stock Request Submit",
|
||||
"summary": "Add submit state on Stock Requests",
|
||||
"version": "12.0.1.0.2",
|
||||
"version": "13.0.1.0.0",
|
||||
"license": "LGPL-3",
|
||||
"website": "https://github.com/stock-logistics-warehouse",
|
||||
"author": "Open Source Integrators, "
|
||||
"Odoo Community Association (OCA)",
|
||||
"author": "Open Source Integrators, " "Odoo Community Association (OCA)",
|
||||
"category": "Warehouse Management",
|
||||
'depends': ['stock_request'],
|
||||
'data': [
|
||||
'views/stock_request_order_views.xml',
|
||||
'views/stock_request_views.xml',
|
||||
],
|
||||
"depends": ["stock_request"],
|
||||
"data": ["views/stock_request_order_views.xml", "views/stock_request_views.xml"],
|
||||
"installable": True,
|
||||
'uninstall_hook': 'uninstall_hook',
|
||||
"uninstall_hook": "uninstall_hook",
|
||||
}
|
||||
|
||||
@@ -5,18 +5,19 @@ from odoo import api, fields, models
|
||||
|
||||
|
||||
class StockRequest(models.Model):
|
||||
_inherit = 'stock.request'
|
||||
_inherit = "stock.request"
|
||||
|
||||
def __get_request_states(self):
|
||||
states = super().__get_request_states()
|
||||
if not ('submitted', 'Submitted') in states:
|
||||
if not ("submitted", "Submitted") in states:
|
||||
states.insert(
|
||||
states.index(('draft', 'Draft')) + 1,
|
||||
('submitted', 'Submitted'))
|
||||
states.index(("draft", "Draft")) + 1, ("submitted", "Submitted")
|
||||
)
|
||||
return states
|
||||
|
||||
route_id = fields.Many2one(states={'draft': [('readonly', False)],
|
||||
'submitted': [('readonly', False)]})
|
||||
route_id = fields.Many2one(
|
||||
states={"draft": [("readonly", False)], "submitted": [("readonly", False)]}
|
||||
)
|
||||
|
||||
@api.multi
|
||||
def action_submit(self):
|
||||
@@ -24,9 +25,11 @@ class StockRequest(models.Model):
|
||||
|
||||
@api.multi
|
||||
def _action_submit(self):
|
||||
self.state = 'submitted'
|
||||
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')
|
||||
return (
|
||||
super(StockRequest, self)._skip_procurement()
|
||||
and self.state != "submitted"
|
||||
or self.product_id.type not in ("consu", "product")
|
||||
)
|
||||
|
||||
@@ -5,11 +5,11 @@ from odoo import api, models
|
||||
|
||||
|
||||
class StockRequestOrder(models.Model):
|
||||
_inherit = 'stock.request.order'
|
||||
_inherit = "stock.request.order"
|
||||
|
||||
@api.multi
|
||||
def action_submit(self):
|
||||
for line in self.stock_request_ids:
|
||||
line.action_submit()
|
||||
self.state = 'submitted'
|
||||
self.state = "submitted"
|
||||
return True
|
||||
|
||||
@@ -4,4 +4,3 @@
|
||||
* Steve Campbell <scampbell@opensourceintegrators.com>
|
||||
|
||||
* Héctor Villarreal Ortega <hector.villarreal@eficent.com>
|
||||
|
||||
|
||||
@@ -1,41 +1,46 @@
|
||||
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
|
||||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0).
|
||||
from odoo import fields
|
||||
|
||||
from odoo.addons.stock_request.tests import test_stock_request
|
||||
|
||||
|
||||
class TestStockRequestSubmit(test_stock_request.TestStockRequest):
|
||||
|
||||
def setUp(self):
|
||||
super(TestStockRequestSubmit, self).setUp()
|
||||
|
||||
def test_stock_request_submit(self):
|
||||
expected_date = fields.Datetime.now()
|
||||
vals = {
|
||||
'company_id': self.main_company.id,
|
||||
'warehouse_id': self.warehouse.id,
|
||||
'location_id': self.warehouse.lot_stock_id.id,
|
||||
'expected_date': expected_date,
|
||||
'stock_request_ids': [(0, 0, {
|
||||
'product_id': self.product.id,
|
||||
'product_uom_id': self.product.uom_id.id,
|
||||
'product_uom_qty': 5.0,
|
||||
'company_id': self.main_company.id,
|
||||
'warehouse_id': self.warehouse.id,
|
||||
'location_id': self.warehouse.lot_stock_id.id,
|
||||
'expected_date': expected_date,
|
||||
})]
|
||||
"company_id": self.main_company.id,
|
||||
"warehouse_id": self.warehouse.id,
|
||||
"location_id": self.warehouse.lot_stock_id.id,
|
||||
"expected_date": expected_date,
|
||||
"stock_request_ids": [
|
||||
(
|
||||
0,
|
||||
0,
|
||||
{
|
||||
"product_id": self.product.id,
|
||||
"product_uom_id": self.product.uom_id.id,
|
||||
"product_uom_qty": 5.0,
|
||||
"company_id": self.main_company.id,
|
||||
"warehouse_id": self.warehouse.id,
|
||||
"location_id": self.warehouse.lot_stock_id.id,
|
||||
"expected_date": expected_date,
|
||||
},
|
||||
)
|
||||
],
|
||||
}
|
||||
|
||||
order = self.request_order.sudo(
|
||||
self.stock_request_user).create(vals)
|
||||
order = self.request_order.sudo(self.stock_request_user).create(vals)
|
||||
|
||||
stock_request = order.stock_request_ids
|
||||
|
||||
self.product.route_ids = [(6, 0, self.route.ids)]
|
||||
order.action_submit()
|
||||
self.assertEqual(order.state, 'submitted')
|
||||
self.assertEqual(stock_request.state, 'submitted')
|
||||
self.assertEqual(order.state, "submitted")
|
||||
self.assertEqual(stock_request.state, "submitted")
|
||||
order.action_confirm()
|
||||
self.assertEqual(order.state, 'open')
|
||||
self.assertEqual(stock_request.state, 'open')
|
||||
self.assertEqual(order.state, "open")
|
||||
self.assertEqual(stock_request.state, "open")
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
# Copyright 2019 Eficent Business and IT Consulting Services, S.L.
|
||||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from odoo import api, SUPERUSER_ID
|
||||
from odoo import SUPERUSER_ID, api
|
||||
|
||||
|
||||
def uninstall_hook(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
sr = env['stock.request'].search([('state', '=', 'submitted')])
|
||||
sr.write({'state': 'draft'})
|
||||
sro = env['stock.request.order'].search([('state', '=', 'submitted')])
|
||||
sro.write({'state': 'draft'})
|
||||
sr = env["stock.request"].search([("state", "=", "submitted")])
|
||||
sr.write({"state": "draft"})
|
||||
sro = env["stock.request.order"].search([("state", "=", "submitted")])
|
||||
sro.write({"state": "draft"})
|
||||
|
||||
Reference in New Issue
Block a user