diff --git a/addons/pos_gift_card/__init__.py b/addons/pos_gift_card/__init__.py deleted file mode 100644 index dc5e6b693d1..00000000000 --- a/addons/pos_gift_card/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from . import models diff --git a/addons/pos_gift_card/__manifest__.py b/addons/pos_gift_card/__manifest__.py deleted file mode 100644 index d248853a47c..00000000000 --- a/addons/pos_gift_card/__manifest__.py +++ /dev/null @@ -1,32 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -{ - 'name': "Gift Card for point of sales module", - 'summary': "Use gift card in your sales orders", - 'description': """Integrate gift card mechanism in sales orders.""", - 'category': 'Sales/Sales', - 'version': '1.0', - 'depends': ['gift_card', 'point_of_sale'], - 'auto_install': True, - 'data': [ - 'data/gift_card_data.xml', - 'views/gift_card_views.xml', - 'views/res_config_settings_views.xml', - 'views/pos_config_views.xml', - 'security/ir.model.access.csv', - ], - 'assets': { - 'point_of_sale.assets': [ - 'pos_gift_card/static/src/css/giftCard.css', - 'pos_gift_card/static/src/js/models.js', - 'pos_gift_card/static/src/js/GiftCardButton.js', - 'pos_gift_card/static/src/js/GiftCardPopup.js', - 'pos_gift_card/static/src/js/PaymentScreen.js', - ], - 'web.assets_qweb': [ - 'pos_gift_card/static/src/xml/**/*', - ], - }, - 'license': 'LGPL-3', -} diff --git a/addons/pos_gift_card/data/gift_card_data.xml b/addons/pos_gift_card/data/gift_card_data.xml deleted file mode 100644 index 4ec5db91191..00000000000 --- a/addons/pos_gift_card/data/gift_card_data.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - True - - - - Gift Card - gift.card - qweb-pdf - pos_gift_card.gift_card_template - report - - - - - - diff --git a/addons/pos_gift_card/i18n/pos_gift_card.pot b/addons/pos_gift_card/i18n/pos_gift_card.pot deleted file mode 100644 index 64be6360b22..00000000000 --- a/addons/pos_gift_card/i18n/pos_gift_card.pot +++ /dev/null @@ -1,282 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * pos_gift_card -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server saas~15.2\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-02-11 14:34+0000\n" -"PO-Revision-Date: 2022-02-11 14:34+0000\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_gift_card -#: model_terms:ir.ui.view,arch_db:pos_gift_card.gift_card_template -msgid "Gift Card Code" -msgstr "" - -#. module: pos_gift_card -#. openerp-web -#: code:addons/pos_gift_card/static/src/xml/GiftCardPopup.xml:0 -#: code:addons/pos_gift_card/static/src/xml/GiftCardPopup.xml:0 -#, python-format -msgid "Amount of the gift card:" -msgstr "" - -#. module: pos_gift_card -#: model_terms:ir.ui.view,arch_db:pos_gift_card.gift_card_template -msgid "Barcode" -msgstr "" - -#. module: pos_gift_card -#: model:ir.model,name:pos_gift_card.model_barcode_rule -msgid "Barcode Rule" -msgstr "" - -#. module: pos_gift_card -#: model:ir.model.fields,field_description:pos_gift_card.field_pos_order_line__generated_gift_card_ids -msgid "Bought Gift Card" -msgstr "" - -#. module: pos_gift_card -#: model:ir.model.fields,field_description:pos_gift_card.field_gift_card__buy_pos_order_line_id -msgid "Buy Pos Order Line" -msgstr "" - -#. module: pos_gift_card -#. openerp-web -#: code:addons/pos_gift_card/static/src/xml/GiftCardPopup.xml:0 -#: code:addons/pos_gift_card/static/src/xml/GiftCardPopup.xml:0 -#, python-format -msgid "Cancel" -msgstr "" - -#. module: pos_gift_card -#: model_terms:ir.ui.view,arch_db:pos_gift_card.gift_card_template -msgid "Card expires" -msgstr "" - -#. module: pos_gift_card -#. openerp-web -#: code:addons/pos_gift_card/static/src/xml/GiftCardPopup.xml:0 -#, python-format -msgid "Check a gift card" -msgstr "" - -#. module: pos_gift_card -#. openerp-web -#: code:addons/pos_gift_card/static/src/xml/GiftCardPopup.xml:0 -#: code:addons/pos_gift_card/static/src/xml/GiftCardPopup.xml:0 -#: code:addons/pos_gift_card/static/src/xml/GiftCardPopup.xml:0 -#: code:addons/pos_gift_card/static/src/xml/GiftCardPopup.xml:0 -#: code:addons/pos_gift_card/static/src/xml/GiftCardPopup.xml:0 -#, python-format -msgid "Confirm" -msgstr "" - -#. module: pos_gift_card -#: model:ir.model.fields,help:pos_gift_card.field_pos_order_line__gift_card_id -msgid "Deducted from this Gift Card" -msgstr "" - -#. module: pos_gift_card -#: model:ir.model.fields,help:pos_gift_card.field_pos_config__gift_card_settings -msgid "Defines the way you want to set your gift cards." -msgstr "" - -#. module: pos_gift_card -#. openerp-web -#: code:addons/pos_gift_card/static/src/xml/GiftCardPopup.xml:0 -#: code:addons/pos_gift_card/static/src/xml/GiftCardPopup.xml:0 -#: code:addons/pos_gift_card/static/src/xml/GiftCardPopup.xml:0 -#: code:addons/pos_gift_card/static/src/xml/GiftCardPopup.xml:0 -#, python-format -msgid "Discard" -msgstr "" - -#. module: pos_gift_card -#: model:ir.model.fields.selection,name:pos_gift_card.selection__pos_config__gift_card_settings__create_set -msgid "Generate a new barcode and set a price" -msgstr "" - -#. module: pos_gift_card -#. openerp-web -#: code:addons/pos_gift_card/static/src/xml/GiftCardPopup.xml:0 -#, python-format -msgid "Generate barcode" -msgstr "" - -#. module: pos_gift_card -#. openerp-web -#: code:addons/pos_gift_card/static/src/xml/GiftCardButton.xml:0 -#: code:addons/pos_gift_card/static/src/xml/GiftCardPopup.xml:0 -#: model:ir.actions.report,name:pos_gift_card.gift_card_report_pdf -#: model:ir.model,name:pos_gift_card.model_gift_card -#: model:ir.model.fields,field_description:pos_gift_card.field_pos_config__use_gift_card -#: model:ir.model.fields,field_description:pos_gift_card.field_pos_order_line__gift_card_id -#: model:ir.model.fields.selection,name:pos_gift_card.selection__barcode_rule__type__gift_card -#: model_terms:ir.ui.view,arch_db:pos_gift_card.pos_gift_card_config_view_form -#: model_terms:ir.ui.view,arch_db:pos_gift_card.res_config_view_form_inherit_pos_coupon -#, python-format -msgid "Gift Card" -msgstr "" - -#. module: pos_gift_card -#. openerp-web -#: code:addons/pos_gift_card/static/src/xml/GiftCardPopup.xml:0 -#: code:addons/pos_gift_card/static/src/xml/GiftCardPopup.xml:0 -#: code:addons/pos_gift_card/static/src/xml/GiftCardPopup.xml:0 -#: code:addons/pos_gift_card/static/src/xml/GiftCardPopup.xml:0 -#, python-format -msgid "Gift Card Barcode:" -msgstr "" - -#. module: pos_gift_card -#: model:ir.model.fields,field_description:pos_gift_card.field_pos_order__gift_card_count -msgid "Gift Card Count" -msgstr "" - -#. module: pos_gift_card -#. openerp-web -#: code:addons/pos_gift_card/static/src/js/PaymentScreen.js:0 -#: code:addons/pos_gift_card/static/src/js/PaymentScreen.js:0 -#, python-format -msgid "Gift Card Error" -msgstr "" - -#. module: pos_gift_card -#: model:ir.model.fields,field_description:pos_gift_card.field_pos_config__gift_card_product_id -#: model_terms:ir.ui.view,arch_db:pos_gift_card.pos_gift_card_config_view_form -msgid "Gift Card Product" -msgstr "" - -#. module: pos_gift_card -#: model:ir.ui.menu,name:pos_gift_card.pos_gift_card_menu -msgid "Gift Cards" -msgstr "" - -#. module: pos_gift_card -#: model:ir.model.fields,field_description:pos_gift_card.field_pos_config__gift_card_settings -msgid "Gift Cards settings" -msgstr "" - -#. module: pos_gift_card -#. openerp-web -#: code:addons/pos_gift_card/static/src/js/PaymentScreen.js:0 -#, python-format -msgid "Gift card balance is too low." -msgstr "" - -#. module: pos_gift_card -#. openerp-web -#: code:addons/pos_gift_card/static/src/js/PaymentScreen.js:0 -#, python-format -msgid "Gift card is not valid." -msgstr "" - -#. module: pos_gift_card -#: model_terms:ir.ui.view,arch_db:pos_gift_card.pos_gift_card_config_view_form -msgid "Gift card settings" -msgstr "" - -#. module: pos_gift_card -#: model_terms:ir.ui.view,arch_db:pos_gift_card.gift_card_template -msgid "Here is your gift card!" -msgstr "" - -#. module: pos_gift_card -#: model:ir.model,name:pos_gift_card.model_pos_config -msgid "Point of Sale Configuration" -msgstr "" - -#. module: pos_gift_card -#: model:ir.model,name:pos_gift_card.model_pos_order_line -msgid "Point of Sale Order Lines" -msgstr "" - -#. module: pos_gift_card -#: model:ir.model,name:pos_gift_card.model_pos_order -msgid "Point of Sale Orders" -msgstr "" - -#. module: pos_gift_card -#: model:ir.model,name:pos_gift_card.model_pos_session -msgid "Point of Sale Session" -msgstr "" - -#. module: pos_gift_card -#: model:ir.model.fields,help:pos_gift_card.field_gift_card__buy_pos_order_line_id -msgid "Pos Order line where this gift card has been bought." -msgstr "" - -#. module: pos_gift_card -#: model:ir.model.fields,field_description:pos_gift_card.field_gift_card__redeem_pos_order_line_ids -msgid "Pos Redeems" -msgstr "" - -#. module: pos_gift_card -#. openerp-web -#: code:addons/pos_gift_card/static/src/xml/GiftCardPopup.xml:0 -#, python-format -msgid "Remaining amount of the gift card:" -msgstr "" - -#. module: pos_gift_card -#: model:ir.model.fields.selection,name:pos_gift_card.selection__pos_config__gift_card_settings__scan_set -msgid "Scan an existing barcode and set a price" -msgstr "" - -#. module: pos_gift_card -#: model:ir.model.fields.selection,name:pos_gift_card.selection__pos_config__gift_card_settings__scan_use -msgid "Scan an existing barcode with an existing price" -msgstr "" - -#. module: pos_gift_card -#. openerp-web -#: code:addons/pos_gift_card/static/src/xml/GiftCardPopup.xml:0 -#, python-format -msgid "Scan and set price on gift card" -msgstr "" - -#. module: pos_gift_card -#. openerp-web -#: code:addons/pos_gift_card/static/src/xml/GiftCardPopup.xml:0 -#, python-format -msgid "Scan gift card" -msgstr "" - -#. module: pos_gift_card -#. openerp-web -#: code:addons/pos_gift_card/static/src/js/GiftCardPopup.js:0 -#, python-format -msgid "This gift card has already been sold" -msgstr "" - -#. module: pos_gift_card -#: model:ir.model.fields,help:pos_gift_card.field_pos_config__gift_card_product_id -msgid "This product is used as reference on customer receipts." -msgstr "" - -#. module: pos_gift_card -#: model:ir.model.fields,field_description:pos_gift_card.field_barcode_rule__type -msgid "Type" -msgstr "" - -#. module: pos_gift_card -#. openerp-web -#: code:addons/pos_gift_card/static/src/xml/GiftCardPopup.xml:0 -#, python-format -msgid "Use a gift card" -msgstr "" - -#. module: pos_gift_card -#. openerp-web -#: code:addons/pos_gift_card/static/src/js/GiftCardPopup.js:0 -#, python-format -msgid "You cannot sell a gift card that has already been sold" -msgstr "" diff --git a/addons/pos_gift_card/models/__init__.py b/addons/pos_gift_card/models/__init__.py deleted file mode 100644 index b35598fd84e..00000000000 --- a/addons/pos_gift_card/models/__init__.py +++ /dev/null @@ -1,9 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from . import barcode_rule -from . import gift_card -from . import pos_config -from . import pos_order -from . import pos_order_line -from . import pos_session diff --git a/addons/pos_gift_card/models/barcode_rule.py b/addons/pos_gift_card/models/barcode_rule.py deleted file mode 100644 index bf4a97eec01..00000000000 --- a/addons/pos_gift_card/models/barcode_rule.py +++ /dev/null @@ -1,14 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from odoo import models, fields - - -class BarcodeRule(models.Model): - _inherit = 'barcode.rule' - - type = fields.Selection(selection_add=[ - ('gift_card', 'Gift Card'), - ], ondelete={ - 'gift_card': 'set default', - }) diff --git a/addons/pos_gift_card/models/gift_card.py b/addons/pos_gift_card/models/gift_card.py deleted file mode 100644 index fcde18d10c8..00000000000 --- a/addons/pos_gift_card/models/gift_card.py +++ /dev/null @@ -1,44 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from odoo import api, fields, models - - -class GiftCard(models.Model): - _inherit = "gift.card" - - buy_pos_order_line_id = fields.Many2one( - "pos.order.line", - copy=False, - readonly=True, - help="Pos Order line where this gift card has been bought.", - ) - redeem_pos_order_line_ids = fields.One2many( - "pos.order.line", "gift_card_id", string="Pos Redeems" - ) - - @api.depends("redeem_pos_order_line_ids") - def _compute_balance(self): - super()._compute_balance() - for record in self: - confirmed_line = record.redeem_pos_order_line_ids.sudo().filtered( - lambda l: l.order_id.state in ('paid', 'done', 'invoiced') - ) - balance = record.balance - if confirmed_line: - balance -= sum( - confirmed_line.mapped( - lambda line: line.currency_id._convert( - line.price_unit, - record.currency_id, - record.env.company, - line.create_date, - ) - * -1 - ) - ) - record.balance = balance - - def can_be_used_in_pos(self): - # expired state are computed once a day, so can be not synchro - return self.state == 'valid' and self.balance > 0 and self.expired_date >= fields.Date.today() diff --git a/addons/pos_gift_card/models/pos_config.py b/addons/pos_gift_card/models/pos_config.py deleted file mode 100644 index ef55d864364..00000000000 --- a/addons/pos_gift_card/models/pos_config.py +++ /dev/null @@ -1,36 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from odoo import api, fields, models - - -class PosConfig(models.Model): - _inherit = "pos.config" - - use_gift_card = fields.Boolean(string="Gift Card") - - gift_card_product_id = fields.Many2one( - "product.product", - string="Gift Card Product", - help="This product is used as reference on customer receipts.", - ) - - gift_card_settings = fields.Selection( - [ - ("create_set", "Generate a new barcode and set a price"), - ("scan_set", "Scan an existing barcode and set a price"), - ("scan_use", "Scan an existing barcode with an existing price"), - ], - string="Gift Cards settings", - default="create_set", - help="Defines the way you want to set your gift cards.", - ) - - @api.onchange("use_gift_card") - def _onchange_giftproduct(self): - if self.use_gift_card: - self.gift_card_product_id = self.env.ref( - "gift_card.pay_with_gift_card_product", False - ) - else: - self.gift_card_product_id = False diff --git a/addons/pos_gift_card/models/pos_order.py b/addons/pos_gift_card/models/pos_order.py deleted file mode 100644 index dace6d2a7da..00000000000 --- a/addons/pos_gift_card/models/pos_order.py +++ /dev/null @@ -1,64 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from odoo import api, fields, models -import base64 - - -class PosOrder(models.Model): - _inherit = "pos.order" - - gift_card_count = fields.Integer(compute="_compute_gift_card_count") - - @api.depends("lines.generated_gift_card_ids") - def _compute_gift_card_count(self): - for record in self: - record.gift_card_count = len(record.lines.mapped("generated_gift_card_ids")) - - @api.model - def create_from_ui(self, orders, draft=False): - order_ids = super(PosOrder, self).create_from_ui(orders, draft) - for order in self.sudo().browse([o["id"] for o in order_ids]): - gift_card_config = order.config_id.gift_card_settings - for line in order.lines: - if line.product_id.id == order.config_id.gift_card_product_id.id: - if not line.gift_card_id: - if gift_card_config == "create_set": - new_card = line._create_gift_cards() - new_card.partner_id = order.partner_id or False - line.generated_gift_card_ids = new_card - else: - gift_card = self.env["gift.card"].search( - [("id", "=", line.generated_gift_card_ids.id)] - ) - gift_card.buy_pos_order_line_id = line.id - gift_card.expired_date = fields.Date.add( - fields.Date.today(), years=1 - ) - gift_card.partner_id = order.partner_id or False - - if gift_card_config == "scan_set": - gift_card.initial_amount = line.price_unit - - return order_ids - - def get_new_card_ids(self): - return self.lines.mapped("generated_gift_card_ids").ids - - def _add_mail_attachment(self, name, ticket): - attachment = super()._add_mail_attachment(name, ticket) - if self.config_id.use_gift_card and len(self.get_new_card_ids()) > 0: - report = self.env.ref('pos_gift_card.gift_card_report_pdf')._render_qweb_pdf(self.get_new_card_ids()) - filename = name + '.pdf' - gift_card = self.env['ir.attachment'].create({ - 'name': filename, - 'type': 'binary', - 'datas': base64.b64encode(report[0]), - 'store_fname': filename, - 'res_model': 'pos.order', - 'res_id': self.ids[0], - 'mimetype': 'application/x-pdf' - }) - attachment += [(4, gift_card.id)] - - return attachment diff --git a/addons/pos_gift_card/models/pos_order_line.py b/addons/pos_gift_card/models/pos_order_line.py deleted file mode 100644 index 0f4bc9e9eb7..00000000000 --- a/addons/pos_gift_card/models/pos_order_line.py +++ /dev/null @@ -1,34 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from odoo import fields, models - - -class PosOrderLine(models.Model): - _inherit = "pos.order.line" - - generated_gift_card_ids = fields.One2many( - "gift.card", "buy_pos_order_line_id", string="Bought Gift Card" - ) - gift_card_id = fields.Many2one( - "gift.card", help="Deducted from this Gift Card", copy=False - ) - - def _is_not_sellable_line(self): - return self.gift_card_id or super()._is_not_sellable_line() - - def _create_gift_cards(self): - return self.env["gift.card"].create( - [self._build_gift_card() for _ in range(int(self.qty))] - ) - - def _build_gift_card(self): - return { - "initial_amount": self.order_id.currency_id._convert( - self.price_unit, - self.company_id.currency_id, - self.company_id, - fields.Date.today(), - ), - "buy_pos_order_line_id": self.id, - } diff --git a/addons/pos_gift_card/models/pos_session.py b/addons/pos_gift_card/models/pos_session.py deleted file mode 100644 index 1907daa83ac..00000000000 --- a/addons/pos_gift_card/models/pos_session.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from odoo import models -from odoo.osv.expression import OR - - -class PosSession(models.Model): - _inherit = 'pos.session' - - def _loader_params_product_product(self): - result = super()._loader_params_product_product() - if self.config_id.use_gift_card and self.config_id.gift_card_product_id: - result['search_params']['domain'] = OR([result['search_params']['domain'], [('id', '=', self.config_id.gift_card_product_id.id)]]) - return result diff --git a/addons/pos_gift_card/security/ir.model.access.csv b/addons/pos_gift_card/security/ir.model.access.csv deleted file mode 100644 index 1468d9216f2..00000000000 --- a/addons/pos_gift_card/security/ir.model.access.csv +++ /dev/null @@ -1,3 +0,0 @@ -id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink -access_gift_card_sales,Gift Card Program Salesman,model_gift_card,point_of_sale.group_pos_manager,1,0,0,0 -access_pos_gift_card_manager,Gift Card Program Sale Manager,model_gift_card,point_of_sale.group_pos_manager,1,1,1,1 diff --git a/addons/pos_gift_card/static/src/css/giftCard.css b/addons/pos_gift_card/static/src/css/giftCard.css deleted file mode 100644 index 061367a5bdf..00000000000 --- a/addons/pos_gift_card/static/src/css/giftCard.css +++ /dev/null @@ -1,46 +0,0 @@ -.giftCardPopupMain { - display: flex; - flex-wrap: wrap; - - justify-content: space-around; - - text-align: center; - padding: 1em; -} - -.giftCardPopupContainer { - display: flex; - justify-content: center; - flex-wrap: wrap; - padding: 5px; - - font-weight: bold; - text-align: center; - width: 100%; -} - -.giftCardPopupFooter { - display: flex; - justify-content: space-evenly; - - text-align: center; -} - -.giftCardPopupInput { - border-bottom: 1px solid !important; - background-color: #F0EEEE !important; - box-shadow: none !important; - text-align: right !important; -} - -.giftCardPopupButton { - width: auto !important; - height: auto !important; - padding: 10px; -} - -.giftCardPopupConfirmButton { - flex-grow: 1; - height: auto !important; - padding: 10px; -} diff --git a/addons/pos_gift_card/static/src/js/GiftCardButton.js b/addons/pos_gift_card/static/src/js/GiftCardButton.js deleted file mode 100644 index 8e8da6be5fe..00000000000 --- a/addons/pos_gift_card/static/src/js/GiftCardButton.js +++ /dev/null @@ -1,30 +0,0 @@ -odoo.define("pos_gift_card.GiftCardButton", function (require) { - "use strict"; - - const PosComponent = require("point_of_sale.PosComponent"); - const ProductScreen = require("point_of_sale.ProductScreen"); - const { useListener } = require("@web/core/utils/hooks"); - const Registries = require("point_of_sale.Registries"); - - class GiftCardButton extends PosComponent { - setup() { - super.setup(); - useListener("click", this.onClick); - } - async onClick() { - this.showPopup("GiftCardPopup", {}); - } - } - GiftCardButton.template = "GiftCardButton"; - - ProductScreen.addControlButton({ - component: GiftCardButton, - condition: function () { - return this.env.pos.config.use_gift_card; - }, - }); - - Registries.Component.add(GiftCardButton); - - return GiftCardButton; -}); diff --git a/addons/pos_gift_card/static/src/js/GiftCardPopup.js b/addons/pos_gift_card/static/src/js/GiftCardPopup.js deleted file mode 100644 index 6133057bb9c..00000000000 --- a/addons/pos_gift_card/static/src/js/GiftCardPopup.js +++ /dev/null @@ -1,158 +0,0 @@ -odoo.define("pos_gift_card.GiftCardPopup", function (require) { - "use strict"; - - const AbstractAwaitablePopup = require("point_of_sale.AbstractAwaitablePopup"); - const Registries = require("point_of_sale.Registries"); - - const { useState } = owl; - - class GiftCardPopup extends AbstractAwaitablePopup { - setup() { - super.setup(); - this.state = useState({ - giftCardConfig: this.env.pos.config.gift_card_settings, - showBarcodeGeneration: false, - showNewGiftCardMenu: false, - showUseGiftCardMenu: false, - showGiftCardDetails: false, - amountToSet: 0, - giftCardBarcode: "", - }); - } - - switchBarcodeView() { - this.state.showBarcodeGeneration = !this.state.showBarcodeGeneration; - if (this.state.showUseGiftCardMenu) - this.state.showUseGiftCardMenu = false; - if (this.state.showGiftCardDetails) - this.state.showGiftCardDetails = false; - } - - switchToUseGiftCardMenu() { - this.switchBarcodeView(); - this.state.showUseGiftCardMenu = true; - } - - switchToShowGiftCardDetails() { - this.switchBarcodeView(); - this.state.showGiftCardDetails = true; - } - - async addGiftCardProduct(giftCard) { - let gift = - this.env.pos.db.product_by_id[ - this.env.pos.config.gift_card_product_id[0] - ]; - - let can_be_sold = true; - if (giftCard) { - can_be_sold = !(giftCard.buy_pos_order_line_id || giftCard.buy_line_id); - } - - if (can_be_sold) { - this.env.pos.get_order().add_product(gift, { - price: this.state.amountToSet, - quantity: 1, - merge: false, - generated_gift_card_ids: giftCard ? giftCard.id : false, - extras: { price_manually_set: true }, - }); - } else { - await this.showPopup('ErrorPopup', { - 'title': this.env._t('This gift card has already been sold'), - 'body': this.env._t('You cannot sell a gift card that has already been sold'), - }); - } - } - - async getGiftCard() { - if (this.state.giftCardBarcode == "") return; - - let giftCard = await this.rpc({ - model: "gift.card", - method: "search_read", - args: [[["code", "=", this.state.giftCardBarcode]]], - }); - if (giftCard.length) { - giftCard = giftCard[0]; - } else { - return false; - } - - return giftCard; - } - - async scanAndUseGiftCard() { - let giftCard = await this.getGiftCard(); - if (!giftCard) return; - - if (this.state.giftCardConfig === "scan_use") - this.state.amountToSet = giftCard.initial_amount; - - await this.addGiftCardProduct(giftCard); - this.cancel(); - } - - async generateBarcode() { - await this.addGiftCardProduct(false); - this.confirm(); - } - - async isGiftCardAlreadyUsed() { - let order = this.env.pos.get_order(); - let giftProduct = - this.env.pos.db.product_by_id[ - this.env.pos.config.gift_card_product_id[0] - ]; - - for (let line of order.orderlines) { - if (line.product.id === giftProduct.id && line.price < 0) { - if (line.gift_card_id === await this.getGiftCard().id) return line; - } - } - return false; - } - - getPriceToRemove(giftCard) { - let currentOrder = this.env.pos.get_order(); - return currentOrder.get_total_with_tax() > giftCard.balance - ? -giftCard.balance - : -currentOrder.get_total_with_tax(); - } - - async payWithGiftCard() { - let giftCard = await this.getGiftCard(); - if (!giftCard) return; - - let gift = - this.env.pos.db.product_by_id[ - this.env.pos.config.gift_card_product_id[0] - ]; - - let currentOrder = this.env.pos.get_order(); - let lineUsed = this.isGiftCardAlreadyUsed() - if (lineUsed) currentOrder.remove_orderline(lineUsed); - - currentOrder.add_product(gift, { - price: this.getPriceToRemove(giftCard), - quantity: 1, - merge: false, - gift_card_id: giftCard.id, - }); - - this.cancel(); - } - - async ShowRemainingAmount() { - let giftCard = await this.getGiftCard(); - if (!giftCard) return; - - this.state.amountToSet = giftCard.balance; - } - } - GiftCardPopup.template = "GiftCardPopup"; - - Registries.Component.add(GiftCardPopup); - - return GiftCardPopup; -}); diff --git a/addons/pos_gift_card/static/src/js/PaymentScreen.js b/addons/pos_gift_card/static/src/js/PaymentScreen.js deleted file mode 100644 index 01094035b4f..00000000000 --- a/addons/pos_gift_card/static/src/js/PaymentScreen.js +++ /dev/null @@ -1,80 +0,0 @@ -odoo.define('pos_gift_card.PaymentScreen', function(require) { - "use strict"; - - const PaymentScreen = require('point_of_sale.PaymentScreen'); - const Registries = require('point_of_sale.Registries'); - var core = require('web.core'); - var _t = core._t; - - - const PosGiftCardPaymentScreen = PaymentScreen => class extends PaymentScreen { - //@Override - async validateOrder(isForceValidate) { - if(this.env.pos.config.use_gift_card) { - if (await this._isOrderValid(isForceValidate)) { - try { - let giftProduct = this.env.pos.db.product_by_id[this.env.pos.config.gift_card_product_id[0]]; - - for (let line of this.currentOrder.orderlines) { - if(line.product.id === giftProduct.id && line.price <= 0) { - let is_valid = await this.rpc({ - model: "gift.card", - method: 'can_be_used_in_pos', - args: [line.gift_card_id], - }); - - if(!is_valid) { - await this.showPopup('ErrorPopup', { - 'title': _t("Gift Card Error"), - 'body': _t("Gift card is not valid."), - }); - return; - } - - let gift_card = await this.rpc({ - model: "gift.card", - method: 'search_read', - domain: [['id', '=', line.gift_card_id]], - fields: ['balance'], - }); - - if(Math.abs(line.price) > gift_card[0].balance) { - await this.showPopup('ErrorPopup', { - 'title': _t("Gift Card Error"), - 'body': _t("Gift card balance is too low."), - }); - return; - } - } - } - } catch (_e) { - // do nothing with the error - } - } - } - await super.validateOrder(...arguments); - } - - async _postPushOrderResolve(order, server_ids) { - if(this.env.pos.config.use_gift_card) { - let ids = await this.rpc({ - model: 'pos.order', - method: 'get_new_card_ids', - args: [server_ids] - }); - if (ids.length > 0) { - this.env.legacyActionManager.do_action('pos_gift_card.gift_card_report_pdf', { - additional_context: { - active_ids: [ids], - }, - }); - } - } - return super._postPushOrderResolve(order, server_ids); - } - }; - - Registries.Component.extend(PaymentScreen, PosGiftCardPaymentScreen); - - return PosGiftCardPaymentScreen; -}); diff --git a/addons/pos_gift_card/static/src/js/models.js b/addons/pos_gift_card/static/src/js/models.js deleted file mode 100644 index c56440a9976..00000000000 --- a/addons/pos_gift_card/static/src/js/models.js +++ /dev/null @@ -1,46 +0,0 @@ -odoo.define("pos_gift_card.gift_card", function (require) { - "use strict"; - - const { Order, Orderline } = require("point_of_sale.models"); - const Registries = require('point_of_sale.Registries'); - - - const PosGiftCardOrder = (Order) => class PosGiftCardOrder extends Order { - set_orderline_options(orderline, options) { - super.set_orderline_options(...arguments); - if (options && options.generated_gift_card_ids) { - orderline.generated_gift_card_ids = [options.generated_gift_card_ids]; - } - if (options && options.gift_card_id) { - orderline.gift_card_id = options.gift_card_id; - } - } - wait_for_push_order() { - if(this.pos.config.use_gift_card) { - let giftProduct = this.pos.db.product_by_id[this.pos.config.gift_card_product_id[0]]; - for (let line of this.orderlines) { - if(line.product.id === giftProduct.id) - return true; - } - } - return super.wait_for_push_order(...arguments); - } - } - Registries.Model.extend(Order, PosGiftCardOrder); - - - const PosGiftCardOrderline = (Orderline) => class PosGiftCardOrderline extends Orderline { - export_as_JSON() { - var json = super.export_as_JSON(...arguments); - json.generated_gift_card_ids = this.generated_gift_card_ids; - json.gift_card_id = this.gift_card_id; - return json; - } - init_from_JSON(json) { - super.init_from_JSON(...arguments); - this.generated_gift_card_ids = json.generated_gift_card_ids; - this.gift_card_id = json.gift_card_id; - } - } - Registries.Model.extend(Orderline, PosGiftCardOrderline); -}); diff --git a/addons/pos_gift_card/static/src/xml/GiftCardButton.xml b/addons/pos_gift_card/static/src/xml/GiftCardButton.xml deleted file mode 100644 index 0ac7c533ac0..00000000000 --- a/addons/pos_gift_card/static/src/xml/GiftCardButton.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - Gift Card - - - - diff --git a/addons/pos_gift_card/static/src/xml/GiftCardPopup.xml b/addons/pos_gift_card/static/src/xml/GiftCardPopup.xml deleted file mode 100644 index aea1ffc0478..00000000000 --- a/addons/pos_gift_card/static/src/xml/GiftCardPopup.xml +++ /dev/null @@ -1,138 +0,0 @@ - - - - - - - - - - diff --git a/addons/pos_gift_card/views/gift_card_views.xml b/addons/pos_gift_card/views/gift_card_views.xml deleted file mode 100644 index 8904e07c1fd..00000000000 --- a/addons/pos_gift_card/views/gift_card_views.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - gift.card.form Website - gift.card - - - - - - - - - - - - - - - - - - - diff --git a/addons/pos_gift_card/views/pos_config_views.xml b/addons/pos_gift_card/views/pos_config_views.xml deleted file mode 100644 index 9ae52ae0a82..00000000000 --- a/addons/pos_gift_card/views/pos_config_views.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - pos.config.form - pos.config - - - -
-
- -
-
-
-
-
-
-
-
diff --git a/addons/pos_gift_card/views/res_config_settings_views.xml b/addons/pos_gift_card/views/res_config_settings_views.xml deleted file mode 100644 index 702b619466d..00000000000 --- a/addons/pos_gift_card/views/res_config_settings_views.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - res.config.form.inherit.pos.coupon - res.config.settings - - - -
-
-
-
-
-