Skip to content

Commit

Permalink
[MIG] stock_account_valuation_report: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
RicardCForgeFlow committed Oct 10, 2023
1 parent 112b192 commit f1634bc
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion stock_account_valuation_report/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{
"name": "Stock Account Valuation Report",
"version": "15.0.1.0.1",
"version": "16.0.1.0.0",
"summary": "Improves logic of the Inventory Valuation Report",
"author": "ForgeFlow S.L., Odoo Community Association (OCA)",
"website": "https://github.com/OCA/stock-logistics-reporting",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,30 @@ def setUp(self):
self.stock_location_customer_id = self.ref("stock.stock_location_customers")
self.stock_location_supplier_id = self.ref("stock.stock_location_suppliers")
# Account types
expense_type = self.env.ref("account.data_account_type_expenses")
equity_type = self.env.ref("account.data_account_type_equity")
asset_type = self.env.ref("account.data_account_type_fixed_assets")
expense_type = 'expense'
equity_type = 'equity'
asset_type = 'asset_current'
# Create account for Goods Received Not Invoiced
name = "Goods Received Not Invoiced"
code = "grni"
acc_type = equity_type
self.account_grni = self._create_account(acc_type, name, code, self.company)
account_type = equity_type
self.account_grni = self._create_account(account_type, name, code, self.company)
# Create account for Cost of Goods Sold
name = "Cost of Goods Sold"
code = "cogs"
acc_type = expense_type
self.account_cogs = self._create_account(acc_type, name, code, self.company)
account_type= expense_type
self.account_cogs = self._create_account(account_type, name, code, self.company)
# Create account for Goods Delivered Not Invoiced
name = "Goods Delivered Not Invoiced"
code = "gdni"
acc_type = expense_type
self.account_gdni = self._create_account(acc_type, name, code, self.company)
account_type = expense_type
self.account_gdni = self._create_account(account_type, name, code, self.company)
# Create account for Inventory
name = "Inventory"
code = "inventory"
acc_type = asset_type
account_type = asset_type
self.account_inventory = self._create_account(
acc_type, name, code, self.company
account_type, name, code, self.company
)

self.stock_journal = self.env["account.journal"].create(
Expand Down Expand Up @@ -93,13 +93,13 @@ def _create_user(self, login, groups, company):
)
return user

def _create_account(self, acc_type, name, code, company):
def _create_account(self, account_type, name, code, company):
"""Create an account."""
account = self.account_model.create(
{
"name": name,
"code": code,
"user_type_id": acc_type.id,
"account_type": account_type,
"company_id": company.id,
}
)
Expand Down Expand Up @@ -146,7 +146,7 @@ def _create_delivery(self, product, qty, price_unit=10.0):
"picking_type_id": self.stock_picking_type_out.id,
"location_id": self.stock_location_id,
"location_dest_id": self.stock_location_customer_id,
"move_lines": [
"move_ids": [
(
0,
0,
Expand All @@ -173,7 +173,7 @@ def _create_drophip_picking(self, product, qty, price_unit=10.0):
"picking_type_id": self.stock_picking_type_out.id,
"location_id": self.stock_location_supplier_id,
"location_dest_id": self.stock_location_customer_id,
"move_lines": [
"move_ids": [
(
0,
0,
Expand All @@ -200,7 +200,7 @@ def _create_receipt(self, product, qty, move_dest_id=False, price_unit=10.0):
"picking_type_id": self.stock_picking_type_in.id,
"location_id": self.stock_location_supplier_id,
"location_dest_id": self.stock_location_id,
"move_lines": [
"move_ids": [
(
0,
0,
Expand All @@ -223,15 +223,15 @@ def _create_receipt(self, product, qty, move_dest_id=False, price_unit=10.0):
def _do_picking(self, picking, date, qty):
"""Do picking with only one move on the given date."""
picking.write({"date": date})
picking.move_lines.write({"date": date})
picking.move_ids.write({"date": date})
picking.action_confirm()
picking.action_assign()
picking.move_lines.quantity_done = qty
picking.move_ids.quantity_done = qty
picking.button_validate()
# hacking the create_date of the layer in order to test
self.env.cr.execute(
"""UPDATE stock_valuation_layer SET create_date = %s WHERE id in %s""",
(date, tuple(picking.move_lines.stock_valuation_layer_ids.ids)),
(date, tuple(picking.move_ids.stock_valuation_layer_ids.ids)),
)
return True

Expand All @@ -251,7 +251,7 @@ def test_01_stock_receipt(self):
inv_aml = aml.filtered(lambda l: l.account_id == self.account_inventory)
balance_inv = sum(inv_aml.mapped("balance"))
self.assertEqual(balance_inv, 10.0)
move = in_picking.move_lines
move = in_picking.move_ids
layer = self.layer_model.search([("stock_move_id", "=", move.id)])
self.assertEqual(layer.remaining_value, 10.0)
# The accounting value and the stock value match
Expand All @@ -267,7 +267,7 @@ def test_01_stock_receipt(self):
self.assertEqual(layer.remaining_qty, 0.0)
self.assertEqual(layer.remaining_value, 0.0)
# The layer out took that out
move = out_picking.move_lines
move = out_picking.move_ids
layer = self.layer_model.search([("stock_move_id", "=", move.id)])
self.assertEqual(layer.value, -10.0)
# The report shows the material is gone
Expand Down Expand Up @@ -296,7 +296,7 @@ def test_02_drop_ship(self):
balance_inv = sum(inv_aml.mapped("balance"))
self.assertEqual(balance_inv, 0.0)
# There are two a stock valuation layers associated to this product
move = dropship_picking.move_lines
move = dropship_picking.move_ids
layers = self.layer_model.search([("stock_move_id", "=", move.id)])
self.assertEqual(len(layers), 2)
in_layer = layers.filtered(lambda l: l.quantity > 0)
Expand Down Expand Up @@ -325,7 +325,7 @@ def test_03_stock_receipt_several_costs_several_dates(self):
inv_aml = aml.filtered(lambda l: l.account_id == self.account_inventory)
balance_inv = sum(inv_aml.mapped("balance"))
self.assertEqual(balance_inv, 10.0)
move = in_picking.move_lines
move = in_picking.move_ids
layer = self.layer_model.search([("stock_move_id", "=", move.id)])
self.assertEqual(layer.remaining_value, 10.0)
# Receive more
Expand All @@ -344,7 +344,7 @@ def test_03_stock_receipt_several_costs_several_dates(self):
inv_aml = aml.filtered(lambda l: l.account_id == self.account_inventory)
balance_inv = sum(inv_aml.mapped("balance"))
self.assertEqual(balance_inv, 50.0)
move2 = in_picking2.move_lines
move2 = in_picking2.move_ids
layer = self.layer_model.search([("stock_move_id", "=", move2.id)])
self.assertEqual(layer.remaining_value, 40.0)
# Now we check the report reflects the same
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
name="action_view_valuation_layers"
type="object"
icon="fa-info-circle"
title="View Valuation Layers"
attrs="{'invisible': [('valuation', '!=', 'real_time')]}"
/>
<field
Expand All @@ -38,6 +39,7 @@
name="action_view_amls"
type="object"
icon="fa-info-circle"
title="View AMLS"
attrs="{'invisible': [('valuation', '!=', 'real_time')]}"
/>
<field name="qty_discrepancy" sum="Qty Discrepancy" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@
<group>
<field name="inventory_datetime" />
</group>
<footer>
<button
name="open_at_date"
string="Confirm"
type="object"
class="btn-primary"
/>
<button string="Cancel" class="btn-secondary" special="cancel" />
</footer>
<button
name="open_at_date"
string="Confirm"
type="object"
class="btn-primary"
/>
<button string="Cancel" class="btn-secondary" special="cancel" />
</form>
</field>
</record>
Expand Down

0 comments on commit f1634bc

Please sign in to comment.