From 867e3af50a24d4d0bda9053e46505c3e987bff3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phan=20Sainl=C3=A9ger?= Date: Sun, 9 Oct 2022 11:27:29 +0200 Subject: [PATCH] [ADD] create `sale_outstanding` add-on --- sale_outstanding/.gitignore | 2 + sale_outstanding/README.rst | 44 +++++++++++++++ sale_outstanding/__init__.py | 1 + sale_outstanding/__manifest__.py | 34 ++++++++++++ sale_outstanding/i18n/README | 1 + sale_outstanding/i18n/fr.po | 62 ++++++++++++++++++++++ sale_outstanding/i18n/sale_outstanding.pot | 62 ++++++++++++++++++++++ sale_outstanding/models/__init__.py | 1 + sale_outstanding/models/sale.py | 21 ++++++++ sale_outstanding/views/sale_views.xml | 38 +++++++++++++ 10 files changed, 266 insertions(+) create mode 100644 sale_outstanding/.gitignore create mode 100644 sale_outstanding/README.rst create mode 100644 sale_outstanding/__init__.py create mode 100644 sale_outstanding/__manifest__.py create mode 100644 sale_outstanding/i18n/README create mode 100644 sale_outstanding/i18n/fr.po create mode 100644 sale_outstanding/i18n/sale_outstanding.pot create mode 100644 sale_outstanding/models/__init__.py create mode 100644 sale_outstanding/models/sale.py create mode 100644 sale_outstanding/views/sale_views.xml diff --git a/sale_outstanding/.gitignore b/sale_outstanding/.gitignore new file mode 100644 index 0000000..6da5887 --- /dev/null +++ b/sale_outstanding/.gitignore @@ -0,0 +1,2 @@ +*.*~ +*pyc diff --git a/sale_outstanding/README.rst b/sale_outstanding/README.rst new file mode 100644 index 0000000..8ae1dc9 --- /dev/null +++ b/sale_outstanding/README.rst @@ -0,0 +1,44 @@ +================ +sale_outstanding +================ + +Calculates and displays the sale order outstanding and pending work. + +Installation +============ + +Use Odoo normal module installation procedure to install +``sale_outstanding``. + +Known issues / Roadmap +====================== + +None yet. +Bug Tracker +=========== + +Bugs are tracked on `our issues website `_. 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 +------------ + +* Stéphan Sainléger + +Funders +------- + +The development of this module has been financially supported by: +* Elabore (https://elabore.coop) +* Datactivist (https://datactivist.coop) + + +Maintainer +---------- + +This module is maintained by Elabore. diff --git a/sale_outstanding/__init__.py b/sale_outstanding/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/sale_outstanding/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/sale_outstanding/__manifest__.py b/sale_outstanding/__manifest__.py new file mode 100644 index 0000000..0e92ba7 --- /dev/null +++ b/sale_outstanding/__manifest__.py @@ -0,0 +1,34 @@ +# Copyright 2022 Stéphan Sainléger (Elabore) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "sale_outstanding", + "version": "14.0.1.0.0", + "author": "Elabore", + "website": "https://elabore.coop", + "maintainer": "Stéphan Sainléger", + "license": "AGPL-3", + "category": "Tools", + "summary": "Calculates and displays the sale order outstanding and pending work.", + # any module necessary for this one to work correctly + "depends": [ + "base", "sale" + ], + "qweb": [], + "external_dependencies": { + "python": [], + }, + # always loaded + "data": [ + "views/sale_views.xml", + ], + # only loaded in demonstration mode + "demo": [], + "js": [], + "css": [], + "installable": True, + # Install this module automatically if all dependency have been previously + # and independently installed. Used for synergetic or glue modules. + "auto_install": False, + "application": False, +} \ No newline at end of file diff --git a/sale_outstanding/i18n/README b/sale_outstanding/i18n/README new file mode 100644 index 0000000..62197a1 --- /dev/null +++ b/sale_outstanding/i18n/README @@ -0,0 +1 @@ +This directory should contain the *.po for Odoo translation. diff --git a/sale_outstanding/i18n/fr.po b/sale_outstanding/i18n/fr.po new file mode 100644 index 0000000..4e3a9d0 --- /dev/null +++ b/sale_outstanding/i18n/fr.po @@ -0,0 +1,62 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_outstanding +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2022-11-24 18:04+0000\n" +"PO-Revision-Date: 2022-11-24 18:04+0000\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: sale_outstanding +#: model:ir.model.fields,field_description:sale_outstanding.field_sale_order__display_name +msgid "Display Name" +msgstr "Nom affiché" + +#. module: sale_outstanding +#: model:ir.model.fields,field_description:sale_outstanding.field_sale_order__id +msgid "ID" +msgstr "" + +#. module: sale_outstanding +#: model:ir.model.fields,field_description:sale_outstanding.field_sale_order____last_update +msgid "Last Modified on" +msgstr "Dernière modification le" + +#. module: sale_outstanding +#: model_terms:ir.ui.view,arch_db:sale_outstanding.view_order_tree_inherit_outstanding +#: model_terms:ir.ui.view,arch_db:sale_outstanding.view_quotation_tree_inherit_outstanding +msgid "Outstanding Total" +msgstr "Total en cours HT" + +#. module: sale_outstanding +#: code:addons/sale_outstanding/models/sale.py:0 +#: model:ir.model.fields,field_description:sale_outstanding.field_sale_order__sum_outstanding +#, python-format +msgid "Outstanding Untaxed" +msgstr "En cours HT" + +#. module: sale_outstanding +#: model_terms:ir.ui.view,arch_db:sale_outstanding.view_order_tree_inherit_outstanding +#: model_terms:ir.ui.view,arch_db:sale_outstanding.view_quotation_tree_inherit_outstanding +msgid "Pending work Total" +msgstr "Total Reste à produire HT" + +#. module: sale_outstanding +#: model:ir.model,name:sale_outstanding.model_sale_order +msgid "Sales Order" +msgstr "Bon de commande" + +#. module: sale_outstanding +#: code:addons/sale_outstanding/models/sale.py:0 +#: model:ir.model.fields,field_description:sale_outstanding.field_sale_order__sum_pending_work +#, python-format +msgid "To Do Untaxed" +msgstr "Reste à produire HT" diff --git a/sale_outstanding/i18n/sale_outstanding.pot b/sale_outstanding/i18n/sale_outstanding.pot new file mode 100644 index 0000000..bb1fa8a --- /dev/null +++ b/sale_outstanding/i18n/sale_outstanding.pot @@ -0,0 +1,62 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_outstanding +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2022-11-24 18:02+0000\n" +"PO-Revision-Date: 2022-11-24 18:02+0000\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: sale_outstanding +#: model:ir.model.fields,field_description:sale_outstanding.field_sale_order__display_name +msgid "Display Name" +msgstr "" + +#. module: sale_outstanding +#: model:ir.model.fields,field_description:sale_outstanding.field_sale_order__id +msgid "ID" +msgstr "" + +#. module: sale_outstanding +#: model:ir.model.fields,field_description:sale_outstanding.field_sale_order____last_update +msgid "Last Modified on" +msgstr "" + +#. module: sale_outstanding +#: model_terms:ir.ui.view,arch_db:sale_outstanding.view_order_tree_inherit_outstanding +#: model_terms:ir.ui.view,arch_db:sale_outstanding.view_quotation_tree_inherit_outstanding +msgid "Outstanding Total" +msgstr "" + +#. module: sale_outstanding +#: code:addons/sale_outstanding/models/sale.py:0 +#: model:ir.model.fields,field_description:sale_outstanding.field_sale_order__sum_outstanding +#, python-format +msgid "Outstanding Untaxed" +msgstr "" + +#. module: sale_outstanding +#: model_terms:ir.ui.view,arch_db:sale_outstanding.view_order_tree_inherit_outstanding +#: model_terms:ir.ui.view,arch_db:sale_outstanding.view_quotation_tree_inherit_outstanding +msgid "Pending work Total" +msgstr "" + +#. module: sale_outstanding +#: model:ir.model,name:sale_outstanding.model_sale_order +msgid "Sales Order" +msgstr "" + +#. module: sale_outstanding +#: code:addons/sale_outstanding/models/sale.py:0 +#: model:ir.model.fields,field_description:sale_outstanding.field_sale_order__sum_pending_work +#, python-format +msgid "To Do Untaxed" +msgstr "" diff --git a/sale_outstanding/models/__init__.py b/sale_outstanding/models/__init__.py new file mode 100644 index 0000000..7d5ef02 --- /dev/null +++ b/sale_outstanding/models/__init__.py @@ -0,0 +1 @@ +from . import sale \ No newline at end of file diff --git a/sale_outstanding/models/sale.py b/sale_outstanding/models/sale.py new file mode 100644 index 0000000..abe5f6c --- /dev/null +++ b/sale_outstanding/models/sale.py @@ -0,0 +1,21 @@ +from odoo import _, api, fields, models + +class SaleOrder(models.Model): + _inherit = "sale.order" + + @api.depends("order_line.qty_delivered", "order_line.qty_invoiced", "order_line.qty_to_invoice", "order_line.price_unit") + def _compute_sum_outstanding(self): + for order in self: + lines_outstanding = order.order_line.mapped(lambda r:(r.qty_to_invoice * r.price_unit)) + order["sum_outstanding"] = sum(lines_outstanding) + + @api.depends("order_line.qty_delivered", "order_line.product_uom_qty", "order_line.price_unit") + def _compute_sum_pending_work(self): + for order in self: + lines_pending_work = order.order_line.mapped(lambda r:((r.product_uom_qty - r.qty_delivered) * r.price_unit)) + order["sum_pending_work"] = sum(lines_pending_work) + + + sum_outstanding = fields.Monetary(_("Outstanding Untaxed"), readonly=True, store=True, compute="_compute_sum_outstanding") + sum_pending_work = fields.Monetary(_("To Do Untaxed"), readonly=True, store=True, compute="_compute_sum_pending_work") + diff --git a/sale_outstanding/views/sale_views.xml b/sale_outstanding/views/sale_views.xml new file mode 100644 index 0000000..3391897 --- /dev/null +++ b/sale_outstanding/views/sale_views.xml @@ -0,0 +1,38 @@ + + + + sale.order.view.form.inherit + sale.order + + + + + + + + + + + sale.order.tree.outstanding + sale.order + + + + + + + + + + + quotation.tree.outstanding + sale.order + + + + + + + + + \ No newline at end of file