From 4ff21974e6ff58dd54706e30f5b25c30fb4aff30 Mon Sep 17 00:00:00 2001 From: Kitti U Date: Mon, 19 Aug 2019 18:01:15 +0700 Subject: [PATCH] [12.0][ADD] budget_management --- budget_management/__init__.py | 3 + budget_management/__manifest__.py | 22 ++ budget_management/models/__init__.py | 6 + budget_management/models/account_move.py | 19 ++ budget_management/models/budget_control.py | 125 ++++++++ budget_management/models/budget_management.py | 275 ++++++++++++++++++ budget_management/models/mis_budget_item.py | 27 ++ budget_management/readme/CONTRIBUTORS.rst | 1 + budget_management/readme/DESCRIPTION.rst | 0 .../security/ir.model.access.csv | 3 + budget_management/static/description/icon.png | Bin 0 -> 9455 bytes budget_management/tests/__init__.py | 4 + .../tests/test_budget_management.py | 161 ++++++++++ .../views/budget_control_view.xml | 98 +++++++ .../views/budget_management_view.xml | 75 +++++ budget_management_expense/__init__.py | 3 + budget_management_expense/__manifest__.py | 22 ++ budget_management_expense/models/__init__.py | 5 + .../models/budget_management.py | 33 +++ .../models/expense_budget_move.py | 58 ++++ .../models/hr_expense.py | 84 ++++++ .../readme/CONTRIBUTORS.rst | 1 + .../readme/DESCRIPTION.rst | 6 + .../security/ir.model.access.csv | 2 + .../static/description/icon.png | Bin 0 -> 9455 bytes .../views/budget_management_view.xml | 15 + .../views/hr_expense_view.xml | 28 ++ budget_management_purchase/__init__.py | 3 + budget_management_purchase/__manifest__.py | 22 ++ budget_management_purchase/models/__init__.py | 6 + .../models/account_invoice.py | 45 +++ .../models/budget_management.py | 33 +++ budget_management_purchase/models/purchase.py | 87 ++++++ .../models/purchase_budget_move.py | 68 +++++ .../readme/CONTRIBUTORS.rst | 1 + .../readme/DESCRIPTION.rst | 6 + .../security/ir.model.access.csv | 2 + .../static/description/icon.png | Bin 0 -> 9455 bytes .../views/budget_management_view.xml | 15 + .../views/purchase_view.xml | 29 ++ 40 files changed, 1393 insertions(+) create mode 100644 budget_management/__init__.py create mode 100644 budget_management/__manifest__.py create mode 100644 budget_management/models/__init__.py create mode 100644 budget_management/models/account_move.py create mode 100644 budget_management/models/budget_control.py create mode 100644 budget_management/models/budget_management.py create mode 100644 budget_management/models/mis_budget_item.py create mode 100644 budget_management/readme/CONTRIBUTORS.rst create mode 100644 budget_management/readme/DESCRIPTION.rst create mode 100644 budget_management/security/ir.model.access.csv create mode 100644 budget_management/static/description/icon.png create mode 100644 budget_management/tests/__init__.py create mode 100644 budget_management/tests/test_budget_management.py create mode 100644 budget_management/views/budget_control_view.xml create mode 100644 budget_management/views/budget_management_view.xml create mode 100644 budget_management_expense/__init__.py create mode 100644 budget_management_expense/__manifest__.py create mode 100644 budget_management_expense/models/__init__.py create mode 100644 budget_management_expense/models/budget_management.py create mode 100644 budget_management_expense/models/expense_budget_move.py create mode 100644 budget_management_expense/models/hr_expense.py create mode 100644 budget_management_expense/readme/CONTRIBUTORS.rst create mode 100644 budget_management_expense/readme/DESCRIPTION.rst create mode 100644 budget_management_expense/security/ir.model.access.csv create mode 100644 budget_management_expense/static/description/icon.png create mode 100644 budget_management_expense/views/budget_management_view.xml create mode 100644 budget_management_expense/views/hr_expense_view.xml create mode 100644 budget_management_purchase/__init__.py create mode 100644 budget_management_purchase/__manifest__.py create mode 100644 budget_management_purchase/models/__init__.py create mode 100644 budget_management_purchase/models/account_invoice.py create mode 100644 budget_management_purchase/models/budget_management.py create mode 100644 budget_management_purchase/models/purchase.py create mode 100644 budget_management_purchase/models/purchase_budget_move.py create mode 100644 budget_management_purchase/readme/CONTRIBUTORS.rst create mode 100644 budget_management_purchase/readme/DESCRIPTION.rst create mode 100644 budget_management_purchase/security/ir.model.access.csv create mode 100644 budget_management_purchase/static/description/icon.png create mode 100644 budget_management_purchase/views/budget_management_view.xml create mode 100644 budget_management_purchase/views/purchase_view.xml diff --git a/budget_management/__init__.py b/budget_management/__init__.py new file mode 100644 index 00000000..2452acf9 --- /dev/null +++ b/budget_management/__init__.py @@ -0,0 +1,3 @@ +# Copyright 2019 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from . import models diff --git a/budget_management/__manifest__.py b/budget_management/__manifest__.py new file mode 100644 index 00000000..0090c3eb --- /dev/null +++ b/budget_management/__manifest__.py @@ -0,0 +1,22 @@ +# Copyright 2019 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + 'name': 'Budget Management', + 'version': '12.0.1.0.0', + 'license': 'AGPL-3', + 'author': 'Ecosoft,Odoo Community Association (OCA)', + 'website': 'https://github.com/OCA/account-budgeting', + 'depends': [ + 'mis_builder_budget', + 'web_widget_x2many_2d_matrix', + ], + 'data': [ + 'security/ir.model.access.csv', + 'views/budget_management_view.xml', + 'views/budget_control_view.xml', + ], + 'installable': True, + 'maintainers': ['kittiu'], + 'development_status': 'Beta', +} diff --git a/budget_management/models/__init__.py b/budget_management/models/__init__.py new file mode 100644 index 00000000..51e57e95 --- /dev/null +++ b/budget_management/models/__init__.py @@ -0,0 +1,6 @@ +# Copyright 2019 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from . import account_move +from . import budget_management +from . import budget_control +from . import mis_budget_item diff --git a/budget_management/models/account_move.py b/budget_management/models/account_move.py new file mode 100644 index 00000000..e3ea8fe0 --- /dev/null +++ b/budget_management/models/account_move.py @@ -0,0 +1,19 @@ +# Copyright 2019 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import fields, models, api, _ +from odoo.exceptions import UserError, ValidationError + + +class AccountMove(models.Model): + _inherit = 'account.move' + + @api.multi + def post(self, invoice=False): + res = super().post(invoice=invoice) + # Force no budget check, if not Vendor Bill + no_check = invoice and invoice.type != 'in_invoice' and True or False + ctx = {'force_no_budget_check': no_check} + BudgetManagement = self.env['budget.management'].with_context(ctx) + for doc in self: + BudgetManagement.check_budget(doc.line_ids) + return res diff --git a/budget_management/models/budget_control.py b/budget_management/models/budget_control.py new file mode 100644 index 00000000..c47876a4 --- /dev/null +++ b/budget_management/models/budget_control.py @@ -0,0 +1,125 @@ +# Copyright 2019 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import fields, models, api, _ +from odoo.exceptions import UserError + + +class BudgetControl(models.Model): + _name = 'budget.control' + _description = 'Budget plan ease filling the MIS Budget form' + + name = fields.Char( + required=True, + ) + budget_id = fields.Many2one( + comodel_name='mis.budget', + string='MIS Budget', + required=True, + ondelete='restrict', + domain=lambda self: self._get_mis_budget_domain(), + help="List of mis.budget created by and linked to budget.management", + ) + date_from = fields.Date( + related='budget_id.date_from', + ) + date_to = fields.Date( + related='budget_id.date_to', + ) + active = fields.Boolean( + default=True, + ) + analytic_account_id = fields.Many2one( + comodel_name='account.analytic.account', + required=True, + ondelete='restrict', + ) + item_ids = fields.One2many( + comodel_name='mis.budget.item', + inverse_name='budget_control_id', + string='Budget Items', + ) + plan_date_range_type_id = fields.Many2one( + comodel_name='date.range.type', + string='Plan Date Range', + required=True, + ) + _sql_constraints = [ + ('name_uniq', 'UNIQUE(name)', 'Name must be unique!'), + ('budget_control_uniq', 'UNIQUE(budget_id, analytic_account_id)', + 'Duplicated analytic account for the same budget!') + ] + + @api.model + def _get_mis_budget_domain(self): + all_budget_mgnts = self.env['budget.management'].search([]) + return [('id', 'in', all_budget_mgnts.mapped('mis_budget_id').ids)] + + @api.model + def create(self, vals): + plan = super().create(vals) + plan.prepare_budget_control_matrix() + return plan + + @api.multi + def write(self, vals): + # if any field in header changes, reset the plan matrix + res = super().write(vals) + fixed_fields = ['budget_id', + 'plan_date_range_type_id', + 'analytic_account_id'] + change_fields = list(vals.keys()) + if list(set(fixed_fields) & set(change_fields)): + self.prepare_budget_control_matrix() + return res + + @api.multi + def prepare_budget_control_matrix(self): + KpiExpression = self.env['mis.report.kpi.expression'] + DateRange = self.env['date.range'] + for plan in self: + plan.item_ids.unlink() + if not plan.plan_date_range_type_id: + raise UserError(_('Please select range')) + date_ranges = DateRange.search([ + ('type_id', '=', plan.plan_date_range_type_id.id), + ('date_start', '>=', plan.date_from), + ('date_end', '<=', plan.date_to)]) + kpi_expressions = KpiExpression.search([ + ('kpi_id.report_id', '=', plan.budget_id.report_id.id), + ('kpi_id.budgetable', '=', True)]) + items = [] + for date_range in date_ranges: + for kpi_expression in kpi_expressions: + vals = {'budget_id': plan.budget_id.id, + 'kpi_expression_id': kpi_expression.id, + 'date_range_id': date_range.id, + 'date_from': date_range.date_start, + 'date_to': date_range.date_end, + 'analytic_account_id': plan.analytic_account_id.id, + } + items += [(0, 0, vals)] + plan.write({'item_ids': items}) + + @api.multi + def _report_instance(self): + self.ensure_one() + budget_mgnt = self.env['budget.management'].search([ + ('mis_budget_id', '=', self.budget_id.id)]) + ctx = {'mis_report_filters': {}} + if self.analytic_account_id: + ctx['mis_report_filters']['analytic_account_id'] = { + 'value': self.analytic_account_id.id, + } + return budget_mgnt.report_instance_id.with_context(ctx) + + @api.multi + def preview(self): + return self._report_instance().preview() + + @api.multi + def print_pdf(self): + return self._report_instance().print_pdf() + + @api.multi + def export_xls(self): + return self._report_instance().export_xls() diff --git a/budget_management/models/budget_management.py b/budget_management/models/budget_management.py new file mode 100644 index 00000000..21b35e53 --- /dev/null +++ b/budget_management/models/budget_management.py @@ -0,0 +1,275 @@ +# Copyright 2019 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import fields, models, api, _ +from odoo.exceptions import ValidationError, UserError + + +class BudgetManagement(models.Model): + _name = 'budget.management' + _inherits = {'mis.report.instance': 'report_instance_id'} + _description = 'For each fiscal year, manage how budget is controlled' + + report_instance_id = fields.Many2one( + comodel_name='mis.report.instance', + string='Budget MIS Instance', + readonly=False, + ondelete='restrict', + required=True, + help="Automatically created report instance for this budget mgnt", + ) + mis_budget_id = fields.Many2one( + comodel_name='mis.budget', + string='MIS Budget', + readonly=True, + ondelete='restrict', + help="Automatically created mis budget", + ) + bm_date_from = fields.Date( + string='Date From', + required=True, + ) + bm_date_to = fields.Date( + string='Date To', + required=True, + ) + account = fields.Boolean( + string='On Account', + default=False, + help="Control budget on journal document(s), i.e., vendor bill", + ) + control_all_analytic_accounts = fields.Boolean( + string='Control All Analytics', + default=True, + ) + control_analytic_account_ids = fields.Many2many( + comodel_name='account.analytic.account', + relation='budget_management_analytic_account_rel', + string='Controlled Analytics', + ) + + @api.model + def create(self, vals): + # Auto create mis.budget, and link it to same kpi and date range + mis_budget = self.env['mis.budget'].create({ + 'name': _('%s - Budget') % vals['name'], + 'report_id': vals['report_id'], + 'date_from': vals['bm_date_from'], + 'date_to': vals['bm_date_to'], + }) + vals.update({'comparison_mode': True, + 'target_move': 'posted', + 'mis_budget_id': mis_budget.id, }) + budget_mgnt = super().create(vals) + budget_mgnt._recompute_report_instance_periods() + return budget_mgnt + + @api.multi + def write(self, vals): + vals.update({'comparison_mode': True, 'target_move': 'posted'}) + res = super().write(vals) + self._recompute_report_instance_periods() + return res + + @api.multi + def unlink(self): + report_instances = self.mapped('report_instance_id') + mis_budgets = self.mapped('mis_budget_id') + res = super().unlink() + report_instances.mapped('period_ids.source_sumcol_ids').unlink() + report_instances.mapped('period_ids').unlink() + report_instances.unlink() + mis_budgets.unlink() + return res + + @api.multi + def action_view_budget_control(self): + """View all budget.control sharing same mis_budget_id.""" + self.ensure_one() + action = self.env.ref('budget_management.budget_control_action') + res = action.read()[0] + budget_controls = self.env['budget.control'].search([ + ('budget_id', '=', self.mis_budget_id.id)]) + res.update({ + 'domain': [('id', 'in', budget_controls.ids)] + }) + return res + + @api.multi + def _recompute_report_instance_periods(self): + for budget_mgnt in self: + budget_mgnt.report_instance_id.period_ids.\ + mapped('source_sumcol_ids').unlink() + budget_mgnt.report_instance_id.period_ids.unlink() + budget_mgnt._create_report_instance_period() + + @api.multi + def _create_budget_move_periods(self): + self.ensure_one() + Period = self.env['mis.report.instance.period'] + periods = {} + budget = Period.create({ + 'name': 'Budgeted', + 'report_instance_id': self.report_instance_id.id, + 'sequence': 10, + 'source': 'mis_budget', + 'source_mis_budget_id': self.mis_budget_id.id, + 'mode': 'fix', + 'manual_date_from': self.bm_date_from, + 'manual_date_to': self.bm_date_to, + }) + actual = Period.create({ + 'name': 'Actuals', + 'report_instance_id': self.report_instance_id.id, + 'sequence': 20, + 'source': 'actuals', + 'mode': 'fix', + 'manual_date_from': self.bm_date_from, + 'manual_date_to': self.bm_date_to, + }) + periods = {budget: '+', actual: '-'} + return periods + + @api.multi + def _create_report_instance_period(self): + self.ensure_one() + Period = self.env['mis.report.instance.period'] + periods = self._create_budget_move_periods() + sumcols_list = [] + for period, sign in periods.items(): + sumcols_list.append((0, 0, { + 'sign': sign, 'period_to_sum_id': period.id})) + Period.create({ + 'name': 'Available', + 'report_instance_id': self.report_instance_id.id, + 'sequence': 30, + 'source': 'sumcol', + 'source_sumcol_ids': sumcols_list, + 'mode': 'none', + }) + + @api.model + def check_budget(self, budget_moves, doc_type='account'): + """Based in input budget_moves, i.e., account_move_line + 1. Get a valid budget.management (how budget is being controlled) + 2. (1) and budget_moves, determine what account(kpi)+analytic to ctrl + 3. Prepare kpis (kpi by account_id) + 4. Get report instance as created by budget.management + 5. (2) + (3) + (4) -> kpi_matrix -> negative budget -> warnings + """ + print(self._context.get('force_no_budget_check')) + if self._context.get('force_no_budget_check'): + return + # Find active budget.management based on budget_moves date + date = set(budget_moves.mapped('date')) + if len(date) != 1: + raise ValidationError(_("Budget moves' date not unified")) + budget_mgnt = self._get_eligible_budget_mgnt(date.pop(), doc_type) + if not budget_mgnt: + return + # Find combination of account(kpi) + analytic(i.e.,project) to control + controls = self._prepare_controls(budget_mgnt, budget_moves) + if not controls: + return + # Prepare kpis by account_id + instance = budget_mgnt.report_instance_id + company = self.env.user.company_id + kpis = instance.report_id.get_kpis_by_account_id(company) + if not kpis: + return + # Check budget on each control elements against each kpi/avail(period) + warnings = self._check_budget_available(instance, controls, kpis) + if warnings: + msg = '\n'.join([_('Budget not sufficient,'), '\n'.join(warnings)]) + raise UserError(msg) + return + + @api.model + def _get_eligible_budget_mgnt(self, date, doc_type): + BudgetMgnt = self.env['budget.management'] + budget_mgnt = BudgetMgnt.search([('bm_date_from', '<=', date), + ('bm_date_to', '>=', date), + (doc_type, '=', True)]) + if budget_mgnt and len(budget_mgnt) > 1: + raise ValidationError( + _('Multiple Budget Mgnt found for date %s.\nPlease ensure ' + 'one Budget Mgnt valid for this date') % date) + return budget_mgnt + + @api.model + def _prepare_controls(self, budget_mgnt, budget_moves): + controls = set() + control_analytics = budget_mgnt.control_analytic_account_ids + for i in budget_moves: + if budget_mgnt.control_all_analytic_accounts: + if i.analytic_account_id and i.account_id: + controls.add((i.analytic_account_id.id, i.account_id.id)) + else: # Only analtyic in control + if i.analytic_account_id in control_analytics and i.account_id: + controls.add((i.analytic_account_id.id, i.account_id.id)) + return controls + + @api.model + def _prepare_matrix_by_analytic(self, instance, analytic_ids): + """Return resulting matrix based on each analytic.""" + matrix = {} + for analytic_id in analytic_ids: + if not matrix.get(analytic_id): + filter = {'analytic_account_id': {'value': analytic_id, + 'operator': '='}} + ctx = {'mis_report_filters': filter} + matrix[analytic_id] = \ + instance.with_context(ctx)._compute_matrix() + return matrix + + @api.model + def _get_kpi_value(self, kpi_matrix, kpi, period): + for row in kpi_matrix.iter_rows(): + if row.kpi == kpi: + for cell in row.iter_cells(): + if cell.subcol.col.key == period.id: + return cell.val or 0.0 + return 0.0 + + @api.model + def _check_budget_available(self, instance, controls, kpis): + warnings = [] + Account = self.env['account.account'] + Analytic = self.env['account.analytic.account'] + # Prepare result matrix for all analytic_id to be tested + analytic_ids = [x[0] for x in list(controls)] + kpi_matrix = self._prepare_matrix_by_analytic(instance, analytic_ids) + # Find period that determine budget amount available (sumcol) + period = instance.period_ids.filtered(lambda l: l.source == 'sumcol') + period.ensure_one() # Test to ensure one + for analytic_id, account_id in controls: + kpi = kpis.get(account_id, False) + if not kpi: + continue + if len(kpi) != 1: + account = Account.browse(account_id) + raise UserError( + _('KPI Template "%s" has more than one KPI being ' + 'refereced by same account code %s') % + (instance.report_id.name, account.code)) + amount = self._get_kpi_value(kpi_matrix[analytic_id], + list(kpi)[0], period) + if amount < 0: + analytic = Analytic.browse(analytic_id).display_name + warnings.append(_('On {0}, will result ' + 'in {1:,.2f}').format(analytic, amount)) + return warnings + + @api.multi + def budget_preview(self): + # Redirect to report_instance_id + return self.report_instance_id.preview() + + @api.multi + def budget_print_pdf(self): + # Redirect to report_instance_id + return self.report_instance_id.print_pdf() + + @api.multi + def budget_export_xls(self): + # Redirect to report_instance_id + return self.report_instance_id.export_xls() diff --git a/budget_management/models/mis_budget_item.py b/budget_management/models/mis_budget_item.py new file mode 100644 index 00000000..83654263 --- /dev/null +++ b/budget_management/models/mis_budget_item.py @@ -0,0 +1,27 @@ +# Copyright 2019 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import fields, models, api + + +class MisBudgetItem(models.Model): + _inherit = 'mis.budget.item' + + budget_control_id = fields.Many2one( + comodel_name='budget.control', + ondelete='cascade', + index=True, + ) + active = fields.Boolean( + compute='_compute_active', + readonly=True, + store=True, + ) + + @api.multi + @api.depends('budget_control_id.active') + def _compute_active(self): + for rec in self: + if rec.budget_control_id: + rec.active = rec.budget_control_id.active + else: + rec.active = True diff --git a/budget_management/readme/CONTRIBUTORS.rst b/budget_management/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..033e67f4 --- /dev/null +++ b/budget_management/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Kitti Upariphutthiphong diff --git a/budget_management/readme/DESCRIPTION.rst b/budget_management/readme/DESCRIPTION.rst new file mode 100644 index 00000000..e69de29b diff --git a/budget_management/security/ir.model.access.csv b/budget_management/security/ir.model.access.csv new file mode 100644 index 00000000..9fe136e4 --- /dev/null +++ b/budget_management/security/ir.model.access.csv @@ -0,0 +1,3 @@ +"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" +manage_budget_management,manage_budget_management,model_budget_management,account.group_account_manager,1,1,1,1 +manage_budget_plan,manage_budget_plan,model_budget_control,account.group_account_manager,1,1,1,1 diff --git a/budget_management/static/description/icon.png b/budget_management/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..3a0328b516c4980e8e44cdb63fd945757ddd132d GIT binary patch literal 9455 zcmW++2RxMjAAjx~&dlBk9S+%}OXg)AGE&Cb*&}d0jUxM@u(PQx^-s)697TX`ehR4?GS^qbkof1cslKgkU)h65qZ9Oc=ml_0temigYLJfnz{IDzUf>bGs4N!v3=Z3jMq&A#7%rM5eQ#dc?k~! zVpnB`o+K7|Al`Q_U;eD$B zfJtP*jH`siUq~{KE)`jP2|#TUEFGRryE2`i0**z#*^6~AI|YzIWy$Cu#CSLW3q=GA z6`?GZymC;dCPk~rBS%eCb`5OLr;RUZ;D`}um=H)BfVIq%7VhiMr)_#G0N#zrNH|__ zc+blN2UAB0=617@>_u;MPHN;P;N#YoE=)R#i$k_`UAA>WWCcEVMh~L_ zj--gtp&|K1#58Yz*AHCTMziU1Jzt_jG0I@qAOHsk$2}yTmVkBp_eHuY$A9)>P6o~I z%aQ?!(GqeQ-Y+b0I(m9pwgi(IIZZzsbMv+9w{PFtd_<_(LA~0H(xz{=FhLB@(1&qHA5EJw1>>=%q2f&^X>IQ{!GJ4e9U z&KlB)z(84HmNgm2hg2C0>WM{E(DdPr+EeU_N@57;PC2&DmGFW_9kP&%?X4}+xWi)( z;)z%wI5>D4a*5XwD)P--sPkoY(a~WBw;E~AW`Yue4kFa^LM3X`8x|}ZUeMnqr}>kH zG%WWW>3ml$Yez?i%)2pbKPI7?5o?hydokgQyZsNEr{a|mLdt;X2TX(#B1j35xPnPW z*bMSSOauW>o;*=kO8ojw91VX!qoOQb)zHJ!odWB}d+*K?#sY_jqPdg{Sm2HdYzdEx zOGVPhVRTGPtv0o}RfVP;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z~(=;5lD-aPWD3z8PZS@AaUiomF!G8I}Mf>e~0g#BelA-5#`cj;O5>N Xviia!U7SGha1wx#SCgwmn*{w2TRX*I literal 0 HcmV?d00001 diff --git a/budget_management/tests/__init__.py b/budget_management/tests/__init__.py new file mode 100644 index 00000000..53a5a702 --- /dev/null +++ b/budget_management/tests/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2019 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import test_budget_management diff --git a/budget_management/tests/test_budget_management.py b/budget_management/tests/test_budget_management.py new file mode 100644 index 00000000..02625453 --- /dev/null +++ b/budget_management/tests/test_budget_management.py @@ -0,0 +1,161 @@ +# Copyright 2019 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +import datetime +from dateutil.rrule import MONTHLY +from odoo.tests.common import TransactionCase +from odoo.tests.common import Form +from odoo.exceptions import UserError + + +class TestMisBudget(TransactionCase): + + def setUp(self): + super(TestMisBudget, self).setUp() + self.year = datetime.datetime.now().year + RangeType = self.env['date.range.type'] + Analytic = self.env['account.analytic.account'] + BudgetControl = self.env['budget.control'] + # Create quarterly date range for current year + self.date_range_type = RangeType.create({'name': 'TestQuarter'}) + self._create_date_range_quarter() + # Create budget kpi + self.report = self._create_mis_report_kpi() + # Create budget.management for current year + self.budget_mgnt = self._create_budget_mgnt_fy(self.report.id) + # Create budget.control for CostCenter1, + # by selected budget_id and date range (by quarter) + self.costcenter1 = Analytic.create({'name': 'CostCenter1'}) + self.budget_control = BudgetControl.create({ + 'name': 'CostCenter1/%s', + 'budget_id': self.budget_mgnt.mis_budget_id.id, + 'analytic_account_id': self.costcenter1.id, + 'plan_date_range_type_id': self.date_range_type.id}) + # Test item created for 3 kpi x 4 quarters = 12 budget items + self.assertEquals(len(self.budget_control.item_ids), 12) + # Assign budget.control amount: KPI1 = 100x4=400, KPI2=800, KPI3=1,200 + self.budget_control.item_ids.filtered( + lambda l: l.kpi_expression_id == self.kpi1.expression_ids[0]).\ + write({'amount': 100}) + self.budget_control.item_ids.filtered( + lambda l: l.kpi_expression_id == self.kpi2.expression_ids[0]).\ + write({'amount': 200}) + self.budget_control.item_ids.filtered( + lambda l: l.kpi_expression_id == self.kpi3.expression_ids[0]).\ + write({'amount': 300}) + # Assign product to purchase using KPI1, KPI2, KPI3 account codes + self.product_kpi1 = self.env.ref('product.product_product_6') + self.product_kpi1.property_account_expense_id = self.account_kpi1 + self.product_kpi2 = self.env.ref('product.product_product_7') + self.product_kpi2.property_account_expense_id = self.account_kpi2 + self.product_kpi3 = self.env.ref('product.product_product_8') + self.product_kpi3.property_account_expense_id = self.account_kpi3 + # Vendor + self.vendor = self.env.ref('base.res_partner_12') + + def _create_date_range_quarter(self): + Generator = self.env['date.range.generator'] + generator = Generator.create({ + 'date_start': '%s-01-01' % self.year, + 'name_prefix': '%s/Test/Q-' % self.year, + 'type_id': self.date_range_type.id, + 'duration_count': 3, + 'unit_of_time': MONTHLY, + 'count': 4}) + generator.action_apply() + + def _create_mis_report_kpi(self): + Account = self.env['account.account'] + type_exp = self.env.ref('account.data_account_type_expenses').id + self.account_kpi1 = Account.create({'name': 'KPI1', 'code': 'KPI1', + 'user_type_id': type_exp}) + self.account_kpi2 = Account.create({'name': 'KPI2', 'code': 'KPI2', + 'user_type_id': type_exp}) + self.account_kpi3 = Account.create({'name': 'KPI3', 'code': 'KPI3', + 'user_type_id': type_exp}) + # create report + report = self.env['mis.report'].create(dict( + name='Test KPI', + )) + self.kpi1 = self.env['mis.report.kpi'].create(dict( + report_id=report.id, name='kpi1', budgetable=True, + description='kpi 1', expression='balp[KPI1]', + )) + self.kpi2 = self.env['mis.report.kpi'].create(dict( + report_id=report.id, name='kpi2', budgetable=True, + description='kpi 2', expression='balp[KPI2]', + )) + self.kpi3 = self.env['mis.report.kpi'].create(dict( + report_id=report.id, name='kpi3', budgetable=True, + description='kpi 3', expression='balp[KPI3]', + )) + return report + + def _create_budget_mgnt_fy(self, report_id): + BudgetMgnt = self.env['budget.management'] + budget_bgmt = BudgetMgnt.create({ + 'name': 'Budget for FY%s' % self.year, + 'report_id': report_id, + 'bm_date_from': '%s-01-01' % self.year, + 'bm_date_to': '%s-12-31' % self.year}) + return budget_bgmt + + def _create_invoice(self, inv_type, vendor, analytic, invoice_lines=[]): + Invoice = self.env['account.invoice'] + with Form(Invoice.with_context(type=inv_type), + view='account.invoice_supplier_form') as inv: + inv.partner_id = vendor + for invoice_line in invoice_lines: + with inv.invoice_line_ids.new() as line: + line.quantity = 1 + line.product_id = invoice_line.get('product') + line.price_unit = invoice_line.get('price_unit') + line.account_analytic_id = analytic + invoice = inv.save() + return invoice + + def test_vendor_blll_budget_check(self): + """If budget.management is set to check budget, KPI1=400.0 allocated + - First 400.0 will used all budget allocated + - Second 1.0 will make it exceed""" + # Check budget + self.budget_mgnt.account = True + bill1 = self._create_invoice('in_invoice', self.vendor, + self.costcenter1, + [{'product': self.product_kpi1, + 'price_unit': 400.0}]) # Equal budget + bill1.action_invoice_open() + # 1.0 amount will exceed the budget, and throw error + bill2 = self._create_invoice('in_invoice', self.vendor, + self.costcenter1, + [{'product': self.product_kpi1, + 'price_unit': 1.0}]) + with self.assertRaises(UserError): + bill2.action_invoice_open() + + def test_vendor_blll_no_budget_check(self): + """If budget.management is not set to check budget, no budget check""" + # No budget check + self.budget_mgnt.account = False + bill1 = self._create_invoice('in_invoice', self.vendor, + self.costcenter1, + [{'product': self.product_kpi1, + 'price_unit': 100000.0}]) # big amount + bill1.action_invoice_open() + + def test_refund_budget_check(self): + """For refund, always not checking""" + # First, make budget actual to exceed budget first + self.budget_mgnt.account = False # No budget check first + bill1 = self._create_invoice('in_invoice', self.vendor, + self.costcenter1, + [{'product': self.product_kpi1, + 'price_unit': 100000.0}]) # big amount + bill1.action_invoice_open() + # Check budget, for in_refund, force no budget check + self.budget_mgnt.account = True + invoice = self._create_invoice('in_refund', self.vendor, + self.costcenter1, + [{'product': self.product_kpi1, + 'price_unit': 100.0}]) + invoice.action_invoice_open() diff --git a/budget_management/views/budget_control_view.xml b/budget_management/views/budget_control_view.xml new file mode 100644 index 00000000..b34eac02 --- /dev/null +++ b/budget_management/views/budget_control_view.xml @@ -0,0 +1,98 @@ + + + + + mis.budget.item.tree.view.readonly + mis.budget.item + + + + + + + + + + + + + + MIS Budget Items + mis.budget.item + tree,form + [('budget_control_id', '=', active_id)] + + + + + budget.control.view.tree + budget.control + + + + + + + + + + + + budget.control.view.form + budget.control + +
+ +
+
+
+
+ + + + + + + + + + + + + + +
+
+ +
+
+
+
+
+
+ + + Budget Control Sheet + + budget.control + form + tree,form + {'active_test': False} + + + + +
diff --git a/budget_management/views/budget_management_view.xml b/budget_management/views/budget_management_view.xml new file mode 100644 index 00000000..917fd3a4 --- /dev/null +++ b/budget_management/views/budget_management_view.xml @@ -0,0 +1,75 @@ + + + + + budget.management.view.tree + budget.management + + + + + + + + + + + budget.management.view.form + budget.management + +
+ +
+
+
+
+
+

