Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[17.0][MIG] documents_purchase #830

Merged
merged 4 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions documents_purchase/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
=============================
Documents for Purchase Orders
=============================

.. |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 purchase orders attachments will
be available.

**Table of contents**

.. contents::
:local:

Usage
=====

* Go to Purchase > Orders > Requests for Quotation (or Purchase Orders)
* Create or open a record
* Upload a file as an attachment
* Go to Documents
* Select the Purchase folder
* Select the file uploaded previously. It is linked to the Purchase Order.

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 <ayamuta@opensourceintegrators.com>
* Maxime Chambreuil <mchambreuil@opensourceintegrators.com>
* Melody Fetterly <mfetterly@opensourceintegrators.com>

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_purchase/__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_purchase/__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 - Purchase",
"summary": "Documents for Purchase Orders",
"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", "purchase"],
"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_purchase/data/documents_facet.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<odoo noupdate="1">

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

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

<record id="documents_purchase_folder" model="documents.folder">
<field name="name">Purchase</field>
<field name="sequence">14</field>
</record>

</odoo>
9 changes: 9 additions & 0 deletions documents_purchase/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_purchase_facet" />
<field name="sequence">10</field>
</record>

</odoo>
7 changes: 7 additions & 0 deletions documents_purchase/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="purchase_folder" ref="documents_purchase_folder" />
</record>

</odoo>
5 changes: 5 additions & 0 deletions documents_purchase/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 purchase_order
from . import res_config_settings
20 changes: 20 additions & 0 deletions documents_purchase/models/purchase_order.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 PurchaseOrder(models.Model):
_name = "purchase.order"
_inherit = ["purchase.order", "documents.mixin"]

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

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

def _check_create_documents(self):
company = self.company_id or self.env.company
return company.documents_purchase_settings and super()._check_create_documents()
22 changes: 22 additions & 0 deletions documents_purchase/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_purchase_settings = fields.Boolean()
purchase_folder = fields.Many2one(
"documents.folder",
string="Purchase Workspace",
domain=_domain_company,
default=lambda self: self.env.ref(
"documents_purchase_folder", raise_if_not_found=False
),
)
purchase_tags = fields.Many2many("documents.tag", "purchase_tags_table")
31 changes: 31 additions & 0 deletions documents_purchase/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_purchase_settings = fields.Boolean(
related="company_id.documents_purchase_settings",
readonly=False,
string="Purchase",
)
purchase_folder = fields.Many2one(
"documents.folder",
related="company_id.purchase_folder",
readonly=False,
string="Purchase Default Workspace",
)
purchase_tags = fields.Many2many(
"documents.tag",
"purchase_tags_table",
related="company_id.purchase_tags",
readonly=False,
string="Purchase Tags",
)

@api.onchange("purchase_folder")
def on_purchase_folder_change(self):
if self.purchase_folder != self.purchase_tags.mapped("folder_id"):
self.purchase_tags = False
Binary file added documents_purchase/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_purchase/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.purchase</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 request for quotations and purchase orders"
>
<field name="documents_purchase_settings" />
<div
class="content-group"
invisible="not documents_purchase_settings"
>
<div class="row mt16">
<label
class="o_form_label col-lg-3"
for="purchase_folder"
string="Workspace"
/>
<field
name="purchase_folder"
required="documents_purchase_settings"
/>
</div>
<div class="row">
<label
class="o_form_label col-lg-3"
for="purchase_tags"
string="Default Tags"
/>
<field
name="purchase_tags"
widget="many2many_tags"
domain="[('folder_id','=', purchase_folder)]"
/>
</div>
</div>
</setting>
</block>
</xpath>
</field>
</record>

</odoo>
Loading