Browse Source

Jun 30 : [UPDT] Updated 'base_account_budget'

pull/280/head
AjmalCybro 2 years ago
parent
commit
14d56e3b46
  1. 17
      base_account_budget/README.rst
  2. 2
      base_account_budget/__manifest__.py
  3. 8
      base_account_budget/doc/RELEASE_NOTES.md
  4. 1
      base_account_budget/models/__init__.py
  5. 3
      base_account_budget/models/account_analytic_account.py
  6. 81
      base_account_budget/models/account_budget.py
  7. BIN
      base_account_budget/static/description/assets/icons/logo.png
  8. 18
      base_account_budget/static/description/index.html

17
base_account_budget/README.rst

@ -1,5 +1,9 @@
Odoo 15 Budgets Management
==========================
.. image:: https://img.shields.io/badge/licence-LGPL--3-green.svg
:target: https://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
Odoo 15 Budget Management
=========================
* Budgets Management system for Odoo 15 Community edition
Installation
@ -10,7 +14,7 @@ Installation
License
-------
General Public License, Version 3 (LGPL v3).
(https://www.odoo.com/documentation/user/13.0/legal/licenses/licenses.html)
(https://www.gnu.org/licenses/lgpl-3.0-standalone.html)
Company
-------
@ -33,12 +37,13 @@ Bugs are tracked on GitHub Issues. In case of trouble, please check there if you
Maintainer
==========
.. image:: https://cybrosys.com/images/logo.png
:target: https://cybrosys.com
This module is maintained by Cybrosys Technologies.
For support and more information, please visit https://www.cybrosys.com
Further information
===================
HTML Description: `<static/description
/index.html>`__
HTML Description: `<static/description/index.html>`__

2
base_account_budget/__manifest__.py

@ -21,7 +21,7 @@
#############################################################################
{
'name': 'Odoo 15 Budget Management',
'version': '15.0.1.1.0',
'version': '15.0.1.1.1',
'summary': """ Budget Management for Odoo 15 Community Edition. """,
'description': """ This module allows accountants to manage analytic and budgets.

8
base_account_budget/doc/RELEASE_NOTES.md

@ -1,7 +1,11 @@
## Module <kit_account_budget>
## Module <base_account_budget>
#### 06.10.2021
#### Version 15.0.1.0.0
#### ADD
- Initial commit for base_account_budget
- Initial commit for Odoo 15 Budget Management
#### 27.06.2023
#### Version 15.0.1.1.1
#### REF
- Refactor code and remove unused files

1
base_account_budget/models/__init__.py

@ -19,6 +19,5 @@
# If not, see <http://www.gnu.org/licenses/>.
#
#############################################################################
from . import account_budget
from . import account_analytic_account

3
base_account_budget/models/account_analytic_account.py

@ -25,4 +25,5 @@ from odoo import fields, models
class AccountAnalyticAccount(models.Model):
_inherit = "account.analytic.account"
budget_line = fields.One2many('budget.lines', 'analytic_account_id', 'Budget Lines')
budget_line = fields.One2many('budget.lines', 'analytic_account_id',
string='Budget Lines')

81
base_account_budget/models/account_budget.py

@ -19,7 +19,6 @@
# If not, see <http://www.gnu.org/licenses/>.
#
#############################################################################
from odoo import api, fields, models, _
from odoo.exceptions import ValidationError
@ -30,10 +29,13 @@ class AccountBudgetPost(models.Model):
_description = "Budgetary Position"
name = fields.Char('Name', required=True)
account_ids = fields.Many2many('account.account', 'account_budget_rel', 'budget_id', 'account_id', 'Accounts',
domain=[('deprecated', '=', False)])
budget_line = fields.One2many('budget.lines', 'general_budget_id', 'Budget Lines')
company_id = fields.Many2one('res.company', 'Company', required=True,
account_ids = fields.Many2many(
'account.account', 'account_budget_rel', 'budget_id', 'account_id',
string='Accounts', domain=[('deprecated', '=', False)])
budget_line = fields.One2many('budget.lines', 'general_budget_id',
string='Budget Lines')
company_id = fields.Many2one(
'res.company', string='Company', required=True,
default=lambda self: self.env['res.company']._company_default_get(
'account.budget.post'))
@ -43,7 +45,8 @@ class AccountBudgetPost(models.Model):
else:
account_ids = self.account_ids
if not account_ids:
raise ValidationError(_('The budget must have at least one account.'))
raise ValidationError(
_('The budget must have at least one account.'))
@api.model
def create(self, vals):
@ -60,20 +63,27 @@ class Budget(models.Model):
_description = "Budget"
_inherit = ['mail.thread']
name = fields.Char('Budget Name', required=True, states={'done': [('readonly', True)]})
creating_user_id = fields.Many2one('res.users', 'Responsible', default=lambda self: self.env.user)
date_from = fields.Date('Start Date', required=True, states={'done': [('readonly', True)]})
date_to = fields.Date('End Date', required=True, states={'done': [('readonly', True)]})
name = fields.Char(
'Budget Name', required=True, states={'done': [('readonly', True)]})
creating_user_id = fields.Many2one(
'res.users', 'Responsible', default=lambda self: self.env.user)
date_from = fields.Date(
'Start Date', required=True, states={'done': [('readonly', True)]})
date_to = fields.Date(
'End Date', required=True, states={'done': [('readonly', True)]})
state = fields.Selection([
('draft', 'Draft'),
('cancel', 'Cancelled'),
('confirm', 'Confirmed'),
('validate', 'Validated'),
('done', 'Done')
], 'Status', default='draft', index=True, required=True, readonly=True, copy=False, track_visibility='always')
budget_line = fields.One2many('budget.lines', 'budget_id', 'Budget Lines',
], 'Status', default='draft', index=True, required=True, readonly=True,
copy=False, track_visibility='always')
budget_line = fields.One2many(
'budget.lines', 'budget_id', 'Budget Lines',
states={'done': [('readonly', True)]}, copy=True)
company_id = fields.Many2one('res.company', 'Company', required=True,
company_id = fields.Many2one(
'res.company', 'Company', required=True,
default=lambda self: self.env['res.company']._company_default_get(
'account.budget.post'))
@ -98,17 +108,25 @@ class BudgetLines(models.Model):
_rec_name = "budget_id"
_description = "Budget Line"
budget_id = fields.Many2one('budget.budget', 'Budget', ondelete='cascade', index=True, required=True)
analytic_account_id = fields.Many2one('account.analytic.account', 'Analytic Account')
general_budget_id = fields.Many2one('account.budget.post', 'Budgetary Position', required=True)
date_from = fields.Date('Start Date', required=True)
date_to = fields.Date('End Date', required=True)
paid_date = fields.Date('Paid Date')
planned_amount = fields.Float('Planned Amount', required=True, digits=0)
practical_amount = fields.Float(compute='_compute_practical_amount', string='Practical Amount', digits=0)
theoretical_amount = fields.Float(compute='_compute_theoretical_amount', string='Theoretical Amount', digits=0)
percentage = fields.Float(compute='_compute_percentage', string='Achievement')
company_id = fields.Many2one(related='budget_id.company_id', comodel_name='res.company',
budget_id = fields.Many2one('budget.budget', string='Budget',
ondelete='cascade', index=True, required=True)
analytic_account_id = fields.Many2one('account.analytic.account',
string='Analytic Account')
general_budget_id = fields.Many2one(
'account.budget.post', string='Budgetary Position', required=True)
date_from = fields.Date(string='Start Date', required=True)
date_to = fields.Date(string='End Date', required=True)
paid_date = fields.Date(string='Paid Date')
planned_amount = fields.Float(
string='Planned Amount', required=True, digits=0)
practical_amount = fields.Float(compute='_compute_practical_amount',
string='Practical Amount', digits=0)
theoretical_amount = fields.Float(compute='_compute_theoretical_amount',
string='Theoretical Amount', digits=0)
percentage = fields.Float(
compute='_compute_percentage', string='Achievement')
company_id = fields.Many2one(
related='budget_id.company_id', comodel_name='res.company',
string='Company', store=True, readonly=True)
def _compute_practical_amount(self):
@ -116,7 +134,8 @@ class BudgetLines(models.Model):
result = 0.0
acc_ids = line.general_budget_id.account_ids.ids
date_to = self.env.context.get('wizard_date_to') or line.date_to
date_from = self.env.context.get('wizard_date_from') or line.date_from
date_from = self.env.context.get(
'wizard_date_from') or line.date_from
if line.analytic_account_id.id:
self.env.cr.execute("""
SELECT SUM(amount)
@ -124,7 +143,8 @@ class BudgetLines(models.Model):
WHERE account_id=%s
AND date between %s AND %s
AND general_account_id=ANY(%s)""",
(line.analytic_account_id.id, date_from, date_to, acc_ids,))
(line.analytic_account_id.id, date_from,
date_to, acc_ids,))
result = self.env.cr.fetchone()[0] or 0.0
line.practical_amount = result
@ -134,8 +154,10 @@ class BudgetLines(models.Model):
# Used for the report
if self.env.context.get('wizard_date_from') and self.env.context.get('wizard_date_to'):
date_from = fields.Datetime.from_string(self.env.context.get('wizard_date_from'))
date_to = fields.Datetime.from_string(self.env.context.get('wizard_date_to'))
date_from = fields.Datetime.from_string(
self.env.context.get('wizard_date_from'))
date_to = fields.Datetime.from_string(
self.env.context.get('wizard_date_to'))
if date_from < fields.Datetime.from_string(line.date_from):
date_from = fields.Datetime.from_string(line.date_from)
elif date_from > fields.Datetime.from_string(line.date_to):
@ -182,6 +204,7 @@ class BudgetLines(models.Model):
def _compute_percentage(self):
for line in self:
if line.theoretical_amount != 0.00:
line.percentage = float((line.practical_amount or 0.0) / line.theoretical_amount) * 100
line.percentage = float(
(line.practical_amount or 0.0) / line.theoretical_amount) * 100
else:
line.percentage = 0.00

BIN
base_account_budget/static/description/assets/icons/logo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

18
base_account_budget/static/description/index.html

@ -1,3 +1,17 @@
<div class="container" style="padding: 1rem !important; margin-bottom: 1rem !important;">
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-12 d-flex justify-content-between" style="border-bottom: 1px solid #d5d5d5;">
<div class="my-3">
<img src="./assets/icons/logo.png" style="width: auto !important; height: 40px !important;">
</div>
<div class="my-3 d-flex align-items-center">
<div style="background-color: #875A7B !important; color: #fff !important; font-weight: 600 !important; padding: 5px 15px 8px !important; margin: 0 5px !important;">
<i class="fa fa-check mr-1"></i>Community
</div>
</div>
</div>
</div>
</div>
<div class="container" style="padding: 4rem 1.5rem !important">
<div class="row" style="height: 900px !important;">
<div class="col-sm-12 col-md-12 col-lg-12"
@ -427,7 +441,7 @@
</div>
</div>
</section>
<!-- END OF END OF OUR SERVICES -->
<!-- END OF OUR SERVICES -->
<!-- OUR INDUSTRIES -->
<section class="container" style="margin-top: 6rem !important;">
@ -560,7 +574,7 @@
</div>
</section>
<!-- END OF END OF OUR INDUSTRIES -->
<!-- END OF OUR INDUSTRIES -->
<!-- FOOTER -->
<!-- Footer Section -->

Loading…
Cancel
Save