[MIG] account_spread_cost_revenue: Migration to 17.0

This commit is contained in:
Antoni Marroig Campomar
2024-05-02 17:28:27 +02:00
parent 4e5b8fee4d
commit 63c8e86e08
15 changed files with 147 additions and 140 deletions

View File

@@ -232,6 +232,9 @@ Contributors
- Andrea Stirpe <a.stirpe@onestein.nl>
- Kitti U. <kittiu@ecosoft.co.th>
- Saran Lim. <saranl@ecosoft.co.th>
- `APSL <https://www.apsl.tech>`__:
- Antoni Marroig <<amarroig@apsl.net>>
Other credits
-------------

View File

@@ -4,7 +4,7 @@
{
"name": "Cost-Revenue Spread",
"summary": "Spread costs and revenues over a custom period",
"version": "16.0.1.0.1",
"version": "17.0.1.0.0",
"development_status": "Beta",
"author": "Onestein,Odoo Community Association (OCA)",
"license": "AGPL-3",

View File

@@ -1,7 +1,7 @@
# Copyright 2016-2020 Onestein (<https://www.onestein.eu>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import api, models
from odoo import models
class AccountMove(models.Model):
@@ -33,7 +33,6 @@ class AccountMove(models.Model):
res = super().button_cancel()
return res
@api.constrains("name", "journal_id", "state")
def _check_unique_sequence_number(self):
def _get_unbalanced_moves(self, container):
if not self.env.context.get("skip_unique_sequence_number"):
return super()._check_unique_sequence_number()
return super()._get_unbalanced_moves(container)

View File

@@ -118,7 +118,6 @@ class AccountSpread(models.Model):
)
invoice_id = fields.Many2one(
related="invoice_line_id.move_id",
readonly=True,
store=True,
)
estimated_amount = fields.Float(digits="Account")

View File

@@ -10,11 +10,11 @@ class AccountInvoiceSpreadLine(models.Model):
_description = "Account Spread Lines"
_order = "date"
name = fields.Char("Description", readonly=True)
name = fields.Char("Description")
amount = fields.Float(digits="Account", required=True)
date = fields.Date(required=True)
spread_id = fields.Many2one("account.spread", ondelete="cascade")
move_id = fields.Many2one("account.move", string="Journal Entry", readonly=True)
move_id = fields.Many2one("account.move", string="Journal Entry")
def create_and_reconcile_moves(self):
grouped_lines = {}

View File

