[IMP] stock_inventory_cost_info: black, isort

This commit is contained in:
Sergio Teruel
2020-02-07 23:33:07 +01:00
committed by sergio-teruel
parent 6edf0d9455
commit 37a48090b3
4 changed files with 52 additions and 45 deletions

View File

@@ -5,19 +5,13 @@
"name": "Stock Inventory Cost Info",
"summary": "Shows the cost of the inventory adjustments",
"version": "12.0.1.0.0",
"author": "Tecnativa, "
"Odoo Community Association (OCA)",
"author": "Tecnativa, " "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/stock-logistics-warehouse",
"category": "Warehouse",
"depends": [
"stock",
],
"data": [
"views/stock_inventory_views.xml",
"views/report_stockinventory.xml",
],
"depends": ["stock"],
"data": ["views/stock_inventory_views.xml", "views/report_stockinventory.xml"],
"pre_init_hook": "pre_init_hook",
"license": "AGPL-3",
'installable': True,
'application': False,
"installable": True,
"application": False,
}

View File

@@ -3,9 +3,13 @@
def pre_init_hook(cr):
cr.execute("""ALTER TABLE stock_inventory_line
cr.execute(
"""ALTER TABLE stock_inventory_line
ADD COLUMN adjustment_cost numeric
DEFAULT 0""")
DEFAULT 0"""
)
cr.execute("""ALTER TABLE stock_inventory_line
ALTER COLUMN adjustment_cost DROP DEFAULT;""")
cr.execute(
"""ALTER TABLE stock_inventory_line
ALTER COLUMN adjustment_cost DROP DEFAULT;"""
)

View File

@@ -8,14 +8,10 @@ class InventoryLine(models.Model):
_inherit = "stock.inventory.line"
currency_id = fields.Many2one(
string="Currency",
related="inventory_id.company_id.currency_id",
readonly=True,
string="Currency", related="inventory_id.company_id.currency_id", readonly=True
)
adjustment_cost = fields.Monetary(
string="Adjustment cost",
compute="_compute_adjustment_cost",
store=True,
string="Adjustment cost", compute="_compute_adjustment_cost", store=True
)
@api.depends("product_qty", "theoretical_qty", "inventory_id.state")

View File

@@ -8,30 +8,43 @@ from odoo.tests.common import TransactionCase
class TestStockInventoryCostInfo(TransactionCase):
def setUp(self):
super(TestStockInventoryCostInfo, self).setUp()
product_obj = self.env['product.product']
self.product_1 = product_obj.create({
'name': 'product test 1',
'type': 'product',
'standard_price': 1000,
})
self.product_2 = product_obj.create({
'name': 'product test 2',
'type': 'product',
'standard_price': 2000,
})
self.inventory = self.env['stock.inventory'].create({
'name': 'Another inventory',
'filter': 'partial',
'line_ids': [(0, 0, {
'product_id': self.product_1.id,
'product_qty': 10,
'location_id': self.env.ref('stock.warehouse0').lot_stock_id.id
}), (0, 0, {
'product_id': self.product_2.id,
'product_qty': 20,
'location_id': self.env.ref('stock.warehouse0').lot_stock_id.id
})]
})
product_obj = self.env["product.product"]
self.product_1 = product_obj.create(
{"name": "product test 1", "type": "product", "standard_price": 1000}
)
self.product_2 = product_obj.create(
{"name": "product test 2", "type": "product", "standard_price": 2000}
)
self.inventory = self.env["stock.inventory"].create(
{
"name": "Another inventory",
"filter": "partial",
"line_ids": [
(
0,
0,
{
"product_id": self.product_1.id,
"product_qty": 10,
"location_id": self.env.ref(
"stock.warehouse0"
).lot_stock_id.id,
},
),
(
0,
0,
{
"product_id": self.product_2.id,
"product_qty": 20,
"location_id": self.env.ref(
"stock.warehouse0"
).lot_stock_id.id,
},
),
],
}
)
def test_compute_adjustment_cost(self):
"""Tests if the adjustment_cost is correctly computed."""