Skip to content

Commit 0d48aef

Browse files
committed
add account dms field
fix author and correct Readme
1 parent 554890a commit 0d48aef

File tree

12 files changed

+231
-0
lines changed

12 files changed

+231
-0
lines changed

Diff for: account_dms_field/README.rst

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
=========================
2+
Add dms field for account
3+
=========================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:b7f18580a215d7c509b59f1e27607ad97ff06df4cc445bd45e838ead8c9e5164
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
13+
:target: https://odoo-community.org/page/development-status
14+
:alt: Beta
15+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
16+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
17+
:alt: License: AGPL-3
18+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fdms-lightgray.png?logo=github
19+
:target: https://github.com/OCA/dms/tree/16.0/account_dms_field
20+
:alt: OCA/dms
21+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
22+
:target: https://translation.odoo-community.org/projects/dms-16-0/dms-16-0-account_dms_field
23+
:alt: Translate me on Weblate
24+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
25+
:target: https://runboat.odoo-community.org/builds?repo=OCA/dms&target_branch=16.0
26+
:alt: Try me on Runboat
27+
28+
|badge1| |badge2| |badge3| |badge4| |badge5|
29+
30+
Add the Documents tab with the files in the account move form view.
31+
32+
**Table of contents**
33+
34+
.. contents::
35+
:local:
36+
37+
Configuration
38+
=============
39+
40+
#. *Go to Documents > Configuration > File templates* and create a new record.
41+
#. Set a storage, a model (account.move) and the access groups you want.
42+
#. Click on the "Documents" tab icon and a folder hierarchy will be created.
43+
#. You can set here the hierarchy of directories, subdirectories and files you need, this hierarchy will be used as a base when creating a new record (res.partner for example).
44+
45+
Usage
46+
=====
47+
48+
#. Go to the form view of an existing account move and click on the "Documents" tab icon, a hierarchy of
49+
folders and files linked to that record will be created.
50+
#. Create a new account.move. A hierarchy of folders and files linked to that record will be created.
51+
52+
53+
Bug Tracker
54+
===========
55+
56+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/dms/issues>`_.
57+
In case of trouble, please check there if your issue has already been reported.
58+
If you spotted it first, help us to smash it by providing a detailed and welcomed
59+
`feedback <https://github.com/OCA/dms/issues/new?body=module:%20account_dms_field%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
60+
61+
Do not contact contributors directly about support or help with technical issues.
62+
63+
Credits
64+
=======
65+
66+
Authors
67+
~~~~~~~
68+
69+
* Agenterp
70+
71+
Contributors
72+
~~~~~~~~~~~~
73+
74+
* `Agenterp <https://www.agenterp.com/>`_:
75+
76+
* Georg Notter
77+
78+
Maintainers
79+
~~~~~~~~~~~
80+
81+
This module is maintained by the OCA.
82+
83+
.. image:: https://odoo-community.org/logo.png
84+
:alt: Odoo Community Association
85+
:target: https://odoo-community.org
86+
87+
OCA, or the Odoo Community Association, is a nonprofit organization whose
88+
mission is to support the collaborative development of Odoo features and
89+
promote its widespread use.
90+
91+
.. |maintainer-victoralmau| image:: https://github.com/victoralmau.png?size=40px
92+
:target: https://github.com/victoralmau
93+
:alt: victoralmau
94+
95+
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
96+
97+
|maintainer-victoralmau|
98+
99+
This module is part of the `OCA/dms <https://github.com/OCA/dms/tree/16.0/account_dms_field>`_ project on GitHub.
100+
101+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

Diff for: account_dms_field/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models

Diff for: account_dms_field/__manifest__.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "Add dms field for account",
3+
"version": "16.0.1.0.0",
4+
"category": "Accounting/Accounting",
5+
"website": "https://github.com/OCA/dms",
6+
"author": "Agent ERP GmbH, Odoo Community Association (OCA)",
7+
"depends": ["account", "dms_field"],
8+
"data": ["views/account_move_view.xml"],
9+
"demo": ["demo/account_dms_data.xml"],
10+
"installable": True,
11+
"license": "LGPL-3",
12+
}

