[13.0][fix][account_asset_management] display only accounts associated
to the current company.
This commit is contained in:
parent
7d2a79fea4
commit
319042dc87
@ -34,6 +34,7 @@ class AccountAsset(models.Model):
|
|||||||
_name = "account.asset"
|
_name = "account.asset"
|
||||||
_description = "Asset"
|
_description = "Asset"
|
||||||
_order = "date_start desc, code, name"
|
_order = "date_start desc, code, name"
|
||||||
|
_check_company_auto = True
|
||||||
|
|
||||||
account_move_line_ids = fields.One2many(
|
account_move_line_ids = fields.One2many(
|
||||||
comodel_name="account.move.line",
|
comodel_name="account.move.line",
|
||||||
@ -41,6 +42,7 @@ class AccountAsset(models.Model):
|
|||||||
string="Entries",
|
string="Entries",
|
||||||
readonly=True,
|
readonly=True,
|
||||||
copy=False,
|
copy=False,
|
||||||
|
check_company=True,
|
||||||
)
|
)
|
||||||
move_line_check = fields.Boolean(
|
move_line_check = fields.Boolean(
|
||||||
compute="_compute_move_line_check", string="Has accounting entries"
|
compute="_compute_move_line_check", string="Has accounting entries"
|
||||||
@ -98,6 +100,7 @@ class AccountAsset(models.Model):
|
|||||||
change_default=True,
|
change_default=True,
|
||||||
required=True,
|
required=True,
|
||||||
states=READONLY_STATES,
|
states=READONLY_STATES,
|
||||||
|
check_company=True,
|
||||||
)
|
)
|
||||||
group_ids = fields.Many2many(
|
group_ids = fields.Many2many(
|
||||||
comodel_name="account.asset.group",
|
comodel_name="account.asset.group",
|
||||||
@ -252,6 +255,7 @@ class AccountAsset(models.Model):
|
|||||||
string="Depreciation Lines",
|
string="Depreciation Lines",
|
||||||
copy=False,
|
copy=False,
|
||||||
states=READONLY_STATES,
|
states=READONLY_STATES,
|
||||||
|
check_company=True,
|
||||||
)
|
)
|
||||||
company_id = fields.Many2one(
|
company_id = fields.Many2one(
|
||||||
comodel_name="res.company",
|
comodel_name="res.company",
|
||||||
|
@ -12,6 +12,7 @@ class AccountAssetGroup(models.Model):
|
|||||||
_description = "Asset Group"
|
_description = "Asset Group"
|
||||||
_order = "code, name"
|
_order = "code, name"
|
||||||
_parent_store = True
|
_parent_store = True
|
||||||
|
_check_company_auto = True
|
||||||
|
|
||||||
name = fields.Char(string="Name", size=64, required=True, index=True)
|
name = fields.Char(string="Name", size=64, required=True, index=True)
|
||||||
code = fields.Char(index=True)
|
code = fields.Char(index=True)
|
||||||
@ -26,11 +27,13 @@ class AccountAssetGroup(models.Model):
|
|||||||
comodel_name="account.asset.group",
|
comodel_name="account.asset.group",
|
||||||
string="Parent Asset Group",
|
string="Parent Asset Group",
|
||||||
ondelete="restrict",
|
ondelete="restrict",
|
||||||
|
check_company=True,
|
||||||
)
|
)
|
||||||
child_ids = fields.One2many(
|
child_ids = fields.One2many(
|
||||||
comodel_name="account.asset.group",
|
comodel_name="account.asset.group",
|
||||||
inverse_name="parent_id",
|
inverse_name="parent_id",
|
||||||
string="Child Asset Groups",
|
string="Child Asset Groups",
|
||||||
|
check_company=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
|
@ -10,10 +10,12 @@ class AccountAssetLine(models.Model):
|
|||||||
_name = "account.asset.line"
|
_name = "account.asset.line"
|
||||||
_description = "Asset depreciation table line"
|
_description = "Asset depreciation table line"
|
||||||
_order = "type, line_date"
|
_order = "type, line_date"
|
||||||
|
_check_company_auto = True
|
||||||
|
|
||||||
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,
|
||||||
)
|
)
|
||||||
previous_id = fields.Many2one(
|
previous_id = fields.Many2one(
|
||||||
comodel_name="account.asset.line",
|
comodel_name="account.asset.line",
|
||||||
@ -42,7 +44,8 @@ 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,
|
||||||
)
|
)
|
||||||
move_check = fields.Boolean(
|
move_check = fields.Boolean(
|
||||||
compute="_compute_move_check", string="Posted", store=True
|
compute="_compute_move_check", string="Posted", store=True
|
||||||
@ -61,6 +64,12 @@ class AccountAssetLine(models.Model):
|
|||||||
help="Set this flag for entries of previous fiscal years "
|
help="Set this flag for entries of previous fiscal years "
|
||||||
"for which Odoo has not generated accounting entries.",
|
"for which Odoo has not generated accounting entries.",
|
||||||
)
|
)
|
||||||
|
company_id = fields.Many2one(
|
||||||
|
'res.company',
|
||||||
|
store=True,
|
||||||
|
readonly=True,
|
||||||
|
related='asset_id.company_id',
|
||||||
|
)
|
||||||
|
|
||||||
@api.depends("amount", "previous_id", "type")
|
@api.depends("amount", "previous_id", "type")
|
||||||
def _compute_values(self):
|
def _compute_values(self):
|
||||||
|
@ -7,6 +7,7 @@ from odoo.exceptions import UserError
|
|||||||
|
|
||||||
class AccountAssetProfile(models.Model):
|
class AccountAssetProfile(models.Model):
|
||||||
_name = "account.asset.profile"
|
_name = "account.asset.profile"
|
||||||
|
_check_company_auto = True
|
||||||
_description = "Asset profile"
|
_description = "Asset profile"
|
||||||
_order = "name"
|
_order = "name"
|
||||||
|
|
||||||
@ -20,41 +21,48 @@ class AccountAssetProfile(models.Model):
|
|||||||
)
|
)
|
||||||
account_asset_id = fields.Many2one(
|
account_asset_id = fields.Many2one(
|
||||||
comodel_name="account.account",
|
comodel_name="account.account",
|
||||||
domain=[("deprecated", "=", False)],
|
domain="[('deprecated', '=', False), ('company_id', '=', company_id)]",
|
||||||
string="Asset Account",
|
string="Asset Account",
|
||||||
|
check_company=True,
|
||||||
required=True,
|
required=True,
|
||||||
)
|
)
|
||||||
account_depreciation_id = fields.Many2one(
|
account_depreciation_id = fields.Many2one(
|
||||||
comodel_name="account.account",
|
comodel_name="account.account",
|
||||||
domain=[("deprecated", "=", False)],
|
domain="[('deprecated', '=', False), ('company_id', '=', company_id)]",
|
||||||
string="Depreciation Account",
|
string="Depreciation Account",
|
||||||
|
check_company=True,
|
||||||
required=True,
|
required=True,
|
||||||
)
|
)
|
||||||
account_expense_depreciation_id = fields.Many2one(
|
account_expense_depreciation_id = fields.Many2one(
|
||||||
comodel_name="account.account",
|
comodel_name="account.account",
|
||||||
domain=[("deprecated", "=", False)],
|
domain="[('deprecated', '=', False), ('company_id', '=', company_id)]",
|
||||||
string="Depr. Expense Account",
|
string="Depr. Expense Account",
|
||||||
|
check_company=True,
|
||||||
required=True,
|
required=True,
|
||||||
)
|
)
|
||||||
account_plus_value_id = fields.Many2one(
|
account_plus_value_id = fields.Many2one(
|
||||||
comodel_name="account.account",
|
comodel_name="account.account",
|
||||||
domain=[("deprecated", "=", False)],
|
domain="[('deprecated', '=', False), ('company_id', '=', company_id)]",
|
||||||
|
check_company=True,
|
||||||
string="Plus-Value Account",
|
string="Plus-Value Account",
|
||||||
)
|
)
|
||||||
account_min_value_id = fields.Many2one(
|
account_min_value_id = fields.Many2one(
|
||||||
comodel_name="account.account",
|
comodel_name="account.account",
|
||||||
domain=[("deprecated", "=", False)],
|
domain="[('deprecated', '=', False), ('company_id', '=', company_id)]",
|
||||||
|
check_company=True,
|
||||||
string="Min-Value Account",
|
string="Min-Value Account",
|
||||||
)
|
)
|
||||||
account_residual_value_id = fields.Many2one(
|
account_residual_value_id = fields.Many2one(
|
||||||
comodel_name="account.account",
|
comodel_name="account.account",
|
||||||
domain=[("deprecated", "=", False)],
|
domain="[('deprecated', '=', False), ('company_id', '=', company_id)]",
|
||||||
|
check_company=True,
|
||||||
string="Residual Value Account",
|
string="Residual Value Account",
|
||||||
)
|
)
|
||||||
journal_id = fields.Many2one(
|
journal_id = fields.Many2one(
|
||||||
comodel_name="account.journal",
|
comodel_name="account.journal",
|
||||||
domain=[("type", "=", "general")],
|
domain="[('type', '=', 'general'), ('company_id', '=', company_id)]",
|
||||||
string="Journal",
|
string="Journal",
|
||||||
|
check_company=True,
|
||||||
required=True,
|
required=True,
|
||||||
)
|
)
|
||||||
company_id = fields.Many2one(
|
company_id = fields.Many2one(
|
||||||
@ -68,6 +76,7 @@ class AccountAssetProfile(models.Model):
|
|||||||
relation="account_asset_profile_group_rel",
|
relation="account_asset_profile_group_rel",
|
||||||
column1="profile_id",
|
column1="profile_id",
|
||||||
column2="group_id",
|
column2="group_id",
|
||||||
|
check_company=True,
|
||||||
string="Asset Groups",
|
string="Asset Groups",
|
||||||
)
|
)
|
||||||
method = fields.Selection(
|
method = fields.Selection(
|
||||||
|
@ -15,7 +15,15 @@ _logger = logging.getLogger(__name__)
|
|||||||
class AccountAssetRemove(models.TransientModel):
|
class AccountAssetRemove(models.TransientModel):
|
||||||
_name = "account.asset.remove"
|
_name = "account.asset.remove"
|
||||||
_description = "Remove Asset"
|
_description = "Remove Asset"
|
||||||
|
_check_company_auto = True
|
||||||
|
|
||||||
|
company_id = fields.Many2one(
|
||||||
|
comodel_name="res.company",
|
||||||
|
string="Company",
|
||||||
|
readonly=True,
|
||||||
|
required=True,
|
||||||
|
default=lambda self: self._default_company_id(),
|
||||||
|
)
|
||||||
date_remove = fields.Date(
|
date_remove = fields.Date(
|
||||||
string="Asset Removal Date",
|
string="Asset Removal Date",
|
||||||
required=True,
|
required=True,
|
||||||
@ -30,25 +38,25 @@ class AccountAssetRemove(models.TransientModel):
|
|||||||
account_sale_id = fields.Many2one(
|
account_sale_id = fields.Many2one(
|
||||||
comodel_name="account.account",
|
comodel_name="account.account",
|
||||||
string="Asset Sale Account",
|
string="Asset Sale Account",
|
||||||
domain=[("deprecated", "=", False)],
|
domain="[('deprecated', '=', False), ('company_id', '=', company_id)]",
|
||||||
default=lambda self: self._default_account_sale_id(),
|
default=lambda self: self._default_account_sale_id(),
|
||||||
)
|
)
|
||||||
account_plus_value_id = fields.Many2one(
|
account_plus_value_id = fields.Many2one(
|
||||||
comodel_name="account.account",
|
comodel_name="account.account",
|
||||||
string="Plus-Value Account",
|
string="Plus-Value Account",
|
||||||
domain=[("deprecated", "=", False)],
|
domain="[('deprecated', '=', False), ('company_id', '=', company_id)]",
|
||||||
default=lambda self: self._default_account_plus_value_id(),
|
default=lambda self: self._default_account_plus_value_id(),
|
||||||
)
|
)
|
||||||
account_min_value_id = fields.Many2one(
|
account_min_value_id = fields.Many2one(
|
||||||
comodel_name="account.account",
|
comodel_name="account.account",
|
||||||
string="Min-Value Account",
|
string="Min-Value Account",
|
||||||
domain=[("deprecated", "=", False)],
|
domain="[('deprecated', '=', False), ('company_id', '=', company_id)]",
|
||||||
default=lambda self: self._default_account_min_value_id(),
|
default=lambda self: self._default_account_min_value_id(),
|
||||||
)
|
)
|
||||||
account_residual_value_id = fields.Many2one(
|
account_residual_value_id = fields.Many2one(
|
||||||
comodel_name="account.account",
|
comodel_name="account.account",
|
||||||
string="Residual Value Account",
|
string="Residual Value Account",
|
||||||
domain=[("deprecated", "=", False)],
|
domain="[('deprecated', '=', False), ('company_id', '=', company_id)]",
|
||||||
default=lambda self: self._default_account_residual_value_id(),
|
default=lambda self: self._default_account_residual_value_id(),
|
||||||
)
|
)
|
||||||
posting_regime = fields.Selection(
|
posting_regime = fields.Selection(
|
||||||
@ -69,6 +77,12 @@ class AccountAssetRemove(models.TransientModel):
|
|||||||
if self.sale_value < 0:
|
if self.sale_value < 0:
|
||||||
raise ValidationError(_("The Sale Value must be positive!"))
|
raise ValidationError(_("The Sale Value must be positive!"))
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def _default_company_id(self):
|
||||||
|
asset_id = self.env.context.get("active_id")
|
||||||
|
asset = self.env['account.asset'].browse(asset_id)
|
||||||
|
return asset.company_id
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _default_sale_value(self):
|
def _default_sale_value(self):
|
||||||
return self._get_sale()["sale_value"]
|
return self._get_sale()["sale_value"]
|
||||||
|
@ -6,6 +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="date_remove" />
|
<field name="date_remove" />
|
||||||
<field name="force_date" />
|
<field name="force_date" />
|
||||||
<field name="sale_value" />
|
<field name="sale_value" />
|
||||||
|
Loading…
Reference in New Issue
Block a user