diff --git a/addons/account/account.py b/addons/account/account.py
index 6d074beb646..1033f02f841 100644
--- a/addons/account/account.py
+++ b/addons/account/account.py
@@ -586,12 +586,12 @@ class account_journal(osv.osv):
_columns = {
'name': fields.char('Journal Name', size=64, required=True, translate=True),
'code': fields.char('Code', size=16, required=True, help="The code will be used to generate the numbers of the journal entries of this journal."),
- 'type': fields.selection([('sale', 'Sale'),('sale_refund','Sale Refund'), ('purchase', 'Purchase'), ('purchase_refund','Purchase Refund'), ('cash', 'Cash'), ('bank', 'Bank and Cheques'), ('general', 'General'), ('situation', 'Situation')], 'Type', size=32, required=True,
+ 'type': fields.selection([('sale', 'Sale'),('sale_refund','Sale Refund'), ('purchase', 'Purchase'), ('purchase_refund','Purchase Refund'), ('cash', 'Cash'), ('bank', 'Bank and Cheques'), ('general', 'General'), ('situation', 'Opening/Closing Situation')], 'Type', size=32, required=True,
help="Select 'Sale' for Sale journal to be used at the time of making invoice."\
" Select 'Purchase' for Purchase Journal to be used at the time of approving purchase order."\
" Select 'Cash' to be used at the time of making payment."\
- " Select 'General' to be used at the time of stock input/output."\
- " Select 'Situation' to be used at the time of making vouchers."),
+ " Select 'General' for miscellaneous operations."\
+ " Select 'Opening/Closing Situation' to be used at the time of new fiscal year creation or end of year entries generation."),
'refund_journal': fields.boolean('Refund Journal', help='Fill this if the journal is to be used for refunds of invoices.'),
'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')]),
@@ -614,6 +614,21 @@ class account_journal(osv.osv):
'user_id': lambda self,cr,uid,context: uid,
'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
}
+ _sql_constraints = [
+ ('code_company_uniq', 'unique (code, company_id)', 'The code of the journal must be unique per company !'),
+ ('name_company_uniq', 'unique (name, company_id)', 'The name of the journal must be unique per company !'),
+ ]
+
+ _order = 'code'
+
+ def copy(self, cr, uid, id, default={}, context=None, done_list=[], local=False):
+ journal = self.browse(cr, uid, id, context=context)
+ if not default:
+ default = {}
+ default = default.copy()
+ default['code'] = (journal['code'] or '') + '(copy)'
+ default['name'] = (journal['name'] or '') + '(copy)'
+ return super(account_journal, self).copy(cr, uid, id, default, context=context)
def write(self, cr, uid, ids, vals, context=None):
if 'company_id' in vals:
@@ -1109,7 +1124,7 @@ class account_move(osv.osv):
'name': '/',
'state': 'draft',
'period_id': _get_period,
- 'date': time.strftime('%Y-%m-%d'),
+ 'date': lambda *a: time.strftime('%Y-%m-%d'),
'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
}
@@ -1584,7 +1599,6 @@ class account_tax_code(osv.osv):
'notprintable':fields.boolean("Not Printable in Invoice", help="Check this box if you don't want any VAT related to this Tax Code to appear on invoices"),
}
-
def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80):
if not args:
args = []
@@ -1627,7 +1641,7 @@ class account_tax_code(osv.osv):
_constraints = [
(_check_recursion, 'Error ! You can not create recursive accounts.', ['parent_id'])
]
- _order = 'code,name'
+ _order = 'code'
account_tax_code()
class account_tax(osv.osv):
@@ -2143,7 +2157,7 @@ class account_subscription(osv.osv):
'lines_id': fields.one2many('account.subscription.line', 'subscription_id', 'Subscription Lines')
}
_defaults = {
- 'date_start': time.strftime('%Y-%m-%d'),
+ 'date_start': lambda *a: time.strftime('%Y-%m-%d'),
'period_type': 'month',
'period_total': 12,
'period_nbr': 1,
@@ -2541,8 +2555,8 @@ class wizard_multi_charts_accounts(osv.osv_memory):
'bank_accounts_id': fields.one2many('account.bank.accounts.wizard', 'bank_account_id', 'Bank Accounts', required=True),
'code_digits':fields.integer('# of Digits', required=True, help="No. of Digits to use for account code"),
'seq_journal':fields.boolean('Separated Journal Sequences', help="Check this box if you want to use a different sequence for each created journal. Otherwise, all will use the same sequence."),
- "sale_tax": fields.many2one("account.tax.template", "Sale Tax"),
- "purchase_tax": fields.many2one("account.tax.template", "Purchase Tax"),
+ "sale_tax": fields.many2one("account.tax.template", "Default Sale Tax"),
+ "purchase_tax": fields.many2one("account.tax.template", "Default Purchase Tax"),
}
def onchange_chart_template_id(self, cr, uid, ids, chart_template_id=False, context=None):
res = {}
@@ -2550,12 +2564,12 @@ class wizard_multi_charts_accounts(osv.osv_memory):
res['value']["sale_tax"] = False
res['value']["purchase_tax"] = False
if chart_template_id:
- ids = self.pool.get('account.tax.template').search(cr, uid, [("chart_template_id"
- , "=", chart_template_id)], order="sequence")
- if len(ids) > 0:
- id=ids[0]
- res['value']["sale_tax"] = id
- res['value']["purchase_tax"] = id
+ sale_tax_ids = self.pool.get('account.tax.template').search(cr, uid, [("chart_template_id"
+ , "=", chart_template_id), ('type_tax_use', 'in', ('sale','all'))], order="sequence")
+ purchase_tax_ids = self.pool.get('account.tax.template').search(cr, uid, [("chart_template_id"
+ , "=", chart_template_id), ('type_tax_use', 'in', ('purchase','all'))], order="sequence")
+ res['value']["sale_tax"] = sale_tax_ids and sale_tax_ids[0] or False
+ res['value']["purchase_tax"] = purchase_tax_ids and purchase_tax_ids[0] or False
return res
def _get_chart(self, cr, uid, context={}):
@@ -2708,9 +2722,17 @@ class wizard_multi_charts_accounts(osv.osv_memory):
if obj_multi.seq_journal:
seq_id_sale = obj_sequence.search(cr, uid, [('name','=','Sale Journal')])[0]
seq_id_purchase = obj_sequence.search(cr, uid, [('name','=','Purchase Journal')])[0]
+ seq_id_sale_refund = obj_sequence.search(cr, uid, [('name','=','Sales Refund Journal')])
+ if seq_id_sale_refund:
+ seq_id_sale_refund = seq_id_sale_refund[0]
+ seq_id_purchase_refund = obj_sequence.search(cr, uid, [('name','=','Purchase Refund Journal')])
+ if seq_id_purchase_refund:
+ seq_id_purchase_refund = seq_id_purchase_refund[0]
else:
seq_id_sale = seq_id
seq_id_purchase = seq_id
+ seq_id_sale_refund = seq_id
+ seq_id_purchase_refund = seq_id
vals_journal['view_id'] = view_id
@@ -2749,6 +2771,60 @@ class wizard_multi_charts_accounts(osv.osv_memory):
obj_journal.create(cr,uid,vals_journal)
+ # Creating Journals Sales Refund and Purchase Refund
+ vals_journal = {}
+ data_id = obj_data.search(cr, uid, [('model', '=', 'account.journal.view'), ('name', '=', 'account_sp_refund_journal_view')], context=context)
+ data = obj_data.browse(cr, uid, data_id[0], context=context)
+ view_id = data.res_id
+
+ #Sales Refund Journal
+ vals_journal = {
+ 'view_id': view_id,
+ 'name': _('Sales Refund Journal'),
+ 'type': 'sale_refund',
+ 'refund_journal': True,
+ 'code': _('SCNJ'),
+ 'sequence_id': seq_id_sale_refund,
+ 'analytic_journal_id': analitical_journal_sale,
+ 'company_id': company_id
+ }
+
+ if obj_multi.chart_template_id.property_account_receivable:
+ vals_journal['default_credit_account_id'] = acc_template_ref[obj_multi.chart_template_id.property_account_income_categ.id]
+ vals_journal['default_debit_account_id'] = acc_template_ref[obj_multi.chart_template_id.property_account_income_categ.id]
+
+
+# if obj_multi.property_account_receivable:
+# vals_journal.update({
+# 'default_credit_account_id': acc_template_ref[obj_multi.chart_template_id.property_account_income_categ.id],
+# 'default_debit_account_id': acc_template_ref[obj_multi.chart_template_id.property_account_income_categ.id]
+# })
+ obj_journal.create(cr, uid, vals_journal, context=context)
+
+ # Purchase Refund Journal
+ vals_journal = {
+ 'view_id': view_id,
+ 'name': _('Purchase Refund Journal'),
+ 'type': 'purchase_refund',
+ 'refund_journal': True,
+ 'code': _('ECNJ'),
+ 'sequence_id': seq_id_purchase_refund,
+ 'analytic_journal_id': analitical_journal_purchase,
+ 'company_id': company_id
+ }
+
+ if obj_multi.chart_template_id.property_account_payable:
+ vals_journal['default_credit_account_id'] = acc_template_ref[obj_multi.chart_template_id.property_account_expense_categ.id]
+ vals_journal['default_debit_account_id'] = acc_template_ref[obj_multi.chart_template_id.property_account_expense_categ.id]
+
+
+# if obj_multi.property_account_payable:
+# vals_journal.update({
+# 'default_credit_account_id': acc_template_ref[obj_multi.property_account_expense_categ.id],
+# 'default_debit_account_id': acc_template_ref[obj_multi.property_account_expense_categ.id]
+# })
+ obj_journal.create(cr, uid, vals_journal, context=context)
+
# Bank Journals
data_id = obj_data.search(cr, uid, [('model','=','account.journal.view'), ('name','=','account_journal_bank_view')])
data = obj_data.browse(cr, uid, data_id[0])
@@ -2883,18 +2959,18 @@ class wizard_multi_charts_accounts(osv.osv_memory):
wizard_multi_charts_accounts()
class account_bank_accounts_wizard(osv.osv_memory):
- _name='account.bank.accounts.wizard'
+ _name = 'account.bank.accounts.wizard'
_columns = {
- 'acc_name':fields.char('Account Name.', size=64, required=True),
- 'bank_account_id':fields.many2one('wizard.multi.charts.accounts', 'Bank Account', required=True),
- 'currency_id':fields.many2one('res.currency', 'Currency'),
- 'account_type':fields.selection([('cash','Cash'),('check','Check'),('bank','Bank')], 'Type', size=32),
+ 'acc_name': fields.char('Account Name.', size=64, required=True),
+ 'bank_account_id': fields.many2one('wizard.multi.charts.accounts', 'Bank Account', required=True),
+ 'currency_id': fields.many2one('res.currency', 'Currency'),
+ 'account_type': fields.selection([('cash','Cash'),('check','Check'),('bank','Bank')], 'Type', size=32),
}
_defaults = {
'currency_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.currency_id.id,
- }
+ }
account_bank_accounts_wizard()
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/account/account_analytic_line.py b/addons/account/account_analytic_line.py
index 497b7cdc8ae..5730245b83c 100644
--- a/addons/account/account_analytic_line.py
+++ b/addons/account/account_analytic_line.py
@@ -41,7 +41,7 @@ class account_analytic_line(osv.osv):
}
_defaults = {
- 'date': time.strftime('%Y-%m-%d'),
+ 'date': lambda *a: time.strftime('%Y-%m-%d'),
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.analytic.line', context=c),
}
_order = 'date desc'
diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py
index 41cb20ba2d1..aa4f45bad58 100644
--- a/addons/account/account_bank_statement.py
+++ b/addons/account/account_bank_statement.py
@@ -141,7 +141,7 @@ class account_bank_statement(osv.osv):
res[statement_id] = (currency_id, currency_names[currency_id])
return res
- _order = "date desc"
+ _order = "date desc, id desc"
_name = "account.bank.statement"
_description = "Bank Statement"
_columns = {
@@ -173,7 +173,7 @@ class account_bank_statement(osv.osv):
_defaults = {
'name': "/",
- 'date': time.strftime('%Y-%m-%d'),
+ 'date': lambda *a: time.strftime('%Y-%m-%d'),
'state': 'draft',
'balance_start': _default_balance_start,
'journal_id': _default_journal_id,
@@ -271,13 +271,10 @@ class account_bank_statement(osv.osv):
if st_line.account_id and st_line.account_id.currency_id and st_line.account_id.currency_id.id <> company_currency_id:
val['currency_id'] = st_line.account_id.currency_id.id
- if company_currency_id==st_line.account_id.currency_id.id:
- amount_cur = st_line.amount
- else:
- amount_cur = res_currency_obj.compute(cr, uid, company_currency_id,
- st_line.account_id.currency_id.id, amount, context=context,
- account=acc_cur)
- val['amount_currency'] = amount_cur
+ amount_cur = res_currency_obj.compute(cr, uid, company_currency_id,
+ st_line.account_id.currency_id.id, amount, context=context,
+ account=acc_cur)
+ val['amount_currency'] = -amount_cur
move_line_id = account_move_line_obj.create(cr, uid, val, context=context)
torec.append(move_line_id)
@@ -473,7 +470,7 @@ class account_bank_statement_line(osv.osv):
}
_defaults = {
'name': lambda self,cr,uid,context={}: self.pool.get('ir.sequence').get(cr, uid, 'account.bank.statement.line'),
- 'date': time.strftime('%Y-%m-%d'),
+ 'date': lambda *a: time.strftime('%Y-%m-%d'),
'type': 'general',
}
diff --git a/addons/account/account_cash_statement.py b/addons/account/account_cash_statement.py
index db3325e313c..ffcc979169d 100644
--- a/addons/account/account_cash_statement.py
+++ b/addons/account/account_cash_statement.py
@@ -233,7 +233,7 @@ class account_cash_statement(osv.osv):
}
_defaults = {
'state': 'draft',
- 'date': time.strftime("%Y-%m-%d %H:%M:%S"),
+ 'date': lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
'user_id': lambda self, cr, uid, context=None: uid,
'starting_details_ids': _get_cash_open_box_lines,
'ending_details_ids': _get_default_cash_close_box_lines
diff --git a/addons/account/account_end_fy.xml b/addons/account/account_end_fy.xml
index d0c966898d6..5f4ed44adfe 100644
--- a/addons/account/account_end_fy.xml
+++ b/addons/account/account_end_fy.xml
@@ -8,7 +8,7 @@
form
{'search_default_draft': 1}
- After closing a period, you will no longer be able to post entries to the period once it has been closed.
+ A period is a fiscal period of time during which accounting entries should be recorded for accounting related activities. Monthly period is the norm but depending on your countries or company needs, you could also have quarterly periods. Closing a period will make it impossible to record new accounting entries, all new entries should then be made on the following open period. Close a period when you do not want to record new entries and want to lock this period for tax related calculation.