Skip to content
Snippets Groups Projects
Commit 629ccfafd166 authored by Houzefa Abbasbhay's avatar Houzefa Abbasbhay :slight_smile:
Browse files

Accdocs: Default period around today

parent 8b71dd27616e
No related branches found
No related tags found
No related merge requests found
......@@ -34,6 +34,17 @@
_inherit = 'account.move'
def _default_period_id(self):
"""Find a default period around today."""
today = date.today()
return self.env['account.period'].search([
('company_id', '=', self.env.user.company_id.id),
('date_start', '<=', today),
('date_stop', '>=', today),
], limit=1)
period_id = fields.Many2one(
comodel_name='account.period',
string='Period',
......@@ -37,6 +48,7 @@
period_id = fields.Many2one(
comodel_name='account.period',
string='Period',
default=_default_period_id,
help='The period this accounting document is in.',
ondelete='restrict',
required=True,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment