diff --git a/account_usability/account.py b/account_usability/account.py
index 895ce8e..5aaad72 100644
--- a/account_usability/account.py
+++ b/account_usability/account.py
@@ -82,14 +82,34 @@ class AccountJournal(models.Model):
_inherit = 'account.journal'
@api.multi
+ @api.depends(
+ 'name', 'currency_id', 'company_id', 'company_id.currency_id', 'code')
def name_get(self):
+ res = []
if self._context.get('journal_show_code_only'):
- res = []
- for record in self:
- res.append((record.id, record.code))
+ for journal in self:
+ res.append((journal.id, journal.code))
return res
else:
- return super(AccountJournal, self).name_get()
+ for journal in self:
+ currency = journal.currency_id or journal.company_id.currency_id
+ name = "[%s] %s (%s)" % (journal.code, journal.name, currency.name)
+ res.append((journal.id, name))
+ return res
+
+ # Also search on start of 'code', not only on 'name'
+ @api.model
+ def name_search(
+ self, name='', args=None, operator='ilike', limit=80):
+ if args is None:
+ args = []
+ if name:
+ jrls = self.search(
+ [('code', '=ilike', name + '%')] + args, limit=limit)
+ if jrls:
+ return jrls.name_get()
+ return super(AccountJournal, self).name_search(
+ name=name, args=args, operator=operator, limit=limit)
class AccountAccount(models.Model):
@@ -128,6 +148,16 @@ class AccountAnalyticAccount(models.Model):
'exists in the same company!')]
+class AccountMove(models.Model):
+ _inherit = 'account.move'
+
+ default_move_line_name = fields.Char(string='Default Label',
+ states={'posted': [('readonly', True)]})
+ # By default, we can still modify "ref" when account move is posted
+ # which seems a bit lazy for me...
+ ref = fields.Char(states={'posted': [('readonly', True)]})
+
+
class AccountMoveLine(models.Model):
_inherit = 'account.move.line'
@@ -170,6 +200,19 @@ class AccountMoveLine(models.Model):
else:
self.credit = amount_company_currency
+ @api.multi
+ def show_account_move_form(self):
+ self.ensure_one()
+ action = self.env['ir.actions.act_window'].for_xml_id(
+ 'account', 'action_move_line_form')
+ action.update({
+ 'res_id': self.move_id.id,
+ 'view_id': False,
+ 'views': False,
+ 'view_mode': 'form,tree',
+ })
+ return action
+
class AccountBankStatement(models.Model):
_inherit = 'account.bank.statement'
diff --git a/account_usability/account_view.xml b/account_usability/account_view.xml
index 365d265..5043002 100644
--- a/account_usability/account_view.xml
+++ b/account_usability/account_view.xml
@@ -176,6 +176,12 @@ module -->
account.move
+
+
+
+
+ {'line_ids': line_ids, 'journal_id': journal_id, 'default_name': default_move_line_name}
+
@@ -224,6 +230,9 @@ module -->
+
+
+