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

[14.0][MIG] maintenance_stock: Migration to 14.0 #347

Open
wants to merge 14 commits into
base: 14.0
Choose a base branch
from
Open
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
122 changes: 122 additions & 0 deletions maintenance_stock/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
=================
Maintenance Stock
=================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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%2Fmaintenance-lightgray.png?logo=github
:target: https://github.com/OCA/maintenance/tree/12.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-12-0/maintenance-12-0-maintenance_stock
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/240/12.0
:alt: Try me on Runbot

|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:

.. figure:: https://raw.githubusercontent.com/OCA/maintenance/12.0/maintenance_stock/static/description/equipment.png
:alt: Kanban view
:width: 600 px

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:

.. figure:: https://raw.githubusercontent.com/OCA/maintenance/12.0/maintenance_stock/static/description/request-1.png
:alt: Kanban view
:width: 600 px

.. figure:: https://raw.githubusercontent.com/OCA/maintenance/12.0/maintenance_stock/static/description/pick-1.png
:alt: Kanban view
:width: 600 px

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:

.. figure:: https://raw.githubusercontent.com/OCA/maintenance/12.0/maintenance_stock/static/description/move-line.png
:alt: Kanban view
:width: 600 px

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:

.. figure:: https://raw.githubusercontent.com/OCA/maintenance/12.0/maintenance_stock/static/description/pick-2.png
:alt: Kanban view
:width: 600 px

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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/maintenance/issues/new?body=module:%20maintenance_stock%0Aversion:%2012.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/12.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": "14.0.1.0.0",
"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,
}
150 changes: 150 additions & 0 deletions maintenance_stock/data/demo_maintenance_stock.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
<?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">product</field>
<field name="categ_id" ref="product.product_category_5" />
<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="uom_po_id" ref="uom.product_uom_unit" />
<field
name="image_1920"
type="base64"
file="maintenance_stock/static/img/toner.png"
/>

</record>

<record id="stock_inventory_toner" model="stock.inventory">
<field name="name">Inventory for Toner</field>
<field
name="product_ids"
eval="[(6,0,[ref('maintenance_stock.product_toner'),])]"
/>

</record>

<record id="stock_inventory_toner_line" model="stock.inventory.line">
<field name="product_id" ref="maintenance_stock.product_toner" />
<field name="product_uom_id" ref="uom.product_uom_unit" />
<field name="inventory_id" ref="maintenance_stock.stock_inventory_toner" />
<field name="product_qty">50.0</field>
<field name="location_id" ref="maintenance_stock.main_location_stock" />
</record>
<function name="action_start" model="stock.inventory">
<function
eval="[[('id', '=', ref('maintenance_stock.stock_inventory_toner'))]]"
model="stock.inventory"
name="search"
/>
</function>
<function model="stock.inventory" name="action_validate">
<function
eval="[[('state','in', ['draft', 'confirm']),('id', '=', ref('maintenance_stock.stock_inventory_toner'))]]"
model="stock.inventory"
name="search"
/>
</function>

<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="location_id" ref="maintenance_stock.main_location_stock" />
<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="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_lines"
model="stock.move"
eval="[(0, 0, {
'name': obj().env.ref('maintenance_stock.product_toner').name,
'product_id': ref('maintenance_stock.product_toner'),
'product_uom': ref('uom.product_uom_unit'),
'product_uom_qty': 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>
24 changes: 24 additions & 0 deletions maintenance_stock/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# © 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

from odoo import SUPERUSER_ID, api


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

env = api.Environment(cr, SUPERUSER_ID, {})
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