mirror of
https://github.com/bringout/oca-pos.git
synced 2026-04-19 16:21:58 +02:00
Move all OCA POS modules from oca-technical to dedicated oca-pos submodule
Reorganized 74 POS-related modules for better structure: - Moved all odoo-bringout-oca-pos-* packages from packages/oca-technical/ - Now organized in dedicated packages/oca-pos/ submodule - Includes payment, receipt, loyalty, order, product, and partner modules - Maintains all module functionality while improving project organization This creates a cleaner separation between general technical modules and Point of Sale specific functionality. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
3791451dc1
commit
377f346a99
2675 changed files with 93308 additions and 0 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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);
|
||||
|
|
@ -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);
|
||||
|
|
@ -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() < 0 ? 'margin-negative' : '')"
|
||||
>
|
||||
(<t t-out="props.line.get_margin_rate_str()" />)
|
||||
</span>
|
||||
</t>
|
||||
</xpath>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
Loading…
Add table
Add a link
Reference in a new issue