[MERGE][FIX][IMP]Latest trunk + lots of things. I should have pushed more often, but its too late now : (
bzr revid: dle@openerp.com-20121121172954-qpnw0arhb632b8ve
This commit is contained in:
commit
d05caecd7e
|
@ -73,7 +73,6 @@ for a particular financial year and for preparation of vouchers there is a modul
|
|||
'wizard/account_fiscalyear_close_state.xml',
|
||||
'wizard/account_chart_view.xml',
|
||||
'wizard/account_tax_chart_view.xml',
|
||||
'wizard/account_move_journal_view.xml',
|
||||
'wizard/account_move_line_reconcile_select_view.xml',
|
||||
'wizard/account_open_closed_fiscalyear_view.xml',
|
||||
'wizard/account_move_line_unreconcile_select_view.xml',
|
||||
|
@ -128,9 +127,11 @@ for a particular financial year and for preparation of vouchers there is a modul
|
|||
],
|
||||
'js': [
|
||||
'static/src/js/account_move_reconciliation.js',
|
||||
'static/src/js/account_move_line_quickadd.js',
|
||||
],
|
||||
'qweb' : [
|
||||
"static/src/xml/account_move_reconciliation.xml",
|
||||
"static/src/xml/account_move_line_quickadd.xml",
|
||||
],
|
||||
'css':['static/src/css/account_move_reconciliation.css'
|
||||
],
|
||||
|
|
|
@ -738,7 +738,7 @@ class account_journal(osv.osv):
|
|||
" Select 'Opening/Closing Situation' for entries generated for new fiscal years."),
|
||||
'type_control_ids': fields.many2many('account.account.type', 'account_journal_type_rel', 'journal_id','type_id', 'Type Controls', domain=[('code','<>','view'), ('code', '<>', 'closed')]),
|
||||
'account_control_ids': fields.many2many('account.account', 'account_account_type_rel', 'journal_id','account_id', 'Account', domain=[('type','<>','view'), ('type', '<>', 'closed')]),
|
||||
'view_id': fields.many2one('account.journal.view', 'Display Mode', required=True, help="Gives the view used when writing or browsing entries in this journal. The view tells OpenERP which fields should be visible, required or readonly and in which order. You can create your own view for a faster encoding in each journal."),
|
||||
#'view_id': fields.many2one('account.journal.view', 'Display Mode', required=True, help="Gives the view used when writing or browsing entries in this journal. The view tells OpenERP which fields should be visible, required or readonly and in which order. You can create your own view for a faster encoding in each journal."),
|
||||
'default_credit_account_id': fields.many2one('account.account', 'Default Credit Account', domain="[('type','!=','view')]", help="It acts as a default account for credit amount"),
|
||||
'default_debit_account_id': fields.many2one('account.account', 'Default Debit Account', domain="[('type','!=','view')]", help="It acts as a default account for debit amount"),
|
||||
'centralisation': fields.boolean('Centralised Counterpart', help="Check this box to determine that each entry of this journal won't create a new counterpart but will share the same counterpart. This is used in fiscal year closing."),
|
||||
|
|
|
@ -551,6 +551,33 @@ class account_move_line(osv.osv):
|
|||
cur = self.pool.get('account.journal').browse(cr, uid, context['journal_id']).currency
|
||||
return cur and cur.id or False
|
||||
|
||||
def _get_period(self, cr, uid, context=None):
|
||||
"""
|
||||
Return default account period value
|
||||
"""
|
||||
account_period_obj = self.pool.get('account.period')
|
||||
ids = account_period_obj.find(cr, uid, context=context)
|
||||
period_id = False
|
||||
if ids:
|
||||
period_id = ids[0]
|
||||
return period_id
|
||||
|
||||
def _get_journal(self, cr, uid, context=None):
|
||||
"""
|
||||
Return journal based on the journal type
|
||||
"""
|
||||
|
||||
journal_id = False
|
||||
|
||||
journal_pool = self.pool.get('account.journal')
|
||||
if context.get('journal_type', False):
|
||||
jids = journal_pool.search(cr, uid, [('type','=', context.get('journal_type'))])
|
||||
if not jids:
|
||||
raise osv.except_osv(_('Configuration Error!'), _('Cannot find any account journal of %s type for this company.\n\nYou can create one in the menu: \nConfiguration/Journals/Journals.') % context.get('journal_type'))
|
||||
journal_id = jids[0]
|
||||
return journal_id
|
||||
|
||||
|
||||
_defaults = {
|
||||
'blocked': False,
|
||||
'centralisation': 'normal',
|
||||
|
@ -558,12 +585,12 @@ class account_move_line(osv.osv):
|
|||
'date_created': fields.date.context_today,
|
||||
'state': 'draft',
|
||||
'currency_id': _get_currency,
|
||||
'journal_id': lambda self, cr, uid, c: c.get('journal_id', False),
|
||||
'journal_id': _get_journal,
|
||||
'credit': 0.0,
|
||||
'debit': 0.0,
|
||||
'amount_currency': 0.0,
|
||||
'account_id': lambda self, cr, uid, c: c.get('account_id', False),
|
||||
'period_id': lambda self, cr, uid, c: c.get('period_id', False),
|
||||
'period_id': _get_period,
|
||||
'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.move.line', context=c)
|
||||
}
|
||||
_order = "date desc, id desc"
|
||||
|
@ -1383,6 +1410,20 @@ class account_move_line(osv.osv):
|
|||
move_obj.button_validate(cr,uid, [vals['move_id']], context)
|
||||
return result
|
||||
|
||||
def list_periods(self, cr, uid, context=None):
|
||||
ids = self.pool.get('account.period').search(cr,uid,[])
|
||||
return self.pool.get('account.period').name_get(cr, uid, ids, context=context)
|
||||
|
||||
def list_journals(self, cr, uid, context=None):
|
||||
ng = dict(self.pool.get('account.journal').name_search(cr,uid,'',[]))
|
||||
ids = ng.keys()
|
||||
result = []
|
||||
print ng
|
||||
for journal in self.pool.get('account.journal').browse(cr, uid, ids, context=context):
|
||||
result.append((journal.id,ng[journal.id],journal.type,
|
||||
bool(journal.currency),bool(journal.analytic_journal_id)))
|
||||
return result
|
||||
|
||||
account_move_line()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -489,7 +489,6 @@
|
|||
<group>
|
||||
<group>
|
||||
<field name="user_id"/>
|
||||
<field name="view_id" widget="selection"/>
|
||||
<field name="sequence_id" required="0"/>
|
||||
</group>
|
||||
<group>
|
||||
|
@ -1063,76 +1062,31 @@
|
|||
</tree_account_reconciliation>
|
||||
</field>
|
||||
</record>
|
||||
<!--
|
||||
|
||||
Sale :
|
||||
|
||||
1 Journal Entry
|
||||
2 Ref
|
||||
3 Date
|
||||
5 Partner
|
||||
6 Account
|
||||
7 Name
|
||||
8 Due Date
|
||||
11 Debit
|
||||
12 Credit
|
||||
13 Tax
|
||||
14 Analytic Account
|
||||
19 Status
|
||||
20 Reconcile
|
||||
|
||||
Bank :
|
||||
1 Journal Entry
|
||||
2 Ref
|
||||
3 Date
|
||||
4 Statement
|
||||
5 Partner
|
||||
6 Account
|
||||
7 Name
|
||||
11 Debit
|
||||
12 Credit
|
||||
19 Status
|
||||
20 Reconcile
|
||||
Sale Refund :
|
||||
|
||||
1 Journal Entry
|
||||
2 Ref
|
||||
3 Date
|
||||
5 Partner
|
||||
6 Account
|
||||
7 Name
|
||||
8 Due Date
|
||||
11 Debit
|
||||
12 Credit
|
||||
13 Tax
|
||||
14 Analytic Account
|
||||
19 Status
|
||||
20 Reconcile
|
||||
-->
|
||||
<record id="view_move_line_tree" model="ir.ui.view">
|
||||
<field name="name">account.move.line.tree</field>
|
||||
<field name="model">account.move.line</field>
|
||||
<field eval="4" name="priority"/>
|
||||
<field name="arch" type="xml">
|
||||
<tree colors="red:state == 'draft';black:state == 'valid'" string="Journal Items" editable="top" on_write="on_create_write">
|
||||
<field name="move_id"/>
|
||||
<field name="ref"/>
|
||||
<tree colors="red:state == 'draft';black:state == 'valid'" string="Journal Items" create="true" on_write="on_create_write" version="7.0" editable="top">
|
||||
<field name="date"/>
|
||||
<field name="statement_id" invisible="context.get('journal_type', False) in ['sale','purchase']"/>
|
||||
<field name="partner_id" on_change="onchange_partner_id(move_id, partner_id, account_id, debit, credit, date, journal_id)"/>
|
||||
<field name="account_id" domain="[('journal_id','=',journal_id), ('company_id', '=', company_id)]"/>
|
||||
<field name="name"/>
|
||||
<field name="date_maturity" invisible="context.get('journal_type', False) in ['bank']"/>
|
||||
<field name="debit" sum="Total debit"/>
|
||||
<field name="credit" sum="Total credit"/>
|
||||
<field name="account_tax_id" invisible="context.get('journal_type', False) in ['bank']"/>
|
||||
<field name="analytic_account_id" groups="analytic.group_analytic_accounting" domain="[('parent_id','!=',False)]" invisible="context.get('journal_type', False) in ['sale','purchase']"/>
|
||||
<field name="state" />
|
||||
<field name="ref"/>
|
||||
<field name="statement_id" invisible="1"/>
|
||||
<field name="partner_id" on_change="onchange_partner_id(move_id, partner_id, account_id, debit, credit, date, journal_id)"/>
|
||||
<field name="account_id" options='{"no_open":True}' domain="[('journal_id','=',journal_id), ('company_id', '=', company_id)]"/>
|
||||
<field name="date_maturity" invisible="context.get('journal_type', False) not in ['sale','sale_refund','purchase','purchase_refund']"/>
|
||||
<field name="account_tax_id" options='{"no_open":True}' invisible="context.get('journal_type', False) not in ['sale','sale_refund','purchase','purchase_refund','general']"/>
|
||||
<field name="analytic_account_id" groups="analytic.group_analytic_accounting" domain="[('type','not in',['view','template'])]" invisible="not context.get('analytic_journal_id',False)"/>
|
||||
<field name="move_id" required="0"/>
|
||||
<field name="debit" sum="Total Debit"/>
|
||||
<field name="credit" sum="Total Credit"/>
|
||||
<field name="reconcile_partial_id"/>
|
||||
<field name="reconcile_id"/>
|
||||
<field name="invoice" invisible="context.get('journal_type', False) in ['sale','purchase','bank']"/>
|
||||
<field name="amount_currency" attrs="{'readonly':[('state','=','valid')]}" groups="base.group_multi_currency" />
|
||||
<field name="currency_id" attrs="{'readonly':[('state','=','valid')]}" groups="base.group_multi_currency" />
|
||||
<field name="invoice" invisible="1"/>
|
||||
<field name="amount_currency" readonly="True" invisible="not context.get('currency',False)"/>
|
||||
<field name="currency_id" readonly="True" invisible="not context.get('currency',False)" />
|
||||
<field name="state" />
|
||||
<field name="journal_id" invisible="1"/>
|
||||
<field name="period_id" invisible="1"/>
|
||||
</tree>
|
||||
|
@ -1302,8 +1256,8 @@ Sale Refund :
|
|||
<field name="name">Journal Items</field>
|
||||
<field name="res_model">account.move.line</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="context">{}</field>
|
||||
<field name="view_mode">tree_account_move_line_quickadd</field>
|
||||
<field name="context">{'journal_type':'general','view_mode':True}</field>
|
||||
<field name="search_view_id" ref="view_account_move_line_filter"/>
|
||||
<field name="help" type="html">
|
||||
<p class="oe_view_nocontent_create">
|
||||
|
@ -1327,39 +1281,6 @@ Sale Refund :
|
|||
groups="group_account_user"
|
||||
/>
|
||||
|
||||
<record id="action_account_moves_sale" model="ir.actions.act_window">
|
||||
<field name="name">Journal Items</field>
|
||||
<field name="res_model">account.move.journal</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="context">{'journal_type':'sale'}</field>
|
||||
<field name="help">This view is used by accountants in order to record entries massively in OpenERP. If you want to record a customer invoice, select the journal and the period in the search toolbar. Then, start by recording the entry line of the income account. OpenERP will propose to you automatically the Tax related to this account and the counter-part "Account receivable".</field>
|
||||
</record>
|
||||
<menuitem action="action_account_moves_sale" sequence="16" id="menu_eaction_account_moves_sale"
|
||||
parent="menu_finance_receivables" icon="STOCK_JUSTIFY_FILL" groups="group_account_user,group_account_manager"/>
|
||||
|
||||
<record id="action_account_moves_purchase" model="ir.actions.act_window">
|
||||
<field name="name">Journal Items</field>
|
||||
<field name="res_model">account.move.journal</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="context">{'journal_type':'purchase'}</field>
|
||||
<field name="help">This view is used by accountants in order to record entries massively in OpenERP. If you want to record a supplier invoice, start by recording the line of the expense account, OpenERP will propose to you automatically the Tax related to this account and the counter-part "Account Payable".</field>
|
||||
</record>
|
||||
<menuitem action="action_account_moves_purchase"
|
||||
id="menu_eaction_account_moves_purchase"
|
||||
parent="menu_finance_payables"
|
||||
icon="STOCK_JUSTIFY_FILL"
|
||||
sequence="16"
|
||||
groups="group_account_user,group_account_manager"/>
|
||||
|
||||
<record id="action_account_moves_bank" model="ir.actions.act_window">
|
||||
<field name="name">Journal Items</field>
|
||||
<field name="res_model">account.move.journal</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="context">{'journal_type':'bank'}</field>
|
||||
<field name="help">This view is used by accountants in order to record entries massively in OpenERP. Journal items are created by OpenERP if you use Bank Statements, Cash Registers, or Customer/Supplier payments.</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="action_view_move_line" model="ir.actions.act_window">
|
||||
<field name="name">Lines to reconcile</field>
|
||||
<field name="res_model">account.move.line</field>
|
||||
|
@ -1638,6 +1559,7 @@ Sale Refund :
|
|||
</p>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<menuitem
|
||||
name="Journal Items to Reconcile"
|
||||
action="action_account_manual_reconcile"
|
||||
|
|
|
@ -0,0 +1,104 @@
|
|||
|
||||
openerp.account.quickadd = function (instance) {
|
||||
var _t = instance.web._t,
|
||||
_lt = instance.web._lt;
|
||||
var QWeb = instance.web.qweb;
|
||||
|
||||
instance.web.account = instance.web.account || {};
|
||||
|
||||
instance.web.views.add('tree_account_move_line_quickadd', 'instance.web.account.QuickAddListView');
|
||||
instance.web.account.QuickAddListView = instance.web.ListView.extend({
|
||||
_template: 'ListView',
|
||||
|
||||
init: function() {
|
||||
this._super.apply(this, arguments);
|
||||
this.journals = [];
|
||||
this.periods = [];
|
||||
this.current_journal = null;
|
||||
this.current_period = null;
|
||||
this.default_period = null;
|
||||
this.default_journal = null;
|
||||
this.current_journal_type = null;
|
||||
this.current_journal_currency = null;
|
||||
this.current_journal_analytic = null;
|
||||
},
|
||||
start:function(){
|
||||
var tmp = this._super.apply(this, arguments);
|
||||
var self = this;
|
||||
this.$el.parent().prepend(QWeb.render("AccountMoveLineQuickAdd", {widget: this}));
|
||||
|
||||
this.$el.parent().find('.oe_account_select_journal').change(function() {
|
||||
self.current_journal = parseInt(this.value);
|
||||
self.do_search(self.last_domain, self.last_context, self.last_group_by);
|
||||
});
|
||||
this.$el.parent().find('.oe_account_select_period').change(function() {
|
||||
self.current_period = parseInt(this.value);
|
||||
self.do_search(self.last_domain, self.last_context, self.last_group_by);
|
||||
});
|
||||
this.on('edit:after', this, function () {
|
||||
self.$el.parent().find('.oe_account_select_journal').attr('disabled', 'disabled');
|
||||
self.$el.parent().find('.oe_account_select_period').attr('disabled', 'disabled');
|
||||
});
|
||||
this.on('save:after cancel:after', this, function () {
|
||||
self.$el.parent().find('.oe_account_select_journal').removeAttr('disabled');
|
||||
self.$el.parent().find('.oe_account_select_period').removeAttr('disabled');
|
||||
});
|
||||
return tmp;
|
||||
},
|
||||
do_search: function(domain, context, group_by) {
|
||||
var self = this;
|
||||
this.last_domain = domain;
|
||||
this.last_context = context;
|
||||
this.last_group_by = group_by;
|
||||
this.old_search = _.bind(this._super, this);
|
||||
var mod = new instance.web.Model("account.move.line", context, domain);
|
||||
return $.when(mod.call("list_journals", []).then(function(result) {
|
||||
self.journals = result;
|
||||
}),mod.call("list_periods", []).then(function(result) {
|
||||
self.periods = result;
|
||||
}),mod.call("default_get", [['journal_id','period_id'],self.last_context]).then(function(result) {
|
||||
self.default_period = result['period_id'];
|
||||
self.default_journal = result['journal_id'];
|
||||
})).then(function () {
|
||||
self.current_journal = self.current_journal === null ? self.default_journal : self.current_journal;
|
||||
self.current_period = self.current_period === null ? self.default_period :self.current_period;
|
||||
var o;
|
||||
//self.$('.oe_account_select_journal',self.$el.parent())[0].children().remove().end();
|
||||
self.$el.parent().find('.oe_account_select_journal').children().remove().end();
|
||||
for (var i = 0;i < self.journals.length;i++){
|
||||
o = new Option(self.journals[i][1], self.journals[i][0]);
|
||||
if (self.journals[i][0] === self.current_journal){
|
||||
self.current_journal_type = self.journals[i][2];
|
||||
self.current_journal_currency = self.journals[i][3];
|
||||
self.current_journal_analytic = self.journals[i][4];
|
||||
$(o).attr('selected',true);
|
||||
}
|
||||
self.$el.parent().find('.oe_account_select_journal').append(o);
|
||||
}
|
||||
self.$el.parent().find('.oe_account_select_period').children().remove().end();
|
||||
for (var i = 0;i < self.periods.length;i++){
|
||||
o = new Option(self.periods[i][1], self.periods[i][0]);
|
||||
self.$el.parent().find('.oe_account_select_period').append(o);
|
||||
}
|
||||
self.$el.parent().find('.oe_account_select_period').val(self.current_period).attr('selected',true);
|
||||
return self.search_by_journal_period();
|
||||
});
|
||||
},
|
||||
search_by_journal_period: function() {
|
||||
var self = this;
|
||||
|
||||
var compoundDomain = new instance.web.CompoundDomain(self.last_domain,
|
||||
[
|
||||
["journal_id", "=", self.current_journal],
|
||||
["period_id", "=", self.current_period]
|
||||
]);
|
||||
self.last_context["journal_id"] = self.current_journal;
|
||||
self.last_context["period_id"] = self.current_period;
|
||||
self.last_context["journal_type"] = self.current_journal_type;
|
||||
self.last_context["currency"] = self.current_journal_currency;
|
||||
self.last_context["analytic_journal_id"] = self.current_journal_analytic;
|
||||
var compoundContext = self.last_context;
|
||||
return self.old_search(compoundDomain, compoundContext, self.last_group_by);
|
||||
},
|
||||
});
|
||||
};
|
|
@ -1,9 +1,10 @@
|
|||
openerp.account = function (instance) {
|
||||
openerp.account.quickadd(instance);
|
||||
var _t = instance.web._t,
|
||||
_lt = instance.web._lt;
|
||||
var QWeb = instance.web.qweb;
|
||||
|
||||
instance.web.account = {};
|
||||
instance.web.account = instance.web.account || {};
|
||||
|
||||
instance.web.views.add('tree_account_reconciliation', 'instance.web.account.ReconciliationListView');
|
||||
instance.web.account.ReconciliationListView = instance.web.ListView.extend({
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<templates id="template" xml:space="preserve">
|
||||
|
||||
<t t-name="AccountMoveLineQuickAdd">
|
||||
<div class="oe_account_quickadd ui-toolbar" style="margin-bottom:0px;">
|
||||
<div class="oe_form_dropdown_section">
|
||||
<h4>Period :</h4>
|
||||
<select class="oe_account_select_period">
|
||||
|
||||
</select>
|
||||
</div>
|
||||
<div class="oe_form_dropdown_section">
|
||||
<h4>Journal :</h4>
|
||||
<select class="oe_account_select_journal" >
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
</templates>
|
|
@ -32,8 +32,8 @@
|
|||
import time
|
||||
date = self._get_date(cr, uid, {'lang': u'en_US', 'normal_view': False, 'active_model': 'ir.ui.menu',
|
||||
'search_default_journal_id': 1, 'journal_type': 'sale', 'search_default_period_id': 6, 'journal_id': 1, 'view_mode': False,
|
||||
'visible_id': 1, 'period_id': 6, 'tz': False, 'active_ids': [ref('menu_eaction_account_moves_sale')],
|
||||
'search_default_posted': 0, 'active_id': ref('menu_eaction_account_moves_sale')})
|
||||
'visible_id': 1, 'period_id': 6, 'tz': False, 'active_ids': [ref('action_account_manual_account_move_line_quickadd')],
|
||||
'search_default_posted': 0, 'active_id': ref('action_account_manual_account_move_line_quickadd')})
|
||||
partner = self.onchange_partner_id(cr, uid, [], False, ref('base.res_partner_12'), ref('account.cash'), debit=0, credit=2000, date=date, journal=False)
|
||||
account = self.onchange_account_id(cr, uid, [], account_id=ref('account.a_recv'), partner_id= ref('base.res_partner_12'))
|
||||
vals = {
|
||||
|
@ -62,11 +62,11 @@
|
|||
!python {model: account.move.line}: |
|
||||
ids = self._balance_search(cr, uid, self, 'balance', [('balance', '=', 2000.0)], None, {'lang': u'en_US', 'tz': False, 'active_model': 'ir.ui.menu',
|
||||
'search_default_journal_id': 1, 'journal_type': 'sale', 'search_default_period_id': 6, 'view_mode': False, 'visible_id': 1,
|
||||
'active_ids': [ref('menu_eaction_account_moves_sale')], 'search_default_posted': 0, 'active_id': ref('menu_eaction_account_moves_sale')})
|
||||
'active_ids': [ref('action_account_manual_account_move_line_quickadd')], 'search_default_posted': 0, 'active_id': ref('action_account_manual_account_move_line_quickadd')})
|
||||
bal = self._balance(cr, uid, ids[0][2], 'balance', None,{'lang': u'en_US', 'tz': False, 'active_model': 'ir.ui.menu',
|
||||
'search_default_journal_id': 1, 'journal_type': 'sale', 'search_default_period_id': 6, 'view_mode': False,
|
||||
'visible_id': 1, 'active_ids': [ref('menu_eaction_account_moves_sale')], 'search_default_posted': 0,
|
||||
'active_id': ref('menu_eaction_account_moves_sale')})
|
||||
'visible_id': 1, 'active_ids': [ref('action_account_manual_account_move_line_quickadd')], 'search_default_posted': 0,
|
||||
'active_id': ref('action_account_manual_account_move_line_quickadd')})
|
||||
assert bal, 'Balance has not been computed correctly'
|
||||
-
|
||||
I check that Initially account move state is "Draft"
|
||||
|
|
Loading…
Reference in New Issue