-
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_location_inventory_policy]
- Loading branch information
Showing
8 changed files
with
187 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 Location 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 Location 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,19 @@ | ||
# -*- 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 Location 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", | ||
], | ||
} |
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,38 @@ | ||
# -*- 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 | ||
from lxml import etree | ||
|
||
|
||
class StockInventory(models.Model): | ||
_inherit = "stock.inventory" | ||
|
||
location_id = fields.Many2one( | ||
default=lambda self: False, | ||
) | ||
|
||
@api.model | ||
def fields_view_get( | ||
self, view_id=None, view_type="form", toolbar=False, submenu=False | ||
): | ||
res = super(StockInventory, self).fields_view_get( | ||
view_id=view_id, view_type=view_type, | ||
toolbar=toolbar, submenu=submenu) | ||
doc = etree.XML(res['arch']) | ||
domain = [] | ||
list_location_ids = [] | ||
obj_stock_location =\ | ||
self.env["stock.location"] | ||
location_ids = obj_stock_location.search([]) | ||
for location in location_ids: | ||
if self.env.user.id in location.all_user_inventory_ids.ids: | ||
list_location_ids.append(location.id) | ||
if list_location_ids: | ||
domain = [("id", "in", list_location_ids)] | ||
if domain: | ||
for node in doc.xpath("//field[@name='location_id']"): | ||
node.set("domain", str(domain)) | ||
res['arch'] = etree.tostring(doc) | ||
return res |
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,47 @@ | ||
# -*- 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" | ||
|
||
@api.depends( | ||
"allowed_group_inventory_ids", | ||
"allowed_user_inventory_ids") | ||
def _compute_all_user_inventory_ids(self): | ||
obj_res_users = self.env["res.users"] | ||
for location in self: | ||
users = location.allowed_user_inventory_ids | ||
group_ids = location.allowed_group_inventory_ids.ids | ||
criteria = [ | ||
("groups_id", "in", group_ids) | ||
] | ||
users += obj_res_users.search(criteria) | ||
location.all_user_inventory_ids = users | ||
|
||
allowed_group_inventory_ids = fields.Many2many( | ||
string="Allowed Groups to Iventory Adjustments", | ||
comodel_name="res.groups", | ||
relation="relation_location_2_groups_inventory", | ||
column1="location_id", | ||
column2="group_inventory_id", | ||
) | ||
allowed_user_inventory_ids = fields.Many2many( | ||
string="Allowed Users to Iventory Adjustments", | ||
comodel_name="res.users", | ||
relation="relation_location_2_user_inventory", | ||
column1="location_id", | ||
column2="user_inventory_id", | ||
) | ||
all_user_inventory_ids = fields.Many2many( | ||
string="All Allowed Users for Iventory Adjustments", | ||
comodel_name="res.users", | ||
compute="_compute_all_user_inventory_ids", | ||
store=True, | ||
relation="relation_location_2_user_all_inventory", | ||
column1="location_id", | ||
column2="user_inventory_id", | ||
) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions
24
stock_inventory_location_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,24 @@ | ||
<?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="grp_inventory_location_policy" colspan="4" col="2" string="Inventory Policy"> | ||
<field name="allowed_group_inventory_ids" widget="many2many_tags"/> | ||
<field name="allowed_user_inventory_ids" widget="many2many_tags"/> | ||
<field name="all_user_inventory_ids" widget="many2many_tags" invisible="1"/> | ||
</group> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
</data> | ||
</openerp> |