-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
356 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
|
||
==================== | ||
Stock Picking Policy | ||
==================== | ||
|
||
Manage picking's workflow button invisibility by groups | ||
|
||
|
||
Installation | ||
============ | ||
|
||
To install this module, you need to: | ||
|
||
1. Clone the branch 8.0 of the repository https://github.com/open-synergy/opnsynid-stock-logistics-workflow | ||
2. Add the path to this repository in your configuration (addons-path) | ||
3. Update the module list | ||
4. Go to menu *Setting -> Modules -> Local Modules* | ||
5. Search For *Stock Picking Policy* | ||
6. Install the module | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues | ||
<https://github.com/open-synergy/opnsynid-stock-logistics-workflow/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. | ||
|
||
|
||
Credits | ||
======= | ||
|
||
Contributors | ||
------------ | ||
|
||
* Andhitia Rama <andhitia.r@gmail.com> | ||
|
||
Maintainer | ||
---------- | ||
|
||
.. image:: https://opensynergy-indonesia.com/logo.png | ||
:alt: OpenSynergy Indonesia | ||
:target: https://opensynergy-indonesia.com | ||
|
||
This module is maintained by the OpenSynergy Indonesia. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2017 OpenSynergy Indonesia | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2017 OpenSynergy Indonesia | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
{ | ||
"name": "Stock Picking Policy", | ||
"version": "8.0.1.0.0", | ||
"category": "Stock Management", | ||
"website": "https://opensynergy-indonesia.com", | ||
"author": "OpenSynergy Indonesia", | ||
"license": "AGPL-3", | ||
"installable": True, | ||
"depends": [ | ||
"stock", | ||
], | ||
"data": [ | ||
"views/stock_picking_type_views.xml", | ||
"views/stock_picking_views.xml", | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2017 OpenSynergy Indonesia | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from . import stock_picking_type | ||
from . import stock_picking |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2017 OpenSynergy Indonesia | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from openerp import models, api, fields | ||
|
||
|
||
class StockPicking(models.Model): | ||
_inherit = "stock.picking" | ||
|
||
@api.multi | ||
@api.depends( | ||
"state", | ||
"picking_type_id.confirm_group_ids", | ||
"picking_type_id.force_group_ids", | ||
"picking_type_id.transfer_group_ids", | ||
"picking_type_id.return_group_ids", | ||
"picking_type_id.cancel_group_ids", | ||
"picking_type_id.unreserve_group_ids", | ||
) | ||
def _compute_policy(self): | ||
obj_picking_type = self.env["stock.picking.type"] | ||
for picking in self: | ||
picking.confirm_ok = picking.force_ok = picking.transfer_ok = \ | ||
picking.return_ok = picking.cancel_ok = \ | ||
picking.unreserve_ok = False | ||
picking_id = self.env.context.get("default_picking_type_id", False) | ||
if not picking_id: | ||
continue | ||
picking_type = obj_picking_type.browse([picking_id])[0] | ||
picking.confirm_ok = self._confirm_policy(picking_type) | ||
picking.force_ok = self._force_policy(picking_type) | ||
picking.transfer_ok = self._transfer_policy(picking_type) | ||
picking.return_ok = self._return_policy(picking_type) | ||
picking.cancel_ok = self._cancel_policy(picking_type) | ||
picking.unreserve_ok = self._unreserve_policy(picking_type) | ||
|
||
@api.model | ||
def _confirm_policy(self, picking_type): | ||
result = False | ||
user = self.env.user | ||
confirm_group_ids = picking_type.confirm_group_ids.ids | ||
group_ids = user.groups_id.ids | ||
if not picking_type.confirm_group_ids.ids: | ||
result = True | ||
else: | ||
if (set(confirm_group_ids) & set(group_ids)): | ||
result = True | ||
return result | ||
|
||
@api.model | ||
def _force_policy(self, picking_type): | ||
result = False | ||
user = self.env.user | ||
force_group_ids = picking_type.force_group_ids.ids | ||
group_ids = user.groups_id.ids | ||
if not picking_type.force_group_ids.ids: | ||
result = True | ||
else: | ||
if (set(force_group_ids) & set(group_ids)): | ||
result = True | ||
return result | ||
|
||
@api.model | ||
def _transfer_policy(self, picking_type): | ||
result = False | ||
user = self.env.user | ||
transfer_group_ids = picking_type.transfer_group_ids.ids | ||
group_ids = user.groups_id.ids | ||
if not picking_type.transfer_group_ids.ids: | ||
result = True | ||
else: | ||
if (set(transfer_group_ids) & set(group_ids)): | ||
result = True | ||
return result | ||
|
||
@api.model | ||
def _return_policy(self, picking_type): | ||
result = False | ||
user = self.env.user | ||
return_group_ids = picking_type.return_group_ids.ids | ||
group_ids = user.groups_id.ids | ||
if not picking_type.return_group_ids.ids: | ||
result = True | ||
else: | ||
if (set(return_group_ids) & set(group_ids)): | ||
result = True | ||
return result | ||
|
||
@api.model | ||
def _cancel_policy(self, picking_type): | ||
result = False | ||
user = self.env.user | ||
cancel_group_ids = picking_type.cancel_group_ids.ids | ||
group_ids = user.groups_id.ids | ||
if not picking_type.cancel_group_ids.ids: | ||
result = True | ||
else: | ||
if (set(cancel_group_ids) & set(group_ids)): | ||
result = True | ||
return result | ||
|
||
@api.model | ||
def _unreserve_policy(self, picking_type): | ||
result = False | ||
user = self.env.user | ||
unreserve_group_ids = picking_type.unreserve_group_ids.ids | ||
group_ids = user.groups_id.ids | ||
if not picking_type.unreserve_group_ids.ids: | ||
result = True | ||
else: | ||
if (set(unreserve_group_ids) & set(group_ids)): | ||
result = True | ||
return result | ||
|
||
confirm_ok = fields.Boolean( | ||
string="Can Confirm", | ||
compute="_compute_policy", | ||
store=False, | ||
) | ||
force_ok = fields.Boolean( | ||
string="Can Force Availability", | ||
compute="_compute_policy", | ||
store=False, | ||
) | ||
transfer_ok = fields.Boolean( | ||
string="Can Transfer", | ||
compute="_compute_policy", | ||
store=False, | ||
) | ||
return_ok = fields.Boolean( | ||
string="Can Return", | ||
compute="_compute_policy", | ||
store=False, | ||
) | ||
cancel_ok = fields.Boolean( | ||
string="Can Cancel", | ||
compute="_compute_policy", | ||
store=False, | ||
) | ||
unreserve_ok = fields.Boolean( | ||
string="Can Unreserve", | ||
compute="_compute_policy", | ||
store=False, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2017 OpenSynergy Indonesia | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from openerp import models, fields | ||
|
||
|
||
class StockPickingType(models.Model): | ||
_inherit = "stock.picking.type" | ||
|
||
confirm_group_ids = fields.Many2many( | ||
string="Allowed to Confirm", | ||
comodel_name="res.groups", | ||
rel="rel_picking_confirm", | ||
col1="type_id", | ||
col2="group_id", | ||
) | ||
force_group_ids = fields.Many2many( | ||
string="Allowed to Force Availability", | ||
comodel_name="res.groups", | ||
rel="rel_picking_force", | ||
col1="type_id", | ||
col2="group_id", | ||
) | ||
transfer_group_ids = fields.Many2many( | ||
string="Allowed to Transfer", | ||
comodel_name="res.groups", | ||
rel="rel_picking_transfer", | ||
col1="type_id", | ||
col2="group_id", | ||
) | ||
return_group_ids = fields.Many2many( | ||
string="Allowed to Reverse", | ||
comodel_name="res.groups", | ||
rel="rel_picking_return", | ||
col1="type_id", | ||
col2="group_id", | ||
) | ||
cancel_group_ids = fields.Many2many( | ||
string="Allowed to Cancel", | ||
comodel_name="res.groups", | ||
rel="rel_picking_cancel", | ||
col1="type_id", | ||
col2="group_id", | ||
) | ||
unreserve_group_ids = fields.Many2many( | ||
string="Allowed to Unreserve", | ||
comodel_name="res.groups", | ||
rel="rel_picking_unreserve", | ||
col1="type_id", | ||
col2="group_id", | ||
) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<openerp> | ||
<data> | ||
<record id="stock_picking_type_view_form" model="ir.ui.view"> | ||
<field name="name">Stock Picking Type Policy Form</field> | ||
<field name="model">stock.picking.type</field> | ||
<field name="inherit_id" ref="stock.view_picking_type_form"/> | ||
<field name="arch" type="xml"> | ||
<data> | ||
<xpath expr="//sheet" position="inside"> | ||
<group name="grp_policy" string="Policy" colspan="4" col="2" groups="base.group_system"> | ||
<field name="confirm_group_ids" widget="many2many_tags"/> | ||
<field name="force_group_ids" widget="many2many_tags"/> | ||
<field name="transfer_group_ids" widget="many2many_tags"/> | ||
<field name="return_group_ids" widget="many2many_tags"/> | ||
<field name="cancel_group_ids" widget="many2many_tags"/> | ||
<field name="unreserve_group_ids" widget="many2many_tags"/> | ||
</group> | ||
</xpath> | ||
</data> | ||
</field> | ||
</record> | ||
</data> | ||
</openerp> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<openerp> | ||
<data> | ||
<record id="stock_picking_view_form" model="ir.ui.view"> | ||
<field name="name">Stock Picking Picking Form</field> | ||
<field name="model">stock.picking</field> | ||
<field name="inherit_id" ref="stock.view_picking_form"/> | ||
<field name="arch" type="xml"> | ||
<data> | ||
<xpath expr="//notebook" position="inside"> | ||
<page name="page_policy" string="Policy" groups="base.group_system"> | ||
<group name="grp_policy_1"> | ||
<field name="confirm_ok"/> | ||
<field name="force_ok"/> | ||
<field name="transfer_ok"/> | ||
<field name="return_ok"/> | ||
<field name="cancel_ok"/> | ||
<field name="unreserve_ok"/> | ||
</group> | ||
</page> | ||
</xpath> | ||
|
||
<xpath expr="//button[@name='action_confirm']" position="attributes"> | ||
<attribute name="groups"/> | ||
<attribute name="attrs">{'invisible':['|',('state','!=','draft'),'&',('state','=','draft'),('confirm_ok','=',False)]}</attribute> | ||
<attribute name="states"/> | ||
</xpath> | ||
|
||
<xpath expr="//button[@name='force_assign']" position="attributes"> | ||
<attribute name="groups"/> | ||
<attribute name="attrs">{'invisible':['|',('state','not in',['confirmed','waiting','partially_available']),'&',('state','in',['confirmed','waiting','partially_available']),('force_ok','=',False)]}</attribute> | ||
<attribute name="states"/> | ||
</xpath> | ||
|
||
<xpath expr="//button[@name='do_enter_transfer_details']" position="attributes"> | ||
<attribute name="groups"/> | ||
<attribute name="attrs">{'invisible':['|',('state','not in',['assigned','partially_available']),'&',('state','in',['assigned','partially_available']),('transfer_ok','=',False)]}</attribute> | ||
<attribute name="states"/> | ||
</xpath> | ||
|
||
<xpath expr="//button[@name='%(stock.act_stock_return_picking)d']" position="attributes"> | ||
<attribute name="groups"/> | ||
<attribute name="attrs">{'invisible':['|',('state','!=','done'),'&',('state','=','done'),('return_ok','=',False)]}</attribute> | ||
<attribute name="states"/> | ||
</xpath> | ||
|
||
<xpath expr="//button[@name='action_cancel']" position="attributes"> | ||
<attribute name="groups"/> | ||
<attribute name="attrs">{'invisible':['|',('state','not in',['assigned','confirmed','partially_available','draft','waiting']),'&',('state','in',['assigned','confirmed','partially_available','draft','waiting']),('cancel_ok','=',False)]}</attribute> | ||
<attribute name="states"/> | ||
</xpath> | ||
</data> | ||
</field> | ||
</record> | ||
</data> | ||
</openerp> |