Skip to content

Commit

Permalink
[IMP] stock_request: Add group to submit (OCA#595)
Browse files Browse the repository at this point in the history
  • Loading branch information
max3903 committed Jun 11, 2019
1 parent c40f741 commit 4b08488
Show file tree
Hide file tree
Showing 13 changed files with 108 additions and 100 deletions.
104 changes: 16 additions & 88 deletions stock_request/README.rst
@@ -1,93 +1,21 @@
.. image:: https://img.shields.io/badge/licence-LGPL--3-blue.svg
:target: https://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
**This file is going to be generated by oca-gen-addon-readme.**

=============
Stock Request
=============
*Manual changes will be overwritten.*

This module was written to allow users to request products that are
frequently stocked by the company, to be transferred to their chosen location.
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)

Configuration
=============
Content of this README will also be drawn from the addon manifest,
from keys such as name, authors, maintainers, development_status,
and license.

Users should be assigned to the groups 'Stock Request / User' or 'Stock
Request / Manager'.

Group Stock Request / User
--------------------------

* Can see her/his own Stock Requests, and others that she/he's been granted
permission to follow.

* Can create/update only her/his Stock Requests.

Group Stock Request / Manager
-----------------------------

* Can fully manage all Stock Requests


Usage
=====

Creation
--------
* Go to 'Stock Requests / Stock Requests' and create a new Request.
* Indicate a product, quantity and location.
* Press 'Confirm'.

Upon confirmation the request will be evaluated using the procurement rules
for the selected location.

In case that transfers are created, the user will be able to access to them
from the button 'Transfers' available in the Stock Request.

Cancel
------
When the user cancels a Stock Request, the related pending stock moves will be
also cancelled.


