2
0

[13.0][account_asset_management] propose account when user chooses

This commit is contained in:
Mateu Griful 2021-02-23 13:59:08 +01:00 committed by Rodrigo
parent ffa8d96851
commit 69299744f2
3 changed files with 10 additions and 8 deletions

View File

@ -14,7 +14,10 @@ class AccountAssetLine(models.Model):
name = fields.Char(string="Depreciation Name", size=64, readonly=True) name = fields.Char(string="Depreciation Name", size=64, readonly=True)
asset_id = fields.Many2one( asset_id = fields.Many2one(
comodel_name="account.asset", string="Asset", required=True, ondelete="cascade", comodel_name="account.asset",
string="Asset",
required=True,
ondelete="cascade",
check_company=True, check_company=True,
) )
previous_id = fields.Many2one( previous_id = fields.Many2one(
@ -44,7 +47,9 @@ class AccountAssetLine(models.Model):
line_date = fields.Date(string="Date", required=True) line_date = fields.Date(string="Date", required=True)
line_days = fields.Integer(string="Days", readonly=True) line_days = fields.Integer(string="Days", readonly=True)
move_id = fields.Many2one( move_id = fields.Many2one(
comodel_name="account.move", string="Depreciation Entry", readonly=True, comodel_name="account.move",
string="Depreciation Entry",
readonly=True,
check_company=True, check_company=True,
) )
move_check = fields.Boolean( move_check = fields.Boolean(
@ -65,10 +70,7 @@ class AccountAssetLine(models.Model):
"for which Odoo has not generated accounting entries.", "for which Odoo has not generated accounting entries.",
) )
company_id = fields.Many2one( company_id = fields.Many2one(
'res.company', "res.company", store=True, readonly=True, related="asset_id.company_id",
store=True,
readonly=True,
related='asset_id.company_id',
) )
@api.depends("amount", "previous_id", "type") @api.depends("amount", "previous_id", "type")

View File

@ -80,7 +80,7 @@ class AccountAssetRemove(models.TransientModel):
@api.model @api.model
def _default_company_id(self): def _default_company_id(self):
asset_id = self.env.context.get("active_id") asset_id = self.env.context.get("active_id")
asset = self.env['account.asset'].browse(asset_id) asset = self.env["account.asset"].browse(asset_id)
return asset.company_id return asset.company_id
@api.model @api.model

View File

@ -6,7 +6,7 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="Remove Asset"> <form string="Remove Asset">
<group colspan="4" col="4"> <group colspan="4" col="4">
<field name="company_id" groups="base.group_multi_company"/> <field name="company_id" groups="base.group_multi_company" />
<field name="date_remove" /> <field name="date_remove" />
<field name="force_date" /> <field name="force_date" />
<field name="sale_value" /> <field name="sale_value" />