-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP]price_security_sale_margin: new module
hides sale margin fields in sale order views
- Loading branch information
Showing
7 changed files
with
195 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,80 @@ | ||
.. |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 | ||
|
||
=============================== | ||
Price Security with sale margin | ||
=============================== | ||
|
||
This module is an integration of Price Security with Sale Margin. | ||
|
||
Installation | ||
============ | ||
|
||
To install this module, you need to: | ||
|
||
#. Just install this module. | ||
|
||
|
||
Configuration | ||
============= | ||
|
||
To configure this module, you need to: | ||
|
||
#. Set 'Restrict Prices' for users you want to restrict. | ||
#. For the same users, configure discounts range on "Discounts Permissions" users tab. | ||
|
||
|
||
Usage | ||
===== | ||
|
||
To use this module, you need to: | ||
|
||
For users with price restriction, it restricts: | ||
|
||
* on sales orders: change payment term or pricelist | ||
* on sales order lines: change unit price and set limits on discount (limits configured on user) | ||
* on partners: change payment term or pricelist | ||
* on invoices: change unit price | ||
* on invoice lines: change unit price and set limits on discount (limits configured on user) | ||
* on product: change price | ||
|
||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas | ||
:alt: Try me on Runbot | ||
:target: http://runbot.adhoc.com.ar/ | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues | ||
<https://github.com/ingadhoc/product/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 | ||
======= | ||
|
||
Images | ||
------ | ||
|
||
* |company| |icon| | ||
|
||
Contributors | ||
------------ | ||
|
||
Maintainer | ||
---------- | ||
|
||
|company_logo| | ||
|
||
This module is maintained by the |company|. | ||
|
||
To contribute to this module, please visit https://www.adhoc.com.ar. |
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 @@ | ||
############################################################################## | ||
# For copyright and license notices, see __manifest__.py file in module root | ||
# directory | ||
############################################################################## | ||
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,33 @@ | ||
############################################################################## | ||
# | ||
# Copyright (C) 2015 ADHOC SA (http://www.adhoc.com.ar) | ||
# All Rights Reserved. | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as | ||
# published by the Free Software Foundation, either version 3 of the | ||
# License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
############################################################################## | ||
{ | ||
'name': 'Price Security with sale margin', | ||
'version': "16.0.1.0.0", | ||
'category': 'Sales Management', | ||
'author': 'ADHOC SA', | ||
'website': 'http://www.adhoc.com.ar/', | ||
'license': 'AGPL-3', | ||
'depends': [ | ||
'price_security', | ||
'sale_margin', | ||
], | ||
'installable': True, | ||
'auto_install': 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,15 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 15.0+e\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2022-04-25 13:24+0000\n" | ||
"PO-Revision-Date: 2022-04-19 21:47+0000\n" | ||
"Language-Team: Spanish (https://www.transifex.com/adhoc/teams/133229/es/)\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Language: es\n" | ||
"Plural-Forms: nplurals=2; plural=(n != 1);\n" |
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 @@ | ||
from . import sale_order | ||
from . import sale_order_line |
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,30 @@ | ||
from odoo import models, api | ||
import json | ||
|
||
|
||
class SaleOrder(models.Model): | ||
_inherit = 'sale.order' | ||
|
||
@api.model | ||
def _get_view(self, view_id=None, view_type='form', **options): | ||
arch, view = super()._get_view(view_id, view_type, **options) | ||
if view_type == 'form': | ||
if self.env.user.has_group('price_security.group_only_view'): | ||
readonly_fields = (arch.xpath("//field[@name='purchase_price']") | ||
+ arch.xpath("//field[@name='margin']") | ||
+ arch.xpath("//field[@name='margin_percent']")) | ||
for node in readonly_fields: | ||
node.set('readonly', '1') | ||
modifiers = json.loads(node.get("modifiers") or "{}") | ||
modifiers['readonly'] = True | ||
node.set("modifiers", json.dumps(modifiers)) | ||
if self.env.user.has_group('price_security.group_only_view_sale_price'): | ||
invisible_fields = (arch.xpath("//field[@name='purchase_price']") | ||
+ arch.xpath("//field[@name='margin']") | ||
+ arch.xpath("//field[@name='margin_percent']")) | ||
for node in invisible_fields: | ||
node.set('invisible', '1') | ||
modifiers = json.loads(node.get("modifiers") or "{}") | ||
modifiers['invisible'] = True | ||
node.set("modifiers", json.dumps(modifiers)) | ||
return arch, view |
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,30 @@ | ||
from odoo import models, api | ||
import json | ||
|
||
|
||
class SaleOrder(models.Model): | ||
_inherit = 'sale.order.line' | ||
|
||
@api.model | ||
def _get_view(self, view_id=None, view_type='form', **options): | ||
arch, view = super()._get_view(view_id, view_type, **options) | ||
if view_type == 'tree': | ||
if self.env.user.has_group('price_security.group_only_view'): | ||
readonly_fields = (arch.xpath("//field[@name='purchase_price']") | ||
+ arch.xpath("//field[@name='margin']") | ||
+ arch.xpath("//field[@name='margin_percent']")) | ||
for node in readonly_fields: | ||
node.set('readonly', '1') | ||
modifiers = json.loads(node.get("modifiers") or "{}") | ||
modifiers['readonly'] = True | ||
node.set("modifiers", json.dumps(modifiers)) | ||
if self.env.user.has_group('price_security.group_only_view_sale_price'): | ||
invisible_fields = (arch.xpath("//field[@name='purchase_price']") | ||
+ arch.xpath("//field[@name='margin']") | ||
+ arch.xpath("//field[@name='margin_percent']")) | ||
for node in invisible_fields: | ||
node.set('invisible', '1') | ||
modifiers = json.loads(node.get("modifiers") or "{}") | ||
modifiers['invisible'] = True | ||
node.set("modifiers", json.dumps(modifiers)) | ||
return arch, view |