Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[15.0][MIG] account_payment_term_security: Migration to version 15.0 #591

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions account_payment_term_security/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
=====================
Payment Term Security
=====================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! 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-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--payment-lightgray.png?logo=github
:target: https://github.com/OCA/account-payment/tree/13.0/account_payment_term_security
:alt: OCA/account-payment
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/account-payment-13-0/account-payment-13-0-account_payment_term_security
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/96/13.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

In partners and invoices, payment terms can only be changed when the user has permission "Change payment terms in partners and invoices".

**Table of contents**

.. contents::
:local:

Configuration
=============

To use this module, you need to :

Go to Settings > Users & Companies > Users (edit your user) > Set "Change payment terms in partners and invoices" option.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-payment/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/account-payment/issues/new?body=module:%20account_payment_term_security%0Aversion:%2013.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
~~~~~~~

* Tecnativa

Contributors
~~~~~~~~~~~~

* `Tecnativa <https://www.tecnativa.com>`:

* Pedro M. Baeza
* Víctor Martínez

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/account-payment <https://github.com/OCA/account-payment/tree/13.0/account_payment_term_security>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions account_payment_term_security/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
15 changes: 15 additions & 0 deletions account_payment_term_security/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2023 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Payment Term Security",
"version": "15.0.1.0.0",
"category": "Accounting & Finance",
"author": "Tecnativa, Odoo Community Association (OCA)",
"maintainer": "OCA",
"website": "https://github.com/OCA/account-payment",
"license": "AGPL-3",
"depends": ["account"],
"data": ["security/security.xml"],
"installable": True,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_payment_term_security
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: account_payment_term_security
#: model:res.groups,name:account_payment_term_security.account_payment_term_mgmt
msgid "Change payment terms in partners and invoices"
msgstr ""

#. module: account_payment_term_security
#: model:ir.model,name:account_payment_term_security.model_res_partner
msgid "Contact"
msgstr ""

#. module: account_payment_term_security
#: model:ir.model,name:account_payment_term_security.model_account_move
msgid "Journal Entries"
msgstr ""
33 changes: 33 additions & 0 deletions account_payment_term_security/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_payment_term_security
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: \n"
"PO-Revision-Date: 2023-02-06 15:25+0100\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: \n"
"X-Generator: Poedit 3.0.1\n"

#. module: account_payment_term_security
#: model:res.groups,name:account_payment_term_security.account_payment_term_mgmt
msgid "Change payment terms in partners and invoices"
msgstr "Cambiar plazos de pago en contactos y facturas"

#. module: account_payment_term_security
#: model:ir.model,name:account_payment_term_security.model_res_partner
msgid "Contact"
msgstr "Contacto"

#. module: account_payment_term_security
#: model:ir.model,name:account_payment_term_security.model_account_move
msgid "Journal Entries"
msgstr "Asientos contables"
2 changes: 2 additions & 0 deletions account_payment_term_security/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import account_move
from . import res_partner
31 changes: 31 additions & 0 deletions account_payment_term_security/models/account_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2023 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
import json

from lxml import etree

from odoo import api, models


class AccountMove(models.Model):
_inherit = "account.move"

@api.model
def fields_view_get(
self, view_id=None, view_type="form", toolbar=False, submenu=False
):
res = super().fields_view_get(
view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu
)
group = "account_payment_term_security.account_payment_term_mgmt"
if view_type == "form" and not self.env.user.has_group(group):
doc = etree.XML(res["arch"])
for node in doc.xpath("//field[@name='invoice_payment_term_id']"):
node.set("readonly", "1")
node.set("force_save", "1")
modifiers = json.loads(node.get("modifiers"))
modifiers["readonly"] = True
modifiers["force_save"] = 1
node.set("modifiers", json.dumps(modifiers))
res["arch"] = etree.tostring(doc, encoding="unicode")
return res
38 changes: 38 additions & 0 deletions account_payment_term_security/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2023 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
import json

from lxml import etree

from odoo import api, models


class ResPartner(models.Model):
_inherit = "res.partner"

@api.model
def fields_view_get(
self, view_id=None, view_type="form", toolbar=False, submenu=False
):
res = super().fields_view_get(
view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu
)
group = "account_payment_term_security.account_payment_term_mgmt"
if view_type == "form" and not self.env.user.has_group(group):
doc = etree.XML(res["arch"])
for node in doc.xpath("//field[@name='property_payment_term_id']"):
node.set("readonly", "1")
node.set("force_save", "1")
modifiers = json.loads(node.get("modifiers"))
modifiers["readonly"] = True
modifiers["force_save"] = 1
node.set("modifiers", json.dumps(modifiers))
for node in doc.xpath("//field[@name='property_supplier_payment_term_id']"):
node.set("readonly", "1")
node.set("force_save", "1")
modifiers = json.loads(node.get("modifiers"))
modifiers["readonly"] = True
modifiers["force_save"] = 1
node.set("modifiers", json.dumps(modifiers))
res["arch"] = etree.tostring(doc, encoding="unicode")
return res
3 changes: 3 additions & 0 deletions account_payment_term_security/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
To use this module, you need to :

Go to Settings > Users & Companies > Users (edit your user) > Set "Change payment terms in partners and invoices" option.
4 changes: 4 additions & 0 deletions account_payment_term_security/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* `Tecnativa <https://www.tecnativa.com>`:

* Pedro M. Baeza
* Víctor Martínez
1 change: 1 addition & 0 deletions account_payment_term_security/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
In partners and invoices, payment terms can only be changed when the user has permission "Change payment terms in partners and invoices".
12 changes: 12 additions & 0 deletions account_payment_term_security/security/security.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="account_payment_term_mgmt" model="res.groups">
<field name="name">Change payment terms in partners and invoices</field>
<field name="category_id" ref="base.module_category_hidden" />
<field name="implied_ids" eval="[(4, ref('account.group_account_invoice'))]" />
<field
name="users"
eval="[(4, ref('base.user_root')), (4, ref('base.user_admin'))]"
/>
</record>
</odoo>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading