Skip to content

Commit

Permalink
[REL] stock_picking_control to V11.
Browse files Browse the repository at this point in the history
[FIX] Separate view and py files by model.
[FIX] Update README.
  • Loading branch information
Valentino committed Sep 4, 2018
1 parent d92dcc3 commit 5ce67a9
Show file tree
Hide file tree
Showing 12 changed files with 154 additions and 189 deletions.
49 changes: 21 additions & 28 deletions stock_picking_control/README.rst
Original file line number Diff line number Diff line change
@@ -1,53 +1,49 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
.. |company| replace:: ADHOC SA

.. |company_logo| image:: https://raw.githubusercontent.com/ingadhoc/maintainer-tools/master/resources/adhoc-logo.png
:alt: ADHOC SA
:target: https://www.adhoc.com.ar

.. |icon| image:: https://raw.githubusercontent.com/ingadhoc/maintainer-tools/master/resources/adhoc-icon.png

.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: https://www.gnu.org/licenses/agpl
:alt: License: AGPL-3

=====================
Stock Picking Control
=====================
=================
Location Security
=================

This module add this optional constraints configurable by Picking Type:
* Block Picking Edit: Restrict add lines, change parters and other fields edition on pickings of this type. This will only apply to users with group Restrict Edit Blocked Pickings. It also block pickings duplicate.
* Block additional quantiy: Block in pack operation line to send more quantity for products than has in the sale order.
* Block picking deletion: Do not allow to remove pickings.


Installation
============

To install this module, you need to:

#. Just install this module.

#. Only need to install the module

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

To configure this module, you need to:

#. Set your options on each picking type

#. Go to Settings/Users/User select an user then in Preference set "Restrict Location".
#. In page "Allowed Stock Locations" set the locations do you allow.

Usage
=====

To use this module, you need to:

#. Just use this module.


#. No usage needed.

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

.. repo_id is available in https://github.com/OCA/maintainer-tools/blob/master/tools/repos_with_ids.txt
.. branch is "8.0" for example
Known issues / Roadmap
======================

* ...
:target: http://runbot.adhoc.com.ar/

Bug Tracker
===========
Expand All @@ -63,19 +59,16 @@ Credits
Images
------

* ADHOC SA: `Icon <http://fotos.subefotos.com/83fed853c1e15a8023b86b2b22d6145bo.png>`_.
* |company| |icon|

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


Maintainer
----------

.. image:: http://fotos.subefotos.com/83fed853c1e15a8023b86b2b22d6145bo.png
:alt: Odoo Community Association
:target: https://www.adhoc.com.ar
|company_logo|

This module is maintained by the ADHOC SA.
This module is maintained by the |company|.

To contribute to this module, please visit https://www.adhoc.com.ar.
Empty file modified stock_picking_control/__init__.py
100755 → 100644
Empty file.
8 changes: 5 additions & 3 deletions stock_picking_control/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
##############################################################################
{
'name': 'Stock Picking Control',
'version': '9.0.1.3.0',
'version': '11.0.1.0.0',
'category': 'Warehouse Management',
'author': 'ADHOC SA',
'sequence': 14,
'summary': '',
'website': 'www.adhoc.com.ar',
Expand All @@ -32,11 +33,12 @@
],
'data': [
'security/security.xml',
'view/stock_view.xml',
'view/stock_picking_view.xml',
'view/stock_picking_type_view.xml',
],
'demo': [
],
'installable': False,
'installable': True,
'auto_install': False,
'application': False,
}
4 changes: 3 additions & 1 deletion stock_picking_control/models/__init__.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
from . import stock
from . import stock_move_line
from . import stock_picking_type
from . import stock_picking
90 changes: 0 additions & 90 deletions stock_picking_control/models/stock.py

This file was deleted.

35 changes: 35 additions & 0 deletions stock_picking_control/models/stock_move_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
##############################################################################
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
from odoo import models, api, fields, _
from odoo.exceptions import ValidationError


class StockMoveLine(models.Model):

_inherit = 'stock.move.line'

block_additional_quantiy = fields.Boolean(
related='picking_id.block_additional_quantiy',
readonly=True,
default=True,
)

@api.constrains('qty_done')
def _check_quantity(self):
for pack in self:
if pack.picking_id.block_additional_quantiy and pack.\
product_qty < pack.qty_done:
raise ValidationError(_(
'You can not transfer a product without a move on the '
'picking!'))

# @api.model
# def create(self, vals):
# op = super(StockMoveLine, self).create(vals)
# if op.fresh_record
# and op.picking_id.picking_type_id.block_additional_quantiy:
# raise ValidationError(_(
# 'You can not add operations to this picking'))
# return op
32 changes: 32 additions & 0 deletions stock_picking_control/models/stock_picking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
##############################################################################
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
from odoo import models, fields, api, _
from odoo.exceptions import ValidationError


class StockPicking(models.Model):

_inherit = 'stock.picking'

block_additional_quantiy = fields.Boolean(
related='picking_type_id.block_additional_quantiy',
readonly=True,
)

@api.multi
def unlink(self):
"""
To avoid errors we block deletion of pickings in other state than
draft or cancel
"""
not_del_pickings = self.filtered(
lambda x: x.picking_type_id.block_picking_deletion)
if not_del_pickings:
raise ValidationError(_(
'You can not delete this pickings because "Block picking '
'deletion" is enable on the picking type "%s".\n'
'Picking Ids: %s') % (
not_del_pickings.ids, self.picking_type_id.name))
return super(StockPicking, self).unlink()
20 changes: 20 additions & 0 deletions stock_picking_control/models/stock_picking_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
##############################################################################
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
from odoo import fields, models


class StockPickingType(models.Model):

_inherit = 'stock.picking.type'

block_additional_quantiy = fields.Boolean(
string="Block additional quantiy",
help="Restrict additional quantity",
)

block_picking_deletion = fields.Boolean(
default=True,
help="Do not allow to remove pickings",
)
5 changes: 1 addition & 4 deletions stock_picking_control/security/security.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
<?xml version="1.0"?>
<odoo>
<data>

<record model="res.groups" id="group_restrict_edit_picking">
<field name="name">Restrict Edit Blocked Pickings</field>
</record>

</data>
</odoo>

</odoo>
18 changes: 18 additions & 0 deletions stock_picking_control/view/stock_picking_type_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<odoo>

<record id="view_picking_type_form" model="ir.ui.view">
<field name="name">stock.picking.type.form</field>
<field name="model">stock.picking.type</field>
<field name="inherit_id" ref="stock.view_picking_type_form"/>
<field name="arch" type="xml">
<group position="inside">
<group string="Stock">
<field name="block_additional_quantiy"/>
<field name="block_picking_deletion"/>
</group>
</group>
</field>
</record>

</odoo>
19 changes: 19 additions & 0 deletions stock_picking_control/view/stock_picking_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0"?>
<odoo>

<record id="view_picking_form" model="ir.ui.view">
<field name="name">stock.picking.form</field>
<field name="model">stock.picking</field>
<field name="inherit_id" ref="stock.view_picking_form"/>

<!-- por si stock usability esta instalado, queremos que esta pise aquella -->
<field name="priority">20</field>
<field name="groups_id" eval="[(6, 0, [ref('group_restrict_edit_picking')])]"/>
<field name="arch" type="xml">
<field name="partner_id" position="after">
<field name="block_additional_quantiy" invisible="1"/>
</field>
</field>
</record>

</odoo>
Loading

0 comments on commit 5ce67a9

Please sign in to comment.