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