2
0

[16.0][MIG] account_move_template: Migration to 16.0

This commit is contained in:
Abraham Anes 2023-06-06 12:38:05 +02:00
parent e624be9303
commit e85ddb6842
10 changed files with 71 additions and 111 deletions

View File

@ -2,10 +2,13 @@
Account Move Template
=====================
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:20cc4f7ed2bc199b6b560d11a525972060b3a3c13d37bc666eefdd711683e412
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
@ -14,14 +17,14 @@ Account Move Template
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github
:target: https://github.com/OCA/account-financial-tools/tree/15.0/account_move_template
:target: https://github.com/OCA/account-financial-tools/tree/16.0/account_move_template
:alt: OCA/account-financial-tools
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/account-financial-tools-15-0/account-financial-tools-15-0-account_move_template
:target: https://translation.odoo-community.org/projects/account-financial-tools-16-0/account-financial-tools-16-0-account_move_template
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/92/15.0
:alt: Try me on Runbot
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-financial-tools&target_branch=16.0
:alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5|
@ -82,8 +85,8 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-financial-tools/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_move_template%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_move_template%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
@ -128,6 +131,7 @@ Module Contributors
* `Ecosoft <http://ecosoft.co.th>`_:
* Kitti U. <kittiu@ecosoft.co.th> (Add context overwrite)
* Abraham Anes <abrahamanes@gmail.com>
Maintainers
~~~~~~~~~~~
@ -142,6 +146,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
This module is part of the `OCA/account-financial-tools <https://github.com/OCA/account-financial-tools/tree/15.0/account_move_template>`_ project on GitHub.
This module is part of the `OCA/account-financial-tools <https://github.com/OCA/account-financial-tools/tree/16.0/account_move_template>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -5,7 +5,7 @@
{
"name": "Account Move Template",
"version": "15.0.1.0.0",
"version": "16.0.1.0.0",
"category": "Accounting",
"summary": "Templates for recurring Journal Entries",
"author": "Agile Business Group, Aurium Technologies, Vauxoo, ForgeFlow, "

View File

@ -123,10 +123,7 @@ class AccountMoveTemplateLine(models.Model):
string="Partner",
domain=["|", ("parent_id", "=", False), ("is_company", "=", True)],
)
analytic_account_id = fields.Many2one(
"account.analytic.account", string="Analytic Account"
)
analytic_tag_ids = fields.Many2many("account.analytic.tag", string="Analytic Tags")
analytic_distribution = fields.Json(string="New Analytic Distribution")
tax_ids = fields.Many2many("account.tax", string="Taxes")
tax_line_id = fields.Many2one(
"account.tax", string="Originator Tax", ondelete="restrict"

View File

@ -24,3 +24,4 @@ Module Contributors
* `Ecosoft <http://ecosoft.co.th>`_:
* Kitti U. <kittiu@ecosoft.co.th> (Add context overwrite)
* Abraham Anes <abrahamanes@gmail.com>

View File

