diff --git a/addons/account/models/account.py b/addons/account/models/account.py
index d691c647469..ed57081a8a2 100644
--- a/addons/account/models/account.py
+++ b/addons/account/models/account.py
@@ -211,6 +211,7 @@ class AccountAccount(models.Model):
help="Forces all moves for this account to have this account currency.")
code = fields.Char(size=64, required=True, index=True)
deprecated = fields.Boolean(index=True, default=False)
+ used = fields.Boolean(store=False, search='_search_used')
user_type_id = fields.Many2one('account.account.type', string='Type', required=True,
help="Account Type is used for information purpose, to generate country-specific legal reports, and set the rules to close a fiscal year and generate opening entries.")
internal_type = fields.Selection(related='user_type_id.type', string="Internal Type", store=True, readonly=True)
@@ -252,6 +253,17 @@ class AccountAccount(models.Model):
for record in self:
record.root_id = record.code and (ord(record.code[0]) * 1000 + ord(record.code[1])) or False
+ def _search_used(self, operator, value):
+ if operator not in ['=', '!='] or not isinstance(value, bool):
+ raise UserError(_('Operation not supported'))
+ if operator != '=':
+ value = not value
+ self._cr.execute("""
+ SELECT id FROM account_account account
+ WHERE EXISTS (SELECT * FROM account_move_line aml WHERE aml.account_id = account.id LIMIT 1)
+ """)
+ return [('id', 'in' if value else 'not in', [r[0] for r in self._cr.fetchall()])]
+
@api.model
def _search_new_account_code(self, company, digits, prefix):
for num in range(1, 10000):
@@ -560,6 +572,7 @@ class AccountRoot(models.Model):
name = fields.Char()
parent_id = fields.Many2one('account.root')
+ company_id = fields.Many2one('res.company')
def init(self):
tools.drop_view_if_exists(self.env.cr, self._table)
@@ -567,12 +580,14 @@ class AccountRoot(models.Model):
CREATE OR REPLACE VIEW %s AS (
SELECT DISTINCT ASCII(code) * 1000 + ASCII(SUBSTRING(code,2,1)) AS id,
LEFT(code,2) AS name,
- ASCII(code) AS parent_id
+ ASCII(code) AS parent_id,
+ company_id
FROM account_account WHERE code IS NOT NULL
UNION ALL
SELECT DISTINCT ASCII(code) AS id,
LEFT(code,1) AS name,
- NULL::int AS parent_id
+ NULL::int AS parent_id,
+ company_id
FROM account_account WHERE code IS NOT NULL
)''' % (self._table,)
)
diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py
index 61afd62f4eb..c3f2d02d3a9 100644
--- a/addons/account/models/account_move.py
+++ b/addons/account/models/account_move.py
@@ -1521,7 +1521,8 @@ class AccountMove(models.Model):
result = []
for move in self:
if self._context.get('name_groupby') and not (move.type == 'entry' and move.state == 'draft'):
- name = '**%s**, %s' % (format_date(self.env, move.date), move.name or '')
+ move_name = move.name != "/" and move.name or _("Draft %s") % dict(move._fields['type']._description_selection(self.env))[move.type]
+ name = '**%s**, %s' % (format_date(self.env, move.date), move_name or '')
if move.ref:
name += ' (%s)' % move.ref
if move.partner_id.name:
@@ -1529,7 +1530,7 @@ class AccountMove(models.Model):
elif move.type == 'entry':
# Miscellaneous operation.
if move.state == 'draft':
- name = '* %s' % str(move.id)
+ name = _('Draft Entry (* %s)') % str(move.id)
else:
name = move.name
else:
diff --git a/addons/account/security/account_security.xml b/addons/account/security/account_security.xml
index 9f926add834..bc20da1b775 100644
--- a/addons/account/security/account_security.xml
+++ b/addons/account/security/account_security.xml
@@ -124,6 +124,13 @@
['|',('company_id','=',False),('company_id', 'in', company_ids)]
+
+ Account Root multi-company
+
+
+ ['|',('company_id','=',False),('company_id', 'in', company_ids)]
+
+
Tax multi-company
diff --git a/addons/account/views/account_move_views.xml b/addons/account/views/account_move_views.xml
index 8d0e4d10b5a..678bc4e1f47 100644
--- a/addons/account/views/account_move_views.xml
+++ b/addons/account/views/account_move_views.xml
@@ -135,6 +135,7 @@
+
@@ -163,7 +164,7 @@
account.move.line
-
+
diff --git a/addons/account/views/account_view.xml b/addons/account/views/account_view.xml
index 5e5c5198e27..e5e3bfc66c5 100644
--- a/addons/account/views/account_view.xml
+++ b/addons/account/views/account_view.xml
@@ -92,6 +92,9 @@
+
+
+
@@ -962,7 +965,7 @@ action = model.setting_init_bank_account_action()
-
@@ -995,7 +998,7 @@ action = model.setting_init_bank_account_action()
%
-