[ADD] stock_request_picking_type (#590)

This commit is contained in:
Maxime Chambreuil
2019-05-10 18:18:58 -05:00
committed by ps-tubtim
parent f0a9dfd9ed
commit 5b19f3ca15
13 changed files with 303 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
**This file is going to be generated by oca-gen-addon-readme.**
*Manual changes will be overwritten.*
Please provide content in the ``readme`` directory:
* **DESCRIPTION.rst** (required)
* INSTALL.rst (optional)
* CONFIGURE.rst (optional)
* **USAGE.rst** (optional, highly recommended)
* DEVELOP.rst (optional)
* ROADMAP.rst (optional)
* HISTORY.rst (optional, recommended)
* **CONTRIBUTORS.rst** (optional, highly recommended)
* CREDITS.rst (optional)
Content of this README will also be drawn from the addon manifest,
from keys such as name, authors, maintainers, development_status,
and license.
A good, one sentence summary in the manifest is also highly recommended.

View File

@@ -0,0 +1,4 @@
# Copyright 2019 Open Source Integrators
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from . import models

View File

@@ -0,0 +1,23 @@
# Copyright 2019 Open Source Integrators
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
{
'name': 'Stock Request Picking Type',
'summary': 'Add Stock Requests to the Inventory App',
'version': '12.0.1.0.0',
'license': 'LGPL-3',
'website': 'https://github.com/stock-logistics-warehouse',
'author': 'Open Source Integrators, '
'Odoo Community Association (OCA)',
'category': 'Warehouse Management',
'depends': [
'stock_request',
],
'data': [
'data/stock_picking_type.xml',
'views/stock_request_views.xml',
'views/stock_picking_views.xml',
],
'development_status': 'Beta',
'maintainers': ['max3903']
}

View File

@@ -0,0 +1,11 @@
<?xml version="1.0"?>
<odoo noupdate="1">
<record id="stock_request" model="stock.picking.type">
<field name="name">Stock Requests</field>
<field name="sequence_id" ref="stock_request.seq_stock_request"/>
<field name="code">stock_request</field>
<field name="sequence">0</field>
</record>
</odoo>

View File

@@ -0,0 +1,5 @@
# Copyright 2019 Open Source Integrators
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from . import stock_request
from . import stock_picking_type

View File

@@ -0,0 +1,43 @@
# Copyright 2019 Open Source Integrators
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import fields, models
class StockPickingType(models.Model):
_inherit = 'stock.picking.type'
code = fields.Selection(selection_add=[('stock_request',
'Stock Request')])
count_sr_todo = fields.Integer(string="To Do",
compute='_compute_sr_count')
count_sr_open = fields.Integer(string="In Progress",
compute='_compute_sr_count')
count_sr_late = fields.Integer(string="Late",
compute='_compute_sr_count')
def _compute_sr_count(self):
types = self.filtered(lambda picking: picking.code == 'stock_request')
if not types:
return
domains = {
'count_sr_todo': [('state', '=', 'draft')],
'count_sr_open': [('state', '=', 'open')],
'count_sr_late': [('expected_date', '<', fields.Date.today()),
('state', 'in', ('draft', 'open'))],
}
for field in domains:
data = self.env['stock.request'].read_group(
domains[field] +
[('state', 'not in', ('done', 'cancel')),
('picking_type_id', 'in', self.ids)],
['picking_type_id'], ['picking_type_id'])
count = {x['picking_type_id'] and
x['picking_type_id'][0]: x['picking_type_id_count']
for x in data}
for record in types:
record[field] = count.get(record.id, 0)
def get_stock_request_picking_type_action(self):
return self._get_action(
'stock_request_picking_type.action_picking_dashboard')

View File

@@ -0,0 +1,21 @@
# Copyright 2019 Open Source Integrators
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import api, fields, models
class StockRequest(models.Model):
_inherit = 'stock.request'
@api.model
def _get_default_picking_type(self):
return self.env['stock.picking.type'].search([
('code', '=', 'stock_request'),
('warehouse_id.company_id', 'in',
[self.env.context.get('company_id', self.env.user.company_id.id),
False])],
limit=1).id
picking_type_id = fields.Many2one(
'stock.picking.type', 'Operation Type',
default=_get_default_picking_type, required=True)

View File

@@ -0,0 +1 @@
* Maxime Chambreuil <mchambreuil@opensourceintegrators.com>

View File

@@ -0,0 +1 @@
This module adds stock requests within the Inventory app with a new operation type.

View File

@@ -0,0 +1,3 @@
* Go to Inventory
* Click on the Stock Requests tile to process stock requests
* You can also go to Inventory > Operations > Stock Requests

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

View File

@@ -0,0 +1,117 @@
<?xml version="1.0" ?>
<odoo>
<record id="stock_request_type_kanban" model="ir.ui.view">
<field name="name">stock.picking.type.kanban</field>
<field name="model">stock.picking.type</field>
<field name="inherit_id" ref="stock.stock_picking_type_kanban"/>
<field name="arch" type="xml">
<field name="code" position="after">
<field name="count_sr_todo"/>
<field name="count_sr_open"/>
<field name="count_sr_late"/>
</field>
<xpath expr='//div[@name="stock_picking"]' position="after">
<div t-if="record.code.raw_value == 'stock_request'" t-attf-class="#{kanban_color(record.color.raw_value)}">
<div>
<div t-attf-class="o_kanban_card_header">
<div class="o_kanban_card_header_title">
<a type="object" name="get_stock_request_picking_type_action" class="o_primary">
<field name="name"/>
</a>
<div class="o_secondary"><field class="o_secondary" name="warehouse_id"/></div>
</div>
<div class="o_kanban_manage_button_section">
<a class="o_kanban_manage_toggle_button" href="#"><i class="fa fa-ellipsis-v" role="img" aria-label="Manage" title="Manage"/></a>
</div>
</div>
<div class="container o_kanban_card_content">
<div class="row">
<div class="col-6 o_kanban_primary_left">
<button class="btn btn-primary" name="%(action_picking_dashboard)d" type="action" context="{'search_default_todo': 1}">
<span t-if="record.code.raw_value =='stock_request'"><t t-esc="record.count_sr_todo.value"/> To Process</span>
</button>
</div>
<div class="col-6 o_kanban_primary_right">
<div t-if="record.count_sr_open.raw_value > 0" class="row">
<div class="col-9">
<a name="%(action_picking_dashboard)d" type="action" context="{'search_default_inprogress': 1}">
In Progress
</a>
</div>
<div class="col-3">
<field name="count_sr_open"/>
</div>
</div>
<div t-if="record.count_sr_late.raw_value > 0" class="row">
<div class="col-9">
<a class="oe_kanban_stock_picking_type_list" name="%(action_picking_dashboard)d" type="action" context="{'search_default_late': 1}">
Late
</a>
</div>
<div class="col-3">
<field name="count_sr_late"/>
</div>
</div>
</div>
</div>
</div><div class="container o_kanban_card_manage_pane dropdown-menu" role="menu">
<div class="row">
<div class="col-6 o_kanban_card_manage_section o_kanban_manage_view" name="picking_left_manage_pane">
<div role="menuitem" class="o_kanban_card_manage_title">
<span>View</span>
</div>
<div role="menuitem">
<a name="%(action_picking_dashboard)d" type="action">All</a>
</div>
<div role="menuitem">
<a name="%(action_picking_dashboard)d" type="action" context="{'search_default_todo': 1}">Draft</a>
</div>
<div role="menuitem">
<a name="%(action_picking_dashboard)d" type="action" context="{'search_default_open': 1}">In Progress</a>
</div>
<div role="menuitem">
<a name="%(action_picking_dashboard)d" type="action" context="{'search_default_done': 1}">Done</a>
</div>
</div>
<div class="col-6 o_kanban_card_manage_section o_kanban_manage_new">
<div role="menuitem" class="o_kanban_card_manage_title">
<span>New</span>
</div>
<div role="menuitem">
<a name="%(action_stock_request_form)d" type="action">Stock Request</a>
</div>
</div>
</div>
<div t-if="widget.editable" class="o_kanban_card_manage_settings row">
<div role="menuitem" aria-haspopup="true" class="col-8">
<ul role="menu" class="oe_kanban_colorpicker" data-field="color"/>
</div>
<div role="menuitem" class="col-4 text-right">
<a type="edit">Settings</a>
</div>
</div>
</div>
</div>
</div>
</xpath>
</field>
</record>
<record id="view_picking_type_form_inherit_sr" model="ir.ui.view">
<field name="name">Operation Types</field>
<field name="model">stock.picking.type</field>
<field name="inherit_id" ref="stock.view_picking_type_form"/>
<field name="arch" type="xml">
<field name="show_operations" position="attributes">
<attribute name="attrs">{"invisible": [("code", "=", "stock_request")]}</attribute>
</field>
<field name="show_reserved" position="attributes">
<attribute name="attrs">{"invisible": [("code", "=", "stock_request")]}</attribute>
</field>
</field>
</record>
</odoo>

View File

@@ -0,0 +1,53 @@
<?xml version="1.0" ?>
<odoo>
<record id="view_stock_request_filter" model="ir.ui.view">
<field name="name">stock.request.select</field>
<field name="model">stock.request</field>
<field name="arch" type="xml">
<search string="Search Stock Request">
<field name="name"/>
<field name="product_id"/>
<filter string="To Do" name="todo" domain="[('state','=', 'draft')]"
help="Stock Requests in draft."/>
<filter string="In Progress" name="inprogress" domain="[('state', '=', 'open')]"
help="Stock Requesta in Progress."/>
<filter string="Late" domain="['&amp;', ('expected_date', '&lt;', current_date), ('state', 'in', ('draft', 'open'))]"
name="late" help="Late Stock Requests"/>
<filter string="Done" name="done" domain="[('state', '=', 'done')]"/>
<group expand="0" string="Group By...">
<filter string="Product" name="product" domain="[]" context="{'group_by':'product_id'}"/>
<filter string="Expected Date" name="expected_date" domain="[]" context="{'group_by': 'expected_date'}" help="Expected Date by Month"/>
<filter string="State" name="state" domain="[]" context="{'group_by': 'state'}"/>
</group>
</search>
</field>
</record>
<record id="action_picking_dashboard" model="ir.actions.act_window">
<field name="name">Stock Requests</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">stock.request</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" eval="False"/>
<field name="search_view_id" ref="view_stock_request_filter"/>
<field name="domain">[('picking_type_id', '=', active_id)]</field>
<field name="context">{'default_picking_type_id': active_id}</field>
</record>
<record id="action_stock_request_form" model="ir.actions.act_window">
<field name="name">Stock Requests</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">stock.request</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
</record>
<menuitem id="menu_stock_request"
action="stock_request.action_stock_request_form"
name="Stock Requests"
parent="stock.menu_stock_warehouse_mgmt"
sequence="30"/>
</odoo>