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
18 changed files
with
1,033 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,4 @@ | ||
# list the OCA project dependencies, one per line | ||
# add a github url if you need a forked version | ||
purchase_request https://github.com/554513154/purchase-workflow 12.0-mig-purchase_request | ||
purchase_operating_unit https://github.com/eficent/operating-unit 12.0-mig-purchase_operating_unit |
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,94 @@ | ||
=================================== | ||
Operating Unit in Purchase Requests | ||
=================================== | ||
|
||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Beta | ||
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html | ||
:alt: License: LGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Foperating--unit-lightgray.png?logo=github | ||
:target: https://github.com/OCA/operating-unit/tree/12.0/purchase_request_operating_unit | ||
:alt: OCA/operating-unit | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/operating-unit-12-0/operating-unit-12-0-purchase_request_operating_unit | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png | ||
:target: https://runbot.odoo-community.org/runbot/213/12.0 | ||
:alt: Try me on Runbot | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module introduces the following features: | ||
|
||
* Adds the Operating Unit (OU) to the Purchase Request. | ||
|
||
* The user’s default Operating Unit (OU) is proposed at the time of creating the Purchase Request. | ||
|
||
* Security rules are defined to ensure that users can only see the Purchase Request of that Operating Units in which they are allowed access to. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Usage | ||
===== | ||
|
||
Follow these steps: | ||
|
||
#. Create or use an existing Operating Unit (OU) in Settings -> | ||
Users & Configuration -> Operating Unit. | ||
#. Change the configuration of the Users. In Application Accesses, put an User | ||
as Request manager and another one as Request User. | ||
#. Create a Purchase Request Order. By default, if there is no Approver, any | ||
Manager with the same OU can accept the PO. If you specify an Approver, he | ||
must be in the same Operating Unit as the Purchase Request. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/operating-unit/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 <https://github.com/OCA/operating-unit/issues/new?body=module:%20purchase_request_operating_unit%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* Eficent | ||
* SerpentCS | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Jordi Ballester Alomar <jordi.ballester@eficent.com> | ||
* Serpent Consulting Services Pvt. Ltd. <support@serpentcs.com> | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is maintained by the OCA. | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
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. | ||
|
||
This module is part of the `OCA/operating-unit <https://github.com/OCA/operating-unit/tree/12.0/purchase_request_operating_unit>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
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,10 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016-17 Eficent Business and IT Consulting Services S.L. | ||
# (http://www.eficent.com) | ||
# Copyright 2016-17 Serpent Consulting Services Pvt. Ltd. | ||
# (<http://www.serpentcs.com>) | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). | ||
|
||
from . import model | ||
from . import tests | ||
from . import wizard |
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 @@ | ||
# Copyright 2016-19 Eficent Business and IT Consulting Services S.L. | ||
# (http://www.eficent.com) | ||
# Copyright 2016-19 Serpent Consulting Services Pvt. Ltd. | ||
# (<http://www.serpentcs.com>) | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). | ||
|
||
{ | ||
"name": "Operating Unit in Purchase Requests", | ||
"version": "12.0.1.0.0", | ||
"author": "Eficent, " | ||
"SerpentCS, " | ||
"Odoo Community Association (OCA)", | ||
"website": "https://www.github.com/OCA/operating-unit", | ||
"license": "LGPL-3", | ||
"category": "Purchase Management", | ||
"depends": ["purchase_request", | ||
"purchase_operating_unit"], | ||
"data": [ | ||
"security/purchase_security.xml", | ||
"view/purchase_request_view.xml", | ||
"wizard/purchase_request_line_make_purchase_order_view.xml" | ||
], | ||
'installable': 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,3 @@ | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). | ||
|
||
from . import purchase_request |
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,69 @@ | ||
# Copyright 2016-19 Eficent Business and IT Consulting Services S.L. | ||
# (http://www.eficent.com) | ||
# Copyright 2016-19 Serpent Consulting Services Pvt. Ltd. | ||
# (<http://www.serpentcs.com>) | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). | ||
|
||
from odoo import fields, models, api, _ | ||
from odoo.exceptions import ValidationError | ||
|
||
|
||
class PurchaseRequest(models.Model): | ||
_inherit = 'purchase.request' | ||
|
||
operating_unit_id = fields.Many2one( | ||
'operating.unit', | ||
string='Operating Unit', | ||
states={'to_approve': [('readonly', True)], | ||
'approved': [('readonly', True)], | ||
'done': [('readonly', True)]}, | ||
default=lambda self: | ||
self.env['res.users']. | ||
operating_unit_default_get(self._uid), | ||
) | ||
|
||
@api.multi | ||
@api.constrains('operating_unit_id', 'company_id') | ||
def _check_company_operating_unit(self): | ||
for rec in self: | ||
if rec.company_id and rec.operating_unit_id and \ | ||
rec.company_id != rec.operating_unit_id.company_id: | ||
raise ValidationError(_('The Company in the Purchase Request ' | ||
'and in the Operating Unit must be' | ||
'the same.')) | ||
|
||
@api.multi | ||
@api.constrains('operating_unit_id', 'picking_type_id') | ||
def _check_warehouse_operating_unit(self): | ||
for rec in self: | ||
picking_type = rec.picking_type_id | ||
if picking_type: | ||
if picking_type.warehouse_id and\ | ||
picking_type.warehouse_id.operating_unit_id\ | ||
and rec.operating_unit_id and\ | ||
picking_type.warehouse_id.operating_unit_id !=\ | ||
rec.operating_unit_id: | ||
raise ValidationError(_('Configuration error. The\ | ||
Purchase Request and the Warehouse of picking type\ | ||
must belong to the same Operating Unit.')) | ||
|
||
@api.constrains('operating_unit_id') | ||
def _check_approver_operating_unit(self): | ||
for rec in self: | ||
if rec.assigned_to and rec.operating_unit_id and \ | ||
rec.operating_unit_id not in \ | ||
rec.assigned_to.operating_unit_ids: | ||
raise ValidationError(_('Configuration error. The ' | ||
'approver has not the indicated ' | ||
'Operating Unit')) | ||
|
||
|
||
class PurchaseRequestLine(models.Model): | ||
_inherit = 'purchase.request.line' | ||
|
||
operating_unit_id = fields.Many2one( | ||
'operating.unit', | ||
related='request_id.operating_unit_id', | ||
string='Operating Unit', | ||
store=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,2 @@ | ||
* Jordi Ballester Alomar <jordi.ballester@eficent.com> | ||
* Serpent Consulting Services Pvt. Ltd. <support@serpentcs.com> |
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,7 @@ | ||
This module introduces the following features: | ||
|
||
* Adds the Operating Unit (OU) to the Purchase Request. | ||
|
||
* The user’s default Operating Unit (OU) is proposed at the time of creating the Purchase Request. | ||
|
||
* Security rules are defined to ensure that users can only see the Purchase Request of that Operating Units in which they are allowed access to. |
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,9 @@ | ||
Follow these steps: | ||
|
||
#. Create or use an existing Operating Unit (OU) in Settings -> | ||
Users & Configuration -> Operating Unit. | ||
#. Change the configuration of the Users. In Application Accesses, put an User | ||
as Request manager and another one as Request User. | ||
#. Create a Purchase Request Order. By default, if there is no Approver, any | ||
Manager with the same OU can accept the PO. If you specify an Approver, he | ||
must be in the same Operating Unit as the Purchase Request. |
33 changes: 33 additions & 0 deletions
33
purchase_request_operating_unit/security/purchase_security.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,33 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!--Copyright 2016-19 Eficent Business and IT Consulting Services S.L.--> | ||
<!--(http://www.eficent.com)--> | ||
<!--Copyright 2016-19 Serpent Consulting Services Pvt. Ltd.--> | ||
<!--(<http://www.serpentcs.com>)--> | ||
<!--License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).--> | ||
<odoo> | ||
|
||
<record id="ir_rule_purchase_request_allowed_operating_units" model="ir.rule"> | ||
<field name="model_id" ref="purchase_request.model_purchase_request"/> | ||
<field name="domain_force">['|',('operating_unit_id','=',False), | ||
('operating_unit_id','in',[g.id for g in user.operating_unit_ids])]</field> | ||
<field name="name">Purchase Requests from allowed operating units</field> | ||
<field name="global" eval="True"/> | ||
<field eval="0" name="perm_unlink"/> | ||
<field eval="0" name="perm_write"/> | ||
<field eval="1" name="perm_read"/> | ||
<field eval="0" name="perm_create"/> | ||
</record> | ||
|
||
<record id="ir_rule_purchase_request_line_allowed_operating_units" model="ir.rule"> | ||
<field name="model_id" ref="purchase_request.model_purchase_request_line"/> | ||
<field name="domain_force">['|',('request_id.operating_unit_id','=',False), | ||
('request_id.operating_unit_id','in',[g.id for g in user.operating_unit_ids])]</field> | ||
<field name="name">Purchase Requests lines from allowed operating units</field> | ||
<field name="global" eval="True"/> | ||
<field eval="0" name="perm_unlink"/> | ||
<field eval="0" name="perm_write"/> | ||
<field eval="1" name="perm_read"/> | ||
<field eval="0" name="perm_create"/> | ||
</record> | ||
|
||
</odoo> |
Oops, something went wrong.