@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>Account Move Template</title>
<style type="text/css">
@ -366,8 +366,10 @@ ul.auto-toc {
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:20cc4f7ed2bc199b6b560d11a525972060b3a3c13d37bc666eefdd711683e412
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/account-financial-tools/tree/15.0/account_move_template"><img alt="OCA/account-financial-tools" src="https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/account-financial-tools-15-0/account-financial-tools-15-0-account_move_template"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/92/15.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/account-financial-tools/tree/16.0/account_move_template"><img alt="OCA/account-financial-tools" src="https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/account-financial-tools-16-0/account-financial-tools-16-0-account_move_template"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runboat.odoo-community.org/builds?repo=OCA/account-financial-tools&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>The user can configure journal entries templates, useful for recurring entries.
The amount of each template line can be computed (through python code)
or kept as user input.</p>
@ -435,8 +437,8 @@ defined formula, based on other lines, or by requiring user input.</li>
<h1><a class="toc-backref" href="#id2">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-financial-tools/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_move_template%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_move_template%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
@ -481,6 +483,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<li>Kitti U. &lt;<a class="reference external" href="mailto:kittiu&#64;ecosoft.co.th">kittiu&#64;ecosoft.co.th</a>&gt; (Add context overwrite)</li>
</ul>
</li>
<li>Abraham Anes &lt;<a class="reference external" href="mailto:abrahamanes&#64;gmail.com">abrahamanes&#64;gmail.com</a>&gt;</li>
</ul>
</div>
</div>
@ -491,7 +494,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-financial-tools/tree/15.0/account_move_template">OCA/account-financial-tools</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-financial-tools/tree/16.0/account_move_template">OCA/account-financial-tools</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>

View File

@ -76,12 +76,10 @@ class TestAccountMoveTemplate(TransactionCase):
)
)
self.user_type = self.env.ref("account.data_account_type_liquidity")
self.chart = self.env["account.chart.template"].search([], limit=1)
self._chart_of_accounts_create(self.company, self.chart)
account_template = self.env["account.account.template"].create(
{"name": "Test 1", "code": "Code_test", "user_type_id": self.user_type.id}
{"name": "Test 1", "code": "Code_test", "account_type": "asset_cash"}
)
self.env["ir.model.data"].create(
{
@ -126,15 +124,12 @@ class TestAccountMoveTemplate(TransactionCase):
self.partner2 = self.env["res.partner"].create(
{"name": "Test partner 2", "company_id": False}
)
self.account_type = self.env["account.account.type"].create(
{"name": "Test Tax Account Type"}
)
self.tax_account_id = self.env["account.account"].create(
{
"name": "tax account",
"code": "TAX",
"user_type_id": self.account_type.id,
"account_type": "income_other",
"company_id": self.company.id,
}
)

View File

@ -6,51 +6,52 @@ from odoo.tests.common import Form, TransactionCase
class TestAccountMoveTemplateEnhanced(TransactionCase):
def setUp(self):
super(TestAccountMoveTemplateEnhanced, self).setUp()
self.Move = self.env["account.move"]
self.Journal = self.env["account.journal"]
self.Account = self.env["account.account"]
self.Template = self.env["account.move.template"]
self.Partner = self.env["res.partner"]
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.Move = cls.env["account.move"]
cls.Journal = cls.env["account.journal"]
cls.Account = cls.env["account.account"]
cls.Template = cls.env["account.move.template"]
cls.Partner = cls.env["res.partner"]
self.journal = self.Journal.search([("type", "=", "general")], limit=1)
self.ar_account_id = self.Account.search(
[("user_type_id.type", "=", "receivable")], limit=1
cls.journal = cls.Journal.search([("type", "=", "general")], limit=1)
cls.ar_account_id = cls.Account.search(
[("account_type", "=", "asset_receivable")], limit=1
)
self.ap_account_id = self.Account.search(
[("user_type_id.type", "=", "payable")], limit=1
cls.ap_account_id = cls.Account.search(
[("account_type", "=", "liability_payable")], limit=1
)
self.income_account_id = self.Account.search(
cls.income_account_id = cls.Account.search(
[
("user_type_id.type", "=", "other"),
("user_type_id.internal_group", "=", "income"),
("account_type", "=", "income_other"),
("internal_group", "=", "income"),
],
limit=1,
)
self.expense_account_id = self.Account.search(
cls.expense_account_id = cls.Account.search(
[
("user_type_id.type", "=", "other"),
("user_type_id.internal_group", "=", "expense"),
("account_type", "=", "expense"),
("internal_group", "=", "expense"),
],
limit=1,
)
self.partners = self.Partner.search([], limit=3)
cls.partners = cls.Partner.search([], limit=3)
# Create a simple move tempalte
ar_line = {
"sequence": 0,
"name": "AR Line 1",
"account_id": self.ar_account_id.id,
"opt_account_id": self.ap_account_id.id,
"account_id": cls.ar_account_id.id,
"opt_account_id": cls.ap_account_id.id,
"move_line_type": "dr",
"type": "input",
}
income_line1 = {
"sequence": 1,
"name": "Income Line 2",
"account_id": self.income_account_id.id,
"opt_account_id": self.expense_account_id.id,
"account_id": cls.income_account_id.id,
"opt_account_id": cls.expense_account_id.id,
"move_line_type": "cr",
"type": "computed",
"python_code": "L0*1/3",
@ -58,17 +59,17 @@ class TestAccountMoveTemplateEnhanced(TransactionCase):
income_line2 = {
"sequence": 2,
"name": "Income Line 2",
"account_id": self.income_account_id.id,
"opt_account_id": self.expense_account_id.id,
"account_id": cls.income_account_id.id,
"opt_account_id": cls.expense_account_id.id,
"move_line_type": "cr",
"type": "computed",
"python_code": "L0*2/3",
}
self.move_template = self.Template.create(
cls.move_template = cls.Template.create(
{
"name": "Test Template",
"journal_id": self.journal.id,
"journal_id": cls.journal.id,
"line_ids": [
Command.create(ar_line),
Command.create(income_line1),

View File

@ -14,14 +14,10 @@
<field name="partner_id" />
<field name="name" />
<field
name="analytic_account_id"
name="analytic_distribution"
widget="analytic_distribution"
groups="analytic.group_analytic_accounting"
/>
<field
name="analytic_tag_ids"
widget="many2many_tags"
groups="analytic.group_analytic_tags"
/>
<field name="move_line_type" />
<field name="type" />
<field name="note" />
@ -65,13 +61,9 @@
name="analytic"
>
<field
name="analytic_account_id"
domain="[('company_id','=',company_id)]"
/>
<field
name="analytic_tag_ids"
widget="many2many_tags"
groups="analytic.group_analytic_tags"
name="analytic_distribution"
widget="analytic_distribution"
groups="analytic.group_analytic_accounting"
/>
</group>
<group name="amount" string="Amount">
@ -128,18 +120,6 @@
class="btn-primary"
type="object"
/>
<button
type="object"
name="toggle_active"
string="Archive"
attrs="{'invisible': [('active', '=', False)]}"
/>
<button
type="object"
name="toggle_active"
string="Restore"
attrs="{'invisible': [('active', '=', True)]}"
/>
</header>
<sheet>
<widget
@ -157,6 +137,7 @@
</div>
<group name="main">
<group name="main-left">
<field name="company_id" invisible="1" />
<field
name="company_id"
widget="selection"
@ -176,6 +157,7 @@
name="line_ids"
nolabel="1"
context="{'default_company_id': company_id}"
colspan="2"
/>
</group>
</sheet>

View File

@ -52,8 +52,7 @@ Valid dictionary to overwrite template lines:
"move_line_type": tmpl_line.move_line_type,
"tax_line_id": tmpl_line.tax_line_id.id,
"tax_ids": [Command.set(tmpl_line.tax_ids.ids)],
"analytic_account_id": tmpl_line.analytic_account_id.id,
"analytic_tag_ids": [Command.set(tmpl_line.analytic_tag_ids.ids)],
"analytic_distribution": tmpl_line.analytic_distribution,
"note": tmpl_line.note,
"payment_term_id": tmpl_line.payment_term_id.id or False,
"is_refund": tmpl_line.is_refund,
@ -220,7 +219,6 @@ Valid dictionary to overwrite template lines:
debit = line.move_line_type == "dr"
values = {
"name": line.name,
"analytic_account_id": line.analytic_account_id.id,
"account_id": line.account_id.id,
"credit": not debit and amount or 0.0,
"debit": debit and amount or 0.0,
@ -228,8 +226,8 @@ Valid dictionary to overwrite template lines:
"date_maturity": date_maturity or self.date,
"tax_repartition_line_id": line.tax_repartition_line_id.id or False,
}
if line.analytic_tag_ids:
values["analytic_tag_ids"] = [Command.set(line.analytic_tag_ids.ids)]
if line.analytic_distribution:
values["analytic_distribution"] = line.analytic_distribution
if line.tax_ids:
values["tax_ids"] = [Command.set(line.tax_ids.ids)]
tax_repartition = "refund_tax_id" if line.is_refund else "invoice_tax_id"
@ -275,10 +273,7 @@ class AccountMoveTemplateLineRun(models.TransientModel):
sequence = fields.Integer(required=True)
name = fields.Char(readonly=True)
account_id = fields.Many2one("account.account", required=True, readonly=True)
analytic_account_id = fields.Many2one("account.analytic.account", readonly=True)
analytic_tag_ids = fields.Many2many(
"account.analytic.tag", string="Analytic Tags", readonly=True
)
analytic_distribution = fields.Json(string="New Analytic Distribution")
tax_ids = fields.Many2many("account.tax", string="Taxes", readonly=True)
tax_line_id = fields.Many2one(
"account.tax", string="Originator Tax", ondelete="restrict", readonly=True

View File

@ -16,22 +16,9 @@
name="overwrite"
widget="ace"
options="{'mode': 'python'}"
invisible="1"
attrs="{'invisible': [('state', '=', 'set_lines')]}"
/>
<!-- Initial invisibility status of the overwrite field:
attrs="{'invisible': [('state', '=', 'set_lines')]}"
The overwrite option is useful when generating
the move via code, but I think it's not a good idea to display it to
the user. We can't expect users to write a python dict to enter data
via the web interface for their daily usage of Odoo. Of course, most
users will just leave the field empty and use the module as normal, but
it complexifies the interface for everybody, and many users will wonder
what they should enter in this "Overwrite" field and wait for help. So
let's make that field invisible, and you can un-hide it for specific
project where you have an accountant that is good at writing python
dicts and finding IDs of partners!
-->
<field name="company_id" invisible="1" />
<field name="company_id" groups="base.group_multi_company" />
<field name="date" states="set_lines" />
<field name="journal_id" states="set_lines" />
@ -39,7 +26,7 @@ dicts and finding IDs of partners!
<field name="partner_id" states="set_lines" />
</group>
<group name="lines" states="set_lines">
<field name="line_ids" nolabel="1">
<field name="line_ids" nolabel="1" colspan="2">
<tree editable="bottom">
<field name="sequence" invisible="1" />
<field name="name" />
@ -49,15 +36,10 @@ dicts and finding IDs of partners!
/>
<field name="partner_id" />
<field
name="analytic_account_id"
domain="[('company_id','=',company_id)]"
name="analytic_distribution"
widget="analytic_distribution"
groups="analytic.group_analytic_accounting"
/>
<field
name="analytic_tag_ids"
widget="many2many_tags"
groups="analytic.group_analytic_tags"
/>
<field
name="tax_line_id"
attrs="{'invisible': [('tax_line_id','=',False)]}"