+ +

+
+ + + + + + + + + + + + + + + + + + + +
+
+
+
+ + + Budget Management + + budget.management + form + tree,form + + + + + + + +
diff --git a/budget_management_expense/__init__.py b/budget_management_expense/__init__.py new file mode 100644 index 00000000..2452acf9 --- /dev/null +++ b/budget_management_expense/__init__.py @@ -0,0 +1,3 @@ +# Copyright 2019 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from . import models diff --git a/budget_management_expense/__manifest__.py b/budget_management_expense/__manifest__.py new file mode 100644 index 00000000..0cc8e64d --- /dev/null +++ b/budget_management_expense/__manifest__.py @@ -0,0 +1,22 @@ +# Copyright 2019 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + 'name': 'Budget Management on Expense', + 'version': '12.0.1.0.0', + 'license': 'AGPL-3', + 'author': 'Ecosoft,Odoo Community Association (OCA)', + 'website': 'https://github.com/OCA/account-budgeting', + 'depends': [ + 'budget_management', + 'hr_expense', + ], + 'data': [ + 'security/ir.model.access.csv', + 'views/budget_management_view.xml', + 'views/hr_expense_view.xml', + ], + 'installable': True, + 'maintainers': ['kittiu'], + 'development_status': 'Beta', +} diff --git a/budget_management_expense/models/__init__.py b/budget_management_expense/models/__init__.py new file mode 100644 index 00000000..6c5e232d --- /dev/null +++ b/budget_management_expense/models/__init__.py @@ -0,0 +1,5 @@ +# Copyright 2019 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from . import budget_management +from . import expense_budget_move +from . import hr_expense diff --git a/budget_management_expense/models/budget_management.py b/budget_management_expense/models/budget_management.py new file mode 100644 index 00000000..a8a66303 --- /dev/null +++ b/budget_management_expense/models/budget_management.py @@ -0,0 +1,33 @@ +# Copyright 2019 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import fields, models, api + + +class BudgetManagement(models.Model): + _inherit = 'budget.management' + + expense = fields.Boolean( + string='On Expense', + default=False, + help="Control budget on expense approved", + ) + + @api.multi + def _create_budget_move_periods(self): + periods = super()._create_budget_move_periods() + if self.expense: + Period = self.env['mis.report.instance.period'] + model = self.env.ref('budget_management_expense.' + 'model_expense_budget_move') + expense = Period.create({ + 'name': 'Expense Committed', + 'report_instance_id': self.report_instance_id.id, + 'sequence': 16, + 'source': 'actuals_alt', + 'source_aml_model_id': model.id, + 'mode': 'fix', + 'manual_date_from': self.bm_date_from, + 'manual_date_to': self.bm_date_to, + }) + periods.update({expense: '-'}) + return periods diff --git a/budget_management_expense/models/expense_budget_move.py b/budget_management_expense/models/expense_budget_move.py new file mode 100644 index 00000000..5dc58240 --- /dev/null +++ b/budget_management_expense/models/expense_budget_move.py @@ -0,0 +1,58 @@ +# Copyright 2019 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import fields, models + + +class ExpenseBudgetMove(models.Model): + + _name = 'expense.budget.move' + _description = 'Expense Budget Moves' + + sheet_id = fields.Many2one( + comodel_name='hr.expense.sheet', + related='expense_id.sheet_id', + readonly=True, + store=True, + index=True, + ) + expense_id = fields.Many2one( + comodel_name='hr.expense', + readonly=True, + index=True, + help="Commit budget for this expense_id", + ) + date = fields.Date( + required=True, + index=True, + ) + account_id = fields.Many2one( + comodel_name='account.account', + string='Account', + auto_join=True, + index=True, + readonly=True, + ) + analytic_account_id = fields.Many2one( + comodel_name='account.analytic.account', + string='Analytic Account', + auto_join=True, + index=True, + readonly=True, + ) + amount_currency = fields.Float( + required=True, + help="Amount in multi currency", + ) + credit = fields.Float( + readonly=True, + ) + debit = fields.Float( + readonly=True, + ) + company_id = fields.Many2one( + 'res.company', + string='Company', + required=True, + default=lambda self: self.env.user.company_id.id, + index=True, + ) diff --git a/budget_management_expense/models/hr_expense.py b/budget_management_expense/models/hr_expense.py new file mode 100644 index 00000000..2458e26d --- /dev/null +++ b/budget_management_expense/models/hr_expense.py @@ -0,0 +1,84 @@ +# Copyright 2019 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import fields, models, api + + +class HRExpenseSheet(models.Model): + _inherit = 'hr.expense.sheet' + + budget_move_ids = fields.One2many( + comodel_name='expense.budget.move', + inverse_name='sheet_id', + ) + + @api.multi + def recompute_budget_commit(self): + self.mapped('expense_line_ids').recompute_budget_commit() + + @api.multi + def _write(self, vals): + """ + - Commit budget when state approved + - Cancel/Draft document should delete all budget commitment + """ + res = super()._write(vals) + if vals.get('state') in ('approve', 'cancel', 'draft'): + print(self.mapped('expense_line_ids')) + self.mapped('expense_line_ids').commit_budget() + elif vals.get('state') == 'post': + self.mapped('expense_line_ids').uncommit_expense_budget() + return res + + @api.multi + def approve_expense_sheets(self): + res = super().approve_expense_sheets() + BudgetManagement = self.env['budget.management'] + for doc in self: + BudgetManagement.check_budget(doc.budget_move_ids, + doc_type='expense') + return res + + +class HRExpense(models.Model): + _inherit = 'hr.expense' + + budget_move_ids = fields.One2many( + comodel_name='expense.budget.move', + inverse_name='expense_id', + ) + + @api.multi + def recompute_budget_commit(self): + self.mapped('budget_move_ids').unlink() + self.commit_budget() + self.uncommit_expense_budget() + + @api.multi + def commit_budget(self, reverse=False): + """Create budget commit for each expense.""" + for expense in self: + if expense.state in ('approved', 'done'): + company = self.env.user.company_id + amount = expense.currency_id._convert( + expense.untaxed_amount, company.currency_id, + company, expense.date) + self.env['expense.budget.move'].create({ + 'expense_id': expense.id, + 'account_id': expense.account_id.id, + 'analytic_account_id': expense.analytic_account_id.id, + 'date': expense.date, + 'amount_currency': expense.untaxed_amount, + 'debit': not reverse and amount or 0.0, + 'credit': reverse and amount or 0.0, + 'company_id': company.id, + }) + else: + expense.budget_move_ids.unlink() + + @api.multi + def uncommit_expense_budget(self): + """For vendor bill in valid state, do uncommit for related expense.""" + for expense in self: + if expense.sheet_id.state in ('post', 'done') and \ + expense.state in ('approved', 'done'): + expense.commit_budget(reverse=True) diff --git a/budget_management_expense/readme/CONTRIBUTORS.rst b/budget_management_expense/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..033e67f4 --- /dev/null +++ b/budget_management_expense/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Kitti Upariphutthiphong diff --git a/budget_management_expense/readme/DESCRIPTION.rst b/budget_management_expense/readme/DESCRIPTION.rst new file mode 100644 index 00000000..3b4b1af4 --- /dev/null +++ b/budget_management_expense/readme/DESCRIPTION.rst @@ -0,0 +1,6 @@ +This module will create budget commitment for expense (to be used as alternate actual source in mis_builder) + +When expense report is approved, hr_expense.budget.commit is created, and when +journal entry is posted, reversed hr_expense.budget.commit is created. + +A new tab "Budget Commitment" is created on expense report for budget user to keep track of the committed budget. diff --git a/budget_management_expense/security/ir.model.access.csv b/budget_management_expense/security/ir.model.access.csv new file mode 100644 index 00000000..fab59322 --- /dev/null +++ b/budget_management_expense/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_expense_budget_move_user,access_expense_budget_move_user,model_expense_budget_move,,1,1,1,1 diff --git a/budget_management_expense/static/description/icon.png b/budget_management_expense/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..3a0328b516c4980e8e44cdb63fd945757ddd132d GIT binary patch literal 9455 zcmW++2RxMjAAjx~&dlBk9S+%}OXg)AGE&Cb*&}d0jUxM@u(PQx^-s)697TX`ehR4?GS^qbkof1cslKgkU)h65qZ9Oc=ml_0temigYLJfnz{IDzUf>bGs4N!v3=Z3jMq&A#7%rM5eQ#dc?k~! zVpnB`o+K7|Al`Q_U;eD$B zfJtP*jH`siUq~{KE)`jP2|#TUEFGRryE2`i0**z#*^6~AI|YzIWy$Cu#CSLW3q=GA z6`?GZymC;dCPk~rBS%eCb`5OLr;RUZ;D`}um=H)BfVIq%7VhiMr)_#G0N#zrNH|__ zc+blN2UAB0=617@>_u;MPHN;P;N#YoE=)R#i$k_`UAA>WWCcEVMh~L_ zj--gtp&|K1#58Yz*AHCTMziU1Jzt_jG0I@qAOHsk$2}yTmVkBp_eHuY$A9)>P6o~I z%aQ?!(GqeQ-Y+b0I(m9pwgi(IIZZzsbMv+9w{PFtd_<_(LA~0H(xz{=FhLB@(1&qHA5EJw1>>=%q2f&^X>IQ{!GJ4e9U z&KlB)z(84HmNgm2hg2C0>WM{E(DdPr+EeU_N@57;PC2&DmGFW_9kP&%?X4}+xWi)( z;)z%wI5>D4a*5XwD)P--sPkoY(a~WBw;E~AW`Yue4kFa^LM3X`8x|}ZUeMnqr}>kH zG%WWW>3ml$Yez?i%)2pbKPI7?5o?hydokgQyZsNEr{a|mLdt;X2TX(#B1j35xPnPW z*bMSSOauW>o;*=kO8ojw91VX!qoOQb)zHJ!odWB}d+*K?#sY_jqPdg{Sm2HdYzdEx zOGVPhVRTGPtv0o}RfVP;Nd(|CB)I;*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WD3z8PZS@AaUiomF!G8I}Mf>e~0g#BelA-5#`cj;O5>N Xviia!U7SGha1wx#SCgwmn*{w2TRX*I literal 0 HcmV?d00001 diff --git a/budget_management_expense/views/budget_management_view.xml b/budget_management_expense/views/budget_management_view.xml new file mode 100644 index 00000000..060c676e --- /dev/null +++ b/budget_management_expense/views/budget_management_view.xml @@ -0,0 +1,15 @@ + + + + + budget.management.view.form + budget.management + + + + + + + + + diff --git a/budget_management_expense/views/hr_expense_view.xml b/budget_management_expense/views/hr_expense_view.xml new file mode 100644 index 00000000..97c05c7d --- /dev/null +++ b/budget_management_expense/views/hr_expense_view.xml @@ -0,0 +1,28 @@ + + + + + view.hr.expense.sheet.form + hr.expense.sheet + + + + +
+
+ + + + + + + + + +
+
+
+
+ +
diff --git a/budget_management_purchase/__init__.py b/budget_management_purchase/__init__.py new file mode 100644 index 00000000..2452acf9 --- /dev/null +++ b/budget_management_purchase/__init__.py @@ -0,0 +1,3 @@ +# Copyright 2019 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from . import models diff --git a/budget_management_purchase/__manifest__.py b/budget_management_purchase/__manifest__.py new file mode 100644 index 00000000..39faf2f9 --- /dev/null +++ b/budget_management_purchase/__manifest__.py @@ -0,0 +1,22 @@ +# Copyright 2019 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + 'name': 'Budget Management on Purchase', + 'version': '12.0.1.0.0', + 'license': 'AGPL-3', + 'author': 'Ecosoft,Odoo Community Association (OCA)', + 'website': 'https://github.com/OCA/account-budgeting', + 'depends': [ + 'budget_management', + 'purchase', + ], + 'data': [ + 'security/ir.model.access.csv', + 'views/budget_management_view.xml', + 'views/purchase_view.xml', + ], + 'installable': True, + 'maintainers': ['kittiu'], + 'development_status': 'Beta', +} diff --git a/budget_management_purchase/models/__init__.py b/budget_management_purchase/models/__init__.py new file mode 100644 index 00000000..c7fbb296 --- /dev/null +++ b/budget_management_purchase/models/__init__.py @@ -0,0 +1,6 @@ +# Copyright 2019 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from . import budget_management +from . import purchase_budget_move +from . import purchase +from . import account_invoice diff --git a/budget_management_purchase/models/account_invoice.py b/budget_management_purchase/models/account_invoice.py new file mode 100644 index 00000000..bc4a74ca --- /dev/null +++ b/budget_management_purchase/models/account_invoice.py @@ -0,0 +1,45 @@ +# Copyright 2019 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import models, api + + +class AccountInvoice(models.Model): + _inherit = 'account.invoice' + + @api.multi + def _write(self, vals): + """Uncommit budget for source purchase document.""" + res = super()._write(vals) + if vals.get('state') in ('open', 'cancel'): + self.mapped('invoice_line_ids').uncommit_purchase_budget() + return res + + +class AccountInvoiceLine(models.Model): + _inherit = 'account.invoice.line' + + @api.multi + def uncommit_purchase_budget(self): + """For vendor bill in valid state, do uncommit for related purchase.""" + for inv_line in self: + inv_state = inv_line.invoice_id.state + inv_type = inv_line.invoice_id.type + if inv_type in ('in_invoice', 'in_refund'): + if inv_state in ('open', 'in_payment', 'paid'): + rev = inv_type == 'in_invoice' and True or False + purchase_line = inv_line.purchase_line_id + if not purchase_line: + continue + qty = inv_line.uom_id._compute_quantity( + inv_line.quantity, purchase_line.product_uom) + # Confirm vendor bill, do uncommit budget) + qty_bf_invoice = purchase_line.qty_invoiced - qty + qty_balance = purchase_line.product_qty - qty_bf_invoice + qty = qty > qty_balance and qty_balance or qty + if qty <= 0: + continue + purchase_line.commit_budget( + qty, reverse=rev, invoice_line_id=inv_line.id) + else: # Cancel or draft, not commitment line + self.env['purchase.budget.move'].search( + [('invoice_line_id', '=', inv_line.id)]).unlink() diff --git a/budget_management_purchase/models/budget_management.py b/budget_management_purchase/models/budget_management.py new file mode 100644 index 00000000..d9295cce --- /dev/null +++ b/budget_management_purchase/models/budget_management.py @@ -0,0 +1,33 @@ +# Copyright 2019 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import fields, models, api + + +class BudgetManagement(models.Model): + _inherit = 'budget.management' + + purchase = fields.Boolean( + string='On Purchase', + default=False, + help="Control budget on purchase order confirmation", + ) + + @api.multi + def _create_budget_move_periods(self): + periods = super()._create_budget_move_periods() + if self.purchase: + Period = self.env['mis.report.instance.period'] + model = self.env.ref('budget_management_purchase.' + 'model_purchase_budget_move') + purchase = Period.create({ + 'name': 'Purchase Committed', + 'report_instance_id': self.report_instance_id.id, + 'sequence': 12, + 'source': 'actuals_alt', + 'source_aml_model_id': model.id, + 'mode': 'fix', + 'manual_date_from': self.bm_date_from, + 'manual_date_to': self.bm_date_to, + }) + periods.update({purchase: '-'}) + return periods diff --git a/budget_management_purchase/models/purchase.py b/budget_management_purchase/models/purchase.py new file mode 100644 index 00000000..fcf35939 --- /dev/null +++ b/budget_management_purchase/models/purchase.py @@ -0,0 +1,87 @@ +# Copyright 2019 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import fields, models, api + + +class PurchaseOrder(models.Model): + _inherit = 'purchase.order' + + budget_move_ids = fields.One2many( + comodel_name='purchase.budget.move', + inverse_name='purchase_id', + string='Purchase Budget Moves', + ) + + @api.multi + def recompute_budget_move(self): + self.mapped('order_line').recompute_budget_move() + + @api.multi + def _write(self, vals): + """ + - Commit budget when state changes to purchase + - Cancel/Draft document should delete all budget commitment + """ + res = super()._write(vals) + if vals.get('state') in ('purchase', 'cancel', 'draft'): + for purchase_line in self.mapped('order_line'): + purchase_line.commit_budget() + return res + + @api.multi + def button_confirm(self): + res = super().button_confirm() + BudgetManagement = self.env['budget.management'] + for doc in self: + BudgetManagement.check_budget(doc.budget_move_ids, + doc_type='purchase') + return res + + +class PurchaseOrderLine(models.Model): + _inherit = 'purchase.order.line' + + budget_move_ids = fields.One2many( + comodel_name='purchase.budget.move', + inverse_name='purchase_line_id', + string='Purchase Budget Moves', + ) + + @api.multi + def recompute_budget_move(self): + for purchase_line in self: + purchase_line.budget_move_ids.unlink() + # Commit on purchase order + purchase_line.commit_budget() + # Uncommitted on invoice confirm + purchase_line.invoice_lines.uncommit_purchase_budget() + + @api.multi + def commit_budget(self, product_qty=False, + reverse=False, invoice_line_id=False): + """Create budget commit for each purchase.order.line.""" + self.ensure_one() + if self.state in ('purchase', 'done'): + if not product_qty: + product_qty = self.product_qty + fpos = self.order_id.fiscal_position_id + account = self.product_id.product_tmpl_id.\ + get_product_accounts(fpos)['expense'] + company = self.env.user.company_id + amount_currency = product_qty * self.price_unit + date_order = self.order_id.date_order + amount = self.currency_id._convert( + amount_currency, company.currency_id, company, date_order) + self.env['purchase.budget.move'].create({ + 'purchase_line_id': self.id, + 'account_id': account.id, + 'analytic_account_id': self.account_analytic_id.id, + 'date': date_order, + 'amount_currency': amount_currency, + 'debit': not reverse and amount or 0.0, + 'credit': reverse and amount or 0.0, + 'company_id': company.id, + 'invoice_line_id': invoice_line_id, + }) + else: + self.budget_move_ids.unlink() diff --git a/budget_management_purchase/models/purchase_budget_move.py b/budget_management_purchase/models/purchase_budget_move.py new file mode 100644 index 00000000..d24b2066 --- /dev/null +++ b/budget_management_purchase/models/purchase_budget_move.py @@ -0,0 +1,68 @@ +# Copyright 2019 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import fields, models + + +class PurchaseBudgetMove(models.Model): + + _name = 'purchase.budget.move' + _description = 'Purchase Budget Moves' + + purchase_id = fields.Many2one( + comodel_name='purchase.order', + related='purchase_line_id.order_id', + readonly=True, + store=True, + index=True, + ) + purchase_line_id = fields.Many2one( + comodel_name='purchase.order.line', + readonly=True, + index=True, + help="Commit budget for this purchase_line_id", + ) + invoice_id = fields.Many2one( + comodel_name='account.invoice', + related='invoice_line_id.invoice_id', + ) + invoice_line_id = fields.Many2one( + comodel_name='account.invoice.line', + readonly=True, + index=True, + help="Uncommit budget from this invoice_line_id", + ) + date = fields.Date( + required=True, + index=True, + ) + account_id = fields.Many2one( + comodel_name='account.account', + string='Account', + auto_join=True, + index=True, + readonly=True, + ) + analytic_account_id = fields.Many2one( + comodel_name='account.analytic.account', + string='Analytic account', + auto_join=True, + index=True, + readonly=True, + ) + amount_currency = fields.Float( + required=True, + help="Amount in multi currency", + ) + credit = fields.Float( + readonly=True, + ) + debit = fields.Float( + readonly=True, + ) + company_id = fields.Many2one( + 'res.company', + string='Company', + required=True, + default=lambda self: self.env.user.company_id.id, + index=True, + ) diff --git a/budget_management_purchase/readme/CONTRIBUTORS.rst b/budget_management_purchase/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..033e67f4 --- /dev/null +++ b/budget_management_purchase/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Kitti Upariphutthiphong diff --git a/budget_management_purchase/readme/DESCRIPTION.rst b/budget_management_purchase/readme/DESCRIPTION.rst new file mode 100644 index 00000000..37211c10 --- /dev/null +++ b/budget_management_purchase/readme/DESCRIPTION.rst @@ -0,0 +1,6 @@ +This module will create budget commitment for purchase (to be used as alternate actual source in mis_builder) + +When purchase order is confirmed, purchase.budget.commit is created, and when +vendor billed is confirmed, reversed purchase.budget.commit is created. + +A new tab "Budget Commitment" is created on purchase order for budget user to keep track of the committed budget. diff --git a/budget_management_purchase/security/ir.model.access.csv b/budget_management_purchase/security/ir.model.access.csv new file mode 100644 index 00000000..db9d1103 --- /dev/null +++ b/budget_management_purchase/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_purchase_budget_move_user,access_purchase_budget_move_user,model_purchase_budget_move,,1,1,1,1 diff --git a/budget_management_purchase/static/description/icon.png b/budget_management_purchase/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..3a0328b516c4980e8e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=>Ig-$ zbW26Ws~IgY>}^5w`vTB(G`PTZaDiGBo5o(tp)qli|NeV( z@H_=R8V39rt5J5YB2Ky?4eJJ#b`_iBe2ot~6%7mLt5t8Vwi^Jy7|jWXqa3amOIoRb zOr}WVFP--DsS`1WpN%~)t3R!arKF^Q$e12KEqU36AWwnCBICpH4XCsfnyrHr>$I$4 z!DpKX$OKLWarN7nv@!uIA+~RNO)l$$w}p(;b>mx8pwYvu;dD_unryX_NhT8*Tj>BTrTTL&!?O+%Rv;b?B??gSzdp?6Uug9{ zd@V08Z$BdI?fpoCS$)t4mg4rT8Q_I}h`0d-vYZ^|dOB*Q^S|xqTV*vIg?@fVFSmMpaw0qtTRbx} z({Pg?#{2`sc9)M5N$*N|4;^t$+QP?#mov zGVC@I*lBVrOU-%2y!7%)fAKjpEFsgQc4{amtiHb95KQEwvf<(3T<9-Zm$xIew#P22 zc2Ix|App^>v6(3L_MCU0d3W##AB0M~3D00EWoKZqsJYT(#@w$Y_H7G22M~ApVFTRHMI_3be)Lkn#0F*V8Pq zc}`Cjy$bE;FJ6H7p=0y#R>`}-m4(0F>%@P|?7fx{=R^uFdISRnZ2W_xQhD{YuR3t< z{6yxu=4~JkeA;|(J6_nv#>Nvs&FuLA&PW^he@t(UwFFE8)|a!R{`E`K`i^ZnyE4$k z;(749Ix|oi$c3QbEJ3b~D_kQsPz~fIUKym($a_7dJ?o+40*OLl^{=&oq$<#Q(yyrp z{J-FAniyAw9tPbe&IhQ|a`DqFTVQGQ&Gq3!C2==4x{6EJwiPZ8zub-iXoUtkJiG{} zPaR&}_fn8_z~(=;5lD-aPWD3z8PZS@AaUiomF!G8I}Mf>e~0g#BelA-5#`cj;O5>N Xviia!U7SGha1wx#SCgwmn*{w2TRX*I literal 0 HcmV?d00001 diff --git a/budget_management_purchase/views/budget_management_view.xml b/budget_management_purchase/views/budget_management_view.xml new file mode 100644 index 00000000..de094787 --- /dev/null +++ b/budget_management_purchase/views/budget_management_view.xml @@ -0,0 +1,15 @@ + + + + + budget.management.view.form + budget.management + + + + + + + + + diff --git a/budget_management_purchase/views/purchase_view.xml b/budget_management_purchase/views/purchase_view.xml new file mode 100644 index 00000000..7db386ff --- /dev/null +++ b/budget_management_purchase/views/purchase_view.xml @@ -0,0 +1,29 @@ + + + + + purchase.order.form + purchase.order + + + + +
+
+ + + + + + + + + + +
+
+
+
+ +