summaryrefslogtreecommitdiff
path: root/addons/v14_indoteknik/models/account_move.py
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/v14_indoteknik/models/account_move.py
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/v14_indoteknik/models/account_move.py')
-rw-r--r--addons/v14_indoteknik/models/account_move.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/addons/v14_indoteknik/models/account_move.py b/addons/v14_indoteknik/models/account_move.py
new file mode 100644
index 00000000..4063c2d3
--- /dev/null
+++ b/addons/v14_indoteknik/models/account_move.py
@@ -0,0 +1,33 @@
+# -*- coding: utf-8 -*-
+
+from odoo import api, fields, models, _
+from odoo.exceptions import UserError, RedirectWarning, ValidationError, except_orm, Warning
+from datetime import datetime
+
+
+class AccountMove(models.Model):
+ _inherit = "account.move"
+
+ @api.depends('date')
+ def _get_period_id(self):
+ for res in self:
+ period_id = ''
+ period_id = self.env['account.period.line'].search([
+ ('start_date', '<', res.date),
+ ('end_date', '>', res.date)
+ ])
+
+ if period_id:
+ res.period_start_date = period_id[0].start_date
+ res.period_end_date = period_id[0].end_date
+ res.period_id = period_id[0].id
+
+ period_start_date = fields.Date(compute="_get_period_id", string="Period")
+ period_end_date = fields.Date(compute="_get_period_id", string="Period")
+ period_id = fields.Many2one(compute="_get_period_id", comodel_name='account.period.line', string="Period")
+
+ def action_post(self):
+ if self.period_id and self.period_id.state == "Open":
+ super(AccountMove, self).action_post()
+ else:
+ raise ValidationError(_('Period of this Journal has been closed')) \ No newline at end of file