Skip to content

Commit

Permalink
[17.0][MIG] documents_partner (#833)
Browse files Browse the repository at this point in the history
  • Loading branch information
santiagordz authored Aug 30, 2024
1 parent e601426 commit e827e6f
Show file tree
Hide file tree
Showing 13 changed files with 273 additions and 0 deletions.
84 changes: 84 additions & 0 deletions documents_partner/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
=====================
Documents for Vendors
=====================

.. |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-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fosi--addons-lightgray.png?logo=github
:target: https://github.com/OCA/osi-addons/tree/14.0/osi_custom_profit_loss
:alt: OCA/osi-addons

|badge1| |badge2| |badge3|

This module provides a documents folder where all the files attached to partners will
be available.

**Table of contents**

.. contents::
:local:

Usage
=====

* Go to Purchase > Orders > Vendors
* Create or open a record
* Upload a file as an attachment
* Go to Documents
* Select the Vendors folder
* Select the file uploaded previously. It is linked to the vendor.

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/osi-addons/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/osi-addons/issues/new?body=module:%20osi_custom_profit_loss%0Aversion:%2014.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
~~~~~~~

* Open Source Integrators

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

* `Open Source Integrators <https://www.opensourceintegrators.com>`__:

* Antonio Yamuta <[email protected]>
* Maxime Chambreuil <[email protected]>
* Melody Fetterly <[email protected]>

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

This module is maintained by Open Source Integrators.

.. image:: https://github.com/ursais.png
:alt: Open Source Integrators
:target: https://www.opensourceintegrators.com

Open Source Integrators™ (OSI) provides customers a unique combination of
open source business process consulting and implementations.

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

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

|maintainer-max3903|

This module is part of the `OSI Addons <https://github.com/ursais/osi-addons>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions documents_partner/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright (C) 2021 Open Source Integrators
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
from . import models
22 changes: 22 additions & 0 deletions documents_partner/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright (C) 2021 Open Source Integrators
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
{
"name": "Documents for Partners",
"summary": "Manage documents attached to partners",
"category": "Productivity/Documents",
"website": "https://github.com/ursais/osi-addons",
"author": "Open Source Integrators",
"maintainer": "Open Source Integrators",
"version": "17.0.1.0.0",
"license": "LGPL-3",
"depends": ["documents", "contacts"],
"data": [
"data/documents_folder.xml",
"data/res_company.xml",
"data/documents_facet.xml",
"data/documents_tag.xml",
"views/res_config_settings.xml",
],
"development_status": "Beta",
"maintainers": ["max3903"],
}
9 changes: 9 additions & 0 deletions documents_partner/data/documents_facet.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<odoo noupdate="1">

<record id="documents_partner_facet" model="documents.facet">
<field name="name">Documents</field>
<field name="sequence">5</field>
<field name="folder_id" ref="documents_partner_folder" />
</record>

</odoo>
8 changes: 8 additions & 0 deletions documents_partner/data/documents_folder.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<odoo noupdate="1">

<record id="documents_partner_folder" model="documents.folder">
<field name="name">Partners</field>
<field name="sequence">14</field>
</record>

</odoo>
9 changes: 9 additions & 0 deletions documents_partner/data/documents_tag.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<odoo noupdate="1">

<record id="documents_tag_new" model="documents.tag">
<field name="name">New</field>
<field name="facet_id" ref="documents_partner_facet" />
<field name="sequence">10</field>
</record>

</odoo>
7 changes: 7 additions & 0 deletions documents_partner/data/res_company.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<odoo noupdate="1">

<record id="base.main_company" model="res.company">
<field name="partner_folder" ref="documents_partner_folder" />
</record>

</odoo>
5 changes: 5 additions & 0 deletions documents_partner/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright (C) 2021 Open Source Integrators
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
from . import res_company
from . import res_partner
from . import res_config_settings
22 changes: 22 additions & 0 deletions documents_partner/models/res_company.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright (C) 2021 Open Source Integrators
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
from odoo import fields, models


class ResCompany(models.Model):
_inherit = "res.company"

def _domain_company(self):
company = self.env.company
return ["|", ("company_id", "=", False), ("company_id", "=", company)]

documents_partner_settings = fields.Boolean()
partner_folder = fields.Many2one(
"documents.folder",
string="Partner Workspace",
domain=_domain_company,
default=lambda self: self.env.ref(
"documents_partner_folder", raise_if_not_found=False
),
)
partner_tags = fields.Many2many("documents.tag", "partner_tags_table")
31 changes: 31 additions & 0 deletions documents_partner/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright (C) 2021 Open Source Integrators
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
from odoo import api, fields, models


class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"

documents_partner_settings = fields.Boolean(
related="company_id.documents_partner_settings",
readonly=False,
string="Partners",
)
partner_folder = fields.Many2one(
"documents.folder",
related="company_id.partner_folder",
readonly=False,
string="Partners Default Workspace",
)
partner_tags = fields.Many2many(
"documents.tag",
"partner_tags_table",
related="company_id.partner_tags",
readonly=False,
string="Partners Tags",
)

@api.onchange("partner_folder")
def on_partner_folder_change(self):
if self.partner_folder != self.partner_tags.mapped("folder_id"):
self.partner_tags = False
20 changes: 20 additions & 0 deletions documents_partner/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (C) 2021 Open Source Integrators
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
from odoo import models


class ResPartner(models.Model):
_name = "res.partner"
_inherit = ["res.partner", "documents.mixin"]

def _get_document_tags(self):
company = self.company_id or self.env.company
return company.partner_tags

def _get_document_folder(self):
company = self.company_id or self.env.company
return company.partner_folder

def _check_create_documents(self):
company = self.company_id or self.env.company
return company.documents_partner_settings and super()._check_create_documents()
Binary file added documents_partner/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions documents_partner/views/res_config_settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<odoo>

<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">res.config.settings.documents.partner</field>
<field name="model">res.config.settings</field>
<field name="priority" eval="70" />
<field name="inherit_id" ref="base.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//app[@name='documents']" position="attributes">
<attribute name="notApp">0</attribute>
</xpath>
<xpath expr="//app[@name='documents']" position="inside">
<block>
<setting
company_dependent="1"
help="Centralize files attached to partners"
>
<field name="documents_partner_settings" />
<div
class="content-group"
invisible="not documents_partner_settings"
>
<div class="row mt16">
<label
class="o_form_label col-lg-3"
for="partner_folder"
string="Workspace"
/>
<field
name="partner_folder"
required="documents_partner_settings"
/>
</div>
<div class="row">
<label
class="o_form_label col-lg-3"
for="partner_tags"
string="Default Tags"
/>
<field
name="partner_tags"
widget="many2many_tags"
domain="[('folder_id','=', partner_folder)]"
/>
</div>
</div>
</setting>
</block>
</xpath>
</field>
</record>

</odoo>

0 comments on commit e827e6f

Please sign in to comment.