Skip to content
Permalink
Browse files

[IMP] account: add automatic periodical VAT return

Add new fields to define the receivable/payable/advance tax account on account_tax_group and on the chart_template.
Define a new activity widget to display the activity on the journal.
Add a tax group editable list view
  • Loading branch information...
csnauwaert committed Dec 13, 2018
1 parent 36d4c99 commit 9a0ef1be256b954e15449590de73b938483ecb71
@@ -71,6 +71,7 @@
"static/src/xml/account_payment.xml",
"static/src/xml/account_report_backend.xml",
"static/src/xml/bills_tree_upload_views.xml",
'static/src/xml/account_journal_activity.xml',
],
'installable': True,
'application': True,
@@ -883,6 +883,9 @@ class AccountTaxGroup(models.Model):

name = fields.Char(required=True, translate=True)
sequence = fields.Integer(default=10)
property_tax_payable_account_id = fields.Many2one('account.account', company_dependent=True, string='Tax payable account')
property_tax_receivable_account_id = fields.Many2one('account.account', company_dependent=True, string='Tax receivable account')
property_advance_tax_payment_account_id = fields.Many2one('account.account', company_dependent=True, string='Advance Tax payment account')

class AccountTax(models.Model):
_name = 'account.tax'
@@ -2,11 +2,10 @@
from datetime import datetime, timedelta

from babel.dates import format_datetime, format_date

from odoo import models, api, _, fields
from odoo.release import version
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT as DF, safe_eval
from odoo.tools.misc import formatLang
from odoo.tools.misc import formatLang, format_date as odoo_format_date
import random

class account_journal(models.Model):
@@ -23,8 +22,22 @@ def _kanban_dashboard_graph(self):
elif (self.type in ['cash', 'bank']):
self.kanban_dashboard_graph = json.dumps(self.get_line_graph_datas())

def _get_json_activity_data(self):
for journal in self:
activities = []
for activity in journal.activity_ids:
activities.append({
'id': activity.id,
'name': activity.summary or activity.activity_type_id.name,
'state': activity.state,
'activity_category': activity.activity_category,
'date': odoo_format_date(self.env, activity.date_deadline)
})
journal.json_activity_data = json.dumps({'activities': activities})

kanban_dashboard = fields.Text(compute='_kanban_dashboard')
kanban_dashboard_graph = fields.Text(compute='_kanban_dashboard_graph')
json_activity_data = fields.Text(compute='_get_json_activity_data')
show_on_dashboard = fields.Boolean(string='Show journal on dashboard', help="Whether this journal should be displayed on the dashboard or not", default=True)
color = fields.Integer("Color Index", default=0)

@@ -19,6 +19,7 @@
class AccountMove(models.Model):
_name = "account.move"
_description = "Journal Entries"
_inherit = ['mail.thread']
_order = 'date desc, id desc'
_inherit = ['mail.thread', 'mail.activity.mixin']

@@ -124,6 +124,9 @@ class AccountChartTemplate(models.Model):
property_stock_account_input_categ_id = fields.Many2one('account.account.template', string="Input Account for Stock Valuation", oldname="property_stock_account_input_categ")
property_stock_account_output_categ_id = fields.Many2one('account.account.template', string="Output Account for Stock Valuation", oldname="property_stock_account_output_categ")
property_stock_valuation_account_id = fields.Many2one('account.account.template', string="Account Template for Stock Valuation")
property_tax_payable_account_id = fields.Many2one('account.account.template', string="Tax payable account")
property_tax_receivable_account_id = fields.Many2one('account.account.template', string="Tax receivable account")
property_advance_tax_payment_account_id = fields.Many2one('account.account.template', string="Advance tax payment account")

@api.model
def _prepare_transfer_account_template(self):
@@ -419,7 +422,7 @@ def _get_default_account(journal_vals, type='debit'):

