Skip to content
Snippets Groups Projects

16.0.1.3.0 - Fix period selection upon reversal with a specific date + QoL

Merged Houzefa Abbasbhay requested to merge topic/16.0/zouzou into branch/16.0
5 files
+ 79
55
Compare changes
  • Side-by-side
  • Inline
Files
5
+ 9
8
@@ -17,12 +17,11 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from odoo import fields, models
class AccountMove(models.Model):
"""Add a period & dates onto accounting documents."""
"""Journal Entries: Add period, filled based on date."""
_inherit = "account.move"
@@ -30,18 +29,20 @@ class AccountMove(models.Model):
comodel_name="account.period",
string="Period",
ondelete="restrict",
copy=False, # Do not copy; will be reset upon validation.
help="The period this accounting document is in.",
index=True,
states={"posted": [("readonly", True), ("required", True)]},
)
def action_post(self):
"""Override accounting document validation to fill period."""
self.fill_period()
return super().action_post()
def _post(self, soft=True):
"""Override validation to fill period."""
ret = super()._post(soft=soft)
self.filtered(lambda move: move.state == "posted").fill_period()
return ret
def fill_period(self):
"""Find an open period around move date, set it onto that move."""
"""Find an open period around move date, set it onto each move."""
today = fields.Date.context_today(self)
for accdoc in self:
Loading