@@ -1,3 +1,5 @@
- Andrea Stirpe \<<a.stirpe@onestein.nl>\>
- Kitti U. \<<kittiu@ecosoft.co.th>\>
- Saran Lim. \<<saranl@ecosoft.co.th>\>
- [APSL](<https://www.apsl.tech>):
- Antoni Marroig \<\<<amarroig@apsl.net>\>\>

View File

@@ -570,6 +570,10 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
<li>Andrea Stirpe &lt;<a class="reference external" href="mailto:a.stirpe&#64;onestein.nl">a.stirpe&#64;onestein.nl</a>&gt;</li>
<li>Kitti U. &lt;<a class="reference external" href="mailto:kittiu&#64;ecosoft.co.th">kittiu&#64;ecosoft.co.th</a>&gt;</li>
<li>Saran Lim. &lt;<a class="reference external" href="mailto:saranl&#64;ecosoft.co.th">saranl&#64;ecosoft.co.th</a>&gt;</li>
<li><a class="reference external" href="https://www.apsl.tech">APSL</a>:<ul>
<li>Antoni Marroig &lt;&lt;<a class="reference external" href="mailto:amarroig&#64;apsl.net">amarroig&#64;apsl.net</a>&gt;&gt;</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="other-credits">

View File

@@ -9,6 +9,7 @@ from odoo.tests import Form, common
class TestAccountInvoiceSpread(common.TransactionCase):
@classmethod
def create_account_invoice(self, invoice_type, quantity=1.0, price_unit=1000.0):
"""Create an invoice as in a view by triggering its onchange methods"""
@@ -25,18 +26,19 @@ class TestAccountInvoiceSpread(common.TransactionCase):
return invoice_form.save()
def setUp(self):
super().setUp()
@classmethod
def setUpClass(cls):
super().setUpClass()
# Define minimal accounting data to run
a_expense = self.env["account.account"].create(
a_expense = cls.env["account.account"].create(
{
"code": "X2120",
"name": "Expenses - (test)",
"account_type": "expense",
}
)
a_sale = self.env["account.account"].create(
a_sale = cls.env["account.account"].create(
{
"code": "X2020",
"name": "Product Sales - (test)",
@@ -44,7 +46,7 @@ class TestAccountInvoiceSpread(common.TransactionCase):
}
)
self.expenses_journal = self.env["account.journal"].create(
cls.expenses_journal = cls.env["account.journal"].create(
{
"name": "Vendor Bills - Test",
"code": "TEXJ",
@@ -53,7 +55,7 @@ class TestAccountInvoiceSpread(common.TransactionCase):
"refund_sequence": True,
}
)
self.sales_journal = self.env["account.journal"].create(
cls.sales_journal = cls.env["account.journal"].create(
{
"name": "Customer Invoices - Test",
"code": "TINV",
@@ -63,7 +65,7 @@ class TestAccountInvoiceSpread(common.TransactionCase):
}
)
self.account_payable = self.env["account.account"].create(
cls.account_payable = cls.env["account.account"].create(
{
"name": "Test account payable",
"code": "321spread",
@@ -72,7 +74,7 @@ class TestAccountInvoiceSpread(common.TransactionCase):
}
)
self.account_receivable = self.env["account.account"].create(
cls.account_receivable = cls.env["account.account"].create(
{
"name": "Test account receivable",
"code": "322spread",
@@ -81,7 +83,7 @@ class TestAccountInvoiceSpread(common.TransactionCase):
}
)
spread_account_payable = self.env["account.account"].create(
spread_account_payable = cls.env["account.account"].create(
{
"name": "test spread account_payable",
"code": "765spread",
@@ -90,7 +92,7 @@ class TestAccountInvoiceSpread(common.TransactionCase):
}
)
spread_account_receivable = self.env["account.account"].create(
spread_account_receivable = cls.env["account.account"].create(
{
"name": "test spread account_receivable",
"code": "766spread",
@@ -101,47 +103,45 @@ class TestAccountInvoiceSpread(common.TransactionCase):
# Invoices
self.vendor_bill = self.create_account_invoice("in_invoice")
self.vendor_bill.invoice_date = fields.Date.today()
self.sale_invoice = self.create_account_invoice("out_invoice")
self.sale_invoice.invoice_date = fields.Date.today()
self.vendor_bill_line = self.vendor_bill.invoice_line_ids[0]
self.invoice_line = self.sale_invoice.invoice_line_ids[0]
cls.vendor_bill = cls.create_account_invoice(invoice_type="in_invoice")
cls.vendor_bill.invoice_date = fields.Date.today()
cls.sale_invoice = cls.create_account_invoice(invoice_type="out_invoice")
cls.sale_invoice.invoice_date = fields.Date.today()
cls.vendor_bill_line = cls.vendor_bill.invoice_line_ids[0]
cls.invoice_line = cls.sale_invoice.invoice_line_ids[0]
# Set accounts to reconcilable
self.vendor_bill_line.account_id.reconcile = True
self.invoice_line.account_id.reconcile = True
cls.vendor_bill_line.account_id.reconcile = True
cls.invoice_line.account_id.reconcile = True
analytic_plan = self.env["account.analytic.plan"].create(
{"name": "Plan Test", "company_id": False}
)
self.analytic_account = self.env["account.analytic.account"].create(
analytic_plan = cls.env["account.analytic.plan"].create({"name": "Plan Test"})
cls.analytic_account = cls.env["account.analytic.account"].create(
{"name": "test account", "plan_id": analytic_plan.id}
)
self.distribution = self.env["account.analytic.distribution.model"].create(
cls.distribution = cls.env["account.analytic.distribution.model"].create(
{
"partner_id": self.vendor_bill.partner_id.id,
"analytic_distribution": {self.analytic_account.id: 100},
"partner_id": cls.vendor_bill.partner_id.id,
"analytic_distribution": {cls.analytic_account.id: 100},
}
)
self.spread = (
self.env["account.spread"]
cls.spread = (
cls.env["account.spread"]
.with_context(mail_create_nosubscribe=True)
.create(
[
{
"name": "test",
"debit_account_id": spread_account_payable.id,
"credit_account_id": self.account_payable.id,
"credit_account_id": cls.account_payable.id,
"period_number": 12,
"period_type": "month",
"spread_date": datetime.date(2017, 2, 1),
"estimated_amount": 1000.0,
"journal_id": self.vendor_bill.journal_id.id,
"journal_id": cls.vendor_bill.journal_id.id,
"invoice_type": "in_invoice",
"analytic_distribution": self.distribution._get_distribution(
"analytic_distribution": cls.distribution._get_distribution(
{
"partner_id": self.vendor_bill.partner_id.id,
"partner_id": cls.vendor_bill.partner_id.id,
}
),
}
@@ -149,17 +149,17 @@ class TestAccountInvoiceSpread(common.TransactionCase):
)
)
self.spread2 = self.env["account.spread"].create(
cls.spread2 = cls.env["account.spread"].create(
[
{
"name": "test2",
"debit_account_id": spread_account_receivable.id,
"credit_account_id": self.account_receivable.id,
"credit_account_id": cls.account_receivable.id,
"period_number": 12,
"period_type": "month",
"spread_date": datetime.date(2017, 2, 1),
"estimated_amount": 1000.0,
"journal_id": self.sale_invoice.journal_id.id,
"journal_id": cls.sale_invoice.journal_id.id,
"invoice_type": "out_invoice",
}
]
@@ -790,7 +790,6 @@ class TestAccountInvoiceSpread(common.TransactionCase):
{
"date": fields.Date.today(),
"reason": "no reason",
"refund_method": "refund",
"journal_id": self.vendor_bill.journal_id.id,
}
)

View File

@@ -11,18 +11,19 @@ from odoo.tools import mute_logger
class TestAccountSpreadCostRevenue(common.TransactionCase):
def setUp(self):
super().setUp()
@classmethod
def setUpClass(cls):
super().setUpClass()
self.sales_journal = self.env["account.journal"].create(
cls.sales_journal = cls.env["account.journal"].create(
{"name": "Customer Invoices - Test", "code": "TEST1", "type": "sale"}
)
self.expenses_journal = self.env["account.journal"].create(
cls.expenses_journal = cls.env["account.journal"].create(
{"name": "Vendor Bills - Test", "code": "TEST2", "type": "purchase"}
)
self.credit_account = self.env["account.account"].create(
cls.credit_account = cls.env["account.account"].create(
{
"name": "test_account_receivable",
"code": "123",
@@ -31,7 +32,7 @@ class TestAccountSpreadCostRevenue(common.TransactionCase):
}
)
self.debit_account = self.env["account.account"].create(
cls.debit_account = cls.env["account.account"].create(
{
"name": "test account_expenses",
"code": "765",
@@ -40,7 +41,7 @@ class TestAccountSpreadCostRevenue(common.TransactionCase):
}
)
self.account_payable = self.env["account.account"].create(
cls.account_payable = cls.env["account.account"].create(
{
"name": "test_account_payable",
"code": "321",
@@ -49,7 +50,7 @@ class TestAccountSpreadCostRevenue(common.TransactionCase):
}
)
self.account_revenue = self.env["account.account"].create(
cls.account_revenue = cls.env["account.account"].create(
{
"name": "test_account_revenue",
"code": "864",

View File

@@ -8,14 +8,15 @@ from odoo.tests import Form, common
class TestComputeSpreadBoard(common.TransactionCase):
def setUp(self):
super().setUp()
@classmethod
def setUpClass(cls):
super().setUpClass()
journal = self.env["account.journal"].create(
journal = cls.env["account.journal"].create(
{"name": "Test", "type": "general", "code": "test"}
)
self.receivable_account = self.env["account.account"].create(
cls.receivable_account = cls.env["account.account"].create(
{
"name": "test_account_receivable",
"code": "123",
@@ -24,7 +25,7 @@ class TestComputeSpreadBoard(common.TransactionCase):
}
)
self.expense_account = self.env["account.account"].create(
cls.expense_account = cls.env["account.account"].create(
{
"name": "test account_expenses",
"code": "765",
@@ -33,7 +34,7 @@ class TestComputeSpreadBoard(common.TransactionCase):
}
)
self.spread_account = self.env["account.account"].create(
cls.spread_account = cls.env["account.account"].create(
{
"name": "test spread account_expenses",
"code": "321",
@@ -42,11 +43,11 @@ class TestComputeSpreadBoard(common.TransactionCase):
}
)
self.spread = self.env["account.spread"].create(
cls.spread = cls.env["account.spread"].create(
{
"name": "test",
"debit_account_id": self.spread_account.id,
"credit_account_id": self.expense_account.id,
"debit_account_id": cls.spread_account.id,
"credit_account_id": cls.expense_account.id,
"period_number": 12,
"period_type": "month",
"spread_date": "2017-02-01",
@@ -56,11 +57,11 @@ class TestComputeSpreadBoard(common.TransactionCase):
}
)
self.spread2 = self.env["account.spread"].create(
cls.spread2 = cls.env["account.spread"].create(
{
"name": "test2",
"debit_account_id": self.spread_account.id,
"credit_account_id": self.expense_account.id,
"debit_account_id": cls.spread_account.id,
"credit_account_id": cls.expense_account.id,
"period_number": 12,
"period_type": "month",
"spread_date": "2017-02-01",
@@ -70,11 +71,11 @@ class TestComputeSpreadBoard(common.TransactionCase):
}
)
self.spread3 = self.env["account.spread"].create(
cls.spread3 = cls.env["account.spread"].create(
{
"name": "test by cal days",
"debit_account_id": self.spread_account.id,
"credit_account_id": self.expense_account.id,
"debit_account_id": cls.spread_account.id,
"credit_account_id": cls.expense_account.id,
"period_number": 12,
"period_type": "month",
"spread_date": "2017-02-01",
@@ -85,14 +86,14 @@ class TestComputeSpreadBoard(common.TransactionCase):
}
)
self.template = self.env["account.spread.template"].create(
cls.template = cls.env["account.spread.template"].create(
{
"name": "test",
"spread_type": "purchase",
"period_number": 5,
"period_type": "month",
"start_date": "2017-01-01",
"spread_account_id": self.spread_account.id,
"spread_account_id": cls.spread_account.id,
"spread_journal_id": journal.id,
"days_calc": True,
}

View File

@@ -10,7 +10,7 @@
>
<field
name="spread_check"
invisible="1"
column_invisible="1"
groups="account.group_account_user,account.group_account_manager"
/>
<button
@@ -19,7 +19,7 @@
class="btn btn-link"
icon="fa-arrow-circle-right"
title="Not linked to any spread board"
attrs="{'invisible': [('spread_check', '!=', 'unlinked')]}"
invisible="spread_check != 'unlinked'"
groups="account.group_account_user,account.group_account_manager"
/>
<button
@@ -28,7 +28,7 @@
class="btn btn-success"
icon="fa-arrow-circle-right"
title="Linked to spread board"
attrs="{'invisible': [('spread_check', '!=', 'linked')]}"
invisible="spread_check != 'linked'"
groups="account.group_account_user,account.group_account_manager"
/>
</xpath>
@@ -38,7 +38,7 @@
>
<field
name="spread_check"
invisible="1"
column_invisible="1"
groups="account.group_account_user,account.group_account_manager"
/>
<button
@@ -48,7 +48,8 @@
icon="fa-arrow-circle-right"
title="Linked to spread board"
groups="account.group_account_user,account.group_account_manager"
attrs="{'invisible': [('spread_check', '!=', 'linked')], 'column_invisible': ['|', ('parent.move_type', '=', 'entry'), ('parent.state', '!=', 'posted')]}"
invisible="spread_check != 'linked'"
column_invisible="parent.move_type == 'entry' or parent.state != 'posted'"
/>
</xpath>
</field>

View File

@@ -10,27 +10,27 @@
type="object"
string="Recalculate unposted lines"
class="oe_highlight"
attrs="{'invisible': ['|',('debit_account_id', '=', False),('display_recompute_buttons', '=', False)]}"
invisible="not debit_account_id or not display_recompute_buttons"
/>
<button
name="action_recalculate_spread"
type="object"
string="Recalculate entire spread"
attrs="{'invisible': ['|',('debit_account_id', '=', False),('display_recompute_buttons', '=', False)]}"
invisible="not debit_account_id or not display_recompute_buttons"
groups="account.group_account_manager"
/>
<button
name="action_undo_spread"
type="object"
string="Undo spread"
attrs="{'invisible': [('line_ids', '=', [])]}"
invisible="not line_ids"
groups="account.group_account_manager"
/>
<button
name="action_unlink_invoice_line"
type="object"
string="Unlink Invoice Line"
attrs="{'invisible': [('invoice_line_id', '=', False)]}"
invisible="not invoice_line_id"
groups="account.group_account_manager"
/>
</header>
@@ -49,7 +49,7 @@
name="web_ribbon"
title="Archived"
bg_color="bg-danger"
attrs="{'invisible': [('active', '=', True)]}"
invisible="active"
/>
<div class="oe_title">
<label for="name" string="Spread Board Name" />
@@ -63,10 +63,7 @@
<group name="header_info">
<group name="spread_definitions">
<field name="template_id" />
<field
name="invoice_type"
attrs="{'readonly':[('invoice_line_id','!=',False)]}"
/>
<field name="invoice_type" readonly="invoice_line_id" />
<field name="display_recompute_buttons" invisible="1" />
<field name="display_move_line_auto_post" invisible="1" />
<field name="all_posted" invisible="1" />
@@ -81,22 +78,19 @@
for="debit_account_id"
colspan="3"
string="Balance sheet account / Spread account"
attrs="{'invisible':[('invoice_type','not in',('out_invoice','in_refund'))]}"
invisible="invoice_type not in ['out_invoice','in_refund']"
/>
<label
for="debit_account_id"
colspan="3"
string="Expense account"
attrs="{'invisible':[('invoice_type','not in',('in_invoice','out_refund'))]}"
invisible="invoice_type not in ['in_invoice','out_refund']"
/>
<div
attrs="{'invisible': [('use_invoice_line_account', '=', True)]}"
colspan="3"
>
<div invisible="use_invoice_line_account" colspan="3">
<span
class="help-block"
colspan="2"
attrs="{'invisible':[('invoice_type','not in',('out_invoice','in_refund'))]}"
invisible="invoice_type not in ['out_invoice','in_refund']"
>
The Balance Sheet account used for the spreading.<br
/>This account is the counterpart of the account in the invoice line.
@@ -104,20 +98,17 @@
<span
class="help-block"
colspan="2"
attrs="{'invisible':[('invoice_type','not in',('in_invoice','out_refund'))]}"
invisible="invoice_type not in ['in_invoice','out_refund']"
>
The Expense account in the vendor bill line.<br
/>Usually the same account of the vendor bill line.
</span>
</div>
<div
attrs="{'invisible': [('use_invoice_line_account', '!=', True)]}"
colspan="3"
>
<div invisible="not use_invoice_line_account" colspan="3">
<span
class="help-block"
colspan="2"
attrs="{'invisible':[('invoice_type','not in',('out_invoice','in_refund'))]}"
invisible="invoice_type not in ['out_invoice','in_refund']"
>
The Balance Sheet account.<br
/>This is the account in the invoice line.
@@ -125,7 +116,7 @@
<span
class="help-block"
colspan="2"
attrs="{'invisible':[('invoice_type','not in',('in_invoice','out_refund'))]}"
invisible="invoice_type not in ['in_invoice','out_refund']"
>
The Expense account used for the spreading.<br
/>This account is the counterpart of the account of the vendor bill line.
@@ -135,12 +126,12 @@
name="debit_account_id"
required="1"
domain="[('deprecated', '=', False), ('account_type', 'not in', ('asset_cash','liability_credit_card')), ('internal_group', '!=', 'off_balance')]"
attrs="{'readonly':[('invoice_line_id','!=',False)]}"
readonly="invoice_line_id"
/>
<span
class="help-block text-danger"
colspan="2"
attrs="{'invisible':[('is_debit_account_deprecated','!=',True)]}"
invisible="not is_debit_account_deprecated"
>
This account in deprecated! The reconciliation will be NOT possible.
</span>
@@ -151,22 +142,19 @@
for="credit_account_id"
colspan="3"
string="Revenue account"
attrs="{'invisible':[('invoice_type','not in',('out_invoice','in_refund'))]}"
invisible="invoice_type not in ['out_invoice','in_refund']"
/>
<label
for="credit_account_id"
colspan="3"
string="Balance sheet account / Spread account"
attrs="{'invisible':[('invoice_type','not in',('in_invoice','out_refund'))]}"
invisible="invoice_type not in ['in_invoice','out_refund']"
/>
<div
attrs="{'invisible': [('use_invoice_line_account', '=', True)]}"
colspan="3"
>
<div invisible="use_invoice_line_account" colspan="3">
<span
class="help-block"
colspan="2"
attrs="{'invisible':[('invoice_type','not in',('out_invoice','in_refund'))]}"
invisible="invoice_type not in ['out_invoice','in_refund']"
>
The Revenue account in the invoice line.<br
/>Usually the same account of the invoice line.
@@ -174,20 +162,17 @@
<span
class="help-block"
colspan="2"
attrs="{'invisible':[('invoice_type','not in',('in_invoice','out_refund'))]}"
invisible="invoice_type not in ['in_invoice','out_refund']"
>
The Balance Sheet account used for the spreading.<br
/>This account is the counterpart of the account in the vendor bill line.
</span>
</div>
<div
attrs="{'invisible': [('use_invoice_line_account', '!=', True)]}"
colspan="3"
>
<div invisible="not use_invoice_line_account" colspan="3">
<span
class="help-block"
colspan="2"
attrs="{'invisible':[('invoice_type','not in',('out_invoice','in_refund'))]}"
invisible="invoice_type not in ['out_invoice','in_refund']"
>
The Revenue account used for the spreading.<br
/>This account is the counterpart of the account of the invoice line.
@@ -195,7 +180,7 @@
<span
class="help-block"
colspan="2"
attrs="{'invisible':[('invoice_type','not in',('in_invoice','out_refund'))]}"
invisible="invoice_type not in ['in_invoice','out_refund']"
>
The Balance Sheet account.<br
/>This is the account in the vendor bill line.
@@ -205,12 +190,12 @@
name="credit_account_id"
required="1"
domain="[('deprecated', '=', False), ('account_type', 'not in', ('asset_cash','liability_credit_card')), ('internal_group', '!=', 'off_balance')]"
attrs="{'readonly':[('invoice_line_id','!=',False)]}"
readonly="invoice_line_id"
/>
<span
class="help-block text-danger"
colspan="2"
attrs="{'invisible':[('is_credit_account_deprecated','!=',True)]}"
invisible="not is_credit_account_deprecated"
>
This account in deprecated! The reconciliation will be NOT possible.
</span>
@@ -220,24 +205,26 @@
<group>
<field
name="invoice_id"
attrs="{'invisible':[('invoice_id','=',False)]}"
invisible="not invoice_id"
readonly="1"
/>
<field
name="invoice_line_id"
readonly="1"
attrs="{'invisible':[('invoice_line_id','=',False)]}"
invisible="not invoice_line_id"
/>
<field
name="estimated_amount"
attrs="{'readonly':[('invoice_line_id','!=',False)],'invisible':[('estimated_amount','=',0.0),('invoice_line_id','!=',False)]}"
readonly="invoice_line_id"
invisible="estimated_amount == 0.0 and invoice_line_id"
/>
<field
name="total_amount"
attrs="{'invisible':[('invoice_line_id','=',False)]}"
invisible="not invoice_line_id"
/>
<field
name="move_line_auto_post"
attrs="{'invisible':[('display_move_line_auto_post','=',False)]}"
invisible="not display_move_line_auto_post"
/>
</group>
<group>
@@ -246,7 +233,11 @@
<field name="spread_date" />
<field name="days_calc" />
<field name="suitable_journal_ids" invisible="1" />
<field name="journal_id" widget="selection" />
<field
name="journal_id"
widget="selection"
groups="base.group_multi_company"
/>
</group>
</group>
<notebook name="notebook">
@@ -256,7 +247,7 @@
<field name="name" readonly="1" />
<field
name="amount"
attrs="{'readonly':[('move_id','!=',False)]}"
readonly="move_id"
sum="Total"
/>
<field name="date" readonly="1" />
@@ -267,14 +258,14 @@
string="Create Move"
type="object"
groups="account.group_account_manager"
attrs="{'invisible':[('move_id','!=',False)]}"
invisible="move_id"
/>
<button
name="open_move"
icon="fa-plus-square-o"
string="View Move"
type="object"
attrs="{'invisible':[('move_id','=',False)]}"
invisible="not move_id"
/>
<button
name="unlink_move"
@@ -283,7 +274,7 @@
type="object"
confirm="This will delete the move. Are you sure ?"
groups="account.group_account_manager"
attrs="{'invisible':[('move_id','=',False)]}"
invisible="not move_id"
/>
</tree>
</field>
@@ -301,19 +292,19 @@
type="object"
icon="fa-play"
colspan="2"
attrs="{'invisible':[('display_create_all_moves','!=',True)]}"
invisible="not display_create_all_moves"
/>
<field
name="unspread_amount"
attrs="{'invisible': [('unspread_amount', '=', 0)]}"
invisible="unspread_amount == 0"
/>
<field
name="unposted_amount"
attrs="{'invisible': [('unposted_amount', '=', 0)]}"
invisible="unposted_amount == 0"
/>
<field
name="posted_amount"
attrs="{'invisible': [('posted_amount', '=', 0)]}"
invisible="posted_amount == 0"
/>
</group>
</group>

View File

@@ -34,11 +34,13 @@
name="spread_account_id"
domain="[('deprecated', '=', False), ('account_type', 'not in', ('asset_cash','liability_credit_card')), ('internal_group', '!=', 'off_balance')]"
options="{'no_create': True}"
attrs="{'required': [('use_invoice_line_account', '!=', True)], 'invisible': [('use_invoice_line_account', '=', True)]}"
required="not use_invoice_line_account"
invisible="use_invoice_line_account"
/>
<field
name="exp_rev_account_id"
attrs="{'invisible': [('use_invoice_line_account', '=', False)], 'required': [('use_invoice_line_account', '=', True)]}"
invisible="not use_invoice_line_account"
required="use_invoice_line_account"
domain="[('deprecated', '=', False)]"
options="{'no_create': True}"
/>
@@ -54,12 +56,12 @@
<field name="auto_spread" />
<label for="auto_spread" />
</div>
<p attrs="{'invisible': [('auto_spread', '!=', True)]}">
<p invisible="not auto_spread">
Automatically use this spread template on invoice validation for invoice lines using below product and/or account and/or analytic,
</p>
<field
name="auto_spread_ids"
attrs="{'invisible': [('auto_spread', '!=', True)]}"
invisible="not auto_spread"
nolabel="1"
>
<tree editable="bottom">

View File

@@ -27,9 +27,9 @@ class AccountSpreadInvoiceLineLinkWizard(models.TransientModel):
return "link"
invoice_line_id = fields.Many2one(
"account.move.line", readonly=True, required=True, ondelete="cascade"
"account.move.line", required=True, ondelete="cascade"
)
invoice_id = fields.Many2one(related="invoice_line_id.move_id", readonly=True)
invoice_id = fields.Many2one(related="invoice_line_id.move_id")
invoice_type = fields.Selection(
[
("out_invoice", "Customer Invoice"),

View File

@@ -20,35 +20,40 @@
<field name="spread_action_type" widget="radio" />
<field
name="spread_id"
attrs="{'invisible': [('spread_action_type', '!=', 'link')],'required': [('spread_action_type', '=', 'link')]}"
invisible="spread_action_type != 'link'"
required="spread_action_type == 'link'"
domain="[('invoice_type', '=', invoice_type)]"
options="{'no_create': True}"
/>
<field
name="template_id"
attrs="{'invisible': [('spread_action_type', '!=', 'template')],'required': [('spread_action_type', '=', 'template')]}"
invisible="spread_action_type != 'template'"
required="spread_action_type == 'template'"
domain="[('spread_type', '=', spread_type)]"
options="{'no_create': True}"
/>
<field
name="use_invoice_line_account"
attrs="{'invisible': [('spread_action_type', '!=', 'new')]}"
invisible="spread_action_type != 'new'"
/>
<field
name="spread_account_id"
attrs="{'invisible': [('spread_action_type', '!=', 'new')],'required': [('spread_action_type', '=', 'new')]}"
invisible="spread_action_type != 'new'"
required="spread_action_type == 'new'"
domain="[('deprecated', '=', False), ('account_type', 'not in', ('asset_cash','liability_credit_card')), ('internal_group', '!=', 'off_balance')]"
options="{'no_create': True}"
/>
<field
name="exp_rev_account_id"
attrs="{'invisible': ['|', ('use_invoice_line_account', '=', False), ('spread_action_type', '!=', 'new')], 'required': [('use_invoice_line_account', '=', True)]}"
invisible="not use_invoice_line_account or spread_action_type != 'new'"
required="use_invoice_line_account"
domain="[('deprecated', '=', False)]"
options="{'no_create': True}"
/>
<field
name="spread_journal_id"
attrs="{'invisible': [('spread_action_type', '!=', 'new')],'required': [('spread_action_type', '=', 'new')]}"
invisible="spread_action_type != 'new'"
required="spread_action_type == 'new'"
options="{'no_create': True}"
/>
</group>