journals = [{'name': _('Customer Invoices'), 'type': 'sale', 'code': _('INV'), 'favorite': True, 'color': 11, 'sequence': 5},
{'name': _('Vendor Bills'), 'type': 'purchase', 'code': _('BILL'), 'favorite': True, 'color': 11, 'sequence': 6},
{'name': _('Miscellaneous Operations'), 'type': 'general', 'code': _('MISC'), 'favorite': False, 'sequence': 7},
{'name': _('Miscellaneous Operations'), 'type': 'general', 'code': _('MISC'), 'favorite': True, 'sequence': 7},
{'name': _('Exchange Difference'), 'type': 'general', 'code': _('EXCH'), 'favorite': False, 'sequence': 9},
{'name': _('Cash Basis Taxes'), 'type': 'general', 'code': _('CABA'), 'favorite': False, 'sequence': 10}]
if journals_dict != None:
@@ -460,6 +463,9 @@ def generate_properties(self, acc_template_ref, company):
('property_account_income_categ_id', 'product.category', 'account.account'),
('property_account_expense_id', 'product.template', 'account.account'),
('property_account_income_id', 'product.template', 'account.account'),
('property_tax_payable_account_id', 'account.tax.group', 'account.account'),
('property_tax_receivable_account_id', 'account.tax.group', 'account.account'),
('property_advance_tax_payment_account_id', 'account.tax.group', 'account.account'),
]
for record in todo_list:
account = getattr(self, record[0])
@@ -0,0 +1,54 @@
odoo.define('account.activity', function (require) {
"use strict";

var AbstractField = require('web.AbstractField');
var core = require('web.core');
var field_registry = require('web.field_registry');

var QWeb = core.qweb;
var _t = core._t;

var VatActivity = AbstractField.extend({
className: 'o_journal_activity_kanban',
events: {
'click .see_all_activities': '_onOpenJournalSettings',
},
init: function () {
this.MAX_ACTIVITY_DISPLAY = 5;
this._super.apply(this, arguments);
},
//------------------------------------------------------------
// Private
//------------------------------------------------------------
_render: function () {
var self = this;
var info = JSON.parse(this.value);
if (!info) {
this.$el.html('');
return;
}
info.more_activities = false;
if (info.activities.length > this.MAX_ACTIVITY_DISPLAY) {
info.more_activities = true;
info.activities = info.activities.slice(0, this.MAX_ACTIVITY_DISPLAY);
}
this.$el.html(QWeb.render('accountJournalDashboardActivity', info));
},

_onOpenJournalSettings: function(e) {
e.preventDefault();
var self = this;
self.do_action({
target: 'current',
res_id: self.res_id,
type: 'ir.actions.act_window',
res_model: 'account.journal',
views: [[false, 'form']],
});
}
})

field_registry.add('kanban_vat_activity', VatActivity);

return VatActivity;
});
@@ -0,0 +1,8 @@
.o_journal_activity_kanban {
display: block;
.align_activity_center {
width: 100%;
align-items: center;
margin-bottom: 5px;
}
}
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>

<templates>

<t t-name="accountJournalDashboardActivity">
<div class="row">
<div class='col-5'>
<t t-if="activities and activities.length and activities[0].activity_category == 'tax_report'">
<button class="btn btn-primary o_open_vat_report" t-att-data-id="activities[0].id">View Tax report</button>
</t>
</div>
<div class="col-7">
<t t-foreach="activities" t-as="activity">
<div class="row">
<div class="col-6">
<a href="#" class="see_all_activities" t-att-data-id="activity.id">
<t t-esc="activity.name"/>
</a>
</div>
<div class="col-6 text-right">
<span>Due on <t t-esc="activity.date"/></span>
</div>
</div>
</t>
<a t-if="more_activities" class="pull-right see_all_activities" href="#">See all activities</a>
</div>
</div>
</t>

</templates>
@@ -15,13 +15,15 @@
<link rel="stylesheet" type="text/scss" href="/account/static/src/scss/account_dashboard.scss"/>

<link rel="stylesheet" href="/account/static/src/scss/section_and_note_backend.scss"/>
<link rel="stylesheet" type="text/scss" href="/account/static/src/scss/account_activity.scss"/>

