Skip to content

Commit

Permalink
add sale dms field
Browse files Browse the repository at this point in the history
  • Loading branch information
agent-z28 committed Oct 16, 2024
1 parent 554890a commit ea9c0fd
Show file tree
Hide file tree
Showing 11 changed files with 222 additions and 0 deletions.
103 changes: 103 additions & 0 deletions sale_dms_field/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
=======================
Add dms field for sales
=======================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:b7f18580a215d7c509b59f1e27607ad97ff06df4cc445bd45e838ead8c9e5164
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fdms-lightgray.png?logo=github
:target: https://github.com/OCA/dms/tree/16.0/hr_dms_field
:alt: OCA/dms
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/dms-16-0/dms-16-0-hr_dms_field
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/dms&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

Add the Documents tab with the files in the sales's form view.

**Table of contents**

.. contents::
:local:

Configuration
=============

#. *Go to Documents > Configuration > File templates* and create a new record.
#. Set a storage, a model (sales) and the access groups you want.
#. Click on the "Documents" tab icon and a folder hierarchy will be created.
#. 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).

Usage
=====

#. Go to the form view of an existing sales and click on the "Documents" tab icon, a hierarchy of
folders and files linked to that record will be created.
#. Create a new sales. A hierarchy of folders and files linked to that record will be created.


Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/dms/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/dms/issues/new?body=module:%20hr_dms_field%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.

Credits
=======

Authors
~~~~~~~

* Tecnativa

Contributors
~~~~~~~~~~~~

* `Tecnativa <https://www.tecnativa.com>`_:

* Víctor Martínez
* Pedro M. Baeza

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

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.

.. |maintainer-victoralmau| image:: https://github.com/victoralmau.png?size=40px
:target: https://github.com/victoralmau
:alt: victoralmau

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-victoralmau|

This module is part of the `OCA/dms <https://github.com/OCA/dms/tree/16.0/hr_dms_field>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions sale_dms_field/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
12 changes: 12 additions & 0 deletions sale_dms_field/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "Add dms field for sale",
"version": "16.0.1.0.0",
"category": "Sales/Sales",
"website": "https://github.com/OCA/dms",
"author": "Agent ERP GmbH,Odoo Community Association (OCA)",
"depends": ["sale_management", "dms_field"],
"data": ["views/sale_order_view.xml"],
"demo": ["demo/sale_dms_data.xml"],
"installable": True,
"license": "LGPL-3",
}
21 changes: 21 additions & 0 deletions sale_dms_field/demo/sale_dms_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="read_access_sale_order_group" model="dms.access.group">
<field name="name">Everyone for Sale DMS</field>
<field
name="group_ids"
eval="[(4, ref('sales_team.group_sale_salesman_all_leads'))]"
/>
<field name="perm_create" eval="True" />
<field name="perm_write" eval="True" />
<field name="perm_unlink" eval="True" />
</record>

<record id="field_template_sale" model="dms.field.template">
<field name="name">Sale</field>
<field name="storage_id" ref="dms.storage_demo" />
<field name="model_id" ref="sale.model_sale_order" />
<field name="user_field_id" ref="sale.field_sale_order__user_id" />
<field name="group_ids" eval="[(4, ref('read_access_sale_order_group'))]" />
</record>
</odoo>
1 change: 1 addition & 0 deletions sale_dms_field/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import sale_order
6 changes: 6 additions & 0 deletions sale_dms_field/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from odoo import models


class SaleOrder(models.Model):
_name = "sale.order"
_inherit = ["sale.order", "dms.field.mixin"]
1 change: 1 addition & 0 deletions sale_dms_field/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_sale_dms_field
51 changes: 51 additions & 0 deletions sale_dms_field/tests/test_sale_dms_field.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from odoo.addons.base.tests.common import TransactionCase


class TestSaleDmsField(TransactionCase):
def setUp(self):
super(TestSaleDmsField, self).setUp()
self.template = self.env.ref("sale_dms_field.field_template_sale")
self.storage = self.template.storage_id
self.access_group = self.template.group_ids
self.sale_model = self.env["sale.order"]
self.partner = self.env.ref("base.res_partner_12")
self.test_directory = self.env["dms.directory"].create(
{
"name": "Test Directory",
"parent_id": self.template.dms_directory_ids[0].id,
"storage_id": self.template.storage_id.id,
}
)

def test_01_sale_document_directory(self):
sale_order = self.sale_model.create(
{
"partner_id": self.partner.id,
}
)
sale_order.invalidate_model()
directory = sale_order.dms_directory_ids
# Assert that only one directory is created for the sale order.
self.assertEqual(len(directory), 1, "Directory length must be 1.")
# Assert that the storage associated with the directory is the same as the
# template's storage.
self.assertEqual(
directory.storage_id,
self.storage,
"Sale order directory storage is different from the template storage.",
)
# Assert that the custom access group is present in the directory's group
# list.
self.assertIn(
self.access_group,
directory.group_ids,
"Sale order directory groups are different from the template groups.",
)
# Map the names of child directories related to the sale order directory.
child_directory_names = directory.mapped("child_directory_ids.name")
# Assert that a specific child directory, "Test Directory", exists.
self.assertIn(
"Test Directory",
child_directory_names,
"Test Directory is not in the child directory of the sale order directory.",
)
19 changes: 19 additions & 0 deletions sale_dms_field/views/sale_order_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="view_order_form_inherit_sale_dms_field" model="ir.ui.view">
<field name="name">view.order.form.inherit.sale.dms.field</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form" />
<field name="arch" type="xml">
<xpath expr="//notebook" position="inside">
<page
name="documents"
string="Documents"
attrs="{'invisible': [('id', '=', False)]}"
>
<field name="dms_directory_ids" mode="dms_list" />
</page>
</xpath>
</field>
</record>
</odoo>
1 change: 1 addition & 0 deletions setup/sale_dms_field/odoo/addons/sale_dms_field
6 changes: 6 additions & 0 deletions setup/sale_dms_field/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit ea9c0fd

Please sign in to comment.