Compare commits

..

1 Commits
19.0 ... main

4 changed files with 19 additions and 10 deletions

View File

@ -35,6 +35,10 @@ This module allows for the retrospective adjustment of product costs and Cost of
* **Accounting Date**: **End Date** of the Readjustment Period. * **Accounting Date**: **End Date** of the Readjustment Period.
* **Reference**: Includes POS Order and POS Session Name for easy reconciliation. * **Reference**: Includes POS Order and POS Session Name for easy reconciliation.
### 4. Scrap / Inventory Loss Adjustment
* **Trigger**: Moves to a location with Usage "Inventory Loss" (e.g., Scrap/Spoil) where the move is flagged as a Scrap operation or the location is a designated Scrap Location.
* **Account Selection**: Prioritizes the **Location's Incoming Stock Valuation Account** as the counterpart (Expense/Loss account) if configured. This overrides the default Product Category Stock Output account, ensuring precise allocation of losses to specific accounts (e.g., "Waste & Damage Inventory").
## Usage ## Usage
1. Go to **Inventory > Operations > Stock Readjustment**. 1. Go to **Inventory > Operations > Stock Readjustment**.

View File

@ -1,6 +1,6 @@
{ {
'name': 'Stock Readjust Valuation', 'name': 'Stock Readjust Valuation',
'version': '19.0.1.0.0', 'version': '17.0.1.0.0',
'category': 'Inventory/Inventory', 'category': 'Inventory/Inventory',
'summary': 'Retrospective Stock Valuation Adjustment', 'summary': 'Retrospective Stock Valuation Adjustment',
'description': """ 'description': """

View File

@ -42,7 +42,7 @@ class StockReadjustValuation(models.Model):
'name': _('Journal Entries'), 'name': _('Journal Entries'),
'type': 'ir.actions.act_window', 'type': 'ir.actions.act_window',
'res_model': 'account.move', 'res_model': 'account.move',
'view_mode': 'list,form', 'view_mode': 'tree,form',
'domain': [('id', 'in', self.account_move_ids.ids)], 'domain': [('id', 'in', self.account_move_ids.ids)],
'context': {'create': False}, 'context': {'create': False},
} }
@ -437,11 +437,11 @@ class StockReadjustValuation(models.Model):
date_map[t['date_svl']].append(svl.id) date_map[t['date_svl']].append(svl.id)
for d, ids in date_map.items(): for d, ids in date_map.items():
self.env.cr.execute("UPDATE stock_valuation_layer SET create_date = %s WHERE id IN %s", (d, tuple(ids))) self._cr.execute("UPDATE stock_valuation_layer SET create_date = %s WHERE id IN %s", (d, tuple(ids)))
# 4a. Force Dates Moves (Per Chunk) # 4a. Force Dates Moves (Per Chunk)
if chunk_moves: if chunk_moves:
self.env.cr.execute("UPDATE account_move SET date = %s WHERE id IN %s", (self.date_end.date(), tuple(chunk_moves.ids))) self._cr.execute("UPDATE account_move SET date = %s WHERE id IN %s", (self.date_end.date(), tuple(chunk_moves.ids)))
# Link Created Moves to this record (Important for Resume Logic) # Link Created Moves to this record (Important for Resume Logic)
self.write({'account_move_ids': [(4, m.id) for m in chunk_moves]}) self.write({'account_move_ids': [(4, m.id) for m in chunk_moves]})
@ -600,6 +600,11 @@ class StockReadjustValuation(models.Model):
debit_acc = val debit_acc = val
credit_acc = stock credit_acc = stock
else: else:
# Check for Scrap / Inventory Loss
if move.location_dest_id.usage == 'inventory' and (move.scrapped or move.location_dest_id.scrap_location):
if move.location_dest_id.valuation_in_account_id:
stock = move.location_dest_id.valuation_in_account_id.id
debit_acc = stock debit_acc = stock
credit_acc = val credit_acc = val

View File

@ -37,7 +37,7 @@
<notebook> <notebook>
<page string="Products"> <page string="Products">
<field name="line_ids" readonly="state == 'done'"> <field name="line_ids" readonly="state == 'done'">
<list editable="bottom" create="1" delete="1"> <tree editable="bottom" create="1" delete="1">
<field name="product_id" readonly="parent.state != 'draft'"/> <field name="product_id" readonly="parent.state != 'draft'"/>
<field name="initial_qty"/> <field name="initial_qty"/>
@ -50,7 +50,7 @@
<field name="purchase_value" optional="show"/> <field name="purchase_value" optional="show"/>
<field name="new_average_cost" decoration-bf="1"/> <field name="new_average_cost" decoration-bf="1"/>
</list> </tree>
</field> </field>
</page> </page>
</notebook> </notebook>
@ -64,18 +64,18 @@
</field> </field>
</record> </record>
<!-- List View --> <!-- Tree View -->
<record id="view_stock_readjust_valuation_tree" model="ir.ui.view"> <record id="view_stock_readjust_valuation_tree" model="ir.ui.view">
<field name="name">stock.readjust.valuation.tree</field> <field name="name">stock.readjust.valuation.tree</field>
<field name="model">stock.readjust.valuation</field> <field name="model">stock.readjust.valuation</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<list> <tree>
<field name="name"/> <field name="name"/>
<field name="date_start"/> <field name="date_start"/>
<field name="date_end"/> <field name="date_end"/>
<field name="journal_id"/> <field name="journal_id"/>
<field name="state" widget="badge" decoration-info="state == 'draft'" decoration-success="state == 'done'"/> <field name="state" widget="badge" decoration-info="state == 'draft'" decoration-success="state == 'done'"/>
</list> </tree>
</field> </field>
</record> </record>
@ -83,7 +83,7 @@
<record id="action_stock_readjust_valuation" model="ir.actions.act_window"> <record id="action_stock_readjust_valuation" model="ir.actions.act_window">
<field name="name">Stock Readjustment</field> <field name="name">Stock Readjustment</field>
<field name="res_model">stock.readjust.valuation</field> <field name="res_model">stock.readjust.valuation</field>
<field name="view_mode">list,form</field> <field name="view_mode">tree,form</field>
</record> </record>
<!-- Menu --> <!-- Menu -->