[MERGE] forward port branch 9.0 up to 30dda3faee

This commit is contained in:
Christophe Simonis
2017-03-28 13:21:24 +02:00
6 changed files with 40 additions and 30 deletions
@@ -2,7 +2,8 @@
Create demo bank statement
-
!python {model: ir.model.data} : |
journal_id = self.pool.get('account.journal').search(cr, uid, [('type', '=', 'bank')])
default_company = self.pool.get('res.company')._company_default_get(cr, uid, 'account.journal')
journal_id = self.pool.get('account.journal').search(cr, uid, [('type', '=', 'bank'), ('company_id', '=', default_company)], limit=1)
import time
if journal_id:
journal_id = journal_id[0]
@@ -11,7 +12,6 @@
'date': time.strftime('%Y')+'-01-01',
'name': "BNK/2014/001",
'balance_end_real': '8998.2',
'company_id': ref('base.main_company'),
'balance_start': 5103.0
}
self._update(cr, uid, 'account.bank.statement', 'account', vals, 'demo_bank_statement_1')
@@ -19,7 +19,6 @@
'ref': '',
'statement_id': ref('account.demo_bank_statement_1'),
'sequence': 1,
'company_id': ref('base.main_company'),
'name': "SAJ/2014/002 and SAJ/2014/003",
'journal_id': journal_id,
'amount': 1175.0,
@@ -31,7 +30,6 @@
'ref': '',
'statement_id': ref('account.demo_bank_statement_1'),
'sequence': 2,
'company_id': ref('base.main_company'),
'name': "Bank fees",
'journal_id': journal_id,
'amount': -32.58,
@@ -42,7 +40,6 @@
'ref': '',
'statement_id': ref('account.demo_bank_statement_1'),
'sequence': 3,
'company_id': ref('base.main_company'),
'name': "Prepayment",
'journal_id': journal_id,
'amount': 650.0,
@@ -54,7 +51,6 @@
'ref': '',
'statement_id': ref('account.demo_bank_statement_1'),
'sequence': 4,
'company_id': ref('base.main_company'),
'name': "First 2000 € of SAJ/2014/001",
'journal_id': journal_id,
'amount': 2000.0,
@@ -66,7 +62,6 @@
'ref': '',
'statement_id': ref('account.demo_bank_statement_1'),
'sequence': 5,
'company_id': ref('base.main_company'),
'name': "Last Year Interests",
'journal_id': journal_id,
'amount': 102.78,
+17 -17
View File
@@ -2,7 +2,6 @@
Set the context for customer invoices because the 'type' field is readonly in invoice form views, so it value won't be considered by the yaml import
-
!record {model: account.invoice, id: demo_invoice_1}:
company_id: base.main_company
partner_id: base.res_partner_12
user_id: base.user_demo
reference_type: none
@@ -20,7 +19,6 @@
!workflow {model: account.invoice, action: invoice_open, ref: demo_invoice_1}
-
!record {model: account.invoice, id: demo_invoice_2}:
company_id: base.main_company
partner_id: base.res_partner_2
type: 'out_invoice'
date_invoice: !eval time.strftime('%Y-%m')+'-08'
@@ -35,7 +33,6 @@
!workflow {model: account.invoice, action: invoice_open, ref: demo_invoice_2}
-
!record {model: account.invoice, id: demo_invoice_3}:
company_id: base.main_company
partner_id: base.res_partner_2
type: 'out_invoice'
date_invoice: !eval time.strftime('%Y-%m')+'-08'
@@ -55,7 +52,6 @@
type: 'in_invoice'
-
!record {model: account.invoice, id: demo_invoice_0}:
company_id: base.main_company
partner_id: base.res_partner_12
user_id: base.user_demo
reference_type: none
@@ -73,7 +69,6 @@
uom_id: product.product_uom_unit
-
!record {model: account.invoice, id: demo_invoice_january_wages}:
company_id: base.main_company
partner_id: base.res_partner_12
type: 'in_invoice'
date_invoice: !eval time.strftime('%Y-%m')+'-01'
@@ -84,16 +79,16 @@
'name': "CEO wages",
'price_unit': 10000,
}
account_id = self.pool.get('account.account').search(cr, uid, [('tag_ids', 'in', [ref('account.demo_ceo_wages_account')])])
default_company = self.pool.get('res.company')._company_default_get(cr, uid, 'account.account')
account_id = self.pool.get('account.account').search(cr, uid, [('tag_ids', 'in', [ref('account.demo_ceo_wages_account')]), ('company_id', '=', default_company)])
if not account_id:
account_id = self.pool.get('account.account').search(cr, uid, [('user_type_id', '=', ref('account.data_account_type_expenses'))])
account_id = self.pool.get('account.account').search(cr, uid, [('user_type_id', '=', ref('account.data_account_type_expenses')), ('company_id', '=', default_company)])
if account_id:
line_vals['account_id'] = account_id[0]
self._update(cr, uid, 'account.invoice.line', 'account', line_vals, 'ceo_wages_line')
self.pool.get('account.invoice').signal_workflow(cr, uid, [ref('demo_invoice_january_wages')], 'invoice_open')
-
!record {model: account.invoice, id: demo_invoice_equipment_purchase}:
company_id: base.main_company
partner_id: base.res_partner_1
type: 'in_invoice'
date_invoice: !eval time.strftime('%Y-%m')+'-15'
@@ -104,12 +99,14 @@
'name': "Coffee Machine with huge 'employee\'s performances boosting perk'",
'price_unit': 4999.99,
}
account_id = self.pool.get('account.account').search(cr, uid, [('tag_ids', 'in', [ref('account.demo_coffee_machine_account')])])
account_default_company = self.pool.get('res.company')._company_default_get(cr, uid, 'account.account')
account_id = self.pool.get('account.account').search(cr, uid, [('tag_ids', 'in', [ref('account.demo_coffee_machine_account')]), ('company_id', '=', account_default_company)])
if not account_id:
account_id = self.pool.get('account.account').search(cr, uid, [('user_type_id', '=', ref('account.data_account_type_expenses'))])
account_id = self.pool.get('account.account').search(cr, uid, [('user_type_id', '=', ref('account.data_account_type_expenses')), ('company_id', '=', account_default_company)])
if account_id:
line_vals['account_id'] = account_id[0]
tax_id = self.pool.get('account.tax').search(cr, uid, [('type_tax_use', '=', 'purchase'), ('amount', '>', 0)])
tax_default_company = self.pool.get('res.company')._company_default_get(cr, uid, 'account.tax')
tax_id = self.pool.get('account.tax').search(cr, uid, [('type_tax_use', '=', 'purchase'), ('amount', '>', 0), ('company_id', '=', tax_default_company)])
if tax_id:
line_vals['invoice_line_tax_ids'] = [(6, 0, [tax_id[0]])]
self._update(cr, uid, 'account.invoice.line', 'account', line_vals, 'coffee_machine_line')
@@ -117,7 +114,8 @@
self.pool.get('account.invoice').signal_workflow(cr, uid, [ref('demo_invoice_equipment_purchase')], 'invoice_open')
-
!python {model: account.bank.statement.line} : |
account_ids = self.pool.get('account.account').search(cr, uid, [('user_type_id', '=', ref('account.data_account_type_revenue')), ('tag_ids', 'in', [ref('account.account_tag_financing')])])
default_company = self.pool('res.company')._company_default_get(cr, uid, 'account.account')
account_ids = self.pool.get('account.account').search(cr, uid, [('user_type_id', '=', ref('account.data_account_type_revenue')), ('tag_ids', 'in', [ref('account.account_tag_financing')]), ('company_id', '=', default_company)])
line = self.browse(cr, uid, ref('account.demo_bank_statement_line_5'))
if not line.journal_entry_ids and account_ids:
line.write({'account_id': account_ids[0]})
@@ -126,20 +124,22 @@
!python {model: ir.model.data} : |
from datetime import datetime
from dateutil.relativedelta import relativedelta
default_company = self.pool('res.company')._company_default_get(cr, uid, 'account.journal')
vals = {
'company_id': ref('base.main_company'),
'journal_id': self.pool.get('account.journal').search(cr, uid, [('type', '=', 'general')])[0],
'journal_id': self.pool.get('account.journal').search(cr, uid, [('type', '=', 'general'), ('company_id', '=', default_company)])[0],
'date': datetime.now().replace(day=1,month=1) - relativedelta(days=1),
'ref': 'Company Creation',
}
self._update(cr, uid, 'account.move', 'account', vals, 'demo_opening_move')
-
!python {model: ir.model.data} : |
bank_journal_id = self.pool.get('account.journal').search(cr, uid, [('type', '=', 'bank')])[0]
journal_default_company = self.pool('res.company')._company_default_get(cr, uid, 'account.journal')
bank_journal_id = self.pool.get('account.journal').search(cr, uid, [('type', '=', 'bank'), ('company_id', '=', journal_default_company)])[0]
if bank_journal_id:
bank_account_id = self.pool.get('account.journal').browse(cr, uid, bank_journal_id).default_debit_account_id.id
fixed_asset_account_ids = self.pool.get('account.account').search(cr, uid, [('user_type_id', 'in', (ref('account.data_account_type_fixed_assets'),ref('account.data_account_type_current_assets')))])
equity_account_ids = self.pool.get('account.account').search(cr, uid, [('user_type_id', '=', ref('account.data_account_type_equity')), ('tag_ids', 'in', [ref('account.demo_capital_account')])])
account_default_company = self.pool.get('res.company')._company_default_get(cr, uid, 'account.account')
fixed_asset_account_ids = self.pool.get('account.account').search(cr, uid, [('user_type_id', 'in', (ref('account.data_account_type_fixed_assets'),ref('account.data_account_type_current_assets'))), ('company_id', '=', account_default_company)])
equity_account_ids = self.pool.get('account.account').search(cr, uid, [('user_type_id', '=', ref('account.data_account_type_equity')), ('tag_ids', 'in', [ref('account.demo_capital_account')]), ('company_id', '=', account_default_company)])
if bank_account_id and fixed_asset_account_ids and equity_account_ids:
self._update(cr, uid, 'account.move.line', 'account', {
'move_id': ref('account.demo_opening_move'),
+9
View File
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from openerp import fields, models, api, _
from openerp.exceptions import ValidationError
from datetime import timedelta
@@ -79,6 +80,14 @@ Best Regards,''')
@api.multi
def write(self, values):
#restrict the closing of FY if there are still unposted entries
if values.get('fiscalyear_lock_date'):
nb_draft_entries = self.env['account.move'].search([
('company_id', 'in', [c.id for c in self]),
('state', '=', 'draft'),
('date', '<=', values['fiscalyear_lock_date'])])
if nb_draft_entries:
raise ValidationError(_('There are still unposted entries in the period you want to lock. You should either post or delete them.'))
# Reflect the change on accounts
for company in self:
digits = values.get('accounts_code_digits') or company.accounts_code_digits
@@ -11,10 +11,15 @@ class TestPeriodState(AccountingTestCase):
def setUp(self):
super(TestPeriodState, self).setUp()
cr, uid = self.cr, self.uid
self.user_id = self.env['res.users'].browse(self.uid)
self.day_before_yesterday = datetime.now() - timedelta(2)
self.yesterday = datetime.now() - timedelta(1)
self.user_id = self.env['res.users'].browse(self.uid)
self.user_id.company_id.write({'fiscalyear_lock_date': self.yesterday.strftime(DEFAULT_SERVER_DATE_FORMAT)})
self.yesterday_str = self.yesterday.strftime(DEFAULT_SERVER_DATE_FORMAT)
#make sure there is no unposted entry
draft_entries = self.env['account.move'].search([('date', '<=', self.yesterday_str), ('state', '=', 'draft')])
if draft_entries:
draft_entries.post()
self.user_id.company_id.write({'fiscalyear_lock_date': self.yesterday_str})
self.sale_journal_id = self.env['account.journal'].search([('type', '=', 'sale')])[0]
self.account_id = self.env['account.account'].search([('internal_type', '=', 'receivable')])[0]
@@ -101,7 +101,6 @@ class account_payment(models.Model):
raise UserError(_("In order to print multiple checks at once, they must belong to the same bank journal."))
self.filtered(lambda r: r.state == 'draft').post()
self.write({'state': 'sent'})
if not self[0].journal_id.check_manual_sequencing:
# The wizard asks for the number printed on the first pre-printed check
@@ -1,4 +1,6 @@
#wrapwrap {
width: 85%;
margin: 0 auto;
}
@media (min-width: @screen-sm-min){
width: 85%;
margin: 0 auto;
}
}