.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/153/12.0


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

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/stock-logistics-warehouse/issues>`_. In case of
trouble, please check there if your issue has already been reported. If you
spotted it first, help us smash it by providing detailed and welcomed feedback.

Credits
=======

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

* Jordi Ballester (EFICENT) <jordi.ballester@eficent.com>.
* Enric Tobella <etobella@creublanca.es>
* Atte Isopuro <atte.isopuro@avoin.systems>
* Lois Rilo <lois.rilo@eficent.com>
* Raul Martin <raul.martin@braintec-group.com>
* Serpent Consulting Services Pvt. Ltd. <support@serpentcs.com>

Maintainer
----------

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

This module is maintained by the OCA.

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.

To contribute to this module, please visit https://odoo-community.org.
A good, one sentence summary in the manifest is also highly recommended.
6 changes: 5 additions & 1 deletion stock_request/__manifest__.py
Expand Up @@ -4,7 +4,7 @@
{
"name": "Stock Request",
"summary": "Internal request for stock",
"version": "12.0.1.0.0",
"version": "12.0.1.1.0",
"license": "LGPL-3",
"website": "https://github.com/stock-logistics-warehouse",
"author": "Eficent, "
Expand All @@ -27,4 +27,8 @@
"data/stock_request_sequence_data.xml",
],
"installable": True,
"development_status": "Stable",
"maintainers": [
"jbeficent",
]
}
4 changes: 4 additions & 0 deletions stock_request/models/res_config_settings.py
Expand Up @@ -10,6 +10,10 @@ class ResConfigSettings(models.TransientModel):
group_stock_request_order = fields.Boolean(
implied_group='stock_request.group_stock_request_order')

group_stock_request_submit = fields.Boolean(
group='stock.group_stock_user',
implied_group='stock_request.group_stock_request_manager')

module_stock_request_purchase = fields.Boolean(
string='Stock Requests for Purchases')

Expand Down
9 changes: 7 additions & 2 deletions stock_request/models/stock_request.py
Expand Up @@ -8,6 +8,7 @@

REQUEST_STATES = [
('draft', 'Draft'),
('submitted', 'Submitted'),
('open', 'In progress'),
('done', 'Done'),
('cancel', 'Cancelled')]
Expand Down Expand Up @@ -97,7 +98,8 @@ def _get_default_requested_by(self):
states={'draft': [('readonly', False)]}, readonly=True
)
route_id = fields.Many2one(
states={'draft': [('readonly', False)]}, readonly=True
states={'draft': [('readonly', False)],
'submitted': [('readonly', False)]}, readonly=True
)

_sql_constraints = [
Expand Down Expand Up @@ -195,7 +197,10 @@ def _action_confirm(self):

@api.multi
def action_confirm(self):
self._action_confirm()
if self.env.user.has_group('stock_request.group_stock_request_submit'):
self.state = 'submitted'
else:
self._action_confirm()
return True

def action_draft(self):
Expand Down
19 changes: 19 additions & 0 deletions stock_request/readme/CONFIGURE.rst
@@ -0,0 +1,19 @@
To configure this module:

* Go to Stock Requests > Settings

Users should be assigned to the groups 'Stock Request / User' or 'Stock
Request / Manager'.

Group Stock Request / User
--------------------------

* Can see her/his own Stock Requests, and others that she/he's been granted
permission to follow.

* Can create/update only her/his Stock Requests.

Group Stock Request / Manager
-----------------------------

* Can fully manage all Stock Requests
7 changes: 7 additions & 0 deletions stock_request/readme/CONTRIBUTORS.rst
@@ -0,0 +1,7 @@
* Jordi Ballester (EFICENT) <jordi.ballester@eficent.com>.
* Enric Tobella <etobella@creublanca.es>
* Atte Isopuro <atte.isopuro@avoin.systems>
* Lois Rilo <lois.rilo@eficent.com>
* Raul Martin <raul.martin@braintec-group.com>
* Serpent Consulting Services Pvt. Ltd. <support@serpentcs.com>
* Maxime Chambreuil <mchambreuil@opensourceintegrators.com>
1 change: 1 addition & 0 deletions stock_request/readme/CREDITS.rst
@@ -0,0 +1 @@
* Eficent <https://www.eficent.com>
2 changes: 2 additions & 0 deletions stock_request/readme/DESCRIPTION.rst
@@ -0,0 +1,2 @@
This module was written to allow users to request products that are
frequently stocked by the company, to be transferred to their chosen location.
18 changes: 18 additions & 0 deletions stock_request/readme/USAGE.rst
@@ -0,0 +1,18 @@
Creation
--------

* Go to 'Stock Requests / Stock Requests' and create a new Request.
* Indicate a product, quantity and location.
* Press 'Confirm'.

Upon confirmation the request will be evaluated using the procurement rules
for the selected location.

In case that transfers are created, the user will be able to access to them
from the button 'Transfers' available in the Stock Request.

Cancel
------

When the user cancels a Stock Request, the related pending stock moves will be
also cancelled.
2 changes: 1 addition & 1 deletion stock_request/security/ir.model.access.csv
Expand Up @@ -4,7 +4,7 @@ access_stock_request_manager,stock request manager,model_stock_request,group_sto
access_stock_request_stock_user,stock.request stock user,model_stock_request,stock.group_stock_user,1,0,0,0
access_stock_request_allocation_user,stock request allocation user,model_stock_request_allocation,group_stock_request_user,1,1,1,1
access_stock_request_allocation_manager,stock request allocation manager,model_stock_request_allocation,group_stock_request_manager,1,1,1,1
access_stock_request_allocation_stock_user,stock.request.allocation stock user,model_stock_request_allocation,stock.group_stock_user,1,0,0,0
access_stock_request_allocation_stock_user,stock.request.allocation stock user,model_stock_request_allocation,base.group_user,1,0,0,0
access_stock_location_user,stock.location.user,stock.model_stock_location,group_stock_request_user,1,0,0,0
access_stock_location_request_manager,stock.location request manager,stock.model_stock_location,group_stock_request_manager,1,0,0,0
access_stock_rule_request_manager,stock_rule_request_manager,stock.model_stock_rule,group_stock_request_manager,1,0,0,0
Expand Down
5 changes: 5 additions & 0 deletions stock_request/security/stock_request_security.xml
Expand Up @@ -26,6 +26,11 @@
<field name="category_id" ref="base.module_category_hidden"/>
</record>

<record id="group_stock_request_submit" model="res.groups">
<field name="name">Allow users to submit stock requests</field>
<field name="category_id" ref="base.module_category_hidden"/>
</record>

<record id="stock.group_stock_user" model="res.groups">
<field name="implied_ids"
eval="[(4, ref('group_stock_request_user'))]"/>
Expand Down
13 changes: 13 additions & 0 deletions stock_request/views/res_config_settings_views.xml
Expand Up @@ -18,6 +18,19 @@
groups="stock_request.group_stock_request_manager">
<h2>Orders &amp; Configuration</h2>
<div class="row mt16 o_settings_container" id="stock_request">
<div class="col-xs-12 col-md-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="group_stock_request_submit"/>
</div>
<div class="o_setting_right_pane">
<label string="Allow users to submit stock requests"
for="group_stock_request_submit"/>
<div class="text-muted">
Add users to the group "Allow users to submit stock requests".
This option also allows Inventory users to confirm all stock requests.
</div>
</div>
</div>
<div class="col-xs-12 col-md-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="group_stock_request_order"/>
Expand Down
18 changes: 10 additions & 8 deletions stock_request/views/stock_request_views.xml
Expand Up @@ -51,15 +51,17 @@
<form string="Stock Requests">
<header>
<button name="action_confirm"
string="Confirm" type="object"
attrs="{'invisible': [('state', 'not in', ['draft'])]}"/>
<button name="action_cancel" states="draft,open"
type="object" string="Cancel"/>
<button name="action_draft" states="cancel" type="object"
string="Set to Draft"/>
string="Confirm" type="object"
class="oe_highlight"
states="draft,submitted"/>
<button name="action_done"
string="Done" type="object"
attrs="{'invisible': [('state', 'not in', ['open'])]}"/>
string="Done" type="object"
class="oe_highlight"
attrs="{'invisible': [('state', 'not in', ['open'])]}"/>
<button name="action_draft" states="submitted,cancel" type="object"
class="oe_highlight" string="Set to Draft"/>
<button name="action_cancel" states="draft,submitted,cancel,open"
type="object" string="Cancel"/>
<field name="state" widget="statusbar"/>
</header>
<sheet>
Expand Down

0 comments on commit 4b08488

Please sign in to comment.