Small enhancement in account_usability

This commit is contained in:
Alexis de Lattre
2016-01-29 16:43:22 +01:00
parent 6d29f236fd
commit 110d8b6982
2 changed files with 84 additions and 0 deletions

View File

@@ -21,6 +21,7 @@
##############################################################################
from openerp import models, fields, api
from openerp.tools import float_compare
class AccountInvoice(models.Model):
@@ -41,6 +42,48 @@ class AccountInvoice(models.Model):
fiscal_position = fields.Many2one(track_visibility='onchange')
class AccountJournal(models.Model):
_inherit = 'account.journal'
@api.multi
def name_get(self):
if self._context.get('journal_show_code_only'):
res = []
for record in self:
res.append((record.id, record.code))
return res
else:
return super(AccountJournal, self).name_get()
class AccountAccount(models.Model):
_inherit = 'account.account'
@api.multi
def name_get(self):
if self._context.get('account_account_show_code_only'):
res = []
for record in self:
res.append((record.id, record.code))
return res
else:
return super(AccountAccount, self).name_get()
class AccountAnalyticAccount(models.Model):
_inherit = 'account.analytic.account'
@api.multi
def name_get(self):
if self._context.get('analytic_account_show_code_only'):
res = []
for record in self:
res.append((record.id, record.code or record._get_one_full_name(record)))
return res
else:
return super(AccountAnalyticAccount, self).name_get()
class AccountMove(models.Model):
_inherit = 'account.move'
@@ -63,6 +106,25 @@ class AccountMoveLine(models.Model):
if self.debit and self.credit:
self.credit = 0
@api.onchange('currency_id', 'amount_currency')
def _amount_currency_change(self):
if (
self.currency_id and
self.amount_currency and
not self.credit and
not self.debit):
date = self.date or None
amount_company_currency = self.currency_id.with_context(
date=date).compute(
self.amount_currency, self.env.user.company_id.currency_id)
precision = self.env['decimal.precision'].precision_get('Account')
if float_compare(
amount_company_currency, 0,
precision_digits=precision) == -1:
self.debit = amount_company_currency * -1
else:
self.credit = amount_company_currency
class AccountBankStatementLine(models.Model):
_inherit = 'account.bank.statement.line'

View File

@@ -58,6 +58,8 @@
<!-- model account.move.line / Journal Items -->
<record id="account.action_account_moves_all_a" model="ir.actions.act_window">
<field name="limit">200</field>
<!-- Win space, because there are already many columns -->
<field name="context">{'journal_show_code_only': True}</field>
</record>
<!-- model account.move / Journal Entries -->
@@ -65,6 +67,23 @@
<field name="limit">200</field>
</record>
<record id="view_move_form" model="ir.ui.view">
<field name="name">account_usability.account_move_form</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='line_id']/tree/field[@name='tax_code_id']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='line_id']/tree/field[@name='tax_amount']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='line_id']/tree/field[@name='state']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
</field>
</record>
<record id="view_account_move_line_filter" model="ir.ui.view">
<field name="name">account_usability.account_move_line_search</field>
<field name="model">account.move.line</field>
@@ -77,6 +96,9 @@
<filter name="reconciled" string="Fully Reconciled" domain="[('reconcile_id', '!=', False)]"/>
<filter name="partial_reconciled" string="Partially Reconciled" domain="[('reconcile_partial_id', '!=', False)]"/>
</filter>
<field name="name" position="attributes">
<attribute name="string">Name or Reference</attribute>
</field>
</field>
</record>