mirror of
https://github.com/OCA/account-reconcile.git
synced 2025-01-20 12:27:39 +02:00
[IMP] account_reconciliation_widget: show analytic account on counterpart line
This commit is contained in:
@@ -245,6 +245,9 @@ class AccountBankStatementLine(models.Model):
|
||||
if aml_dict["move_line"].partner_id.id:
|
||||
aml_dict["partner_id"] = aml_dict["move_line"].partner_id.id
|
||||
aml_dict["account_id"] = aml_dict["move_line"].account_id.id
|
||||
aml_dict["analytic_account_id"] = (
|
||||
aml_dict["move_line"].analytic_account_id.id or False
|
||||
)
|
||||
|
||||
counterpart_move_line = aml_dict.pop("move_line")
|
||||
new_aml = aml_obj.with_context(check_move_validity=False).create(aml_dict)
|
||||
|
||||
@@ -911,6 +911,7 @@ class AccountReconciliation(models.AbstractModel):
|
||||
"already_paid": line.account_id.internal_type == "liquidity",
|
||||
"account_code": line.account_id.code,
|
||||
"account_name": line.account_id.name,
|
||||
"analytic_account_code": line.analytic_account_id.display_name or "",
|
||||
"account_type": line.account_id.internal_type,
|
||||
"date_maturity": format_date(self.env, line.date_maturity),
|
||||
"date": format_date(self.env, line.date),
|
||||
@@ -1021,6 +1022,8 @@ class AccountReconciliation(models.AbstractModel):
|
||||
"""Returns the data required by the bank statement reconciliation
|
||||
widget to display a statement line"""
|
||||
|
||||
group_analytic = self.env.user.has_group("analytic.group_analytic_accounting")
|
||||
group_analytic_tags = self.env.user.has_group("analytic.group_analytic_tags")
|
||||
statement_currency = (
|
||||
st_line.journal_id.currency_id or st_line.journal_id.company_id.currency_id
|
||||
)
|
||||
@@ -1067,6 +1070,8 @@ class AccountReconciliation(models.AbstractModel):
|
||||
"amount_currency": amount_currency,
|
||||
"has_no_partner": not st_line.partner_id.id,
|
||||
"company_id": st_line.company_id.id,
|
||||
"group_analytic_accounting": group_analytic,
|
||||
"group_analytic_tags": group_analytic_tags,
|
||||
}
|
||||
if st_line.partner_id:
|
||||
data["open_balance_account_id"] = (
|
||||
|
||||
@@ -529,11 +529,22 @@ odoo.define("account.ReconciliationModel", function (require) {
|
||||
_.pluck(accounts, "code")
|
||||
);
|
||||
});
|
||||
var def_analytic_account = this._rpc({
|
||||
model: "account.analytic.account",
|
||||
method: "search_read",
|
||||
fields: ["display_name"],
|
||||
}).then(function (accounts) {
|
||||
self.analytic_accounts = _.object(
|
||||
_.pluck(accounts, "id"),
|
||||
_.pluck(accounts, "display_name")
|
||||
);
|
||||
});
|
||||
var def_taxes = self._loadTaxes();
|
||||
return Promise.all([
|
||||
def_statement,
|
||||
def_reconcileModel,
|
||||
def_account,
|
||||
def_analytic_account,
|
||||
def_taxes,
|
||||
]).then(function () {
|
||||
_.each(self.lines, function (line) {
|
||||
@@ -896,6 +907,12 @@ odoo.define("account.ReconciliationModel", function (require) {
|
||||
? this.accounts[prop.account_id.id]
|
||||
: "";
|
||||
}
|
||||
if ("analytic_account_id" in values) {
|
||||
prop.analytic_account_code = prop.analytic_account_id
|
||||
? this.analytic_accounts[prop.analytic_account_id.id]
|
||||
: "";
|
||||
}
|
||||
|
||||
if ("amount" in values) {
|
||||
prop.base_amount = values.amount;
|
||||
if (prop.reconcileModelId) {
|
||||
@@ -1598,6 +1615,7 @@ odoo.define("account.ReconciliationModel", function (require) {
|
||||
values = values || {};
|
||||
var today = new moment().utc().format();
|
||||
var account = this._formatNameGet(values.account_id);
|
||||
var analytic_account = this._formatNameGet(values.analytic_account_id);
|
||||
var formatOptions = {
|
||||
currency_id: line.st_line.currency_id,
|
||||
};
|
||||
@@ -1641,7 +1659,10 @@ odoo.define("account.ReconciliationModel", function (require) {
|
||||
label: values.label || line.st_line.payment_ref,
|
||||
account_id: account,
|
||||
account_code: account ? this.accounts[account.id] : "",
|
||||
analytic_account_id: this._formatNameGet(values.analytic_account_id),
|
||||
analytic_account_id: analytic_account,
|
||||
analytic_account_code: analytic_account
|
||||
? this.analytic_accounts[analytic_account.id]
|
||||
: "",
|
||||
analytic_tag_ids: this._formatMany2ManyTags(
|
||||
values.analytic_tag_ids || []
|
||||
),
|
||||
|
||||
@@ -353,16 +353,6 @@ odoo.define("account.ReconciliationRenderer", function (require) {
|
||||
}
|
||||
);
|
||||
|
||||
var def3 = session
|
||||
.user_has_group("analytic.group_analytic_tags")
|
||||
.then(function (has_group) {
|
||||
self.group_tags = has_group;
|
||||
});
|
||||
var def4 = session
|
||||
.user_has_group("analytic.group_analytic_accounting")
|
||||
.then(function (has_group) {
|
||||
self.group_acc = has_group;
|
||||
});
|
||||
$('<span class="line_info_button fa fa-info-circle"/>')
|
||||
.appendTo(this.$("thead .cell_info_popover"))
|
||||
.attr(
|
||||
@@ -384,7 +374,7 @@ odoo.define("account.ReconciliationRenderer", function (require) {
|
||||
toggle: "popover",
|
||||
});
|
||||
var def2 = this._super.apply(this, arguments);
|
||||
return Promise.all([def1, def2, def3, def4, def5]);
|
||||
return Promise.all([def1, def2, def5]);
|
||||
},
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
@@ -861,8 +851,6 @@ odoo.define("account.ReconciliationRenderer", function (require) {
|
||||
var $create = $(
|
||||
qweb.render("reconciliation.line.create", {
|
||||
state: state,
|
||||
group_tags: self.group_tags,
|
||||
group_acc: self.group_acc,
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
@@ -156,6 +156,9 @@
|
||||
width: 80px;
|
||||
padding-left: 5px;
|
||||
}
|
||||
.cell_analytic_account {
|
||||
width: 230px;
|
||||
}
|
||||
.cell_due_date {
|
||||
width: 100px;
|
||||
}
|
||||
@@ -187,6 +190,7 @@
|
||||
.cell_label,
|
||||
.cell_due_date,
|
||||
.cell_account_code,
|
||||
.cell_analytic_account,
|
||||
.cell_info_popover {
|
||||
box-shadow: 0 1px 0 #eaeaea;
|
||||
}
|
||||
|
||||
@@ -151,6 +151,12 @@
|
||||
t-esc="state.st_line.account_code"
|
||||
/></td>
|
||||
<td class="cell_due_date"><t t-esc="state.st_line.date" /></td>
|
||||
<td
|
||||
class="cell_analytic_account"
|
||||
t-if="state.st_line.group_analytic_accounting"
|
||||
>
|
||||
<t t-esc="state.st_line.analytic_account_code" />
|
||||
</td>
|
||||
<td class="cell_label"><t
|
||||
t-if="state.st_line.payment_ref"
|
||||
t-esc="state.st_line.payment_ref"
|
||||
@@ -283,6 +289,12 @@
|
||||
<tr t-if="state.balance.show_balance">
|
||||
<td class="cell_account_code"><t t-esc="state.balance.account_code" /></td>
|
||||
<td class="cell_due_date" />
|
||||
<td
|
||||
class="cell_analytic_account"
|
||||
t-if="state.st_line.group_analytic_accounting"
|
||||
>
|
||||
<t t-esc="state.balance.analytic_account_code" />
|
||||
</td>
|
||||
<td class="cell_label"><t t-if="state.st_line.partner_id">Open balance</t><t
|
||||
t-else=""
|
||||
>Choose counterpart or Create Write-off</t></td>
|
||||
@@ -387,13 +399,19 @@
|
||||
>Taxes</label></td>
|
||||
<td class="o_td_field" />
|
||||
</tr>
|
||||
<tr class="create_analytic_account_id" t-if="group_acc">
|
||||
<tr
|
||||
class="create_analytic_account_id"
|
||||
t-if="state.st_line.group_analytic_accounting"
|
||||
>
|
||||
<td class="o_td_label"><label
|
||||
class="o_form_label"
|
||||
>Analytic Acc.</label></td>
|
||||
<td class="o_td_field" />
|
||||
</tr>
|
||||
<tr class="create_analytic_tag_ids" t-if="group_tags">
|
||||
<tr
|
||||
class="create_analytic_tag_ids"
|
||||
t-if="state.st_line.group_analytic_tags"
|
||||
>
|
||||
<td class="o_td_label"><label
|
||||
class="o_form_label"
|
||||
>Analytic Tags.</label></td>
|
||||
@@ -501,6 +519,12 @@
|
||||
</t>
|
||||
<t t-else="" t-esc="line.date_maturity || line.date" />
|
||||
</td>
|
||||
<td
|
||||
class="cell_analytic_account"
|
||||
t-if="state.st_line.group_analytic_accounting"
|
||||
>
|
||||
<t t-esc="line.analytic_account_code" />
|
||||
</td>
|
||||
<td class="cell_label">
|
||||
<t
|
||||
t-if="line.partner_id && line.partner_id !== state.st_line.partner_id"
|
||||
|
||||
Reference in New Issue
Block a user