Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][3825][IMP] stock_picking_accounting_date, stock_valuation_layer_accounting… #86

Merged
merged 6 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions stock_picking_accounting_date/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"license": "AGPL-3",
"depends": ["stock_account"],
"data": [
"views/stock_move_views.xml",
"views/stock_picking_views.xml",
],
"installable": True,
Expand Down
18 changes: 15 additions & 3 deletions stock_picking_accounting_date/models/stock_move.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
# Copyright 2023 Quartile Limited
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import models
from odoo import api, fields, models


class StockMove(models.Model):
_inherit = "stock.move"

accounting_date = fields.Date(
compute="_compute_accounting_date",
store=True,
)

@api.depends("date", "accounting_date")
def _compute_accounting_date(self):
for line in self:
line.accounting_date = fields.Datetime.context_timestamp(self, line.date)
if line.picking_id.accounting_date:
line.accounting_date = line.picking_id.accounting_date

def _prepare_account_move_vals(
self,
credit_account_id,
Expand All @@ -26,6 +38,6 @@ def _prepare_account_move_vals(
svl_id,
cost,
)
if self.picking_id.accounting_date:
am_vals.update({"date": self.picking_id.accounting_date})
if self.accounting_date:
am_vals.update({"date": self.accounting_date})
return am_vals
7 changes: 5 additions & 2 deletions stock_picking_accounting_date/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
This module adds accounting date in picking and pass the value to accounting date
of SVL's journal entry.
This module adds an accounting date in both stock pickings and stock moves.
The accounting date from the picking is propagated to its corresponding stock move.
If a picking doesn't specify an accounting date, the stock move's accounting date
will be set to the 'Effective Date'. This value is then passed to the SVL's journal entry
accounting date.
13 changes: 13 additions & 0 deletions stock_picking_accounting_date/views/stock_move_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="view_move_tree_acceptance_date_inherit" model="ir.ui.view">
<field name="name">stock.move.tree</field>
<field name="model">stock.move</field>
<field name="inherit_id" ref="stock.view_move_tree" />
<field name="arch" type="xml">
<xpath expr="//field[@name='reference']" position="before">
<field name="accounting_date" optional="show" />
</xpath>
</field>
</record>
</odoo>
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ def _compute_accounting_date(self):
if account_move and account_move.state == "posted":
rec.accounting_date = account_move.date
continue
if rec.stock_move_id:
rec.accounting_date = rec.stock_move_id.accounting_date
continue
rec.accounting_date = fields.Datetime.context_timestamp(
self, rec.create_date
)
Loading