From fe97524d776e736f54cad7aaa7cc4d49e23a3be4 Mon Sep 17 00:00:00 2001 From: AjmalCybro Date: Thu, 18 Apr 2024 12:46:56 +0530 Subject: [PATCH] Apr 18 [FIX] : Bug Fixed 'membership_in_pos' --- membership_in_pos/__manifest__.py | 2 +- membership_in_pos/models/membership_card.py | 13 +++++++++---- .../static/src/js/AbstractAwaitablePopup.js | 1 + membership_in_pos/static/src/js/ProductScreen.js | 3 +++ membership_in_pos/views/membership_card_views.xml | 4 ++-- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/membership_in_pos/__manifest__.py b/membership_in_pos/__manifest__.py index 7a9dd35df..14d4bef7a 100644 --- a/membership_in_pos/__manifest__.py +++ b/membership_in_pos/__manifest__.py @@ -31,7 +31,7 @@ 'company': 'Cybrosys Techno Solutions', 'maintainer': 'Cybrosys Techno Solutions', 'website': 'https://www.cybrosys.com', - 'depends': ['pos_sale', 'sale', 'pos_loyalty', 'pos_discount'], + 'depends': ['pos_sale', 'sale', 'pos_loyalty', 'pos_discount','point_of_sale'], 'data': { 'security/ir.model.access.csv', 'views/res_config_settings_views.xml', diff --git a/membership_in_pos/models/membership_card.py b/membership_in_pos/models/membership_card.py index a93fb9a16..0794107f6 100644 --- a/membership_in_pos/models/membership_card.py +++ b/membership_in_pos/models/membership_card.py @@ -23,6 +23,8 @@ from uuid import uuid4 from odoo import api, fields, models, _ from odoo import exceptions +from datetime import datetime, timedelta + class MembershipCard(models.Model): @@ -36,7 +38,8 @@ class MembershipCard(models.Model): required=True, help='Membership id') customer_id = fields.Many2one('res.partner', string="Customer", help='The customer') - issue_date = fields.Date(string="Issue Date", help='Issue date') + issue_date = fields.Date(string="Issue Date", help='Issue date', + default=fields.Date.today()) validity = fields.Float(string='Validity(days)', compute='_compute_validity', help='Validity of membership card') @@ -74,9 +77,11 @@ class MembershipCard(models.Model): def _compute_validity(self): """Computes the validity""" - for rec in self: - date = rec.expiry_date - rec.issue_date - rec.validity = date.days + fmt = '%Y-%m-%d' + date_from = datetime.strptime(str(self.issue_date), fmt) + date_to = datetime.strptime(str(self.expiry_date), fmt) + duration = str((date_to - date_from).days) + self.validity = duration def membership_card_check(self, customer_input): """Checks the validity of the membership card""" diff --git a/membership_in_pos/static/src/js/AbstractAwaitablePopup.js b/membership_in_pos/static/src/js/AbstractAwaitablePopup.js index 607de4d17..1ad51e920 100644 --- a/membership_in_pos/static/src/js/AbstractAwaitablePopup.js +++ b/membership_in_pos/static/src/js/AbstractAwaitablePopup.js @@ -63,6 +63,7 @@ odoo.define('membership_in_pos.MembershipPopup', function (require) { // We add the price as manually set to avoid re computation when changing customer. let discount = - parseFloat(this.env.pos.card.discount) / 100.0 * baseToDiscount; if (discount < 0) { + console.log("fffffffffffff") order.add_product(product, { price: discount, lst_price: discount, diff --git a/membership_in_pos/static/src/js/ProductScreen.js b/membership_in_pos/static/src/js/ProductScreen.js index dca9ea558..23f526cb6 100644 --- a/membership_in_pos/static/src/js/ProductScreen.js +++ b/membership_in_pos/static/src/js/ProductScreen.js @@ -34,6 +34,9 @@ odoo.define('membership_in_pos.customer', function (require) { }); } } + + + } Registries.Component.extend(ProductScreen, PosCustomer); return ProductScreen; diff --git a/membership_in_pos/views/membership_card_views.xml b/membership_in_pos/views/membership_card_views.xml index 67a92b63f..6d82088cc 100644 --- a/membership_in_pos/views/membership_card_views.xml +++ b/membership_in_pos/views/membership_card_views.xml @@ -78,8 +78,8 @@ - + sequence="3"/> +