From 1ca3b3df3421961caec3b747a364071c80f5c7da Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 10 May 2022 17:14:58 +0700 Subject: initial commit --- custom_indoteknik/__init__.py | 3 + custom_indoteknik/__manifest__.py | 18 +++ custom_indoteknik/models/__init__.py | 6 + custom_indoteknik/models/account_move.py | 33 ++++++ custom_indoteknik/models/account_period.py | 147 ++++++++++++++++++++++++ custom_indoteknik/models/export_product.py | 34 ++++++ custom_indoteknik/models/manufacture.py | 26 +++++ custom_indoteknik/models/sale.py | 29 +++++ custom_indoteknik/security/ir.model.access.csv | 4 + custom_indoteknik/static/description/icon.png | Bin 0 -> 1823 bytes custom_indoteknik/views/account_move_view.xml | 16 +++ custom_indoteknik/views/account_period_view.xml | 64 +++++++++++ custom_indoteknik/views/export_product_view.xml | 50 ++++++++ custom_indoteknik/views/manufacture_view.xml | 54 +++++++++ custom_indoteknik/views/menu_items.xml | 22 ++++ custom_indoteknik/views/purchase_view.xml | 18 +++ custom_indoteknik/wizard/__init__.py | 4 + 17 files changed, 528 insertions(+) create mode 100644 custom_indoteknik/__init__.py create mode 100644 custom_indoteknik/__manifest__.py create mode 100644 custom_indoteknik/models/__init__.py create mode 100644 custom_indoteknik/models/account_move.py create mode 100644 custom_indoteknik/models/account_period.py create mode 100644 custom_indoteknik/models/export_product.py create mode 100644 custom_indoteknik/models/manufacture.py create mode 100644 custom_indoteknik/models/sale.py create mode 100644 custom_indoteknik/security/ir.model.access.csv create mode 100644 custom_indoteknik/static/description/icon.png create mode 100644 custom_indoteknik/views/account_move_view.xml create mode 100644 custom_indoteknik/views/account_period_view.xml create mode 100644 custom_indoteknik/views/export_product_view.xml create mode 100644 custom_indoteknik/views/manufacture_view.xml create mode 100644 custom_indoteknik/views/menu_items.xml create mode 100644 custom_indoteknik/views/purchase_view.xml create mode 100644 custom_indoteknik/wizard/__init__.py (limited to 'custom_indoteknik') diff --git a/custom_indoteknik/__init__.py b/custom_indoteknik/__init__.py new file mode 100644 index 0000000..cde864b --- /dev/null +++ b/custom_indoteknik/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import models diff --git a/custom_indoteknik/__manifest__.py b/custom_indoteknik/__manifest__.py new file mode 100644 index 0000000..53ec7c7 --- /dev/null +++ b/custom_indoteknik/__manifest__.py @@ -0,0 +1,18 @@ +{ + 'name': 'Customization for Indoteknik', + 'description': 'Feature for Monthlyu Periods in Accounting', + "category": 'Accounting', + 'author': 'Alfius Samuel', + 'version': '1.0', + 'depends': ['base','purchase','base_accounting_kit','account'], + 'data': [ + 'views/account_period_view.xml', + 'views/account_move_view.xml', + 'views/menu_items.xml', + 'views/purchase_view.xml', + 'security/ir.model.access.csv' + ], + 'qweb': [], + 'installable': True, + 'application': True, +} diff --git a/custom_indoteknik/models/__init__.py b/custom_indoteknik/models/__init__.py new file mode 100644 index 0000000..70d934c --- /dev/null +++ b/custom_indoteknik/models/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- + +from . import account_period +from . import export_product +from . import manufacture +from . import account_move \ No newline at end of file diff --git a/custom_indoteknik/models/account_move.py b/custom_indoteknik/models/account_move.py new file mode 100644 index 0000000..a5c9eaf --- /dev/null +++ b/custom_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" + + period_id = fields.Many2one(compute="_get_period", comodel_name="account.period", string="Period") + + @api.depends('invoice_date') + def _get_period(self): + for res in self: + period_id = "" + + if res.invoice_date: + period_ids = self.env['account.period'].search([ + ('start_date', '<=', res.invoice_date), + ('end_date', '>=', res.invoice_date) + ]) + + if period_ids: + period_id = period_ids[0].id + + res.period_id = period_id + + 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')) diff --git a/custom_indoteknik/models/account_period.py b/custom_indoteknik/models/account_period.py new file mode 100644 index 0000000..9e9b2c0 --- /dev/null +++ b/custom_indoteknik/models/account_period.py @@ -0,0 +1,147 @@ +# -*- 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") + period_name = fields.Char('Period Name') + 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: + if res.line_ids: + for line in res.line_ids: + line.unlink() + + 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, + 'period_name': '01/' + str(res.year), + '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, + 'period_name': '02/' + str(res.year), + '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, + 'period_name': '03/' + str(res.year), + '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, + 'period_name': '04/' + str(res.year), + '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, + 'period_name': '05/' + str(res.year), + '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, + 'period_name': '06/' + str(res.year), + '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, + 'period_name': '07/' + str(res.year), + '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, + 'name': '08/' + str(res.year), + '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, + 'period_name': '09/' + str(res.year), + '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, + 'period_name': '10/' + str(res.year), + '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, + 'period_name': '11/' + str(res.year), + '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, + 'period_name': '12/' + str(res.year), + 'start_date': start_date12, + 'end_date': end_date12 + }) \ No newline at end of file diff --git a/custom_indoteknik/models/export_product.py b/custom_indoteknik/models/export_product.py new file mode 100644 index 0000000..540891e --- /dev/null +++ b/custom_indoteknik/models/export_product.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- + +from odoo import api, fields, models, _ +from odoo.exceptions import UserError, RedirectWarning, ValidationError, except_orm, Warning +from datetime import datetime + + +class ExportProductLine(models.Model): + _name = "export.product.line" + + reference = fields.Many2one('Reference') + value = fields.Char('Value') + +class ExportProduct(models.Model): + _name = "export.product" + + product_template_id = fields.Char('Product External ID') + product_template_name = fields.Char('Product Name') + attribute_id = fields.Char('Attribute') + value_text = fields.Char(compute="_get_value_text", string="Values in Text") + line_ids = fields.One2many('export.product.line', 'reference', 'Lines') + + @api.depends('line_ids.value') + def _get_value_text(self): + for res in self: + value_text = "" + if res.line_ids: + for line in res.line_ids: + if not value_text: + value_text += line.value + elif value_text: + value_text += "," + line.value + + res.value_text = value_text diff --git a/custom_indoteknik/models/manufacture.py b/custom_indoteknik/models/manufacture.py new file mode 100644 index 0000000..55ffe6f --- /dev/null +++ b/custom_indoteknik/models/manufacture.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- + +from odoo import api, fields, models, _ +from odoo.exceptions import UserError, RedirectWarning, ValidationError, except_orm, Warning +from datetime import datetime + + +class XManufacture(models.Model): + _name = "x.manufacture" + + x_name = fields.Char('Name') + x_negara_asal = fields.Char('Negara Asal') + x_short_desc = fields.Text('Short Description') + x_manufacture_category = fields.Many2one('x.manufacture.category', string="Manufacture Category") + x_manufacture_level = fields.Selection([ + ('Prioritas','Prioritas'), + ('Gold','Gold'), + ('Silver','Silver') + ], string="Manufacture Level") + x_produk_aksesoris_sparepart = fields.Selection([ + ('Produk','Produk'), + ('Aksesoris','Aksesoris'), + ('Sparepart','Sparepart') + ], string="Jenis Produk") + x_description = fields.Text('Description') + x_logo_manufacture = fields.Binary('Logo Manufacture') \ No newline at end of file diff --git a/custom_indoteknik/models/sale.py b/custom_indoteknik/models/sale.py new file mode 100644 index 0000000..f020e23 --- /dev/null +++ b/custom_indoteknik/models/sale.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- + +from odoo import api, fields, models, _ +from odoo.exceptions import UserError, RedirectWarning, ValidationError, except_orm, Warning +from datetime import datetime + + +# class SaleOrder(models.Model): +# _inherit = "sale.order" + +# @api.multi +# def action_confirm(self): +# for order in self: +# # Check Invoice Limit +# if order.partner_id.invoice_limit < order.partner_id.total_receivable: +# raise ValidationError(_("This Customer has reached the Limit of Outstanding Invoices")) +# elif order.partner_id.invoice_limit < order.amount_total: +# raise ValidationError(_("This order is more than this Customer Limit")) + +# # Check Overdue invoices +# outstanding_invoice = self.env['account.move'].search([ +# ('partner_id','=',order.partner_id.id), +# ('state','=','open'), +# ('date_due','<',fields.Date.today())]) + +# if outstanding_invoice: +# raise ValidationError(_("There are Overdue Invoices for this Customer")) + +# return super(SaleOrder, self).action_confirm() \ No newline at end of file diff --git a/custom_indoteknik/security/ir.model.access.csv b/custom_indoteknik/security/ir.model.access.csv new file mode 100644 index 0000000..9fe08b9 --- /dev/null +++ b/custom_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/custom_indoteknik/static/description/icon.png b/custom_indoteknik/static/description/icon.png new file mode 100644 index 0000000..89dd872 Binary files /dev/null and b/custom_indoteknik/static/description/icon.png differ diff --git a/custom_indoteknik/views/account_move_view.xml b/custom_indoteknik/views/account_move_view.xml new file mode 100644 index 0000000..8abbb80 --- /dev/null +++ b/custom_indoteknik/views/account_move_view.xml @@ -0,0 +1,16 @@ + + + + + account.move.form + account.move + + + + + + + + + + \ No newline at end of file diff --git a/custom_indoteknik/views/account_period_view.xml b/custom_indoteknik/views/account_period_view.xml new file mode 100644 index 0000000..6b4fd5a --- /dev/null +++ b/custom_indoteknik/views/account_period_view.xml @@ -0,0 +1,64 @@ + + + + + Periods + account.period + + + + + + + + + + + + Periods + account.period + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
\ No newline at end of file diff --git a/custom_indoteknik/wizard/__init__.py b/custom_indoteknik/wizard/__init__.py new file mode 100644 index 0000000..4e3aa25 --- /dev/null +++ b/custom_indoteknik/wizard/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- + +from . import mnc_document_approval_wizard +from . import mnc_document_reject_wizard -- cgit v1.2.3