Second round of improvements

This commit is contained in:
Akim Juillerat
2018-10-15 15:41:00 +02:00
committed by OCA-git-bot
parent 1a6cd81460
commit 1740bf5cb3
15 changed files with 23 additions and 29 deletions

View File

@@ -6,4 +6,4 @@ from . import account_asset_recompute_trigger
from . import account_invoice
from . import account_move
from . import date_range
from . import res_config
from . import res_config_settings

View File

@@ -106,7 +106,7 @@ class AccountAsset(models.Model):
('open', 'Running'),
('close', 'Close'),
('removed', 'Removed'),
], string='Status', required=True, default='draft', copy='draft',
], string='Status', required=True, default='draft', copy=False,
help="When an asset is created, the status is 'Draft'.\n"
"If the asset is confirmed, the status goes in 'Running' "
"and the depreciation lines can be posted "

View File

@@ -22,11 +22,6 @@ class AccountAssetLine(models.Model):
string='Previous Depreciation Line',
readonly=True)
parent_state = fields.Selection(
selection=[
('draft', 'Draft'),
('open', 'Running'),
('close', 'Close'),
('removed', 'Removed')],
related='asset_id.state',
string='State of Asset',
readonly=True,
@@ -66,17 +61,16 @@ class AccountAssetLine(models.Model):
init_entry = fields.Boolean(
string='Initial Balance Entry',
help="Set this flag for entries of previous fiscal years "
"for which OpenERP has not generated accounting entries.")
"for which Odoo has not generated accounting entries.")
@api.depends('amount', 'previous_id', 'type')
@api.multi
def _compute_values(self):
dlines = self
if self.env.context.get('no_compute_asset_line_ids'):
# skip compute for lines in unlink
exclude_ids = self.env.context['no_compute_asset_line_ids']
dlines = dlines.filtered(lambda l: l.id not in exclude_ids)
dlines = self.filtered(lambda l: l.type == 'depreciate')
dlines = self.filtered(lambda l: l.id not in exclude_ids)
dlines = dlines.filtered(lambda l: l.type == 'depreciate')
dlines = dlines.sorted(key=lambda l: l.line_date)
for i, dl in enumerate(dlines):
@@ -240,7 +234,7 @@ class AccountAssetLine(models.Model):
asset_ids.add(asset.id)
# we re-evaluate the assets to determine if we can close them
for asset in self.env['account.asset'].browse(list(asset_ids)):
if asset.company_id.currency_id.is_zero(asset.value_residual):
if asset.company_currency_id.is_zero(asset.value_residual):
asset.state = 'close'
return created_move_ids

View File

@@ -74,9 +74,7 @@ class AccountInvoice(models.Model):
def action_move_create(self):
res = super().action_move_create()
for inv in self:
move = inv.move_id
assets = [aml.asset_id for aml in
[x for x in move.line_ids if x.asset_id]]
assets = inv.move_id.line_ids.mapped('asset_id')
for asset in assets:
asset.code = inv.move_name
asset_line_name = asset._get_depreciation_entry_name(0)
@@ -90,7 +88,7 @@ class AccountInvoice(models.Model):
assets = self.env['account.asset']
for inv in self:
move = inv.move_id
assets = move.line_ids.mapped('asset_id')
assets |= move.line_ids.mapped('asset_id')
super().action_cancel()
if assets:
assets.unlink()

View File

@@ -10,4 +10,4 @@ Assets can be created manually as well as automatically
Excel based reporting is available via the 'account_asset_management_xls' module.
The module contains a large number of functional enhancements compared to
the standard account_asset module from Odoo.
the standard account_asset module from Odoo.

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" ?>
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">

View File

@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_account_form" model="ir.ui.view">

View File

@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record model="ir.ui.view" id="account_asset_view_form">
@@ -194,9 +195,9 @@
<field name="arch" type="xml">
<search string="Account Asset">
<filter string="Draft" name="draft" domain="[('state', '=', 'draft')]" help="Draft Assets"/>
<filter string="Running" domain="[('state', '=', 'open')]" help="Assets in Running State"/>
<filter string="Close" domain="[('state', '=', 'close')]" help="Assets in Close State"/>
<filter string="Removed" domain="[('state', '=', 'removed')]" help="Assets which have been removed"/>
<filter string="Running" name="running" domain="[('state', '=', 'open')]" help="Assets in Running State"/>
<filter string="Close" name="close" domain="[('state', '=', 'close')]" help="Assets in Close State"/>
<filter string="Removed" name="removed" domain="[('state', '=', 'removed')]" help="Assets which have been removed"/>
<separator orientation="vertical"/>
<field name="name" string="Asset"/>
<field name="code"/>

View File

@@ -1,4 +1,5 @@
<openerp>
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="account_asset_profile_view_form" model="ir.ui.view">
@@ -78,4 +79,4 @@
</record>
</data>
</openerp>
</odoo>

View File

@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="invoice_supplier_form" model="ir.ui.view">

View File

@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_invoice_line_form" model="ir.ui.view">

View File

@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_move_form" model="ir.ui.view">

View File

@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_move_line_form" model="ir.ui.view">

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" ?>
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<menuitem id="menu_finance_assets"