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