From 69fbf8f2db4a5c2d0655b035f03c5bc662b043dc Mon Sep 17 00:00:00 2001 From: Vincent Van Rossem Date: Tue, 22 Sep 2020 13:03:10 +0200 Subject: [PATCH] [ADD] beesdoo_purchase: allow inverting of PO ref on inv line --- beesdoo_purchase/README.rst | 1 + beesdoo_purchase/__manifest__.py | 14 +++++++---- beesdoo_purchase/models/__init__.py | 2 ++ beesdoo_purchase/models/account_invoice.py | 14 +++++++++++ beesdoo_purchase/models/res_config.py | 14 +++++++++++ beesdoo_purchase/readme/DESCRIPTION.rst | 1 + .../security/invoice_security.xml | 9 ++++++++ .../static/description/index.html | 18 ++++++++++----- .../views/res_config_settings_view.xml | 23 +++++++++++++++++++ 9 files changed, 86 insertions(+), 10 deletions(-) create mode 100644 beesdoo_purchase/models/account_invoice.py create mode 100644 beesdoo_purchase/models/res_config.py create mode 100644 beesdoo_purchase/security/invoice_security.xml create mode 100644 beesdoo_purchase/views/res_config_settings_view.xml diff --git a/beesdoo_purchase/README.rst b/beesdoo_purchase/README.rst index 9570923..b268c6b 100644 --- a/beesdoo_purchase/README.rst +++ b/beesdoo_purchase/README.rst @@ -27,6 +27,7 @@ create_uid ORM field. His user's contact info is printed on purchases orders as 'Referent'. - A filter w.r.t. the mail sellers is placed on the products field of a purchase order. +- Allow inverting the Purchase Order Reference on the invoice lines. **Table of contents** diff --git a/beesdoo_purchase/__manifest__.py b/beesdoo_purchase/__manifest__.py index 54c42a7..eaf8630 100644 --- a/beesdoo_purchase/__manifest__.py +++ b/beesdoo_purchase/__manifest__.py @@ -1,15 +1,21 @@ { "name": "Bees Purchase", "summary": """ - - Adds a 'Responsible' field to purchase orders, + - Adds a 'Responsible' field to purchase orders - A filter w.r.t. the mail sellers is placed on the products field of a - purchase order. + purchase order + - Allow inverting the Purchase Order Reference on the invoice lines """, "author": "Beescoop - Cellule IT, " "Coop IT Easy SCRLfs", "website": "https://github.com/beescoop/Obeesdoo", "category": "Purchase", - "version": "12.0.1.1.0", + "version": "12.0.1.2.0", "depends": ["base", "purchase", "beesdoo_product"], - "data": ["views/purchase_order.xml", "report/report_purchaseorder.xml"], + "data": [ + "security/invoice_security.xml", + "views/purchase_order.xml", + "views/res_config_settings_view.xml", + "report/report_purchaseorder.xml", + ], "license": "AGPL-3", } diff --git a/beesdoo_purchase/models/__init__.py b/beesdoo_purchase/models/__init__.py index 370f577..118e747 100644 --- a/beesdoo_purchase/models/__init__.py +++ b/beesdoo_purchase/models/__init__.py @@ -1 +1,3 @@ +from . import account_invoice from . import purchase +from . import res_config \ No newline at end of file diff --git a/beesdoo_purchase/models/account_invoice.py b/beesdoo_purchase/models/account_invoice.py new file mode 100644 index 0000000..f6cc57a --- /dev/null +++ b/beesdoo_purchase/models/account_invoice.py @@ -0,0 +1,14 @@ +from odoo import api, fields, models, _ + + +class AccountInvoice(models.Model): + _inherit = 'account.invoice' + + def _prepare_invoice_line_from_po_line(self, line): + """ Override parent's method to invert Purchase Order Reference on invoice line""" + invoice_line = super(AccountInvoice, self)._prepare_invoice_line_from_po_line(line) + if self.user_has_groups( + 'beesdoo_purchase.' + 'group_invert_po_ref_on_inv_line'): + invoice_line['name'] = line.name + ': ' + line.order_id.name + return invoice_line \ No newline at end of file diff --git a/beesdoo_purchase/models/res_config.py b/beesdoo_purchase/models/res_config.py new file mode 100644 index 0000000..f6f4fc0 --- /dev/null +++ b/beesdoo_purchase/models/res_config.py @@ -0,0 +1,14 @@ +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + _inherit = 'res.config.settings' + + group_invert_po_ref_on_inv_line = fields.Boolean( + """Allow inverting the Purchase Order Reference on the + invoice lines""", + implied_group="beesdoo_purchase." + "group_invert_po_ref_on_inv_line", + help="""Allows you to invert Purchase Order Reference on the + invoice lines.""" + ) diff --git a/beesdoo_purchase/readme/DESCRIPTION.rst b/beesdoo_purchase/readme/DESCRIPTION.rst index 6d9e566..8accc85 100644 --- a/beesdoo_purchase/readme/DESCRIPTION.rst +++ b/beesdoo_purchase/readme/DESCRIPTION.rst @@ -6,3 +6,4 @@ create_uid ORM field. His user's contact info is printed on purchases orders as 'Referent'. - A filter w.r.t. the mail sellers is placed on the products field of a purchase order. +- Allow inverting the Purchase Order Reference on the invoice lines. diff --git a/beesdoo_purchase/security/invoice_security.xml b/beesdoo_purchase/security/invoice_security.xml new file mode 100644 index 0000000..344d146 --- /dev/null +++ b/beesdoo_purchase/security/invoice_security.xml @@ -0,0 +1,9 @@ + + + + + Invert Purchase Order Reference on invoice line + + + + diff --git a/beesdoo_purchase/static/description/index.html b/beesdoo_purchase/static/description/index.html index 5572fa8..9b5edf1 100644 --- a/beesdoo_purchase/static/description/index.html +++ b/beesdoo_purchase/static/description/index.html @@ -367,7 +367,7 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 beescoop/obeesdoo

+

Beta License: AGPL-3 OCA/obeesdoo Translate me on Weblate

Extends Purchase module: - Adds a ‘Responsible’ field to purchase orders: This is a user who will follow up the order. This users replaces @@ -375,7 +375,8 @@ the creator in the order’s mail messages followers list, and in the create_uid ORM field. His user’s contact info is printed on purchases orders as ‘Referent’. - A filter w.r.t. the mail sellers is placed on the products field of a -purchase order.

+purchase order. +- Allow inverting the Purchase Order Reference on the invoice lines.

Table of contents

Bug Tracker

-

Bugs are tracked on GitHub Issues. +

Bugs are tracked on GitHub 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.

+feedback.

Do not contact contributors directly about support or help with technical issues.

@@ -414,8 +415,13 @@ If you spotted it first, help us smashing it by providing a detailed and welcome

Maintainers

-

This module is part of the beescoop/obeesdoo project on GitHub.

-

You are welcome to contribute.

+

This module is maintained by the OCA.

+Odoo Community Association +

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/obeesdoo project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/beesdoo_purchase/views/res_config_settings_view.xml b/beesdoo_purchase/views/res_config_settings_view.xml new file mode 100644 index 0000000..a2d4731 --- /dev/null +++ b/beesdoo_purchase/views/res_config_settings_view.xml @@ -0,0 +1,23 @@ + + + + + res invoice line description settings + res.config.settings + + + +
+
+ +
+
+
+
+
+
+
+