diff --git a/addons/account/__terp__.py b/addons/account/__terp__.py
index 130e094d8be..fc4c16319ff 100644
--- a/addons/account/__terp__.py
+++ b/addons/account/__terp__.py
@@ -64,7 +64,8 @@
'project/project_demo.xml',
'project/analytic_account_demo.xml',
'demo/account_minimal.xml',
- 'account_unit_test.xml'
+ 'account_unit_test.xml',
+ 'demo/multi_company_demo.xml',
],
'installable': True,
'active': False,
diff --git a/addons/account/account.py b/addons/account/account.py
index 1c45b6cd415..a67bb002d35 100644
--- a/addons/account/account.py
+++ b/addons/account/account.py
@@ -478,7 +478,8 @@ class account_journal(osv.osv):
'groups_id': fields.many2many('res.groups', 'account_journal_group_rel', 'journal_id', 'group_id', 'Groups'),
'currency': fields.many2one('res.currency', 'Currency', help='The currency used to enter statement'),
'entry_posted': fields.boolean('Skip \'Draft\' State for Created Entries', help='Check this box if you don\'t want new account moves to pass through the \'draft\' state and instead goes directly to the \'posted state\' without any manual validation.'),
- 'company_id': fields.related('default_credit_account_id','company_id',type='many2one', relation="res.company", string="Company"),
+ #'company_id': fields.related('default_credit_account_id','company_id',type='many2one', relation="res.company", string="Company"),
+ 'company_id': fields.many2one('res.company', 'Company', required=True,select=1),
'invoice_sequence_id': fields.many2one('ir.sequence', 'Invoice Sequence', \
help="The sequence used for invoice numbers in this journal."),
}
@@ -486,6 +487,7 @@ class account_journal(osv.osv):
_defaults = {
'active': lambda *a: 1,
'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,
}
def create(self, cr, uid, vals, context={}):
journal_id = super(account_journal, self).create(cr, uid, vals, context)
@@ -520,7 +522,7 @@ class account_fiscalyear(osv.osv):
'name': fields.char('Fiscal Year', size=64, required=True),
'code': fields.char('Code', size=6, required=True),
'company_id': fields.many2one('res.company', 'Company',
- help="Keep empty if the fiscal year belongs to several companies."),
+ help="Keep empty if the fiscal year belongs to several companies.", required=True),
'date_start': fields.date('Start Date', required=True),
'date_stop': fields.date('End Date', required=True),
'period_ids': fields.one2many('account.period', 'fiscalyear_id', 'Periods'),
@@ -529,6 +531,7 @@ class account_fiscalyear(osv.osv):
_defaults = {
'state': lambda *a: 'draft',
+ 'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
}
_order = "date_start"
@@ -587,10 +590,12 @@ class account_period(osv.osv):
'date_start': fields.date('Start of Period', required=True, states={'done':[('readonly',True)]}),
'date_stop': fields.date('End of Period', required=True, states={'done':[('readonly',True)]}),
'fiscalyear_id': fields.many2one('account.fiscalyear', 'Fiscal Year', required=True, states={'done':[('readonly',True)]}, select=True),
- 'state': fields.selection([('draft','Draft'), ('done','Done')], 'Status', readonly=True)
+ 'state': fields.selection([('draft','Draft'), ('done','Done')], 'Status', readonly=True),
+ 'company_id': fields.many2one('res.company', 'Company', required=True)
}
_defaults = {
'state': lambda *a: 'draft',
+ 'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
}
_order = "date_start"
@@ -671,6 +676,7 @@ class account_journal_period(osv.osv):
'active': fields.boolean('Active', required=True),
'state': fields.selection([('draft','Draft'), ('printed','Printed'), ('done','Done')], 'Status', required=True, readonly=True),
'fiscalyear_id': fields.related('period_id', 'fiscalyear_id', string='Fiscal Year', type='many2one', relation='account.fiscalyear'),
+ 'company_id' : fields.many2one('res.company', 'Company')
}
def _check(self, cr, uid, ids, context={}):
@@ -699,6 +705,7 @@ class account_journal_period(osv.osv):
_defaults = {
'state': lambda *a: 'draft',
'active': lambda *a: True,
+ 'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
}
_order = "period_id"
@@ -770,6 +777,7 @@ class account_move(osv.osv):
('journal_pur_voucher','Journal Purchase'),
('journal_voucher','Journal Voucher'),
],'Type', readonly=True, select=True, states={'draft':[('readonly',False)]}),
+ 'company_id': fields.many2one('res.company', 'Company', required=True),
}
_defaults = {
'name': lambda *a: '/',
@@ -777,6 +785,7 @@ class account_move(osv.osv):
'period_id': _get_period,
'type' : lambda *a : 'journal_voucher',
'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,
}
def _check_centralisation(self, cursor, user, ids):
diff --git a/addons/account/account_demo.xml b/addons/account/account_demo.xml
index c2bc9bdc1f4..0b4ee8f097d 100644
--- a/addons/account/account_demo.xml
+++ b/addons/account/account_demo.xml
@@ -11,6 +11,7 @@
+