-
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.
[8.0.1.0.0] stock_inventory_workflow_policy
- Loading branch information
Showing
9 changed files
with
275 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,48 @@ | ||
.. 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 Inventory Workflow Policy | ||
=============================== | ||
|
||
|
||
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 Inventory Workflow 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 | ||
------------ | ||
|
||
* Michael Viriyananda <viriyananda.michael@gmail.com> | ||
* 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 2018 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,20 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2018 OpenSynergy Indonesia | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
# pylint: disable=locally-disabled, manifest-required-author | ||
{ | ||
"name": "Stock Inventory Workflow Policy", | ||
"version": "8.0.1.0.0", | ||
"category": "Accounting & Finance", | ||
"website": "https://opensynergy-indonesia.com", | ||
"author": "OpenSynergy Indonesia", | ||
"license": "AGPL-3", | ||
"installable": True, | ||
"depends": [ | ||
"stock", | ||
], | ||
"data": [ | ||
"views/stock_location_views.xml", | ||
"views/stock_inventory_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 2018 OpenSynergy Indonesia | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from . import stock_location | ||
from . import stock_inventory |
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,58 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2018 OpenSynergy Indonesia | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from openerp import models, api, fields, SUPERUSER_ID | ||
|
||
|
||
class StockInventory(models.Model): | ||
_inherit = "stock.inventory" | ||
|
||
@api.multi | ||
@api.depends( | ||
"location_id", | ||
) | ||
def _compute_policy(self): | ||
for inventory in self: | ||
if self.env.user.id == SUPERUSER_ID: | ||
inventory.validate_ok = inventory.restart_ok = \ | ||
inventory.restart_ok = \ | ||
inventory.start_ok = inventory.cancel_ok = True | ||
continue | ||
|
||
if inventory.location_id: | ||
location = inventory.location_id | ||
for policy in location.\ | ||
_get_inventory_adjustment_button_policy_map(): | ||
setattr( | ||
inventory, | ||
policy[0], | ||
location. | ||
_get_inventory_adjustment_button_policy( | ||
policy[1]), | ||
) | ||
|
||
start_ok = fields.Boolean( | ||
string="Can Start", | ||
compute="_compute_policy", | ||
store=False, | ||
readonly=True, | ||
) | ||
validate_ok = fields.Boolean( | ||
string="Can Validate", | ||
compute="_compute_policy", | ||
store=False, | ||
readonly=True, | ||
) | ||
cancel_ok = fields.Boolean( | ||
string="Can Cancel", | ||
compute="_compute_policy", | ||
store=False, | ||
readonly=True, | ||
) | ||
restart_ok = fields.Boolean( | ||
string="Can Restart", | ||
compute="_compute_policy", | ||
store=False, | ||
readonly=True, | ||
) |
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,65 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2018 OpenSynergy Indonesia | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from openerp import models, fields, api | ||
|
||
|
||
class StockLocation(models.Model): | ||
_inherit = "stock.location" | ||
|
||
inventory_adjustment_start_grp_ids = fields.Many2many( | ||
string="Allowed To Start Inventory Adjustment", | ||
comodel_name="res.groups", | ||
relation="rel_inventory_adjustment_allowed_confirm_groups", | ||
column1="location_id", | ||
column2="group_id", | ||
) | ||
inventory_adjustment_validate_grp_ids = fields.Many2many( | ||
string="Allowed To Validate Inventory Adjustment", | ||
comodel_name="res.groups", | ||
relation="rel_inventory_adjustment_allowed_validate_groups", | ||
column1="location_id", | ||
column2="group_id", | ||
) | ||
inventory_adjustment_restart_grp_ids = fields.Many2many( | ||
string="Allowed To Restart Inventory Adjustment", | ||
comodel_name="res.groups", | ||
relation="rel_inventory_adjustment_allowed_restart_groups", | ||
column1="location_id", | ||
column2="group_id", | ||
) | ||
inventory_adjustment_cancel_grp_ids = fields.Many2many( | ||
string="Allowed To Cancel` Inventory Adjustment", | ||
comodel_name="res.groups", | ||
relation="rel_inventory_adjustment_allowed_cancel_groups", | ||
column1="location_id", | ||
column2="group_id", | ||
) | ||
|
||
@api.model | ||
def _get_inventory_adjustment_button_policy_map(self): | ||
return [ | ||
("validate_ok", "inventory_adjustment_validate_grp_ids"), | ||
("start_ok", "inventory_adjustment_start_grp_ids"), | ||
("cancel_ok", "inventory_adjustment_cancel_grp_ids"), | ||
("restart_ok", "inventory_adjustment_restart_grp_ids"), | ||
] | ||
|
||
@api.multi | ||
def _get_inventory_adjustment_button_policy(self, policy_field): | ||
self.ensure_one() | ||
result = False | ||
button_group_ids = [] | ||
user = self.env.user | ||
group_ids = user.groups_id.ids | ||
|
||
button_group_ids += getattr( | ||
self, policy_field).ids | ||
|
||
if not button_group_ids: | ||
result = True | ||
else: | ||
if (set(button_group_ids) & set(group_ids)): | ||
result = True | ||
return result |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions
48
stock_inventory_workflow_policy/views/stock_inventory_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,48 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- Copyright 2018 OpenSynergy Indonesia | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> | ||
|
||
<openerp> | ||
<data> | ||
|
||
<record id="stock_inventory_view_form" model="ir.ui.view"> | ||
<field name="name">stock.inventory form</field> | ||
<field name="model">stock.inventory</field> | ||
<field name="inherit_id" ref="stock.view_inventory_form"/> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//button[@name='prepare_inventory']" position="attributes"> | ||
<attribute name="groups"/> | ||
<attribute name="attrs">{'invisible':['|',('state','!=','draft'),('start_ok','=',False)]}</attribute> | ||
<attribute name="states"/> | ||
</xpath> | ||
<xpath expr="//button[@name='action_done']" position="attributes"> | ||
<attribute name="groups"/> | ||
<attribute name="attrs">{'invisible':['|',('state','!=','confirm'),('validate_ok','=',False)]}</attribute> | ||
<attribute name="states"/> | ||
</xpath> | ||
<xpath expr="//button[@name='action_cancel_draft']" position="attributes"> | ||
<attribute name="groups"/> | ||
<attribute name="attrs">{'invisible':['|',('state','!=','cancel'),('restart_ok','=',False)]}</attribute> | ||
<attribute name="states"/> | ||
</xpath> | ||
<xpath expr="//button[@name='action_cancel_inventory']" position="attributes"> | ||
<attribute name="groups"/> | ||
<attribute name="attrs">{'invisible':['|',('state','!=','confirm'),('cancel_ok','=',False)]}</attribute> | ||
<attribute name="states"/> | ||
</xpath> | ||
|
||
<xpath expr="//notebook" position="inside"> | ||
<page name="workflow" string="Workflow Policy" groups="base.group_system"> | ||
<group name="workflow_1" colspan="4" col="2"> | ||
<field name="start_ok"/> | ||
<field name="validate_ok"/> | ||
<field name="cancel_ok"/> | ||
<field name="restart_ok"/> | ||
</group> | ||
</page> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
</data> | ||
</openerp> |
25 changes: 25 additions & 0 deletions
25
stock_inventory_workflow_policy/views/stock_location_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,25 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- Copyright 2018 OpenSynergy Indonesia | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> | ||
|
||
<openerp> | ||
<data> | ||
|
||
<record id="stock_location_view_form" model="ir.ui.view"> | ||
<field name="name">stock.location.form invetory policy</field> | ||
<field name="model">stock.location</field> | ||
<field name="inherit_id" ref="stock.view_location_form"/> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//form/group/group[last()]" position="after"> | ||
<group name="inventory_adjustment_workflow_policy" colspan="4" col="2" string="Inventory Adjustment Workflow Policy"> | ||
<field name="inventory_adjustment_start_grp_ids" widget="many2many_tags"/> | ||
<field name="inventory_adjustment_validate_grp_ids" widget="many2many_tags"/> | ||
<field name="inventory_adjustment_cancel_grp_ids" widget="many2many_tags"/> | ||
<field name="inventory_adjustment_restart_grp_ids" widget="many2many_tags"/> | ||
</group> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
</data> | ||
</openerp> |