Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
126 changes: 126 additions & 0 deletions maintenance_stock/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

=================
Maintenance Stock
=================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:be98361e9be2cfee606016d2449925fd179417e40416fd66883992fd29a13255
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/license-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%2Fmaintenance-lightgray.png?logo=github
:target: https://github.com/OCA/maintenance/tree/19.0/maintenance_stock
:alt: OCA/maintenance
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/maintenance-19-0/maintenance-19-0-maintenance_stock
: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/maintenance&target_branch=19.0
:alt: Try me on Runboat

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

This module extends the functionality of Odoo Maintenance module by
allowing link stock consumptions to maintenance requests.

**Table of contents**

.. contents::
:local:

Usage
=====

Once installed, first you should enable consumptions for a certain
equipment and filling a default warehouse for the picking operations:

|image1|

Then, for every mainteance request of this equipment, *Picking List*
button allows us to make consumptions, that will be picking documents
with their own sequence:

|image2|

|image3|

By default, the origin location for this operations will be the stock
location for the default warehouse, and destination a new *Consumptions*
location, that will not compute for stock inventory, like e.g. partner
locations:

|image4|

From both request and equipment forms these stock operations and
*Product Moves* are available.

Return operations are also enabled, and will be linked to the request
and equipment as well:

|image5|

.. |image1| image:: https://raw.githubusercontent.com/OCA/maintenance/19.0/maintenance_stock/static/description/equipment.png
.. |image2| image:: https://raw.githubusercontent.com/OCA/maintenance/19.0/maintenance_stock/static/description/request-1.png
.. |image3| image:: https://raw.githubusercontent.com/OCA/maintenance/19.0/maintenance_stock/static/description/pick-1.png
.. |image4| image:: https://raw.githubusercontent.com/OCA/maintenance/19.0/maintenance_stock/static/description/move-line.png
.. |image5| image:: https://raw.githubusercontent.com/OCA/maintenance/19.0/maintenance_stock/static/description/pick-2.png

Known issues / Roadmap
======================

- Product standard list. Enable defining product standard lists (at
least, product and quantity per line), and link them with equipments.
Then, every maintenance request could select one of them and
automatically fill the product and quantity list.

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

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

* Solvos

Contributors
------------

- David Alonso <david.alonso@solvos.es>

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.

