[MIG]account_asset_management: Migration to 15.0
This commit is contained in:
parent
9d5714cd94
commit
6fc511524d
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
"name": "Assets Management",
|
"name": "Assets Management",
|
||||||
"version": "14.0.2.7.0",
|
"version": "15.0.1.0.0",
|
||||||
"license": "AGPL-3",
|
"license": "AGPL-3",
|
||||||
"depends": ["account", "report_xlsx_helper"],
|
"depends": ["account", "report_xlsx_helper"],
|
||||||
"excludes": ["account_asset"],
|
"excludes": ["account_asset"],
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<odoo>
|
<odoo noupdate="1">
|
||||||
<data noupdate="1">
|
|
||||||
<record forcecreate="True" id="ir_cron_assets_generator" model="ir.cron">
|
<record forcecreate="True" id="ir_cron_assets_generator" model="ir.cron">
|
||||||
<field name="name">Asset Management: Generate assets</field>
|
<field name="name">Asset Management: Generate assets</field>
|
||||||
<field name="model_id" ref="model_account_asset_compute" />
|
<field name="model_id" ref="model_account_asset_compute" />
|
||||||
@ -13,5 +12,4 @@
|
|||||||
<field name="active" eval="False" />
|
<field name="active" eval="False" />
|
||||||
<field name="doall" eval="False" />
|
<field name="doall" eval="False" />
|
||||||
</record>
|
</record>
|
||||||
</data>
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
@ -59,7 +59,6 @@ class AccountAsset(models.Model):
|
|||||||
states=READONLY_STATES,
|
states=READONLY_STATES,
|
||||||
)
|
)
|
||||||
purchase_value = fields.Float(
|
purchase_value = fields.Float(
|
||||||
string="Purchase Value",
|
|
||||||
required=True,
|
required=True,
|
||||||
states=READONLY_STATES,
|
states=READONLY_STATES,
|
||||||
help="This amount represent the initial value of the asset."
|
help="This amount represent the initial value of the asset."
|
||||||
@ -67,7 +66,6 @@ class AccountAsset(models.Model):
|
|||||||
"\nPurchase Value - Salvage Value.",
|
"\nPurchase Value - Salvage Value.",
|
||||||
)
|
)
|
||||||
salvage_value = fields.Float(
|
salvage_value = fields.Float(
|
||||||
string="Salvage Value",
|
|
||||||
digits="Account",
|
digits="Account",
|
||||||
states=READONLY_STATES,
|
states=READONLY_STATES,
|
||||||
help="The estimated value that an asset will realize upon "
|
help="The estimated value that an asset will realize upon "
|
||||||
@ -77,7 +75,6 @@ class AccountAsset(models.Model):
|
|||||||
depreciation_base = fields.Float(
|
depreciation_base = fields.Float(
|
||||||
compute="_compute_depreciation_base",
|
compute="_compute_depreciation_base",
|
||||||
digits="Account",
|
digits="Account",
|
||||||
string="Depreciation Base",
|
|
||||||
store=True,
|
store=True,
|
||||||
help="This amount represent the depreciation base "
|
help="This amount represent the depreciation base "
|
||||||
"of the asset (Purchase Value - Salvage Value).",
|
"of the asset (Purchase Value - Salvage Value).",
|
||||||
@ -94,7 +91,7 @@ class AccountAsset(models.Model):
|
|||||||
string="Depreciated Value",
|
string="Depreciated Value",
|
||||||
store=True,
|
store=True,
|
||||||
)
|
)
|
||||||
note = fields.Text("Note")
|
note = fields.Text()
|
||||||
profile_id = fields.Many2one(
|
profile_id = fields.Many2one(
|
||||||
comodel_name="account.asset.profile",
|
comodel_name="account.asset.profile",
|
||||||
string="Asset Profile",
|
string="Asset Profile",
|
||||||
@ -227,7 +224,6 @@ class AccountAsset(models.Model):
|
|||||||
help="Use number of days to calculate depreciation amount",
|
help="Use number of days to calculate depreciation amount",
|
||||||
)
|
)
|
||||||
use_leap_years = fields.Boolean(
|
use_leap_years = fields.Boolean(
|
||||||
string="Use leap years",
|
|
||||||
compute="_compute_use_leap_years",
|
compute="_compute_use_leap_years",
|
||||||
readonly=False,
|
readonly=False,
|
||||||
store=True,
|
store=True,
|
||||||
@ -1241,13 +1237,11 @@ class AccountAsset(models.Model):
|
|||||||
asset_ref = depreciation.asset_id.name
|
asset_ref = depreciation.asset_id.name
|
||||||
if depreciation.asset_id.code:
|
if depreciation.asset_id.code:
|
||||||
asset_ref = "[{}] {}".format(depreciation.asset_id.code, asset_ref)
|
asset_ref = "[{}] {}".format(depreciation.asset_id.code, asset_ref)
|
||||||
error_log += _("\nError while processing asset '%s': %s") % (
|
error_log += _(
|
||||||
asset_ref,
|
"\nError while processing asset '{ref}': {exception}"
|
||||||
str(e),
|
).format(ref=asset_ref, exception=str(e))
|
||||||
)
|
error_msg = _("Error while processing asset '{ref}': \n\n{tb}").format(
|
||||||
error_msg = _("Error while processing asset '%s': \n\n%s") % (
|
ref=asset_ref, tb=tb
|
||||||
asset_ref,
|
|
||||||
tb,
|
|
||||||
)
|
)
|
||||||
_logger.error("%s, %s", self._name, error_msg)
|
_logger.error("%s, %s", self._name, error_msg)
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ class AccountAssetGroup(models.Model):
|
|||||||
_parent_store = True
|
_parent_store = True
|
||||||
_check_company_auto = True
|
_check_company_auto = True
|
||||||
|
|
||||||
name = fields.Char(string="Name", size=64, required=True, index=True)
|
name = fields.Char(size=64, required=True, index=True)
|
||||||
code = fields.Char(index=True)
|
code = fields.Char(index=True)
|
||||||
parent_path = fields.Char(index=True)
|
parent_path = fields.Char(index=True)
|
||||||
company_id = fields.Many2one(
|
company_id = fields.Many2one(
|
||||||
|
@ -31,7 +31,7 @@ class AccountAssetLine(models.Model):
|
|||||||
depreciation_base = fields.Float(
|
depreciation_base = fields.Float(
|
||||||
related="asset_id.depreciation_base", string="Depreciation Base", readonly=True
|
related="asset_id.depreciation_base", string="Depreciation Base", readonly=True
|
||||||
)
|
)
|
||||||
amount = fields.Float(string="Amount", digits="Account", required=True)
|
amount = fields.Float(digits="Account", required=True)
|
||||||
remaining_value = fields.Float(
|
remaining_value = fields.Float(
|
||||||
compute="_compute_values",
|
compute="_compute_values",
|
||||||
digits="Account",
|
digits="Account",
|
||||||
@ -263,17 +263,17 @@ class AccountAssetLine(models.Model):
|
|||||||
asset = line.asset_id
|
asset = line.asset_id
|
||||||
depreciation_date = line.line_date
|
depreciation_date = line.line_date
|
||||||
am_vals = line._setup_move_data(depreciation_date)
|
am_vals = line._setup_move_data(depreciation_date)
|
||||||
move = self.env["account.move"].with_context(ctx).create(am_vals)
|
move = self.env["account.move"].with_context(**ctx).create(am_vals)
|
||||||
depr_acc = asset.profile_id.account_depreciation_id
|
depr_acc = asset.profile_id.account_depreciation_id
|
||||||
exp_acc = asset.profile_id.account_expense_depreciation_id
|
exp_acc = asset.profile_id.account_expense_depreciation_id
|
||||||
aml_d_vals = line._setup_move_line_data(
|
aml_d_vals = line._setup_move_line_data(
|
||||||
depreciation_date, depr_acc, "depreciation", move
|
depreciation_date, depr_acc, "depreciation", move
|
||||||
)
|
)
|
||||||
self.env["account.move.line"].with_context(ctx).create(aml_d_vals)
|
self.env["account.move.line"].with_context(**ctx).create(aml_d_vals)
|
||||||
aml_e_vals = line._setup_move_line_data(
|
aml_e_vals = line._setup_move_line_data(
|
||||||
depreciation_date, exp_acc, "expense", move
|
depreciation_date, exp_acc, "expense", move
|
||||||
)
|
)
|
||||||
self.env["account.move.line"].with_context(ctx).create(aml_e_vals)
|
self.env["account.move.line"].with_context(**ctx).create(aml_e_vals)
|
||||||
move.action_post()
|
move.action_post()
|
||||||
line.with_context(allow_asset_line_update=True).write({"move_id": move.id})
|
line.with_context(allow_asset_line_update=True).write({"move_id": move.id})
|
||||||
created_move_ids.append(move.id)
|
created_move_ids.append(move.id)
|
||||||
|
@ -11,7 +11,7 @@ class AccountAssetProfile(models.Model):
|
|||||||
_description = "Asset profile"
|
_description = "Asset profile"
|
||||||
_order = "name"
|
_order = "name"
|
||||||
|
|
||||||
name = fields.Char(string="Name", size=64, required=True, index=True)
|
name = fields.Char(size=64, required=True, index=True)
|
||||||
note = fields.Text()
|
note = fields.Text()
|
||||||
account_analytic_id = fields.Many2one(
|
account_analytic_id = fields.Many2one(
|
||||||
comodel_name="account.analytic.account", string="Analytic account"
|
comodel_name="account.analytic.account", string="Analytic account"
|
||||||
@ -129,7 +129,6 @@ class AccountAssetProfile(models.Model):
|
|||||||
help="Use number of days to calculate depreciation amount",
|
help="Use number of days to calculate depreciation amount",
|
||||||
)
|
)
|
||||||
use_leap_years = fields.Boolean(
|
use_leap_years = fields.Boolean(
|
||||||
string="Use leap years",
|
|
||||||
default=False,
|
default=False,
|
||||||
help="If not set, the system will distribute evenly the amount to "
|
help="If not set, the system will distribute evenly the amount to "
|
||||||
"amortize across the years, based on the number of years. "
|
"amortize across the years, based on the number of years. "
|
||||||
|
@ -8,7 +8,7 @@ class AccountAssetRecomputeTrigger(models.Model):
|
|||||||
_name = "account.asset.recompute.trigger"
|
_name = "account.asset.recompute.trigger"
|
||||||
_description = "Asset table recompute triggers"
|
_description = "Asset table recompute triggers"
|
||||||
|
|
||||||
reason = fields.Char(string="Reason", required=True)
|
reason = fields.Char(required=True)
|
||||||
company_id = fields.Many2one("res.company", string="Company", required=True)
|
company_id = fields.Many2one("res.company", string="Company", required=True)
|
||||||
date_trigger = fields.Datetime(
|
date_trigger = fields.Datetime(
|
||||||
"Trigger Date",
|
"Trigger Date",
|
||||||
@ -18,7 +18,6 @@ class AccountAssetRecomputeTrigger(models.Model):
|
|||||||
date_completed = fields.Datetime("Completion Date", readonly=True)
|
date_completed = fields.Datetime("Completion Date", readonly=True)
|
||||||
state = fields.Selection(
|
state = fields.Selection(
|
||||||
selection=[("open", "Open"), ("done", "Done")],
|
selection=[("open", "Open"), ("done", "Done")],
|
||||||
string="State",
|
|
||||||
default="open",
|
default="open",
|
||||||
readonly=True,
|
readonly=True,
|
||||||
)
|
)
|
||||||
|
@ -85,7 +85,7 @@ class AccountMove(models.Model):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def action_post(self):
|
def action_post(self):
|
||||||
super().action_post()
|
ret_val = super().action_post()
|
||||||
for move in self:
|
for move in self:
|
||||||
for aml in move.line_ids.filtered(
|
for aml in move.line_ids.filtered(
|
||||||
lambda line: line.asset_profile_id and not line.tax_line_id
|
lambda line: line.asset_profile_id and not line.tax_line_id
|
||||||
@ -119,12 +119,13 @@ class AccountMove(models.Model):
|
|||||||
if refs:
|
if refs:
|
||||||
message = _("This invoice created the asset(s): %s") % ", ".join(refs)
|
message = _("This invoice created the asset(s): %s") % ", ".join(refs)
|
||||||
move.message_post(body=message)
|
move.message_post(body=message)
|
||||||
|
return ret_val
|
||||||
|
|
||||||
def button_draft(self):
|
def button_draft(self):
|
||||||
invoices = self.filtered(lambda r: r.is_purchase_document())
|
invoices = self.filtered(lambda r: r.is_purchase_document())
|
||||||
if invoices:
|
if invoices:
|
||||||
invoices.line_ids.asset_id.unlink()
|
invoices.line_ids.asset_id.unlink()
|
||||||
super().button_draft()
|
return super().button_draft()
|
||||||
|
|
||||||
def _reverse_move_vals(self, default_values, cancel=True):
|
def _reverse_move_vals(self, default_values, cancel=True):
|
||||||
move_vals = super()._reverse_move_vals(default_values, cancel)
|
move_vals = super()._reverse_move_vals(default_values, cancel)
|
||||||
|
@ -20,3 +20,7 @@
|
|||||||
|
|
||||||
* Jordi Ballester <jordi.ballester@forgeflow.com>
|
* Jordi Ballester <jordi.ballester@forgeflow.com>
|
||||||
* Miquel Raïch <miquel.raich@forgeflow.com>
|
* Miquel Raïch <miquel.raich@forgeflow.com>
|
||||||
|
|
||||||
|
* `Sygel <https://www.sygel.es>`_:
|
||||||
|
|
||||||
|
* Manuel Regidor <manuel.regidor@sygel.es>
|
||||||
|
@ -308,8 +308,8 @@ class AssetReportXlsx(models.AbstractModel):
|
|||||||
self.env["account.asset"]._xls_acquisition_template()
|
self.env["account.asset"]._xls_acquisition_template()
|
||||||
)
|
)
|
||||||
wl_acq = self.env["account.asset"]._xls_acquisition_fields()
|
wl_acq = self.env["account.asset"]._xls_acquisition_fields()
|
||||||
title = self._get_title(wiz, "acquisition", format="normal")
|
title = self._get_title(wiz, "acquisition", frmt="normal")
|
||||||
title_short = self._get_title(wiz, "acquisition", format="short")
|
title_short = self._get_title(wiz, "acquisition", frmt="short")
|
||||||
sheet_name = title_short[:31].replace("/", "-")
|
sheet_name = title_short[:31].replace("/", "-")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -326,8 +326,8 @@ class AssetReportXlsx(models.AbstractModel):
|
|||||||
active_template = self._get_asset_template()
|
active_template = self._get_asset_template()
|
||||||
active_template.update(self.env["account.asset"]._xls_active_template())
|
active_template.update(self.env["account.asset"]._xls_active_template())
|
||||||
wl_act = self.env["account.asset"]._xls_active_fields()
|
wl_act = self.env["account.asset"]._xls_active_fields()
|
||||||
title = self._get_title(wiz, "active", format="normal")
|
title = self._get_title(wiz, "active", frmt="normal")
|
||||||
title_short = self._get_title(wiz, "active", format="short")
|
title_short = self._get_title(wiz, "active", frmt="short")
|
||||||
sheet_name = title_short[:31].replace("/", "-")
|
sheet_name = title_short[:31].replace("/", "-")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -344,8 +344,8 @@ class AssetReportXlsx(models.AbstractModel):
|
|||||||
removal_template = self._get_asset_template()
|
removal_template = self._get_asset_template()
|
||||||
removal_template.update(self.env["account.asset"]._xls_removal_template())
|
removal_template.update(self.env["account.asset"]._xls_removal_template())
|
||||||
wl_dsp = self.env["account.asset"]._xls_removal_fields()
|
wl_dsp = self.env["account.asset"]._xls_removal_fields()
|
||||||
title = self._get_title(wiz, "removal", format="normal")
|
title = self._get_title(wiz, "removal", frmt="normal")
|
||||||
title_short = self._get_title(wiz, "removal", format="short")
|
title_short = self._get_title(wiz, "removal", frmt="short")
|
||||||
sheet_name = title_short[:31].replace("/", "-")
|
sheet_name = title_short[:31].replace("/", "-")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -357,21 +357,21 @@ class AssetReportXlsx(models.AbstractModel):
|
|||||||
"report_type": "removal",
|
"report_type": "removal",
|
||||||
}
|
}
|
||||||
|
|
||||||
def _get_title(self, wiz, report, format="normal"):
|
def _get_title(self, wiz, report, frmt="normal"):
|
||||||
|
|
||||||
prefix = "{} - {}".format(wiz.date_from, wiz.date_to)
|
prefix = "{} - {}".format(wiz.date_from, wiz.date_to)
|
||||||
if report == "acquisition":
|
if report == "acquisition":
|
||||||
if format == "normal":
|
if frmt == "normal":
|
||||||
title = prefix + " : " + _("New Acquisitions")
|
title = prefix + " : " + _("New Acquisitions")
|
||||||
else:
|
else:
|
||||||
title = "ACQ"
|
title = "ACQ"
|
||||||
elif report == "active":
|
elif report == "active":
|
||||||
if format == "normal":
|
if frmt == "normal":
|
||||||
title = prefix + " : " + _("Active Assets")
|
title = prefix + " : " + _("Active Assets")
|
||||||
else:
|
else:
|
||||||
title = "ACT"
|
title = "ACT"
|
||||||
else:
|
else:
|
||||||
if format == "normal":
|
if frmt == "normal":
|
||||||
title = prefix + " : " + _("Removed Assets")
|
title = prefix + " : " + _("Removed Assets")
|
||||||
else:
|
else:
|
||||||
title = "DSP"
|
title = "DSP"
|
||||||
@ -412,9 +412,8 @@ class AssetReportXlsx(models.AbstractModel):
|
|||||||
raise UserError(
|
raise UserError(
|
||||||
_(
|
_(
|
||||||
"Inconsistent reporting structure."
|
"Inconsistent reporting structure."
|
||||||
"\nPlease correct Asset Group '%s' (id %s)"
|
"\nPlease correct Asset Group '{group}' (id {id})"
|
||||||
)
|
).format(group=child.name, id=child.id)
|
||||||
% (child.name, child.id)
|
|
||||||
)
|
)
|
||||||
groups.extend(_child_get(child))
|
groups.extend(_child_get(child))
|
||||||
return groups
|
return groups
|
||||||
@ -468,8 +467,8 @@ class AssetReportXlsx(models.AbstractModel):
|
|||||||
report = ws_params["report_type"]
|
report = ws_params["report_type"]
|
||||||
|
|
||||||
def asset_filter(asset):
|
def asset_filter(asset):
|
||||||
filter = getattr(self, "{}_filter".format(report))
|
filt = getattr(self, "{}_filter".format(report))
|
||||||
return filter(wiz, asset)
|
return filt(wiz, asset)
|
||||||
|
|
||||||
def _has_assets(group, group_val):
|
def _has_assets(group, group_val):
|
||||||
assets = group_val.get("assets")
|
assets = group_val.get("assets")
|
||||||
@ -567,8 +566,8 @@ class AssetReportXlsx(models.AbstractModel):
|
|||||||
row_pos = self._report_title(ws, row_pos, ws_params, data, wiz)
|
row_pos = self._report_title(ws, row_pos, ws_params, data, wiz)
|
||||||
|
|
||||||
def asset_filter(asset):
|
def asset_filter(asset):
|
||||||
filter = getattr(self, "{}_filter".format(report))
|
filt = getattr(self, "{}_filter".format(report))
|
||||||
return filter(wiz, asset)
|
return filt(wiz, asset)
|
||||||
|
|
||||||
assets = data["assets"].filtered(asset_filter)
|
assets = data["assets"].filtered(asset_filter)
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<odoo>
|
<odoo noupdate="1">
|
||||||
<data noupdate="1">
|
|
||||||
<record id="account_asset_profile_multi_company_rule" model="ir.rule">
|
<record id="account_asset_profile_multi_company_rule" model="ir.rule">
|
||||||
<field name="name">Account Asset Profile multi-company</field>
|
<field name="name">Account Asset Profile multi-company</field>
|
||||||
<field ref="model_account_asset_profile" name="model_id" />
|
<field ref="model_account_asset_profile" name="model_id" />
|
||||||
@ -25,5 +24,4 @@
|
|||||||
name="domain_force"
|
name="domain_force"
|
||||||
>['|', ('company_id', '=', False), ('company_id', 'in', company_ids)]</field>
|
>['|', ('company_id', '=', False), ('company_id', 'in', company_ids)]</field>
|
||||||
</record>
|
</record>
|
||||||
</data>
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
@ -7,7 +7,7 @@ import calendar
|
|||||||
import time
|
import time
|
||||||
from datetime import date, datetime
|
from datetime import date, datetime
|
||||||
|
|
||||||
from odoo import fields
|
from odoo import Command, fields
|
||||||
from odoo.tests.common import Form
|
from odoo.tests.common import Form
|
||||||
|
|
||||||
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
|
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
|
||||||
@ -27,37 +27,58 @@ class TestAssetManagement(AccountTestInvoicingCommon):
|
|||||||
cls.product = cls.env["product.product"].create(
|
cls.product = cls.env["product.product"].create(
|
||||||
{"name": "Test", "standard_price": 500.0}
|
{"name": "Test", "standard_price": 500.0}
|
||||||
)
|
)
|
||||||
move_form = Form(
|
|
||||||
cls.env["account.move"].with_context(
|
cls.invoice = (
|
||||||
default_move_type="in_invoice", check_move_validity=False
|
cls.env["account.move"]
|
||||||
|
.with_context(check_move_validity=False)
|
||||||
|
.create(
|
||||||
|
{
|
||||||
|
"move_type": "in_invoice",
|
||||||
|
"invoice_date": fields.Date.context_today(cls.env.user),
|
||||||
|
"partner_id": cls.partner.id,
|
||||||
|
"invoice_line_ids": [
|
||||||
|
Command.create(
|
||||||
|
{
|
||||||
|
"name": "test",
|
||||||
|
"product_id": cls.product.id,
|
||||||
|
"price_unit": 2000.00,
|
||||||
|
"quantity": 1,
|
||||||
|
}
|
||||||
|
),
|
||||||
|
],
|
||||||
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
move_form.invoice_date = fields.Date.context_today(cls.env.user)
|
|
||||||
move_form.partner_id = cls.partner
|
cls.invoice_2 = (
|
||||||
with move_form.invoice_line_ids.new() as line_form:
|
cls.env["account.move"]
|
||||||
line_form.name = "test"
|
.with_context(check_move_validity=False)
|
||||||
line_form.product_id = cls.product
|
.create(
|
||||||
line_form.price_unit = 2000.00
|
{
|
||||||
line_form.quantity = 1
|
"move_type": "in_invoice",
|
||||||
cls.invoice = move_form.save()
|
"invoice_date": fields.Date.context_today(cls.env.user),
|
||||||
move_form = Form(
|
"partner_id": cls.partner.id,
|
||||||
cls.env["account.move"].with_context(
|
"invoice_line_ids": [
|
||||||
default_move_type="in_invoice", check_move_validity=False
|
Command.create(
|
||||||
|
{
|
||||||
|
"name": "test 2",
|
||||||
|
"product_id": cls.product.id,
|
||||||
|
"price_unit": 10000.00,
|
||||||
|
"quantity": 1,
|
||||||
|
}
|
||||||
|
),
|
||||||
|
Command.create(
|
||||||
|
{
|
||||||
|
"name": "test 3",
|
||||||
|
"product_id": cls.product.id,
|
||||||
|
"price_unit": 20000.00,
|
||||||
|
"quantity": 1,
|
||||||
|
}
|
||||||
|
),
|
||||||
|
],
|
||||||
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
move_form.invoice_date = fields.Date.context_today(cls.env.user)
|
|
||||||
move_form.partner_id = cls.partner
|
|
||||||
with move_form.invoice_line_ids.new() as line_form:
|
|
||||||
line_form.name = "test 2"
|
|
||||||
line_form.product_id = cls.product
|
|
||||||
line_form.price_unit = 10000.00
|
|
||||||
line_form.quantity = 1
|
|
||||||
with move_form.invoice_line_ids.new() as line_form:
|
|
||||||
line_form.name = "test 3"
|
|
||||||
line_form.product_id = cls.product
|
|
||||||
line_form.price_unit = 20000.00
|
|
||||||
line_form.quantity = 1
|
|
||||||
cls.invoice_2 = move_form.save()
|
|
||||||
|
|
||||||
# analytic configuration
|
# analytic configuration
|
||||||
cls.env.user.write(
|
cls.env.user.write(
|
||||||
@ -121,20 +142,28 @@ class TestAssetManagement(AccountTestInvoicingCommon):
|
|||||||
"amount": 15.0,
|
"amount": 15.0,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
move_form = Form(
|
|
||||||
self.env["account.move"].with_context(
|
invoice = (
|
||||||
default_move_type="in_invoice", check_move_validity=False
|
self.env["account.move"]
|
||||||
|
.with_context(check_move_validity=False)
|
||||||
|
.create(
|
||||||
|
{
|
||||||
|
"move_type": "in_invoice",
|
||||||
|
"invoice_date": fields.Date.context_today(self.env.user),
|
||||||
|
"partner_id": self.partner.id,
|
||||||
|
"invoice_line_ids": [
|
||||||
|
Command.create(
|
||||||
|
{
|
||||||
|
"name": "Line 1",
|
||||||
|
"price_unit": 200.0,
|
||||||
|
"quantity": 1,
|
||||||
|
"tax_ids": [tax.id],
|
||||||
|
}
|
||||||
|
),
|
||||||
|
],
|
||||||
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
move_form.invoice_date = fields.Date.context_today(self.env.user)
|
|
||||||
move_form.partner_id = self.partner
|
|
||||||
with move_form.invoice_line_ids.new() as line_form:
|
|
||||||
line_form.name = "Line 1"
|
|
||||||
line_form.price_unit = 200.0
|
|
||||||
line_form.quantity = 1
|
|
||||||
line_form.tax_ids.clear()
|
|
||||||
line_form.tax_ids.add(tax)
|
|
||||||
invoice = move_form.save()
|
|
||||||
self.assertEqual(invoice.partner_id, self.partner)
|
self.assertEqual(invoice.partner_id, self.partner)
|
||||||
|
|
||||||
def test_00_fiscalyear_lock_date_month(self):
|
def test_00_fiscalyear_lock_date_month(self):
|
||||||
@ -510,7 +539,7 @@ class TestAssetManagement(AccountTestInvoicingCommon):
|
|||||||
asset.compute_depreciation_board()
|
asset.compute_depreciation_board()
|
||||||
asset.validate()
|
asset.validate()
|
||||||
wiz_ctx = {"active_id": asset.id, "early_removal": True}
|
wiz_ctx = {"active_id": asset.id, "early_removal": True}
|
||||||
wiz = self.remove_model.with_context(wiz_ctx).create(
|
wiz = self.remove_model.with_context(**wiz_ctx).create(
|
||||||
{
|
{
|
||||||
"date_remove": "2019-01-31",
|
"date_remove": "2019-01-31",
|
||||||
"sale_value": 0.0,
|
"sale_value": 0.0,
|
||||||
@ -535,11 +564,10 @@ class TestAssetManagement(AccountTestInvoicingCommon):
|
|||||||
self.assertTrue(len(invoice.invoice_line_ids) > 0)
|
self.assertTrue(len(invoice.invoice_line_ids) > 0)
|
||||||
line = invoice.invoice_line_ids[0]
|
line = invoice.invoice_line_ids[0]
|
||||||
self.assertTrue(line.price_unit > 0.0)
|
self.assertTrue(line.price_unit > 0.0)
|
||||||
move_form = Form(invoice)
|
invoice.invoice_line_ids[0].write(
|
||||||
with move_form.invoice_line_ids.edit(0) as line_form:
|
{"quantity": 2, "asset_profile_id": asset_profile.id}
|
||||||
line_form.quantity = 2
|
)
|
||||||
line_form.asset_profile_id = asset_profile
|
invoice._onchange_invoice_line_ids()
|
||||||
invoice = move_form.save()
|
|
||||||
invoice.action_post()
|
invoice.action_post()
|
||||||
# get all asset after invoice validation
|
# get all asset after invoice validation
|
||||||
current_asset = self.env["account.asset"].search([])
|
current_asset = self.env["account.asset"].search([])
|
||||||
@ -577,8 +605,7 @@ class TestAssetManagement(AccountTestInvoicingCommon):
|
|||||||
def test_11_assets_from_invoice(self):
|
def test_11_assets_from_invoice(self):
|
||||||
all_assets = self.env["account.asset"].search([])
|
all_assets = self.env["account.asset"].search([])
|
||||||
ctx = dict(self.invoice_2._context)
|
ctx = dict(self.invoice_2._context)
|
||||||
del ctx["default_move_type"]
|
invoice = self.invoice_2.with_context(**ctx)
|
||||||
invoice = self.invoice_2.with_context(ctx)
|
|
||||||
asset_profile = self.car5y
|
asset_profile = self.car5y
|
||||||
asset_profile.asset_product_item = True
|
asset_profile.asset_product_item = True
|
||||||
# Compute depreciation lines on invoice validation
|
# Compute depreciation lines on invoice validation
|
||||||
@ -837,7 +864,7 @@ class TestAssetManagement(AccountTestInvoicingCommon):
|
|||||||
)
|
)
|
||||||
wiz = Form(
|
wiz = Form(
|
||||||
self.env["wiz.asset.move.reverse"].with_context(
|
self.env["wiz.asset.move.reverse"].with_context(
|
||||||
{
|
**{
|
||||||
"active_model": depreciation_line._name,
|
"active_model": depreciation_line._name,
|
||||||
"active_id": depreciation_line.id,
|
"active_id": depreciation_line.id,
|
||||||
"active_ids": [depreciation_line.id],
|
"active_ids": [depreciation_line.id],
|
||||||
@ -845,6 +872,7 @@ class TestAssetManagement(AccountTestInvoicingCommon):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
reverse_wizard = wiz.save()
|
reverse_wizard = wiz.save()
|
||||||
|
reverse_wizard.write({"journal_id": depreciation_line.move_id.journal_id.id})
|
||||||
reverse_wizard.reverse_move()
|
reverse_wizard.reverse_move()
|
||||||
ict0.refresh()
|
ict0.refresh()
|
||||||
self.assertEqual(ict0.value_depreciated, 0)
|
self.assertEqual(ict0.value_depreciated, 0)
|
||||||
|
@ -174,7 +174,6 @@
|
|||||||
options="{'reload_on_button': true}"
|
options="{'reload_on_button': true}"
|
||||||
>
|
>
|
||||||
<tree
|
<tree
|
||||||
string="Asset Lines"
|
|
||||||
decoration-info="(move_check == False) and (init_entry == False)"
|
decoration-info="(move_check == False) and (init_entry == False)"
|
||||||
create="false"
|
create="false"
|
||||||
>
|
>
|
||||||
@ -252,7 +251,7 @@
|
|||||||
</page>
|
</page>
|
||||||
<page string="History">
|
<page string="History">
|
||||||
<field name="account_move_line_ids" readonly="1">
|
<field name="account_move_line_ids" readonly="1">
|
||||||
<tree string="Journal Items">
|
<tree>
|
||||||
<field name="date" />
|
<field name="date" />
|
||||||
<field name="move_id" />
|
<field name="move_id" />
|
||||||
<field name="journal_id" optional="show" />
|
<field name="journal_id" optional="show" />
|
||||||
@ -290,7 +289,7 @@
|
|||||||
<field name="name">account.asset.tree</field>
|
<field name="name">account.asset.tree</field>
|
||||||
<field name="model">account.asset</field>
|
<field name="model">account.asset</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree string="Assets">
|
<tree>
|
||||||
<field name="name" />
|
<field name="name" />
|
||||||
<field name="code" optional="show" />
|
<field name="code" optional="show" />
|
||||||
<field name="depreciation_base" optional="show" />
|
<field name="depreciation_base" optional="show" />
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<odoo>
|
<odoo>
|
||||||
<data>
|
|
||||||
<record id="account_asset_group_view_form" model="ir.ui.view">
|
<record id="account_asset_group_view_form" model="ir.ui.view">
|
||||||
<field name="name">account.asset.group.form</field>
|
<field name="name">account.asset.group.form</field>
|
||||||
<field name="model">account.asset.group</field>
|
<field name="model">account.asset.group</field>
|
||||||
@ -25,7 +24,7 @@
|
|||||||
<field name="name">account.asset.group.tree</field>
|
<field name="name">account.asset.group.tree</field>
|
||||||
<field name="model">account.asset.group</field>
|
<field name="model">account.asset.group</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree string="Asset Group" editable="bottom">
|
<tree editable="bottom">
|
||||||
<field name="name" />
|
<field name="name" />
|
||||||
<field name="code" optional="show" />
|
<field name="code" optional="show" />
|
||||||
<field name="parent_id" />
|
<field name="parent_id" />
|
||||||
@ -49,5 +48,4 @@
|
|||||||
<field name="res_model">account.asset.group</field>
|
<field name="res_model">account.asset.group</field>
|
||||||
<field name="view_mode">tree,form</field>
|
<field name="view_mode">tree,form</field>
|
||||||
</record>
|
</record>
|
||||||
</data>
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<odoo>
|
<odoo>
|
||||||
<data>
|
|
||||||
<record id="account_asset_profile_view_form" model="ir.ui.view">
|
<record id="account_asset_profile_view_form" model="ir.ui.view">
|
||||||
<field name="name">account.asset.profile.form</field>
|
<field name="name">account.asset.profile.form</field>
|
||||||
<field name="model">account.asset.profile</field>
|
<field name="model">account.asset.profile</field>
|
||||||
@ -87,7 +86,7 @@
|
|||||||
<field name="name">account.asset.profile.tree</field>
|
<field name="name">account.asset.profile.tree</field>
|
||||||
<field name="model">account.asset.profile</field>
|
<field name="model">account.asset.profile</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree string="Asset profile">
|
<tree>
|
||||||
<field name="name" />
|
<field name="name" />
|
||||||
<field name="method_number" optional="hide" />
|
<field name="method_number" optional="hide" />
|
||||||
<field name="method_period" optional="hide" />
|
<field name="method_period" optional="hide" />
|
||||||
@ -141,5 +140,4 @@
|
|||||||
<field name="res_model">account.asset.profile</field>
|
<field name="res_model">account.asset.profile</field>
|
||||||
<field name="view_mode">tree,form</field>
|
<field name="view_mode">tree,form</field>
|
||||||
</record>
|
</record>
|
||||||
</data>
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
@ -32,9 +32,7 @@ class AccountAssetRemove(models.TransientModel):
|
|||||||
"in case of early removal",
|
"in case of early removal",
|
||||||
)
|
)
|
||||||
force_date = fields.Date(string="Force accounting date")
|
force_date = fields.Date(string="Force accounting date")
|
||||||
sale_value = fields.Float(
|
sale_value = fields.Float(default=lambda self: self._default_sale_value())
|
||||||
string="Sale Value", default=lambda self: self._default_sale_value()
|
|
||||||
)
|
|
||||||
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",
|
||||||
|
@ -18,7 +18,7 @@ class WizAssetMoveReverse(models.TransientModel):
|
|||||||
required=True,
|
required=True,
|
||||||
default=fields.Date.context_today,
|
default=fields.Date.context_today,
|
||||||
)
|
)
|
||||||
reason = fields.Char(string="Reason")
|
reason = fields.Char()
|
||||||
journal_id = fields.Many2one(
|
journal_id = fields.Many2one(
|
||||||
"account.journal",
|
"account.journal",
|
||||||
string="Use Specific Journal",
|
string="Use Specific Journal",
|
||||||
|
Loading…
Reference in New Issue
Block a user