Initial commit: OCA Technical packages (595 packages)

This commit is contained in:
Ernad Husremovic 2025-08-29 15:43:03 +02:00
commit 2cc02aac6e
24950 changed files with 2318079 additions and 0 deletions

View file

@ -0,0 +1,131 @@
================
PoS Order Margin
================
..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:9cafdf6c20cc9a805b5be0f86d884dd9ee484f0f129813b1c287c7711e1a9297
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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%2Fpos-lightgray.png?logo=github
:target: https://github.com/OCA/pos/tree/16.0/pos_margin
:alt: OCA/pos
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/pos-16-0/pos-16-0-pos_margin
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/pos&target_branch=16.0
:alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5|
This module shows margins in PoS frontend during an order creation.
**Table of contents**
.. contents::
:local:
Configuration
=============
* If you want to disable the display of the margin, in the front-office UI, you can
uncheck the check box in the `res.config.settings` shop form:
.. figure:: https://raw.githubusercontent.com/OCA/pos/16.0/pos_margin/static/description/pos_config_setting.png
Known issues / Roadmap
======================
This dependency can be removed, when Odoo Core will be correctly refactored,
moving this ``@api.model`` function in a more generic module (``account``
for exemple).
Changelog
=========
16.0.1.0.0
~~~~~~~~~~
* Migrate to V16.0
* Remove ``pos.order`` and ``pos.order.line`` funcionality from V14.0.
It's already done by V16.0.
* Remove tests.
* Create a ``res.config.settings`` field `pos_iface_display_margin`
to display margins in PoS frontend.
14.0.1.0.0
~~~~~~~~~~
* Migrate to V14.0
13.0.1.0.0
~~~~~~~~~~
* Migrate to V13.0
* Reuse ``sale_margin`` computation to handle multi currency context.
* Correct computation of margin, if a module that adds ``uom_id`` on
``pos.order.line`` is installed.
* Add test
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/pos/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/pos/issues/new?body=module:%20pos_margin%0Aversion:%2016.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
~~~~~~~
* GRAP
* FactorLibre
Contributors
~~~~~~~~~~~~
* Sylvain LE GAL (https://twitter.com/legalsylvain)
* Wolfgang Pichler
* Murtaza Mithaiwala (https://twitter.com/MurtazaMithaiw4)
* Dhara Solanki <dhara.solanki@initos.com>
* Juan Carlos Bonilla <juancarlos.bonilla@factorlibre.com>
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.
.. |maintainer-legalsylvain| image:: https://github.com/legalsylvain.png?size=40px
:target: https://github.com/legalsylvain
:alt: legalsylvain
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|maintainer-legalsylvain|
This module is part of the `OCA/pos <https://github.com/OCA/pos/tree/16.0/pos_margin>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View file

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

View file

@ -0,0 +1,30 @@
# Copyright (C) 2023 - Today: GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "PoS Order Margin",
"summary": "Margin on PoS Order",
"version": "16.0.1.0.2",
"category": "Point Of Sale",
"author": "GRAP, FactorLibre, Odoo Community Association (OCA)",
"maintainers": ["legalsylvain"],
"website": "https://github.com/OCA/pos",
"license": "AGPL-3",
"depends": [
"point_of_sale",
],
"data": [
"views/res_config_settings_view.xml",
"views/view_pos_order.xml",
],
"assets": {
"point_of_sale.assets": [
"pos_margin/static/src/xml/*.xml",
"pos_margin/static/src/js/models.esm.js",
"pos_margin/static/src/js/OrderSummaryMargin.esm.js",
"pos_margin/static/src/css/*.css",
],
},
"installable": True,
}

View file

@ -0,0 +1,59 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_margin
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.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: pos_margin
#: model:ir.model,name:pos_margin.model_res_config_settings
msgid "Config Settings"
msgstr "Postavke"
#. module: pos_margin
#: model:ir.model.fields,field_description:pos_margin.field_pos_config__iface_display_margin
#: model:ir.model.fields,field_description:pos_margin.field_res_config_settings__pos_iface_display_margin
msgid "Diplay Margin"
msgstr "Diplay Margin"
#. module: pos_margin
#: model:ir.model.fields,help:pos_margin.field_pos_config__iface_display_margin
#: model:ir.model.fields,help:pos_margin.field_res_config_settings__pos_iface_display_margin
#: model_terms:ir.ui.view,arch_db:pos_margin.res_config_settings_view_form_margin_inherit
msgid "Display Margin and Margin Rate in the frontend"
msgstr "Display Margin and Margin Rate in the frontend"
#. module: pos_margin
#: model:ir.model.fields,field_description:pos_margin.field_report_pos_order__margin_rate
msgid "Margin Rate (%)"
msgstr "Margin Rate (%)"
#. module: pos_margin
#: model_terms:ir.ui.view,arch_db:pos_margin.view_pos_order_tree_inherit
msgid "Margin Total"
msgstr "Margin Total"
#. module: pos_margin
#. odoo-javascript
#: code:addons/pos_margin/static/src/xml/pos_margin.xml:0
#, python-format
msgid "Margin:"
msgstr "Marža:"
#. module: pos_margin
#: model:ir.model,name:pos_margin.model_pos_config
msgid "Point of Sale Configuration"
msgstr "Postavke prodajnog mjesta"
#. module: pos_margin
#: model:ir.model,name:pos_margin.model_report_pos_order
msgid "Point of Sale Orders Report"
msgstr "Izvješće o narudžbama na prodajnim mjestima"

View file

@ -0,0 +1,81 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_margin
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-01-22 22:22+0000\n"
"PO-Revision-Date: 2023-01-22 22:22+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: pos_margin
#: model:ir.model,name:pos_margin.model_res_config_settings
msgid "Config Settings"
msgstr "Opciones de configuración"
#. module: pos_margin
#: model:ir.model.fields,field_description:pos_margin.field_pos_config__iface_display_margin
#: model:ir.model.fields,field_description:pos_margin.field_res_config_settings__pos_iface_display_margin
msgid "Diplay Margin"
msgstr "Mostrar margen"
#. module: pos_margin
#: model:ir.model.fields,help:pos_margin.field_pos_config__iface_display_margin
#: model:ir.model.fields,help:pos_margin.field_res_config_settings__pos_iface_display_margin
#: model_terms:ir.ui.view,arch_db:pos_margin.res_config_settings_view_form_margin_inherit
msgid "Display Margin and Margin Rate in the frontend"
msgstr "Mostrar margen y tasa de margen en el frontend"
#. module: pos_margin
#: model:ir.model.fields,field_description:pos_margin.field_report_pos_order__margin_rate
msgid "Margin Rate (%)"
msgstr "Tasa de Margen (%)"
#. module: pos_margin
#: model_terms:ir.ui.view,arch_db:pos_margin.view_pos_order_tree_inherit
msgid "Margin Total"
msgstr "Margen total"
#. module: pos_margin
#. odoo-javascript
#: code:addons/pos_margin/static/src/xml/pos_margin.xml:0
#, python-format
msgid "Margin:"
msgstr "Margen:"
#. module: pos_margin
#: model:ir.model,name:pos_margin.model_pos_config
msgid "Point of Sale Configuration"
msgstr "Configuración del TPV"
#. module: pos_margin
#: model:ir.model,name:pos_margin.model_report_pos_order
msgid "Point of Sale Orders Report"
msgstr "Informe de Órdenes del Punto de Venta"
#~ msgid "Cost Price"
#~ msgstr "Precio de coste"
#~ msgid ""
#~ "It gives profitability by calculating the difference between the Unit "
#~ "Price and the cost price."
#~ msgstr ""
#~ "Indica el beneficio calculando la diferencia entre el precio unitario y "
#~ "el precio de coste."
#~ msgid "Margin"
#~ msgstr "Margen"
#~ msgid "Point of Sale Order Lines"
#~ msgstr "Líneas de Orden de Punto de Venta"
#~ msgid "Point of Sale Orders"
#~ msgstr "Pedidos del TPV"

View file

@ -0,0 +1,62 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_margin
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-08-01 12:09+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"
#. module: pos_margin
#: model:ir.model,name:pos_margin.model_res_config_settings
msgid "Config Settings"
msgstr "Impostazioni configurazione"
#. module: pos_margin
#: model:ir.model.fields,field_description:pos_margin.field_pos_config__iface_display_margin
#: model:ir.model.fields,field_description:pos_margin.field_res_config_settings__pos_iface_display_margin
msgid "Diplay Margin"
msgstr "Visualizza margine"
#. module: pos_margin
#: model:ir.model.fields,help:pos_margin.field_pos_config__iface_display_margin
#: model:ir.model.fields,help:pos_margin.field_res_config_settings__pos_iface_display_margin
#: model_terms:ir.ui.view,arch_db:pos_margin.res_config_settings_view_form_margin_inherit
msgid "Display Margin and Margin Rate in the frontend"
msgstr "Visualizza margine e aliquota margine sul frontend"
#. module: pos_margin
#: model:ir.model.fields,field_description:pos_margin.field_report_pos_order__margin_rate
msgid "Margin Rate (%)"
msgstr "Aliquota margine (%)"
#. module: pos_margin
#: model_terms:ir.ui.view,arch_db:pos_margin.view_pos_order_tree_inherit
msgid "Margin Total"
msgstr "Totale margine"
#. module: pos_margin
#. odoo-javascript
#: code:addons/pos_margin/static/src/xml/pos_margin.xml:0
#, python-format
msgid "Margin:"
msgstr "Margine:"
#. module: pos_margin
#: model:ir.model,name:pos_margin.model_pos_config
msgid "Point of Sale Configuration"
msgstr "Configurazione punto vendita"
#. module: pos_margin
#: model:ir.model,name:pos_margin.model_report_pos_order
msgid "Point of Sale Orders Report"
msgstr "Resoconto ordini punto vendita"

View file

@ -0,0 +1,59 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_margin
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.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: pos_margin
#: model:ir.model,name:pos_margin.model_res_config_settings
msgid "Config Settings"
msgstr ""
#. module: pos_margin
#: model:ir.model.fields,field_description:pos_margin.field_pos_config__iface_display_margin
#: model:ir.model.fields,field_description:pos_margin.field_res_config_settings__pos_iface_display_margin
msgid "Diplay Margin"
msgstr ""
#. module: pos_margin
#: model:ir.model.fields,help:pos_margin.field_pos_config__iface_display_margin
#: model:ir.model.fields,help:pos_margin.field_res_config_settings__pos_iface_display_margin
#: model_terms:ir.ui.view,arch_db:pos_margin.res_config_settings_view_form_margin_inherit
msgid "Display Margin and Margin Rate in the frontend"
msgstr ""
#. module: pos_margin
#: model:ir.model.fields,field_description:pos_margin.field_report_pos_order__margin_rate
msgid "Margin Rate (%)"
msgstr ""
#. module: pos_margin
#: model_terms:ir.ui.view,arch_db:pos_margin.view_pos_order_tree_inherit
msgid "Margin Total"
msgstr ""
#. module: pos_margin
#. odoo-javascript
#: code:addons/pos_margin/static/src/xml/pos_margin.xml:0
#, python-format
msgid "Margin:"
msgstr ""
#. module: pos_margin
#: model:ir.model,name:pos_margin.model_pos_config
msgid "Point of Sale Configuration"
msgstr ""
#. module: pos_margin
#: model:ir.model,name:pos_margin.model_report_pos_order
msgid "Point of Sale Orders Report"
msgstr ""

View file

@ -0,0 +1,6 @@
# Copyright (C) 2023 - Today: GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import pos_config
from . import res_config_settings

View file

@ -0,0 +1,15 @@
# Copyright (C) 2023 - Today: GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import fields, models
class PosConfig(models.Model):
_inherit = "pos.config"
iface_display_margin = fields.Boolean(
string="Diplay Margin",
help="Display Margin and Margin Rate in the frontend",
default=True,
)

View file

@ -0,0 +1,14 @@
# Copyright (C) 2023 - Today: GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import fields, models
class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"
pos_iface_display_margin = fields.Boolean(
related="pos_config_id.iface_display_margin",
readonly=False,
)

View file

@ -0,0 +1,4 @@
* If you want to disable the display of the margin, in the front-office UI, you can
uncheck the check box in the `res.config.settings` shop form:
.. figure:: ../static/description/pos_config_setting.png

View file

@ -0,0 +1,5 @@
* Sylvain LE GAL (https://twitter.com/legalsylvain)
* Wolfgang Pichler
* Murtaza Mithaiwala (https://twitter.com/MurtazaMithaiw4)
* Dhara Solanki <dhara.solanki@initos.com>
* Juan Carlos Bonilla <juancarlos.bonilla@factorlibre.com>

View file

@ -0,0 +1 @@
This module shows margins in PoS frontend during an order creation.

View file

@ -0,0 +1,23 @@
16.0.1.0.0
~~~~~~~~~~
* Migrate to V16.0
* Remove ``pos.order`` and ``pos.order.line`` funcionality from V14.0.
It's already done by V16.0.
* Remove tests.
* Create a ``res.config.settings`` field `pos_iface_display_margin`
to display margins in PoS frontend.
14.0.1.0.0
~~~~~~~~~~
* Migrate to V14.0
13.0.1.0.0
~~~~~~~~~~
* Migrate to V13.0
* Reuse ``sale_margin`` computation to handle multi currency context.
* Correct computation of margin, if a module that adds ``uom_id`` on
``pos.order.line`` is installed.
* Add test

View file

@ -0,0 +1,3 @@
This dependency can be removed, when Odoo Core will be correctly refactored,
moving this ``@api.model`` function in a more generic module (``account``
for exemple).

View file

@ -0,0 +1,5 @@
# Copyright (C) 2023 - Today: GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import pos_order_report

View file

@ -0,0 +1,28 @@
# Copyright (C) 2023 - Today: GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import fields, models
class PosOrderReport(models.Model):
_inherit = "report.pos.order"
margin_rate = fields.Float(string="Margin Rate (%)", group_operator="avg")
def _select(self):
return (
super(PosOrderReport, self)._select()
+ """,
SUM(l.price_subtotal - l.total_cost / CASE COALESCE(s.currency_rate, 0)
WHEN 0 THEN 1.0 ELSE s.currency_rate END) / NULLIF(SUM(l.price_subtotal), 0) * 100
AS margin_rate
"""
)
def _group_by(self):
group_by_append = """,
l.price_subtotal,
l.total_cost
"""
return super(PosOrderReport, self)._group_by() + group_by_append

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

View file

@ -0,0 +1,481 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>PoS Order Margin</title>
<style type="text/css">
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/
/* used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
border: 0 }
table.borderless td, table.borderless th {
/* Override padding for "table.docutils td" with "! important".
The right padding separates the table cells. */
padding: 0 0.5em 0 0 ! important }
.first {
/* Override more specific margin styles with "! important". */
margin-top: 0 ! important }
.last, .with-subtitle {
margin-bottom: 0 ! important }
.hidden {
display: none }
.subscript {
vertical-align: sub;
font-size: smaller }
.superscript {
vertical-align: super;
font-size: smaller }
a.toc-backref {
text-decoration: none ;
color: black }
blockquote.epigraph {
margin: 2em 5em ; }
dl.docutils dd {
margin-bottom: 0.5em }
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
overflow: hidden;
}
/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
font-weight: bold }
*/
div.abstract {
margin: 2em 5em }
div.abstract p.topic-title {
font-weight: bold ;
text-align: center }
div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
margin: 2em ;
border: medium outset ;
padding: 1em }
div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
font-weight: bold ;
font-family: sans-serif }
div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title, .code .error {
color: red ;
font-weight: bold ;
font-family: sans-serif }
/* Uncomment (and remove this text!) to get reduced vertical space in
compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
margin-bottom: 0.5em }
div.compound .compound-last, div.compound .compound-middle {
margin-top: 0.5em }
*/
div.dedication {
margin: 2em 5em ;
text-align: center ;
font-style: italic }
div.dedication p.topic-title {
font-weight: bold ;
font-style: normal }
div.figure {
margin-left: 2em ;
margin-right: 2em }
div.footer, div.header {
clear: both;
font-size: smaller }
div.line-block {
display: block ;
margin-top: 1em ;
margin-bottom: 1em }
div.line-block div.line-block {
margin-top: 0 ;
margin-bottom: 0 ;
margin-left: 1.5em }
div.sidebar {
margin: 0 0 0.5em 1em ;
border: medium outset ;
padding: 1em ;
background-color: #ffffee ;
width: 40% ;
float: right ;
clear: right }
div.sidebar p.rubric {
font-family: sans-serif ;
font-size: medium }
div.system-messages {
margin: 5em }
div.system-messages h1 {
color: red }
div.system-message {
border: medium outset ;
padding: 1em }
div.system-message p.system-message-title {
color: red ;
font-weight: bold }
div.topic {
margin: 2em }
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
margin-top: 0.4em }
h1.title {
text-align: center }
h2.subtitle {
text-align: center }
hr.docutils {
width: 75% }
img.align-left, .figure.align-left, object.align-left, table.align-left {
clear: left ;
float: left ;
margin-right: 1em }
img.align-right, .figure.align-right, object.align-right, table.align-right {
clear: right ;
float: right ;
margin-left: 1em }
img.align-center, .figure.align-center, object.align-center {
display: block;
margin-left: auto;
margin-right: auto;
}
table.align-center {
margin-left: auto;
margin-right: auto;
}
.align-left {
text-align: left }
.align-center {
clear: both ;
text-align: center }
.align-right {
text-align: right }
/* reset inner alignment in figures */
div.align-right {
text-align: inherit }
/* div.align-center * { */
/* text-align: left } */
.align-top {
vertical-align: top }
.align-middle {
vertical-align: middle }
.align-bottom {
vertical-align: bottom }
ol.simple, ul.simple {
margin-bottom: 1em }
ol.arabic {
list-style: decimal }
ol.loweralpha {
list-style: lower-alpha }
ol.upperalpha {
list-style: upper-alpha }
ol.lowerroman {
list-style: lower-roman }
ol.upperroman {
list-style: upper-roman }
p.attribution {
text-align: right ;
margin-left: 50% }
p.caption {
font-style: italic }
p.credits {
font-style: italic ;
font-size: smaller }
p.label {
white-space: nowrap }
p.rubric {
font-weight: bold ;
font-size: larger ;
color: maroon ;
text-align: center }
p.sidebar-title {
font-family: sans-serif ;
font-weight: bold ;
font-size: larger }
p.sidebar-subtitle {
font-family: sans-serif ;
font-weight: bold }
p.topic-title {
font-weight: bold }
pre.address {
margin-bottom: 0 ;
margin-top: 0 ;
font: inherit }
pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ;
margin-right: 2em }
pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
pre.code .literal.string, code .literal.string { color: #0C5404 }
pre.code .name.builtin, code .name.builtin { color: #352B84 }
pre.code .deleted, code .deleted { background-color: #DEB0A1}
pre.code .inserted, code .inserted { background-color: #A3D289}
span.classifier {
font-family: sans-serif ;
font-style: oblique }
span.classifier-delimiter {
font-family: sans-serif ;
font-weight: bold }
span.interpreted {
font-family: sans-serif }
span.option {
white-space: nowrap }
span.pre {
white-space: pre }
span.problematic {
color: red }
span.section-subtitle {
/* font-size relative to parent (h1..h6 element) */
font-size: 80% }
table.citation {
border-left: solid 1px gray;
margin-left: 1px }
table.docinfo {
margin: 2em 4em }
table.docutils {
margin-top: 0.5em ;
margin-bottom: 0.5em }
table.footnote {
border-left: solid 1px black;
margin-left: 1px }
table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
padding-left: 0.5em ;
padding-right: 0.5em ;
vertical-align: top }
table.docutils th.field-name, table.docinfo th.docinfo-name {
font-weight: bold ;
text-align: left ;
white-space: nowrap ;
padding-left: 0 }
/* "booktabs" style (no vertical lines) */
table.docutils.booktabs {
border: 0px;
border-top: 2px solid;
border-bottom: 2px solid;
border-collapse: collapse;
}
table.docutils.booktabs * {
border: 0px;
}
table.docutils.booktabs th {
border-bottom: thin solid;
text-align: left;
}
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
font-size: 100% }
ul.auto-toc {
list-style-type: none }
</style>
</head>
<body>
<div class="document" id="pos-order-margin">
<h1 class="title">PoS Order Margin</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:9cafdf6c20cc9a805b5be0f86d884dd9ee484f0f129813b1c287c7711e1a9297
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/pos/tree/16.0/pos_margin"><img alt="OCA/pos" src="https://img.shields.io/badge/github-OCA%2Fpos-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/pos-16-0/pos-16-0-pos_margin"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/pos&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module shows margins in PoS frontend during an order creation.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#configuration" id="toc-entry-1">Configuration</a></li>
<li><a class="reference internal" href="#known-issues-roadmap" id="toc-entry-2">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#changelog" id="toc-entry-3">Changelog</a><ul>
<li><a class="reference internal" href="#section-1" id="toc-entry-4">16.0.1.0.0</a></li>
<li><a class="reference internal" href="#section-2" id="toc-entry-5">14.0.1.0.0</a></li>
<li><a class="reference internal" href="#section-3" id="toc-entry-6">13.0.1.0.0</a></li>
</ul>
</li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-7">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-8">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-9">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-10">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-11">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="configuration">
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
<ul class="simple">
<li>If you want to disable the display of the margin, in the front-office UI, you can
uncheck the check box in the <cite>res.config.settings</cite> shop form:</li>
</ul>
<div class="figure">
<img alt="https://raw.githubusercontent.com/OCA/pos/16.0/pos_margin/static/description/pos_config_setting.png" src="https://raw.githubusercontent.com/OCA/pos/16.0/pos_margin/static/description/pos_config_setting.png" />
</div>
</div>
<div class="section" id="known-issues-roadmap">
<h1><a class="toc-backref" href="#toc-entry-2">Known issues / Roadmap</a></h1>
<p>This dependency can be removed, when Odoo Core will be correctly refactored,
moving this <tt class="docutils literal">&#64;api.model</tt> function in a more generic module (<tt class="docutils literal">account</tt>
for exemple).</p>
</div>
<div class="section" id="changelog">
<h1><a class="toc-backref" href="#toc-entry-3">Changelog</a></h1>
<div class="section" id="section-1">
<h2><a class="toc-backref" href="#toc-entry-4">16.0.1.0.0</a></h2>
<ul class="simple">
<li>Migrate to V16.0</li>
<li>Remove <tt class="docutils literal">pos.order</tt> and <tt class="docutils literal">pos.order.line</tt> funcionality from V14.0.
Its already done by V16.0.</li>
<li>Remove tests.</li>
<li>Create a <tt class="docutils literal">res.config.settings</tt> field <cite>pos_iface_display_margin</cite>
to display margins in PoS frontend.</li>
</ul>
</div>
<div class="section" id="section-2">
<h2><a class="toc-backref" href="#toc-entry-5">14.0.1.0.0</a></h2>
<ul class="simple">
<li>Migrate to V14.0</li>
</ul>
</div>
<div class="section" id="section-3">
<h2><a class="toc-backref" href="#toc-entry-6">13.0.1.0.0</a></h2>
<ul class="simple">
<li>Migrate to V13.0</li>
<li>Reuse <tt class="docutils literal">sale_margin</tt> computation to handle multi currency context.</li>
<li>Correct computation of margin, if a module that adds <tt class="docutils literal">uom_id</tt> on
<tt class="docutils literal">pos.order.line</tt> is installed.</li>
<li>Add test</li>
</ul>
</div>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-7">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/pos/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/pos/issues/new?body=module:%20pos_margin%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#toc-entry-8">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#toc-entry-9">Authors</a></h2>
<ul class="simple">
<li>GRAP</li>
<li>FactorLibre</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#toc-entry-10">Contributors</a></h2>
<ul class="simple">
<li>Sylvain LE GAL (<a class="reference external" href="https://twitter.com/legalsylvain">https://twitter.com/legalsylvain</a>)</li>
<li>Wolfgang Pichler</li>
<li>Murtaza Mithaiwala (<a class="reference external" href="https://twitter.com/MurtazaMithaiw4">https://twitter.com/MurtazaMithaiw4</a>)</li>
<li>Dhara Solanki &lt;<a class="reference external" href="mailto:dhara.solanki&#64;initos.com">dhara.solanki&#64;initos.com</a>&gt;</li>
<li>Juan Carlos Bonilla &lt;<a class="reference external" href="mailto:juancarlos.bonilla&#64;factorlibre.com">juancarlos.bonilla&#64;factorlibre.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-11">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>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.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/legalsylvain"><img alt="legalsylvain" src="https://github.com/legalsylvain.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/pos/tree/16.0/pos_margin">OCA/pos</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
</div>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View file

@ -0,0 +1,8 @@
.pos .order .orderline .order-line-margin {
font-weight: normal;
color: #888;
}
.pos .order .orderline .order-line-margin.margin-negative {
color: #f00;
}

View file

@ -0,0 +1,25 @@
/** @odoo-module **/
// Copyright (C) 2023 - Today: GRAP (http://www.grap.coop)
// @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import PosComponent from "point_of_sale.PosComponent";
import Registries from "point_of_sale.Registries";
export class OrderSummaryMargin extends PosComponent {
getOrderMargin() {
const self = this;
const order = self.env.pos.get_order();
if (!order.get_orderlines().length) {
return false;
}
const margin = self.env.pos.format_currency(order.get_margin());
const margin_rate = order.get_margin_rate_str();
return {margin, margin_rate};
}
}
OrderSummaryMargin.template = "OrderSummaryMargin";
Registries.Component.add(OrderSummaryMargin);

View file

@ -0,0 +1,62 @@
/** @odoo-module **/
// Copyright (C) 2023 - Today: GRAP (http://www.grap.coop)
// @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import {Order, Orderline} from "point_of_sale.models";
import Registries from "point_of_sale.Registries";
import field_utils from "web.field_utils";
// /////////////////////////////
// Overload models.Order
// /////////////////////////////
const OrderMargin = (OriginalOrder) =>
class extends OriginalOrder {
get_margin() {
return this.get_orderlines().reduce(
(margin, line) => margin + line.get_margin(),
0
);
}
get_margin_rate() {
const priceWithoutTax = this.get_total_without_tax();
return priceWithoutTax ? (this.get_margin() / priceWithoutTax) * 100 : 0;
}
get_margin_rate_str() {
return field_utils.format.float(this.get_margin_rate()) + "%";
}
};
Registries.Model.extend(Order, OrderMargin);
// /////////////////////////////
// Overload models.OrderLine
// /////////////////////////////
const OrderLineMargin = (OriginalOrderline) =>
class extends OriginalOrderline {
get_purchase_price() {
// Overload the function to use another field that the default standard_price
return this.product.standard_price;
}
get_margin() {
return (
this.get_all_prices().priceWithoutTax -
this.quantity * this.get_purchase_price()
);
}
get_margin_rate() {
const priceWithoutTax = this.get_all_prices().priceWithoutTax;
return priceWithoutTax ? (this.get_margin() / priceWithoutTax) * 100 : 0;
}
get_margin_rate_str() {
return field_utils.format.float(this.get_margin_rate()) + "%";
}
};
Registries.Model.extend(Orderline, OrderLineMargin);

View file

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Copyright (C) 2023 - Today: GRAP (http://www.grap.coop)
@author: Sylvain LE GAL (https://twitter.com/legalsylvain)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->
<templates id="template" xml:space="preserve">
<t t-name="OrderSummaryMargin" owl="1">
<div class="summary clearfix">
<t t-if="env.pos.config.iface_display_margin">
<t t-set="_result" t-value="getOrderMargin()" />
<t t-if="_result">
<div class="line">
<div class="subentry order-margin">
<span class="value-margin">Margin:
<t t-out="_result.margin" />
</span>
(<span class="value-margin-rate">
<t t-out="_result.margin_rate" />
</span>)
</div>
</div>
</t>
</t>
</div>
</t>
<t t-inherit="point_of_sale.OrderWidget" t-inherit-mode="extension">
<xpath expr="//div/div/t[@t-else='']" position="inside">
<OrderSummaryMargin />
</xpath>
</t>
<t t-inherit="point_of_sale.Orderline" t-inherit-mode="extension">
<xpath expr="//ul/t/li" position="inside">
<t t-if="env.pos.config.iface_display_margin">
<span
t-att-class="'price order-line-margin ' + (props.line.get_margin_rate() &lt; 0 ? 'margin-negative' : '')"
>
(<t t-out="props.line.get_margin_rate_str()" />)
</span>
</t>
</xpath>
</t>
</templates>

View file

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Copyright (C) 2023 - Today: GRAP (http://www.grap.coop)
@author Sylvain LE GAL (https://twitter.com/legalsylvain)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->
<odoo>
<record id="res_config_settings_view_form_margin_inherit" model="ir.ui.view">
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="point_of_sale.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='module_loyalty']/../.." position="after">
<div class="col-xs-12 col-lg-6 o_setting_box" id="order_margin">
<div class="o_setting_left_pane">
<field name="pos_iface_display_margin" />
</div>
<div class="o_setting_right_pane">
<label for="pos_iface_display_margin" />
<div class="text-muted">
Display Margin and Margin Rate in the frontend
</div>
</div>
</div>
</xpath>
</field>
</record>
</odoo>

View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Copyright (C) 2023 - Today: GRAP (http://www.grap.coop)
@author Sylvain LE GAL (https://twitter.com/legalsylvain)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->
<odoo>
<record id="view_pos_order_tree_inherit" model="ir.ui.view">
<field name="model">pos.order</field>
<field name="inherit_id" ref="point_of_sale.view_pos_order_tree" />
<field name="arch" type="xml">
<xpath expr='//field[@name="amount_total"]' position="before">
<field name="margin" widget="monetary" sum="Margin Total" />
</xpath>
</field>
</record>
</odoo>