This module is part of the `OCA/maintenance <https://github.com/OCA/maintenance/tree/19.0/maintenance_stock>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions maintenance_stock/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from .hooks import post_init_hook
27 changes: 27 additions & 0 deletions maintenance_stock/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# © 2020 Solvos Consultoría Informática (<http://www.solvos.es>)
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
{
"name": "Maintenance Stock",
"summary": "Links maintenance requests to stock",
"author": "Odoo Community Association (OCA), Solvos",
"license": "AGPL-3",
"version": "19.0.1.0.1",
"category": "Warehouse",
"website": "https://github.com/OCA/maintenance",
"depends": [
"base_maintenance",
"stock",
],
"data": [
"views/maintenance_equipment_views.xml",
"views/maintenance_request_views.xml",
"views/stock_move_views.xml",
"views/stock_move_line_views.xml",
"views/stock_picking_views.xml",
],
"demo": [
"data/demo_maintenance_stock.xml",
],
"post_init_hook": "post_init_hook",
"installable": True,
}
114 changes: 114 additions & 0 deletions maintenance_stock/data/demo_maintenance_stock.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">
<record id="location_inventory" model="stock.location">
<field name="name">Inventory adjustment</field>
<field name="usage">inventory</field>
</record>
<record id="stock_warehouse_maintenance" model="stock.warehouse">
<field name="name">Maintenance Warehouse</field>
<field name="partner_id" ref="stock.res_partner_address_41" />
<field name="code">Main</field>
<field name="reception_steps">one_step</field>
<field name="delivery_steps">ship_only</field>
</record>

<function model="ir.model.data" name="_update_xmlids">
<value
model="base"
eval="[{
'xml_id': 'maintenance_stock.main_picking_type_cons',
'record': obj().env.ref('maintenance_stock.stock_warehouse_maintenance').cons_type_id,
'noupdate': True,
}, {
'xml_id': 'maintenance_stock.main_location_stock',
'record': obj().env.ref('maintenance_stock.stock_warehouse_maintenance').lot_stock_id,
'noupdate': True,
}, {
'xml_id': 'maintenance_stock.main_location_cons',
'record': obj().env.ref('maintenance_stock.stock_warehouse_maintenance').wh_cons_loc_id,
'noupdate': True,
}]"
/>
</function>

<record id="product_toner" model="product.product">
<field name="default_code">TON_1234</field>
<field name="name">Toner</field>
<field name="type">consu</field>
<field name="is_storable" eval="True" />
<field name="categ_id" ref="product.product_category_goods" />
<field name="lst_price">100.0</field>
<field name="standard_price">70.0</field>
<field name="uom_id" ref="uom.product_uom_unit" />
<field
name="image_1920"
type="base64"
file="maintenance_stock/static/img/toner.png"
/>
</record>

<record id="maintenance.equipment_printer1" model="maintenance.equipment">
<field name="allow_consumptions" eval="True" />
<field
name="default_consumption_warehouse_id"
ref="maintenance_stock.stock_warehouse_maintenance"
/>
</record>

<record id="m_request_1" model="maintenance.request">
<field name="name">Change toner</field>
<field name="user_id" ref="base.user_demo" />
<field name="owner_user_id" ref="base.user_admin" />
<field name="equipment_id" ref="maintenance.equipment_printer1" />
<field name="color">7</field>
<field name="stage_id" ref="maintenance.stage_1" />
</record>
<record model="stock.quant" id="stock_quant_toner">
<field name="product_id" ref="maintenance_stock.product_toner" />
<field name="quantity">1.0</field>
</record>
<record id="consuption_picking_m_request_1" model="stock.picking">
<field name="picking_type_id" ref="maintenance_stock.main_picking_type_cons" />
<field name="scheduled_date" eval="DateTime.today() - timedelta(days=15)" />
<field name="location_id" ref="maintenance_stock.main_location_stock" />
<field name="location_dest_id" ref="maintenance_stock.main_location_cons" />
<field name="maintenance_request_id" ref="maintenance_stock.m_request_1" />

<field
name="move_ids"
model="stock.move"
eval="[(0, 0, {
'product_id': ref('maintenance_stock.product_toner'),
'product_uom': ref('uom.product_uom_unit'),
'product_uom_qty': 1.0,
'quantity': 1.0,
'picking_type_id': ref('maintenance_stock.main_picking_type_cons'),
'location_id': ref('maintenance_stock.main_location_stock'),
'location_dest_id': ref('maintenance_stock.main_location_cons'),

})]"
/>
</record>

<function model="stock.picking" name="action_confirm">
<value
model="stock.picking"
eval="[
obj().env.ref('maintenance_stock.consuption_picking_m_request_1').id]"
/>
</function>
<function model="stock.picking" name="action_assign">
<value
model="stock.picking"
eval="[
obj().env.ref('maintenance_stock.consuption_picking_m_request_1').id]"
/>
</function>
<function model="stock.picking" name="button_validate">
<value
model="stock.picking"
eval="[
obj().env.ref('maintenance_stock.consuption_picking_m_request_1').id]"
/>
</function>
</odoo>
21 changes: 21 additions & 0 deletions maintenance_stock/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# © 2020 Solvos Consultoría Informática (<http://www.solvos.es>)
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

import logging


def post_init_hook(env):
logging.getLogger("odoo.addons.maintenance_stock").info(
"Adding pending locations, sequences and pìcking types to current warehouses"
)

PickingType = env["stock.picking.type"]
for warehouse in env["stock.warehouse"].search([]):
warehouse._create_missing_locations(vals={})
new_vals = warehouse._create_or_update_sequences_and_picking_types()
warehouse.write(new_vals)
# return picking type workaround for existing warehouses
if "cons_type_id" in new_vals:
PickingType.browse(new_vals["cons_type_id"]).write(
{"return_picking_type_id": warehouse.in_type_id.id}
)
Loading
Loading