-
-
Notifications
You must be signed in to change notification settings - Fork 617
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
331 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Oops, something went wrong.