diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/v14_indoteknik | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/v14_indoteknik')
| -rw-r--r-- | addons/v14_indoteknik/__init__.py | 3 | ||||
| -rw-r--r-- | addons/v14_indoteknik/__manifest__.py | 17 | ||||
| -rw-r--r-- | addons/v14_indoteknik/models/__init__.py | 4 | ||||
| -rw-r--r-- | addons/v14_indoteknik/models/account_move.py | 33 | ||||
| -rw-r--r-- | addons/v14_indoteknik/models/account_period.py | 130 | ||||
| -rw-r--r-- | addons/v14_indoteknik/security/ir.model.access.csv | 4 | ||||
| -rw-r--r-- | addons/v14_indoteknik/static/description/icon.png | bin | 0 -> 1823 bytes | |||
| -rw-r--r-- | addons/v14_indoteknik/views/account_move_view.xml | 20 | ||||
| -rw-r--r-- | addons/v14_indoteknik/views/account_period_view.xml | 63 | ||||
| -rw-r--r-- | addons/v14_indoteknik/views/menu_items.xml | 22 | ||||
| -rw-r--r-- | addons/v14_indoteknik/wizard/__init__.py | 4 |
11 files changed, 300 insertions, 0 deletions
diff --git a/addons/v14_indoteknik/__init__.py b/addons/v14_indoteknik/__init__.py new file mode 100644 index 00000000..cde864ba --- /dev/null +++ b/addons/v14_indoteknik/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import models diff --git a/addons/v14_indoteknik/__manifest__.py b/addons/v14_indoteknik/__manifest__.py new file mode 100644 index 00000000..1ab29e7c --- /dev/null +++ b/addons/v14_indoteknik/__manifest__.py @@ -0,0 +1,17 @@ +{ + 'name': 'Account Period', + 'description': 'Feature for Monthlyu Periods in Accounting', + "category": 'Accounting', + 'author': 'Alfius Samuel', + 'version': '1.0', + 'depends': ['base','base_accounting_kit','account'], + 'data': [ + 'views/account_period_view.xml', + 'views/account_move_view.xml', + 'views/menu_items.xml', + 'security/ir.model.access.csv' + ], + 'qweb': [], + 'installable': True, + 'application': True, +} diff --git a/addons/v14_indoteknik/models/__init__.py b/addons/v14_indoteknik/models/__init__.py new file mode 100644 index 00000000..19d6b2d8 --- /dev/null +++ b/addons/v14_indoteknik/models/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- + +from . import account_period +from . import account_move
\ No newline at end of file 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 diff --git a/addons/v14_indoteknik/models/account_period.py b/addons/v14_indoteknik/models/account_period.py new file mode 100644 index 00000000..fb2a99e2 --- /dev/null +++ b/addons/v14_indoteknik/models/account_period.py @@ -0,0 +1,130 @@ +# -*- coding: utf-8 -*- + +from odoo import api, fields, models, _ +from odoo.exceptions import UserError, RedirectWarning, ValidationError, except_orm, Warning +from datetime import datetime + + +class AccountPeriodLine(models.Model): + _name = "account.period.line" + + reference = fields.Many2one('account.period', string="Reference") + start_date = fields.Date('Start Date') + end_date = fields.Date('End Date') + state = fields.Selection([('Open','Open'),('Closed','Closed')], string="Status", default="Open") + + def action_close_period(self): + for res in self: + res.write({'state': 'Closed'}) + + def action_open_period(self): + for res in self: + res.write({'state': 'Open'}) + +class AccountPeriod(models.Model): + _name = "account.period" + + name = fields.Char('Period Name') + year = fields.Char('Year') + start_date = fields.Date('Start Date') + end_date = fields.Date('End Date') + line_ids = fields.One2many('account.period.line', 'reference', string='Lines') + state = fields.Selection([('Open','Open'),('Closed','Closed')], string="Status", default="Open") + + def action_create_period(self): + for res in self: + start_date1 = datetime(int(res.year), 1, 1) + end_date1 = datetime(int(res.year), 1, 31) + self.env['account.period.line'].create({ + 'reference': res.id, + 'start_date': start_date1, + 'end_date': end_date1 + }) + + start_date2 = datetime(int(res.year), 2, 1) + end_date2 = datetime(int(res.year), 2, 28) + self.env['account.period.line'].create({ + 'reference': res.id, + 'start_date': start_date2, + 'end_date': end_date2 + }) + + start_date3 = datetime(int(res.year), 3, 1) + end_date3 = datetime(int(res.year), 3, 31) + self.env['account.period.line'].create({ + 'reference': res.id, + 'start_date': start_date3, + 'end_date': end_date3 + }) + + start_date4 = datetime(int(res.year), 4, 1) + end_date4 = datetime(int(res.year), 4, 30) + self.env['account.period.line'].create({ + 'reference': res.id, + 'start_date': start_date4, + 'end_date': end_date4 + }) + + start_date5 = datetime(int(res.year), 5, 1) + end_date5 = datetime(int(res.year), 5, 31) + self.env['account.period.line'].create({ + 'reference': res.id, + 'start_date': start_date5, + 'end_date': end_date5 + }) + + start_date6 = datetime(int(res.year), 6, 1) + end_date6 = datetime(int(res.year), 6, 30) + self.env['account.period.line'].create({ + 'reference': res.id, + 'start_date': start_date6, + 'end_date': end_date6 + }) + + start_date7 = datetime(int(res.year), 7, 1) + end_date7 = datetime(int(res.year), 7, 31) + self.env['account.period.line'].create({ + 'reference': res.id, + 'start_date': start_date7, + 'end_date': end_date7 + }) + + start_date8 = datetime(int(res.year), 8, 1) + end_date8 = datetime(int(res.year), 8, 31) + self.env['account.period.line'].create({ + 'reference': res.id, + 'start_date': start_date8, + 'end_date': end_date8 + }) + + start_date9 = datetime(int(res.year), 9, 1) + end_date9 = datetime(int(res.year), 9, 30) + self.env['account.period.line'].create({ + 'reference': res.id, + 'start_date': start_date9, + 'end_date': end_date9 + }) + + start_date10 = datetime(int(res.year), 10, 1) + end_date10 = datetime(int(res.year), 10, 31) + self.env['account.period.line'].create({ + 'reference': res.id, + 'start_date': start_date10, + 'end_date': end_date10 + }) + + start_date11 = datetime(int(res.year), 11, 1) + end_date11 = datetime(int(res.year), 11, 30) + self.env['account.period.line'].create({ + 'reference': res.id, + 'start_date': start_date11, + 'end_date': end_date11 + }) + + start_date12 = datetime(int(res.year), 12, 1) + end_date12 = datetime(int(res.year), 12, 31) + self.env['account.period.line'].create({ + 'reference': res.id, + 'start_date': start_date12, + 'end_date': end_date12 + })
\ No newline at end of file diff --git a/addons/v14_indoteknik/security/ir.model.access.csv b/addons/v14_indoteknik/security/ir.model.access.csv new file mode 100644 index 00000000..9fe08b9a --- /dev/null +++ b/addons/v14_indoteknik/security/ir.model.access.csv @@ -0,0 +1,4 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink + +access_account_period,access_account_period,model_account_period,base.group_user,1,1,1,1 +access_account_period_line,access_account_period_line,model_account_period_line,base.group_user,1,1,1,1
\ No newline at end of file diff --git a/addons/v14_indoteknik/static/description/icon.png b/addons/v14_indoteknik/static/description/icon.png Binary files differnew file mode 100644 index 00000000..89dd8729 --- /dev/null +++ b/addons/v14_indoteknik/static/description/icon.png diff --git a/addons/v14_indoteknik/views/account_move_view.xml b/addons/v14_indoteknik/views/account_move_view.xml new file mode 100644 index 00000000..4d895918 --- /dev/null +++ b/addons/v14_indoteknik/views/account_move_view.xml @@ -0,0 +1,20 @@ +<odoo> + <data> + + <record model="ir.ui.view" id="view_move_form_indoteknik"> + <field name="name">account.move.form</field> + <field name="model">account.move</field> + <field name="inherit_id" ref="account.view_move_form"/> + <field name="arch" type="xml"> + <field name="ref" position="after"> + <label for="period_start_date"/> + <div> + <field name="period_start_date" class="oe_inline"/> - + <field name="period_end_date" class="oe_inline"/> + </div> + </field> + </field> + </record> + + </data> +</odoo>
\ No newline at end of file diff --git a/addons/v14_indoteknik/views/account_period_view.xml b/addons/v14_indoteknik/views/account_period_view.xml new file mode 100644 index 00000000..126a5d05 --- /dev/null +++ b/addons/v14_indoteknik/views/account_period_view.xml @@ -0,0 +1,63 @@ +<odoo> + <data> + + <record id="account_period_tree" model="ir.ui.view"> + <field name="name">Periods</field> + <field name="model">account.period</field> + <field name="arch" type="xml"> + <tree> + <field name="name"/> + <field name="year"/> + <field name="start_date"/> + <field name="end_date"/> + </tree> + </field> + </record> + + <record id="account_period_form" model="ir.ui.view"> + <field name="name">Periods</field> + <field name="model">account.period</field> + <field name="arch" type="xml"> + <form> + <header> + <button name="action_create_period" string="Create Periods" + states="Open" type="object" class="oe_highlight"/> + <field name="state" readonly="1" widget="statusbar"/> + </header> + <sheet> + <group> + <group> + <field name="name" required="1"/> + <field name="year" required="1"/> + </group> + <group> + <field name="start_date" required="1"/> + <field name="end_date" required="1"/> + </group> + </group> + <group> + <notebook> + <page string="Periods"> + <group> + <field name="line_ids" nolabel="1" readonly="1"> + <tree editable="top"> + <field name="start_date"/> + <field name="end_date"/> + <field name="state"/> + <button name="action_close_period" type="object" + string="Close Period" class="oe_highlight" states="Open"/> + <button name="action_open_period" type="object" + string="Open Period" class="oe_highlight" states="Closed"/> + </tree> + </field> + </group> + </page> + </notebook> + </group> + </sheet> + </form> + </field> + </record> + + </data> +</odoo>
\ No newline at end of file diff --git a/addons/v14_indoteknik/views/menu_items.xml b/addons/v14_indoteknik/views/menu_items.xml new file mode 100644 index 00000000..68873ff3 --- /dev/null +++ b/addons/v14_indoteknik/views/menu_items.xml @@ -0,0 +1,22 @@ +<odoo> + <data> + + <record id="account_period_action" model="ir.actions.act_window"> + <field name="name">Periods</field> + <field name="res_model">account.period</field> + <field name="view_mode">tree,form</field> + <field name="help" type="html"> + <p class="oe_view_nocontent_create"> + Click to Add New Data + </p> + </field> + </record> + + <menuitem id="menu_account_period" + name="Accounting Periods" + action="account_period_action" + parent="account.menu_finance_configuration" + sequence="0"/> + + </data> +</odoo>
\ No newline at end of file diff --git a/addons/v14_indoteknik/wizard/__init__.py b/addons/v14_indoteknik/wizard/__init__.py new file mode 100644 index 00000000..4e3aa258 --- /dev/null +++ b/addons/v14_indoteknik/wizard/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- + +from . import mnc_document_approval_wizard +from . import mnc_document_reject_wizard |