<script type="text/javascript" src="/account/static/src/js/reconciliation/reconciliation_action.js"></script>
<script type="text/javascript" src="/account/static/src/js/reconciliation/reconciliation_model.js"></script>
<script type="text/javascript" src="/account/static/src/js/reconciliation/reconciliation_renderer.js"></script>
<script type="text/javascript" src="/account/static/src/js/reconciliation/tour_reconciliation.js"></script>

<script type="text/javascript" src="/account/static/src/js/account_payment_field.js"></script>
<script type="text/javascript" src="/account/static/src/js/mail_activity.js"></script>

<script type="text/javascript" src="/account/static/src/js/bank_statement.js"></script>
<script type="text/javascript" src="/account/static/src/js/section_and_note_fields_backend.js"></script>
@@ -10,6 +10,8 @@
<field name="color"/>
<field name="show_on_dashboard"/>
<field name="kanban_dashboard"/>
<field name="activity_ids"/>
<field name="activity_state"/>
<templates>
<t t-name="kanban-box">
<div t-attf-class="#{kanban_color(record.color.raw_value)}">
@@ -20,11 +22,9 @@
<div class="row">
<t t-if="(journal_type == 'bank' || journal_type == 'cash')" t-call="JournalBodyBankCash"/>
<t t-if="journal_type == 'sale' || journal_type == 'purchase'" t-call="JournalBodySalePurchase"/>
<t t-if="journal_type == 'general' || journal_type == 'situation'">
<div class="col-6 o_kanban_primary_left">
<button type="object" name="open_action" context="{'action_name': 'action_move_journal_line', 'view_no_maturity': 1}" class="btn btn-primary">
<span>Journal Entries</span>
</button>
<t t-if="journal_type == 'general'">
<div class="col-12 o_kanban_primary_left o_general_activity">
<field name="json_activity_data" widget="kanban_vat_activity"/>
</div>
</t>
</div>
@@ -306,11 +306,11 @@
</page>
</notebook>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers"/>
<field name="activity_ids" widget="mail_activity"/>
<field name="message_ids" widget="mail_thread"/>
</div>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers"/>
<field name="activity_ids" widget="mail_activity"/>
<field name="message_ids" widget="mail_thread"/>
</div>
</form>
</field>
</record>
@@ -1223,6 +1223,29 @@
</record>
<menuitem action="action_tax_form" id="menu_action_tax_form" parent="account_account_menu" sequence="2"/>

<!-- Tax group -->
<record id="view_tax_group_tree" model="ir.ui.view">
<field name="name">account.tax.group.tree</field>
<field name="model">account.tax.group</field>
<field name="arch" type="xml">
<tree string="Account Tax Group" editable="bottom" create="false">
<field name="sequence" widget="handle"/>
<field name="name"/>
<field name="property_tax_payable_account_id"/>
<field name="property_tax_receivable_account_id"/>
<field name="property_advance_tax_payment_account_id"/>
</tree>
</field>
</record>
<record id="action_tax_group" model="ir.actions.act_window">
<field name="name">Tax Groups</field>
<field name="res_model">account.tax.group</field>
<field name="view_type">form</field>
<field name="view_mode">tree</field>
<field name="domain" eval="False"/> <!-- Force empty -->
<field name="view_id" ref="view_tax_group_tree"/>
</record>

<!-- Full Reconcile -->
<record id="view_full_reconcile_form" model="ir.ui.view">
<field name="name">account.full.reconcile.form</field>
@@ -9,5 +9,7 @@
<field name="property_account_income_categ_id" ref="a7010"/>
<field name="expense_currency_exchange_account_id" ref="a654"/>
<field name="income_currency_exchange_account_id" ref="a754"/>
<field name="property_tax_payable_account_id" ref="a4512"/>
<field name="property_tax_receivable_account_id" ref="a4112"/>
</record>
</odoo>

0 comments on commit 9a0ef1b

Please sign in to comment.
You can’t perform that action at this time.