Skip to content

Commit

Permalink
[MIG] pos_deposit to v16
Browse files Browse the repository at this point in the history
  • Loading branch information
hbrunn committed Dec 19, 2024
1 parent 2b52924 commit d9530bf
Show file tree
Hide file tree
Showing 18 changed files with 331 additions and 189 deletions.
23 changes: 13 additions & 10 deletions pos_deposit/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
POS Container Deposit
=====================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:08eafc2a868af163a631280209611f70bcd159c77f08568a6e8c9b93a7088910
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
Expand All @@ -14,16 +17,16 @@ POS Container Deposit
: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/13.0/pos_deposit
:target: https://github.com/OCA/pos/tree/16.0/pos_deposit
:alt: OCA/pos
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/pos-13-0/pos-13-0-pos_deposit
:target: https://translation.odoo-community.org/projects/pos-16-0/pos-16-0-pos_deposit
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/184/13.0
:alt: Try me on Runbot
.. |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|
|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows the use of deposit products for PoS products.

Expand Down Expand Up @@ -70,8 +73,8 @@ 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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/pos/issues/new?body=module:%20pos_deposit%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
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_deposit%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.

Expand Down Expand Up @@ -103,6 +106,6 @@ 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.

This module is part of the `OCA/pos <https://github.com/OCA/pos/tree/13.0/pos_deposit>`_ project on GitHub.
This module is part of the `OCA/pos <https://github.com/OCA/pos/tree/16.0/pos_deposit>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
15 changes: 12 additions & 3 deletions pos_deposit/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
{
"name": "POS Container Deposit",
"version": "13.0.1.0.0",
"version": "16.0.1.0.0",
"category": "Point of Sale",
"summary": "This module is used to manage container deposits for products"
" in Point of Sale.",
"author": "Sunflower IT, Open2bizz, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/pos",
"license": "AGPL-3",
"depends": ["point_of_sale"],
"data": ["views/pos_deposit.xml", "views/product_view.xml"],
"qweb": ["static/src/xml/pos.xml"],
"data": [
"views/product_template.xml",
],
"demo": [
"demo/product_product.xml",
],
"assets": {
"point_of_sale.assets": [
"pos_deposit/static/src/js/models.js",
],
},
"installable": True,
}
17 changes: 17 additions & 0 deletions pos_deposit/demo/product_product.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="demo_deposit_product" model="product.product">
<field name="name">Bottle deposit .25</field>
<field name="sale_ok" eval="True" />
<field name="is_deposit" eval="True" />
<field name="available_in_pos" eval="True" />
<field name="lst_price">0.25</field>
</record>
<record id="demo_product" model="product.product">
<field name="name">Generic sugar liquid</field>
<field name="sale_ok" eval="True" />
<field name="available_in_pos" eval="True" />
<field name="deposit_product_id" ref="demo_deposit_product" />
<field name="lst_price">1.75</field>
</record>
</odoo>
2 changes: 2 additions & 0 deletions pos_deposit/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from . import pos_session
from . import product_product
from . import product_template
17 changes: 17 additions & 0 deletions pos_deposit/models/pos_session.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from odoo import models
from odoo.osv.expression import OR


class PosSession(models.Model):
_inherit = "pos.session"

def _loader_params_product_product(self):
"""
Load all deposit products and add deposit related fields
"""
result = super()._loader_params_product_product()
result["search_params"]["domain"] = OR(
[result["search_params"]["domain"], [("is_deposit", "=", True)]]
)
result["search_params"]["fields"] += ["deposit_product_id", "is_deposit"]
return result
16 changes: 16 additions & 0 deletions pos_deposit/models/product_product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2021 Sunflower IT
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import fields, models


class ProductProduct(models.Model):
_inherit = "product.product"

deposit_product_id = fields.Many2one(
"product.product",
"Deposit",
domain=[("is_deposit", "!=", False)],
help="If this product is packaged in a container for which you charge deposit, "
"add a product here that stands for the deposit",
)
55 changes: 49 additions & 6 deletions pos_deposit/models/product_template.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,57 @@
# Copyright 2021 Sunflower IT
# Copyright 2024 Hunki Enterprises BV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import fields, models
from odoo import api, fields, models


class ProductTemplate(models.Model):
_inherit = "product.template"

use_deposit = fields.Boolean("Use Deposit")
is_deposit = fields.Boolean("Is Deposit")
select_deposit = fields.Many2one(
"product.product", "Select Deposit", domain=[("is_deposit", "!=", False)]
is_deposit = fields.Boolean(
help="Check this if this product is a container for which you charge deposit",
)
deposit_product_id = fields.Many2one(
"product.product",
"Deposit product",
domain=[("is_deposit", "!=", False)],
help="If this product is packaged in a container for which you charge deposit, "
"add a product here that stands for the deposit",
compute="_compute_deposit_product_id",
inverse="_inverse_deposit_product_id",
search="_search_deposit_product_id",
)

@api.onchange("is_deposit")
def _onchange_is_deposit(self):
if self.is_deposit:
self.available_in_pos = True

@api.depends("product_variant_ids.deposit_product_id")
def _compute_deposit_product_id(self):
for this in self:
this.deposit_product_id = this.product_variant_ids.deposit_product_id

def _inverse_deposit_product_id(self):
for this in self:
this.product_variant_ids.write(
{
"deposit_product_id": this.deposit_product_id,
}
)

def _search_deposit_product_id(self, operator, value):
return [("product_variant_ids.deposit_product_id", operator, value)]

def copy(self, default=None):
"""
Take care that copies include the deposit product
"""
if default is None:
default = {}
default.setdefault("deposit_product_id", self.deposit_product_id.id)
return super().copy(default=default)

def _get_related_fields_variant_template(self):
result = super()._get_related_fields_variant_template()
result.append("deposit_product_id")
return result
75 changes: 49 additions & 26 deletions pos_deposit/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
<?xml version="1.0" encoding="utf-8" ?>
<!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: http://docutils.sourceforge.net/" />
<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 7614 2013-02-21 15:55:51Z milde $
: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 http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/

Expand All @@ -37,6 +36,14 @@
.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 }
Expand Down Expand Up @@ -161,12 +168,12 @@
hr.docutils {
width: 75% }

img.align-left, .figure.align-left, object.align-left {
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 {
img.align-right, .figure.align-right, object.align-right, table.align-right {
clear: right ;
float: right ;
margin-left: 1em }
Expand All @@ -177,6 +184,11 @@
margin-right: auto;
}

table.align-center {
margin-left: auto;
margin-right: auto;
}

.align-left {
text-align: left }

Expand All @@ -194,6 +206,15 @@
/* 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 }

Expand Down Expand Up @@ -344,8 +365,10 @@ <h1 class="title">POS Container Deposit</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:08eafc2a868af163a631280209611f70bcd159c77f08568a6e8c9b93a7088910
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" 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" 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" href="https://github.com/OCA/pos/tree/13.0/pos_deposit"><img alt="OCA/pos" src="https://img.shields.io/badge/github-OCA%2Fpos-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/pos-13-0/pos-13-0-pos_deposit"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/184/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<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_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_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&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 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
Expand All @@ -354,20 +377,20 @@ <h1 class="title">POS Container Deposit</h1>
<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="id1">Configuration</a></li>
<li><a class="reference internal" href="#usage" id="id2">Usage</a></li>
<li><a class="reference internal" href="#known-issues-roadmap" id="id3">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#bug-tracker" id="id4">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id5">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id6">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id7">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id8">Maintainers</a></li>
<li><a class="reference internal" href="#configuration" id="toc-entry-1">Configuration</a></li>
<li><a class="reference internal" href="#usage" id="toc-entry-2">Usage</a></li>
<li><a class="reference internal" href="#known-issues-roadmap" id="toc-entry-3">Known issues / Roadmap</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="configuration">
<h1><a class="toc-backref" href="#id1">Configuration</a></h1>
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
<p>To configure this module, you need to go to <em>Point of Sale &gt; Products</em>.</p>
<ol class="arabic simple">
<li>Select or add at least one ‘deposit product’, such as ‘Bottle 1L’,
Expand All @@ -378,7 +401,7 @@ <h1><a class="toc-backref" href="#id1">Configuration</a></h1>
</ol>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#id2">Usage</a></h1>
<h1><a class="toc-backref" href="#toc-entry-2">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
Expand All @@ -388,41 +411,41 @@ <h1><a class="toc-backref" href="#id2">Usage</a></h1>
</ol>
</div>
<div class="section" id="known-issues-roadmap">
<h1><a class="toc-backref" href="#id3">Known issues / Roadmap</a></h1>
<h1><a class="toc-backref" href="#toc-entry-3">Known issues / Roadmap</a></h1>
<ul class="simple">
<li>If the screen refreshes or session is reopened, the link between product and container is lost, so the quantities can get out of sync. This is not something that happens often and can be ‘repaired’ by removing and re-adding a product to the order.</li>
</ul>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#id4">Bug Tracker</a></h1>
<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 smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/pos/issues/new?body=module:%20pos_deposit%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
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_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="#id5">Credits</a></h1>
<h1><a class="toc-backref" href="#toc-entry-5">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#id6">Authors</a></h2>
<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="#id7">Contributors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
<p>Tom Blauwendraat &lt;<a class="reference external" href="mailto:tom&#64;sunflowerweb.nl">tom&#64;sunflowerweb.nl</a>&gt;
Stefan Rijnhart &lt;<a class="reference external" href="mailto:stefan&#64;opener.am">stefan&#64;opener.am</a>&gt;</p>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id8">Maintainers</a></h2>
<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/13.0/pos_deposit">OCA/pos</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/pos/tree/16.0/pos_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>
Expand Down
Binary file removed pos_deposit/static/src/img/search.png
Binary file not shown.
Binary file removed pos_deposit/static/src/img/search_reset.gif
Binary file not shown.
Loading

0 comments on commit d9530bf

Please sign in to comment.