mirror of
https://github.com/bringout/oca-technical.git
synced 2026-04-20 23:52:02 +02:00
Initial commit: OCA Technical packages (595 packages)
This commit is contained in:
commit
2cc02aac6e
24950 changed files with 2318079 additions and 0 deletions
Binary file not shown.
|
After Width: | Height: | Size: 9.2 KiB |
|
|
@ -0,0 +1,461 @@
|
|||
<!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 Container Deposit</title>
|
||||
<style type="text/css">
|
||||
|
||||
/*
|
||||
:Author: David Goodger (goodger@python.org)
|
||||
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
|
||||
:Copyright: This stylesheet has been placed in the public domain.
|
||||
|
||||
Default cascading style sheet for the HTML output of Docutils.
|
||||
Despite the name, some widely supported CSS2 features are used.
|
||||
|
||||
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: gray; } /* 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, pre.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-container-deposit">
|
||||
<h1 class="title">POS Container Deposit</h1>
|
||||
|
||||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! source digest: sha256:32a0d00fa71650c51313d74e5b39e1bbec3b17934e275fd3b2e875411d4422f4
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||
<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_container_deposit"><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_container_deposit"><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&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 allows the use of deposit products for PoS products.</p>
|
||||
<p>An example of such a deposit product would be a bottle of cola, where the bottle is
|
||||
being sold for an extra 25 cents, which you get back when you bring the bottle back to
|
||||
the store intact. Whenever the cola is added to a PoS order, the bottle is added too.
|
||||
If the cola quantity changes, the bottle quantity will change as well.</p>
|
||||
<p><strong>Table of contents</strong></p>
|
||||
<div class="contents local topic" id="contents">
|
||||
<ul class="simple">
|
||||
<li><a class="reference internal" href="#use-cases-context" id="toc-entry-1">Use Cases / Context</a></li>
|
||||
<li><a class="reference internal" href="#configuration" id="toc-entry-2">Configuration</a></li>
|
||||
<li><a class="reference internal" href="#usage" id="toc-entry-3">Usage</a></li>
|
||||
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-4">Bug Tracker</a></li>
|
||||
<li><a class="reference internal" href="#credits" id="toc-entry-5">Credits</a><ul>
|
||||
<li><a class="reference internal" href="#authors" id="toc-entry-6">Authors</a></li>
|
||||
<li><a class="reference internal" href="#contributors" id="toc-entry-7">Contributors</a></li>
|
||||
<li><a class="reference internal" href="#maintainers" id="toc-entry-8">Maintainers</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="use-cases-context">
|
||||
<h1><a class="toc-backref" href="#toc-entry-1">Use Cases / Context</a></h1>
|
||||
<p>Note there are several implementations of the concept of deposits with varying degrees of complexity:</p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference external" href="https://odoo-community.org/shop/product-packaging-container-deposit-715405">product_packaging_container_deposit</a></li>
|
||||
<li><a class="reference external" href="https://odoo-community.org/shop/pos-product-pack-716088">pos_product_pack</a></li>
|
||||
</ul>
|
||||
<p>This module focusses on simplicity for users who don’t want to get into packaging.</p>
|
||||
</div>
|
||||
<div class="section" id="configuration">
|
||||
<h1><a class="toc-backref" href="#toc-entry-2">Configuration</a></h1>
|
||||
<p>To configure this module, you need to go to <em>Point of Sale > Products</em>.</p>
|
||||
<ol class="arabic simple">
|
||||
<li>Select or add at least one ‘deposit product’, such as ‘Bottle 1L’,
|
||||
with a non-zero price and with the checkbox ‘Is Deposit’ set to True.</li>
|
||||
<li>Select or add at least one product of which ‘Use Deposit’ is checked,
|
||||
such as ‘1 liter of cola’. In the accompanying product selection field,
|
||||
select the bottle. The two products are now linked.</li>
|
||||
</ol>
|
||||
</div>
|
||||
<div class="section" id="usage">
|
||||
<h1><a class="toc-backref" href="#toc-entry-3">Usage</a></h1>
|
||||
<p>To use this module, open a POS session and:</p>
|
||||
<ol class="arabic simple">
|
||||
<li>When a deposit product (eg. cola) is added, the bottle is added to the
|
||||
order as well and the quantities are kept in sync.</li>
|
||||
<li>When someone brings back bottles to the store, you can just add a bottle
|
||||
and enter a negative sale quantity, thus refunding the bottle.</li>
|
||||
</ol>
|
||||
</div>
|
||||
<div class="section" id="bug-tracker">
|
||||
<h1><a class="toc-backref" href="#toc-entry-4">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_container_deposit%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-5">Credits</a></h1>
|
||||
<div class="section" id="authors">
|
||||
<h2><a class="toc-backref" href="#toc-entry-6">Authors</a></h2>
|
||||
<ul class="simple">
|
||||
<li>Sunflower IT</li>
|
||||
<li>Open2bizz</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="contributors">
|
||||
<h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
|
||||
<p>Tom Blauwendraat <<a class="reference external" href="mailto:tom@sunflowerweb.nl">tom@sunflowerweb.nl</a>>
|
||||
Holger Brunn <<a class="reference external" href="mailto:mail@hunki-enterprises.com">mail@hunki-enterprises.com</a>> (<a class="reference external" href="https://hunki-enterprises.com">https://hunki-enterprises.com</a>)
|
||||
Stefan Rijnhart <<a class="reference external" href="mailto:stefan@opener.am">stefan@opener.am</a>></p>
|
||||
</div>
|
||||
<div class="section" id="maintainers">
|
||||
<h2><a class="toc-backref" href="#toc-entry-8">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>This module is part of the <a class="reference external" href="https://github.com/OCA/pos/tree/16.0/pos_container_deposit">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>
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
/* Copyright 2024 Hunki Enterprises BV
|
||||
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
*/
|
||||
odoo.define("pos_container_deposit.components", function (require) {
|
||||
"use strict";
|
||||
|
||||
const Orderline = require("point_of_sale.Orderline");
|
||||
const Registries = require("point_of_sale.Registries");
|
||||
const PosDepositOrderlineExtension = (Orderline) =>
|
||||
class PosDepositOrderline extends Orderline {
|
||||
selectLine() {
|
||||
/**
|
||||
* Don't allow selecting deposit products
|
||||
**/
|
||||
if (!this.props.line.is_container_deposit) {
|
||||
super.selectLine(...arguments);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Registries.Component.extend(Orderline, PosDepositOrderlineExtension);
|
||||
});
|
||||
|
|
@ -0,0 +1,152 @@
|
|||
/* Copyright 2024 Hunki Enterprises BV
|
||||
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
*/
|
||||
odoo.define("pos_container_deposit.models", function (require) {
|
||||
"use strict";
|
||||
|
||||
const {Order, Orderline} = require("point_of_sale.models");
|
||||
const Registries = require("point_of_sale.Registries");
|
||||
const {Gui} = require("point_of_sale.Gui");
|
||||
const core = require("web.core");
|
||||
const _t = core._t;
|
||||
|
||||
const PosDepositOrderExtension = (Order) =>
|
||||
class PosDepositOrder extends Order {
|
||||
add_product(product) {
|
||||
/**
|
||||
* Show an error message when adding a product with a container deposit product that is not loaded
|
||||
**/
|
||||
var deposit = null;
|
||||
if (product.deposit_product_id) {
|
||||
deposit = this.pos.db.product_by_id[product.deposit_product_id[0]];
|
||||
if (!deposit) {
|
||||
Gui.showPopup("ErrorPopup", {
|
||||
title: _t("Deposit not available"),
|
||||
body: _.str.sprintf(
|
||||
_t(
|
||||
"The product %s is configured as having a deposit but the deposit product %s is not available in POS."
|
||||
),
|
||||
product.display_name,
|
||||
product.deposit_product_id[1]
|
||||
),
|
||||
});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
super.add_product(...arguments);
|
||||
}
|
||||
add_orderline(line) {
|
||||
/**
|
||||
* When adding a product with container deposit, add its container deposit product
|
||||
**/
|
||||
super.add_orderline(...arguments);
|
||||
if (line.container_deposit_product && !line.container_deposit_line) {
|
||||
this.add_product(line.container_deposit_product, {
|
||||
quantity: line.get_quantity(),
|
||||
});
|
||||
line.container_deposit_line = this.get_last_orderline();
|
||||
line.container_deposit_line.is_container_deposit = true;
|
||||
this.select_orderline(line);
|
||||
}
|
||||
}
|
||||
select_orderline(line) {
|
||||
/**
|
||||
* Never select an orderline with deposit, select one next to it instead
|
||||
**/
|
||||
if (line && line.is_container_deposit) {
|
||||
const line_index = this.orderlines.indexOf(line);
|
||||
if (line_index >= 0 && this.orderlines.length > 1) {
|
||||
super.select_orderline(
|
||||
this.orderlines[line_index ? line_index - 1 : 0]
|
||||
);
|
||||
}
|
||||
} else {
|
||||
super.select_orderline(...arguments);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const PosDepositOrderlineExtension = (Orderline) =>
|
||||
class PosDepositOrderLine extends Orderline {
|
||||
constructor() {
|
||||
/**
|
||||
* Set container deposit specific properties
|
||||
**/
|
||||
super(...arguments);
|
||||
const deposit_product = this.product
|
||||
? this.pos.db.get_product_by_id(this.product.id).deposit_product_id
|
||||
: null;
|
||||
if (deposit_product) {
|
||||
this.container_deposit_product = this.pos.db.get_product_by_id(
|
||||
deposit_product[0]
|
||||
);
|
||||
}
|
||||
}
|
||||
init_from_JSON(json) {
|
||||
/**
|
||||
* Restore container deposit specific properties and link between line with deposit and deposit line
|
||||
**/
|
||||
super.init_from_JSON(json);
|
||||
if (json.container_deposit_line_id) {
|
||||
this.container_deposit_line =
|
||||
this.order.get_orderline(json.container_deposit_line_id) ||
|
||||
json.container_deposit_line_id;
|
||||
}
|
||||
if (json.is_container_deposit) {
|
||||
for (var i = 0; i < this.order.orderlines.length; i++) {
|
||||
if (
|
||||
this.order.orderlines[i].container_deposit_line === this.id
|
||||
) {
|
||||
this.order.orderlines[i].container_deposit_line = this;
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.is_container_deposit = true;
|
||||
}
|
||||
}
|
||||
export_as_JSON() {
|
||||
/**
|
||||
* Export deposit line as id
|
||||
**/
|
||||
const result = super.export_as_JSON();
|
||||
result.is_container_deposit = this.is_container_deposit;
|
||||
if (this.container_deposit_line) {
|
||||
result.container_deposit_line_id = this.container_deposit_line.id;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
set_quantity(quantity, keep_price) {
|
||||
/**
|
||||
* When setting quantity of a product with deposit, also add to its deposit line
|
||||
**/
|
||||
const difference =
|
||||
quantity === "remove" ? -this.quantity : quantity - this.quantity;
|
||||
const deposit_line = this.container_deposit_line;
|
||||
const result = super.set_quantity(...arguments);
|
||||
if ((difference || quantity === "remove") && deposit_line) {
|
||||
var deposit_quantity = deposit_line.quantity + difference;
|
||||
deposit_line.set_quantity(
|
||||
deposit_quantity
|
||||
? deposit_quantity
|
||||
: quantity === "remove"
|
||||
? quantity
|
||||
: deposit_quantity,
|
||||
keep_price
|
||||
);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
can_be_merged_with(orderline) {
|
||||
/**
|
||||
* Never merge deposit orderlines
|
||||
**/
|
||||
if (this.is_container_deposit || orderline.is_container_deposit) {
|
||||
return false;
|
||||
}
|
||||
return super.can_be_merged_with(...arguments);
|
||||
}
|
||||
};
|
||||
|
||||
Registries.Model.extend(Order, PosDepositOrderExtension);
|
||||
Registries.Model.extend(Orderline, PosDepositOrderlineExtension);
|
||||
});
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
odoo.define("pos_container_deposit.test_tour", function (require) {
|
||||
"use strict";
|
||||
|
||||
const {ProductScreen} = require("point_of_sale.tour.ProductScreenTourMethods");
|
||||
const {getSteps, startSteps} = require("point_of_sale.tour.utils");
|
||||
const Tour = require("web_tour.tour");
|
||||
const product_name = "Generic sugar liquid";
|
||||
const deposit_product_name = "Bottle deposit .25";
|
||||
|
||||
startSteps();
|
||||
|
||||
ProductScreen.do.clickHomeCategory();
|
||||
ProductScreen.do.clickDisplayedProduct(product_name);
|
||||
ProductScreen.do.clickDisplayedProduct(product_name);
|
||||
ProductScreen.check.checkOrderlinesNumber(2);
|
||||
ProductScreen.check.selectedOrderlineHas(product_name);
|
||||
getSteps().push({
|
||||
content: `selecting orderline with product '${deposit_product_name}' and quantity '2.0'`,
|
||||
trigger: `.order .orderline:not(:has(.selected)) .product-name:contains("${deposit_product_name}") ~ .info-list em:contains("2.0")`,
|
||||
});
|
||||
ProductScreen.check.selectedOrderlineHas(product_name);
|
||||
ProductScreen.do.pressNumpad("Price");
|
||||
ProductScreen.check.modeIsActive("Price");
|
||||
ProductScreen.do.pressNumpad("5");
|
||||
ProductScreen.check.selectedOrderlineHas(product_name, "2", "10");
|
||||
ProductScreen.do.clickDisplayedProduct(product_name);
|
||||
ProductScreen.do.clickDisplayedProduct(product_name);
|
||||
ProductScreen.check.checkOrderlinesNumber(4);
|
||||
ProductScreen.do.pressNumpad("Qty");
|
||||
ProductScreen.do.pressNumpad("Backspace");
|
||||
ProductScreen.do.pressNumpad("Backspace");
|
||||
ProductScreen.check.modeIsActive("Qty");
|
||||
ProductScreen.check.selectedOrderlineHas(product_name, "2", "10");
|
||||
ProductScreen.check.checkOrderlinesNumber(2);
|
||||
ProductScreen.do.pressNumpad("Qty");
|
||||
ProductScreen.do.pressNumpad("Backspace");
|
||||
ProductScreen.do.pressNumpad("Backspace");
|
||||
ProductScreen.check.modeIsActive("Qty");
|
||||
ProductScreen.check.orderIsEmpty();
|
||||
|
||||
Tour.register(
|
||||
"pos_container_deposit.test_tour",
|
||||
{test: true, url: "/pos/ui"},
|
||||
getSteps()
|
||||
);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue