[ADD] create sale_outstanding add-on

This commit is contained in:
Stéphan Sainléger
2022-10-09 11:27:29 +02:00
parent dae461b8d9
commit 867e3af50a
10 changed files with 266 additions and 0 deletions

2
sale_outstanding/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
*.*~
*pyc

View File

@@ -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 <https://github.com/elabore-coop/sale-tools/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
=======
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.

View File

@@ -0,0 +1 @@
from . import models

View File

@@ -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,
}

View File

@@ -0,0 +1 @@
This directory should contain the *.po for Odoo translation.

View File

@@ -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"

View File

@@ -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 ""

View File

@@ -0,0 +1 @@
from . import sale

View File

@@ -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")

View File

@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<record id="view_order_form_inherit_outstanding" model="ir.ui.view">
<field name="name">sale.order.view.form.inherit</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form" />
<field name="arch" type="xml">
<field name="amount_untaxed" position="after">
<field name="sum_outstanding" />
<field name="sum_pending_work" />
</field>
</field>
</record>
<record id="view_order_tree_inherit_outstanding" model="ir.ui.view">
<field name="name">sale.order.tree.outstanding</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_tree" />
<field name="arch" type="xml">
<xpath expr="//field[@name='amount_tax']" position="after">
<field name="sum_outstanding" sum="Outstanding Total" optional="hide" />
<field name="sum_pending_work" sum="Pending work Total" optional="hide" />
</xpath>
</field>
</record>
<record id="view_quotation_tree_inherit_outstanding" model="ir.ui.view">
<field name="name">quotation.tree.outstanding</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_quotation_tree" />
<field name="arch" type="xml">
<xpath expr="//field[@name='amount_tax']" position="after">
<field name="sum_outstanding" sum="Outstanding Total" optional="hide" />
<field name="sum_pending_work" sum="Pending work Total" optional="hide" />
</xpath>
</field>
</record>
</odoo>