Browse Source

[ADD] Initial Commit

pull/30/merge
SHEREEF PT 8 years ago
parent
commit
ac5056e4f8
  1. 24
      round_off_invoices/__init__.py
  2. 43
      round_off_invoices/__manifest__.py
  3. 24
      round_off_invoices/models/__init__.py
  4. 250
      round_off_invoices/models/config.py
  5. BIN
      round_off_invoices/static/description/banner.jpg
  6. BIN
      round_off_invoices/static/description/cybro_logo.png
  7. BIN
      round_off_invoices/static/description/icon.png
  8. 138
      round_off_invoices/static/description/index.html
  9. BIN
      round_off_invoices/static/description/ro1.png
  10. BIN
      round_off_invoices/static/description/ro2.png
  11. BIN
      round_off_invoices/static/description/ro3.png
  12. BIN
      round_off_invoices/static/description/ro4.png
  13. BIN
      round_off_invoices/static/description/ro6.png
  14. 45
      round_off_invoices/views/round_off_view.xml

24
round_off_invoices/__init__.py

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2017-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Treesa Maria Jude(<https://www.cybrosys.com>)
# you can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# It is forbidden to publish, distribute, sublicense, or sell copies
# of the Software or modified copies of the Software.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# GENERAL PUBLIC LICENSE (LGPL v3) along with this program.
# If not, see <https://www.gnu.org/licenses/>.
#
##############################################################################
import models

43
round_off_invoices/__manifest__.py

@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2017-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Treesa Maria Jude(<https://www.cybrosys.com>)
# you can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# It is forbidden to publish, distribute, sublicense, or sell copies
# of the Software or modified copies of the Software.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# GENERAL PUBLIC LICENSE (LGPL v3) along with this program.
# If not, see <https://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'Round Off Invoice Amount',
'version': '10.0.1.0.0',
'summary': 'Allows Rounding on Invoice Amount',
'description': 'Invoice amount is rounded to their nearest digits excluding the decimal part',
'category': 'Accounting',
'author': 'Cybrosys Techno Solutions',
'website': "https://www.cybrosys.com",
'company': 'Cybrosys Techno Solutions',
'maintainer': 'Cybrosys Techno Solutions',
'depends': ['base', 'account'],
'data': [
'views/round_off_view.xml',
],
'license': 'AGPL-3',
'images': ['static/description/banner.jpg'],
'installable': True,
'auto_install': False,
'application': False,
}

24
round_off_invoices/models/__init__.py

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2017-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Treesa Maria Jude(<https://www.cybrosys.com>)
# you can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# It is forbidden to publish, distribute, sublicense, or sell copies
# of the Software or modified copies of the Software.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# GENERAL PUBLIC LICENSE (LGPL v3) along with this program.
# If not, see <https://www.gnu.org/licenses/>.
#
##############################################################################
import config

250
round_off_invoices/models/config.py

@ -0,0 +1,250 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2017-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Treesa Maria Jude(<https://www.cybrosys.com>)
# you can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# It is forbidden to publish, distribute, sublicense, or sell copies
# of the Software or modified copies of the Software.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# GENERAL PUBLIC LICENSE (LGPL v3) along with this program.
# If not, see <https://www.gnu.org/licenses/>.
#
##############################################################################
from odoo.tools import float_is_zero
from odoo.exceptions import UserError
from odoo import fields, models, api, _
class RoundOffSetting(models.TransientModel):
_inherit = 'account.config.settings'
round_off = fields.Boolean(string='Allow rounding of invoice amount', help="Allow rounding of invoice amount")
round_off_account = fields.Many2one('account.account', string='Round Off Account')
@api.multi
def set_round_off(self):
ir_values_obj = self.env['ir.values']
ir_values_obj.sudo().set_default('account.config.settings', "round_off", self.round_off)
ir_values_obj.sudo().set_default('account.config.settings', "round_off_account", self.round_off_account.id)
class AccountRoundOff(models.Model):
_inherit = 'account.invoice'
round_off_value = fields.Float(compute='_compute_amount', string='Round off amount')
rounded_total = fields.Float(compute='_compute_amount', string='Rounded Total')
round_active = fields.Boolean(compute='get_round_active')
def get_round_active(self):
ir_values = self.env['ir.values']
self.round_active = ir_values.get_default('account.config.settings', 'round_off')
@api.one
@api.depends('invoice_line_ids.price_subtotal', 'tax_line_ids.amount', 'currency_id', 'company_id',
'date_invoice', 'type')
def _compute_amount(self):
self.amount_untaxed = sum(line.price_subtotal for line in self.invoice_line_ids)
self.amount_tax = sum(line.amount for line in self.tax_line_ids)
self.rounded_total = round(self.amount_untaxed + self.amount_tax)
self.amount_total = self.amount_untaxed + self.amount_tax
self.round_off_value = self.rounded_total - (self.amount_untaxed + self.amount_tax)
amount_total_company_signed = self.amount_total
amount_untaxed_signed = self.amount_untaxed
if self.currency_id and self.company_id and self.currency_id != self.company_id.currency_id:
currency_id = self.currency_id.with_context(date=self.date_invoice)
amount_total_company_signed = currency_id.compute(self.amount_total, self.company_id.currency_id)
amount_untaxed_signed = currency_id.compute(self.amount_untaxed, self.company_id.currency_id)
sign = self.type in ['in_refund', 'out_refund'] and -1 or 1
self.amount_total_company_signed = amount_total_company_signed * sign
self.amount_total_signed = self.amount_total * sign
self.amount_untaxed_signed = amount_untaxed_signed * sign
@api.one
@api.depends(
'state', 'currency_id', 'invoice_line_ids.price_subtotal',
'move_id.line_ids.amount_residual',
'move_id.line_ids.currency_id')
def _compute_residual(self):
residual = 0.0
residual_company_signed = 0.0
sign = self.type in ['in_refund', 'out_refund'] and -1 or 1
for line in self.sudo().move_id.line_ids:
if line.account_id.internal_type in ('receivable', 'payable'):
residual_company_signed += line.amount_residual
if line.currency_id == self.currency_id:
residual += line.amount_residual_currency if line.currency_id else line.amount_residual
else:
from_currency = (line.currency_id and line.currency_id.with_context(
date=line.date)) or line.company_id.currency_id.with_context(date=line.date)
residual += from_currency.compute(line.amount_residual, self.currency_id)
self.residual_company_signed = abs(residual_company_signed) * sign
self.residual_signed = abs(residual) * sign
if self.round_active is True and self.type == 'out_invoice':
self.residual = round(abs(residual))
else:
self.residual = abs(residual)
digits_rounding_precision = self.currency_id.rounding
if float_is_zero(self.residual, precision_rounding=digits_rounding_precision):
self.reconciled = True
else:
self.reconciled = False
@api.multi
def action_move_create(self):
""" Creates invoice related analytics and financial move lines """
account_move = self.env['account.move']
for inv in self:
if not inv.journal_id.sequence_id:
raise UserError(_('Please define sequence on the journal related to this invoice.'))
if not inv.invoice_line_ids:
raise UserError(_('Please create some invoice lines.'))
if inv.move_id:
continue
ctx = dict(self._context, lang=inv.partner_id.lang)
if not inv.date_invoice:
inv.with_context(ctx).write({'date_invoice': fields.Date.context_today(self)})
date_invoice = inv.date_invoice
company_currency = inv.company_id.currency_id
# create move lines (one per invoice line + eventual taxes and analytic lines)
iml = inv.invoice_line_move_line_get()
iml += inv.tax_line_move_line_get()
diff_currency = inv.currency_id != company_currency
# create one move line for the total and possibly adjust the other lines amount
total, total_currency, iml = inv.with_context(ctx).compute_invoice_totals(company_currency, iml)
name = inv.name or '/'
if inv.payment_term_id:
totlines = inv.with_context(ctx).payment_term_id.with_context(currency_id=company_currency.id).compute(
total, date_invoice)[0]
res_amount_currency = total_currency
ctx['date'] = date_invoice
for i, t in enumerate(totlines):
if inv.currency_id != company_currency:
amount_currency = company_currency.with_context(ctx).compute(t[1], inv.currency_id)
else:
amount_currency = False
# last line: add the diff
res_amount_currency -= amount_currency or 0
if i + 1 == len(totlines):
amount_currency += res_amount_currency
if self.round_active is True and self.type == 'out_invoice':
iml.append({
'type': 'dest',
'name': name,
'price': t[1]+self.round_off_value,
'account_id': inv.account_id.id,
'date_maturity': t[0],
'amount_currency': diff_currency and amount_currency,
'currency_id': diff_currency and inv.currency_id.id,
'invoice_id': inv.id
})
ir_values = self.env['ir.values']
acc_id = ir_values.get_default('account.config.settings', 'round_off_account')
iml.append({
'type': 'dest',
'name': "Round off",
'price': -self.round_off_value,
'account_id': acc_id,
'date_maturity': t[0],
'amount_currency': diff_currency and amount_currency,
'currency_id': diff_currency and inv.currency_id.id,
'invoice_id': inv.id
})
else:
iml.append({
'type': 'dest',
'name': name,
'price': t[1],
'account_id': inv.account_id.id,
'date_maturity': t[0],
'amount_currency': diff_currency and amount_currency,
'currency_id': diff_currency and inv.currency_id.id,
'invoice_id': inv.id
})
else:
if self.round_active is True and self.type == 'out_invoice':
iml.append({
'type': 'dest',
'name': name,
'price': total + self.round_off_value,
'account_id': inv.account_id.id,
'date_maturity': inv.date_due,
'amount_currency': diff_currency and amount_currency,
'currency_id': diff_currency and inv.currency_id.id,
'invoice_id': inv.id
})
ir_values = self.env['ir.values']
acc_id = ir_values.get_default('account.config.settings', 'round_off_account')
iml.append({
'type': 'dest',
'name': "Round off",
'price': -self.round_off_value,
'account_id': acc_id,
'date_maturity': inv.date_due,
'amount_currency': diff_currency and amount_currency,
'currency_id': diff_currency and inv.currency_id.id,
'invoice_id': inv.id
})
else:
iml.append({
'type': 'dest',
'name': name,
'price': total,
'account_id': inv.account_id.id,
'date_maturity': inv.date_due,
'amount_currency': diff_currency and total_currency,
'currency_id': diff_currency and inv.currency_id.id,
'invoice_id': inv.id
})
part = self.env['res.partner']._find_accounting_partner(inv.partner_id)
line = [(0, 0, self.line_get_convert(l, part.id)) for l in iml]
line = inv.group_lines(iml, line)
journal = inv.journal_id.with_context(ctx)
line = inv.finalize_invoice_move_lines(line)
date = inv.date or date_invoice
move_vals = {
'ref': inv.reference,
'line_ids': line,
'journal_id': journal.id,
'date': date,
'narration': inv.comment,
}
ctx['company_id'] = inv.company_id.id
ctx['invoice'] = inv
ctx_nolang = ctx.copy()
ctx_nolang.pop('lang', None)
move = account_move.with_context(ctx_nolang).create(move_vals)
# Pass invoice in context in method post: used if you want to get the same
# account move reference when creating the same invoice after a cancelled one:
move.post()
# make the invoice point to that move
vals = {
'move_id': move.id,
'date': date,
'move_name': move.name,
}
inv.with_context(ctx).write(vals)
return True

BIN
round_off_invoices/static/description/banner.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 KiB

BIN
round_off_invoices/static/description/cybro_logo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

BIN
round_off_invoices/static/description/icon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

138
round_off_invoices/static/description/index.html

@ -0,0 +1,138 @@
<section class="oe_container">
<div class="oe_row oe_spaced">
<h2 class="oe_slogan">Round Off Invoice Amount</h2>
<h3 class="oe_slogan">Rounding on Invoice Amount</h3>
<h4 class="oe_slogan"><a href="https://www.cybrosys.com">Cybrosys Technologies</a> </h4>
</div>
</section>
<section class="oe_container oe_dark">
<div class="oe_row oe_spaced">
<div class="oe_picture">
<h2 class="oe_slogan">Overview</h2>
<p class="oe_mt32">
In any business, rounding of invoice amount is a necessary feature. By default, Odoo ERP
doesn't support this feature. But the 'Round off Invoice Amount' app from Cybrosys allows
you to round off the invoice amount to the nearest whole amount by excluding the decimal
parts. This application also supports you to create separate journal entries for the rounded
amounts, which can assure the amount is balanced.
</p>
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<h2 class="oe_slogan">Allow Round Off Feature</h2>
<div class="oe_row oe_spaced">
<div class="oe_span12">
<p>First, you have to download and Install the application form Odoo App Store. Then follow
the below steps to enable the feature.</p>
<h4> Accounting -->Settings -->Round Off</h4>
<p><ul>
<li style="list-style:none !important;"><span style="color:green;"> &#9745;</span>&nbsp;&nbsp; Tick the 'Allow rounding of invoice amount' option.</li>
<li style="list-style:none !important;"><span style="color:green;"> &#9745;</span>&nbsp;&nbsp; Don't forget to add the Round off Account/
(Journal entry corresponding to write off amount will be passed to this account)</li>
</ul>
</p>
<div class="oe_row_img oe_centered">
<img style="border:10px solid white;" class="oe_picture oe_screenshot" src="ro1.png">
</div>
</div>
</div>
</div>
</section>
<section class="oe_container oe_dark">
<div class="oe_row oe_spaced">
<h2 class="oe_slogan">Round Off Amounts</h2>
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h4>Goto</h4>
<h4> Accounting -->Customer Invoices -->Create</h4>
<div class="oe_row_img oe_centered">
<img style="border:10px solid white;" class="oe_picture oe_screenshot" src="ro2.png">
</div>
</div>
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<h2 class="oe_slogan">Validate the Invoice</h2>
<div class="oe_row oe_spaced">
<div class="oe_span12">
<p> Here, the 'Total amount' is the actual amount. 'Amount Due' is
the amount after rounding off the decimal parts and it is the one customer needs to pay.
</p>
<div class="oe_row_img oe_centered">
<img style="border:10px solid white;" class="oe_picture oe_screenshot" src="ro3.png">
</div>
</div>
</div>
</div>
</section>
<section class="oe_container oe_dark">
<div class="oe_row oe_spaced">
<h2 class="oe_slogan">Journal Entries</h2>
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h4>Goto</h4>
<h4> Accounting -->Customer Invoices -->Invoice -->Other Info -->Journal Entry</h4>
<p>As you can see in the picture a special journal entry is passed to balance the amount.
</p>
<div class="oe_row_img oe_centered">
<img style="border:10px solid white;" class="oe_picture oe_screenshot" src="ro4.png">
</div>
</div>
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<h2 class="oe_slogan">Round Off Details</h2>
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h4>Goto</h4>
<h4> Accounting -->Journal Items-->Search: 'Round Off'</h4>
<div class="oe_row_img oe_centered">
<img style="border:10px solid white;" class="oe_picture oe_screenshot" src="ro6.png">
</div>
</div>
</div>
</div>
</section>
<section class="oe_container oe_dark">
<h2 class="oe_slogan" style="margin-top:20px;" >Need Any Help?</h2>
<div class="oe_slogan" style="margin-top:10px !important;">
<div>
<a class="btn btn-primary btn-lg mt8"
style="color: #FFFFFF !important;border-radius: 0;" href="https://www.cybrosys.com"><i
class="fa fa-envelope"></i> Email </a> <a
class="btn btn-primary btn-lg mt8" style="color: #FFFFFF !important;border-radius: 0;"
href="https://www.cybrosys.com/contact/"><i
class="fa fa-phone"></i> Contact Us </a> <a
class="btn btn-primary btn-lg mt8" style="color: #FFFFFF !important;border-radius: 0;"
href="https://www.cybrosys.com/odoo-customization-and-installation/"><i
class="fa fa-check-square"></i> Request Customization </a>
</div>
<br>
<img src="cybro_logo.png" style="width: 190px; margin-bottom: 20px;" class="center-block">
<div>
<a href="https://twitter.com/cybrosys" target="_blank"><i class="fa fa-2x fa-twitter" style="color:white;background: #00a0d1;width:35px;"></i></a></td>
<a href="https://www.linkedin.com/company/cybrosys-technologies-pvt-ltd" target="_blank"><i class="fa fa-2x fa-linkedin" style="color:white;background: #31a3d6;width:35px;padding-left: 3px;"></i></a></td>
<a href="https://www.facebook.com/cybrosystechnologies" target="_blank"><i class="fa fa-2x fa-facebook" style="color:white;background: #3b5998;width:35px;padding-left: 8px;"></i></a></td>
<a href="https://plus.google.com/106641282743045431892/about" target="_blank"><i class="fa fa-2x fa-google-plus" style="color:white;background: #c53c2c;width:35px;padding-left: 3px;"></i></a></td>
<a href="https://in.pinterest.com/cybrosys" target="_blank"><i class="fa fa-2x fa-pinterest" style="color:white;background: #ac0f18;width:35px;padding-left: 3px;"></i></a></td>
</div>
</div>
</section>

BIN
round_off_invoices/static/description/ro1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

BIN
round_off_invoices/static/description/ro2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

BIN
round_off_invoices/static/description/ro3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

BIN
round_off_invoices/static/description/ro4.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

BIN
round_off_invoices/static/description/ro6.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

45
round_off_invoices/views/round_off_view.xml

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<record id="round_off_config" model="ir.ui.view">
<field name="name">account.config.settings.roundoff</field>
<field name="model">account.config.settings</field>
<field name="inherit_id" ref="account.view_account_config_settings"/>
<field name="arch" type="xml">
<xpath expr="//group[@name='accounting']" position="after">
<group string="Round Off " name="round_off">
<label for="id" string="Round Off"/>
<div name="round_off_conf">
<div>
<field name="round_off" class="oe_inline" />
<label for="round_off"/></div>
<div>
<label for="round_off_account" attrs="{'invisible': [('round_off', '=', False)], 'required': [('round_off', '=', True)]}"/>
<field name="round_off_account" class="oe_inline" attrs="{'invisible': [('round_off', '=', False)], 'required': [('round_off', '=', True)]}"/>
</div>
</div>
</group>
</xpath>
</field>
</record>
<record model="ir.ui.view" id="invoice__extend_round_off_view">
<field name="name">invoice.line.extend_round_off</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='amount_total']" position="after">
<field name="round_active" invisible="1"/>
<field name="rounded_total" attrs="{'invisible': [('round_active', '=', False)]}" />
<field name="round_off_value" attrs="{'invisible': [('round_active', '=', False)]}"/>
</xpath>
</field>
</record>
</data>
</odoo>
Loading…
Cancel
Save