Diff for: account_dms_field/demo/account_dms_data.xml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<odoo>
3+
<record id="read_access_account_move_group" model="dms.access.group">
4+
<field name="name">Everyone for Account DMS</field>
5+
<field name="group_ids" eval="[(4, ref('account.group_account_invoice'))]" />
6+
<field name="perm_create" eval="True" />
7+
<field name="perm_write" eval="True" />
8+
<field name="perm_unlink" eval="True" />
9+
</record>
10+
11+
<record id="field_template_account" model="dms.field.template">
12+
<field name="name">Account</field>
13+
<field name="storage_id" ref="dms.storage_demo" />
14+
<field name="model_id" ref="account.model_account_move" />
15+
<field name="user_field_id" ref="account.field_account_move__user_id" />
16+
<field name="group_ids" eval="[(4, ref('read_access_account_move_group'))]" />
17+
</record>
18+
</odoo>

Diff for: account_dms_field/models/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import account_move
2+
from . import dms_field_template

Diff for: account_dms_field/models/account_move.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from odoo import models
2+
3+
4+
class AccountMove(models.Model):
5+
_name = "account.move"
6+
_inherit = ["account.move", "dms.field.mixin"]

Diff for: account_dms_field/models/dms_field_template.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from odoo import models
2+
3+
4+
class DmsFieldTemplate(models.Model):
5+
_inherit = "dms.field.template"
6+
7+
def _prepare_directory_vals(self, directory, record):
8+
vals = super()._prepare_directory_vals(directory, record)
9+
if "/" not in vals["name"]:
10+
return vals
11+
vals["name"] = vals["name"].replace("/", "-")
12+
return vals

Diff for: account_dms_field/tests/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import test_account_dms_field

Diff for: account_dms_field/tests/test_account_dms_field.py

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
from odoo.addons.base.tests.common import TransactionCase
2+
3+
4+
class TestAccountDmsField(TransactionCase):
5+
def setUp(self):
6+
super(TestAccountDmsField, self).setUp()
7+
self.template = self.env.ref("account_dms_field.field_template_account")
8+
self.storage = self.template.storage_id
9+
self.access_group = self.template.group_ids
10+
self.account_model = self.env["account.move"]
11+
self.partner = self.env.ref("base.res_partner_12")
12+
self.test_directory = self.env["dms.directory"].create(
13+
{
14+
"name": "Test Directory",
15+
"parent_id": self.template.dms_directory_ids[0].id,
16+
"storage_id": self.template.storage_id.id,
17+
}
18+
)
19+
20+
def test_01_account_document_directory(self):
21+
account_move = self.account_model.create(
22+
{
23+
"partner_id": self.partner.id,
24+
}
25+
)
26+
account_move.invalidate_model()
27+
directory = account_move.dms_directory_ids
28+
# Assert that only one directory is created for the account move.
29+
self.assertEqual(len(directory), 1, "Directory length must be 1.")
30+
# Assert that the storage associated with the directory is the same as the
31+
# template's storage.
32+
self.assertEqual(
33+
directory.storage_id,
34+
self.storage,
35+
"Account move directory storage is different from the template storage.",
36+
)
37+
# Assert that the custom access group is present in the directory's group
38+
# list.
39+
self.assertIn(
40+
self.access_group,
41+
directory.group_ids,
42+
"Account move directory groups are different from the template groups.",
43+
)
44+
# Map the names of child directories related to the account move directory.
45+
child_directory_names = directory.mapped("child_directory_ids.name")
46+
# Assert that a specific child directory, "Test Directory", exists.
47+
self.assertIn(
48+
"Test Directory",
49+
child_directory_names,
50+
"Test Directory is not in the child directory of the account move "
51+
"directory.",
52+
)

Diff for: account_dms_field/views/account_move_view.xml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<odoo>
3+
<record id="view_move_form_inherit_account_dms_field" model="ir.ui.view">
4+
<field name="name">view.move.form.inherit.account.dms.field</field>
5+
<field name="model">account.move</field>
6+
<field name="inherit_id" ref="account.view_move_form" />
7+
<field name="arch" type="xml">
8+
<xpath expr="//notebook" position="inside">
9+
<page
10+
name="documents"
11+
string="Documents"
12+
attrs="{'invisible': [('id', '=', False)]}"
13+
>
14+
<field name="dms_directory_ids" mode="dms_list" />
15+
</page>
16+
</xpath>
17+
</field>
18+
</record>
19+
</odoo>
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../account_dms_field

Diff for: setup/account_dms_field/setup.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import setuptools
2+
3+
setuptools.setup(
4+
setup_requires=['setuptools-odoo'],
5+
odoo_addon=True,
6+
)

0 commit comments

Comments
 (0)