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_stock_lot #832

Merged
merged 6 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
86 changes: 86 additions & 0 deletions documents_stock_lot/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
==================================
Documents for Lot/Tracking Numbers
==================================

.. |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-ursais%2Fosi--addons-lightgray.png?logo=github
:target: https://github.com/ursais/osi-addons/tree/17.0/documents_stock_lot
:alt: ursais/osi-addons

|badge1| |badge2| |badge3|

This module allows you to create a document when attaching a file to a lot/tracking
number. It also allows you to upload a document and attach it to an existing lot.

**Table of contents**

.. contents::
:local:

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

#. Go to Documents
#. Activate the lot/tracking number
#. Configure the folder and the tags

Usage
=====

To use this module, you need to:

#. Go to Inventory > Products > Lot/Tracking Numbers
#. Create or select a lot/tracking number
#. Add an attachment
#. Go to Documents
#. Select the Lot/Tracking Numbers folder
#. Select the file uploaded previously. It is linked to the lot/tracking number.

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

Bugs are tracked on `GitHub Issues <https://github.com/ursais/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/ursais/osi-addons/issues/new?body=module:%20documents_stock_lot%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Credits
=======

Authors
~~~~~~~

* Open Source Integrators

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

* Vimal Patel <[email protected]>

Other credits
~~~~~~~~~~~~~

The development of this module has been financially supported by:

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

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

This module is maintained by Open Source Integrators.

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

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

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

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions documents_stock_lot/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright (C) 2021 Open Source Integrators
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
from . import wizards
from . import models
23 changes: 23 additions & 0 deletions documents_stock_lot/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright (C) 2021 Open Source Integrators
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
{
"name": "Documents for lot/tracking number",
"version": "17.0.1.0.0",
"category": "Documents",
"summary": """Manage documents attached to lot/tracking numbers""",
"website": "https://github.com/ursais/osi-addons",
"author": "Open Source Integrators",
"license": "LGPL-3",
"depends": ["documents", "stock"],
"data": [
"security/ir.model.access.csv",
"data/documents_folder.xml",
"data/documents_facet.xml",
"data/documents_tag.xml",
"data/documents_workflow_rule.xml",
"data/res_company.xml",
"views/res_config_settings.xml",
"wizards/select_lot_view.xml",
],
"maintainers": ["bodedra"],
}
9 changes: 9 additions & 0 deletions documents_stock_lot/data/documents_facet.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<odoo noupdate="1">

<record id="documents_facet_lot" model="documents.facet" forcecreate="0">
<field name="name">Lot</field>
<field name="sequence">6</field>
<field name="folder_id" ref="documents_folder_lot" />
</record>

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

<record id="documents_folder_lot" model="documents.folder" forcecreate="0">
<field name="name">Lot/Tracking Numbers</field>
<field name="group_ids" eval="[(4, ref('base.group_user'))]" />
<field name="read_group_ids" eval="[(4, ref('base.group_user'))]" />
<field name="user_specific">True</field>
<field name="sequence">12</field>
</record>

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

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

<record
id="documents_workflow_rule_lot"
model="documents.workflow.rule"
forcecreate="0"
>
<field name="name">Attach to Lot/Tracking Number</field>
<field name="domain_folder_id" ref="documents_folder_lot" />
<field name="condition_type">criteria</field>
<field name="create_model">stock.lot</field>
</record>

</odoo>
7 changes: 7 additions & 0 deletions documents_stock_lot/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="lot_folder" ref="documents_folder_lot" />
</record>

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


class DocumentsWorkflowRule(models.Model):
_inherit = ["documents.workflow.rule"]

def _compute_business(self):
return self._get_business()

has_business_option = fields.Boolean(default=True, compute="_compute_business")
create_model = fields.Selection(
selection_add=[("stock.lot", "Lot/Tracking Number")]
)

def create_record(self, documents=None):
res = super().create_record(documents=documents)
if self.create_model == "stock.lot":
ctx = self._context.copy()
ctx.update({"documents": documents.ids})
view_id = self.env.ref("documents_stock_lot.select_lot_view_form").id
return {
"type": "ir.actions.act_window",
"res_model": "select.lot",
"name": "Lot/Tracking Number",
"context": ctx,
"view_mode": "form",
"target": "new",
"views": [(view_id, "form")],
"view_id": view_id,
}
return res
25 changes: 25 additions & 0 deletions documents_stock_lot/models/res_company.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# 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_lot_settings = fields.Boolean()
lot_folder = fields.Many2one(
"documents.folder",
string="Lot/Tracking Number Workspace",
domain=_domain_company,
default=lambda self: self.env.ref(
"documents_stock_lot.documents_folder_lot",
raise_if_not_found=False,
),
)
document_lot_tags = fields.Many2many(
"documents.tag", "document_lot_tags", string="Lot/Tracking Number Tags"
)
31 changes: 31 additions & 0 deletions documents_stock_lot/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_lot_settings = fields.Boolean(
related="company_id.documents_lot_settings",
readonly=False,
string="Lot",
)
lot_folder = fields.Many2one(
"documents.folder",
related="company_id.lot_folder",
readonly=False,
string="Lot Default Workspace",
)
lot_tags = fields.Many2many(
"documents.tag",
"document_lot_tag",
related="company_id.document_lot_tags",
readonly=False,
string="Lot Tags",
)

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


class StockLot(models.Model):
_name = "stock.lot"
_inherit = ["stock.lot", "documents.mixin"]

def _get_document_folder(self):
return self.company_id.lot_folder

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

def _check_create_documents(self):
company = self.company_id or self.env.company
return company.documents_lot_settings and super()._check_create_documents()
2 changes: 2 additions & 0 deletions documents_stock_lot/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_select_lot,access_select_lot,model_select_lot,base.group_user,1,1,1,1
Binary file added documents_stock_lot/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_stock_lot/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_documents_lot_view_form" model="ir.ui.view">
<field name="name">res.config.settings.view.form.documents.lot</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 lot/tracking numbers"
>
<field name="documents_lot_settings" />
<div
class="content-group"
invisible="not documents_lot_settings"
>
<div class="row mt16">
<label
class="o_form_label col-lg-3"
for="lot_folder"
string="Workspace"
/>
<field
name="lot_folder"
required="documents_lot_settings"
/>
</div>
<div class="row">
<label
class="o_form_label col-lg-3"
for="lot_tags"
string="Default Tags"
/>
<field
name="lot_tags"
widget="many2many_tags"
domain="[('folder_id','=', lot_folder)]"
/>
</div>
</div>
</setting>
</block>
</xpath>
</field>
</record>

</odoo>
4 changes: 4 additions & 0 deletions documents_stock_lot/wizards/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright (C) 2021 Open Source Integrators
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from . import select_lot
Loading
Loading