diff --git a/controllers/booking.py b/controllers/booking.py index 87ffd8a..ed12c42 100644 --- a/controllers/booking.py +++ b/controllers/booking.py @@ -2,6 +2,8 @@ from odoo import fields, http, _ from odoo.http import request import werkzeug from odoo.tools import format_datetime, format_date, is_html_empty +from datetime import datetime,timedelta +from dateutil.relativedelta import relativedelta from odoo.exceptions import UserError,AccessError, MissingError,Warning from odoo.addons.website_event.controllers.main import WebsiteEventController from odoo.addons.auth_signup.controllers.main import AuthSignupHome @@ -160,10 +162,11 @@ class booking(WebsiteEventController,AuthSignupHome): vals['down_payment']=request.session['down_payment'] vals['state']='draft' + res=request.env['event.registration'].sudo().create(vals) request.session['res_id']=res.id vals2={} - + #questionnaire' i=1 vals2['event_registration_id']=res.id @@ -190,19 +193,33 @@ class booking(WebsiteEventController,AuthSignupHome): vals3={} i=1 - + while i <= int(request.session['nb_o']): - vals3['booking_option_id']=request.session['options'][i] + vals3['booking_option_id']=int(request.session['options'][i]) vals3['event_registration_id']=res.id #ajout des options + res3=request.env['event.registration_option'].sudo().create(vals3) + res.write({'option_ids':[(4,res3.id)]}) i=i+1 - invoice=request.env['event.registration'].sudo().action_event_registration_generate_invoice(request.session['res_id'],False) + invoice=request.env['event.registration'].sudo().action_event_registration_generate_invoice(request.session['res_id'],False,False) request.session['invoice_id']=invoice.id + #ajout de l'adhésion + membership_product=request.env['product.product'].sudo().search([('membership_product','=',True)],limit=1) + if not membership_product: raise UserError(_('No membership product, please add one')) + vals={} + vals['invoice_id']=int(invoice.id) + vals['partner_id']=int(res.partner_id) + vals['product_id']=int(membership_product.id) + vals['start_date']=datetime.now() + vals['end_date']=datetime.now()+relativedelta(years=1) + vals['amount']=membership_product.list_price + membership=request.env['kalachakra.membership'].sudo().create(vals) + #redirection sur la page de paiement de la facture : url="/my/invoices/"+str(invoice.id)#+"?access_token="+str(invoice.access_token) return request.redirect(url) diff --git a/models/__init__.py b/models/__init__.py index bd8ee18..c2e7429 100644 --- a/models/__init__.py +++ b/models/__init__.py @@ -21,4 +21,5 @@ from . import event_media_link from . import mailing_list #from . import account from . import res_users +from . import membership_import diff --git a/models/booking_event_registration.py b/models/booking_event_registration.py index bab5c85..8d7c20e 100644 --- a/models/booking_event_registration.py +++ b/models/booking_event_registration.py @@ -93,6 +93,8 @@ class EventRegistration(models.Model): balance_invoice_id=fields.Many2one('account.move' ,ondelete="cascade") #balance_invoice_state=fields.Selection(related='balance_order_id.state') + end_of_stay_invoice_id=fields.Many2one('account.move' ,string='end of stay invoice',ondelete="cascade") + payment_status=fields.Char(string='payment status',compute='_compute_payment_status') payment_adjustement=fields.Monetary('payment adjustement',currency_field='currency_id') @@ -182,12 +184,10 @@ class EventRegistration(models.Model): donation_draft.state='done' + - def action_event_registration_generate_invoice(self,id_registration=None,backoffice=True): - - - #suppression des factures existantes - if self.invoice_id: + def remove_invoice(self): + if self.invoice_id and self.invoice_state!='paid': invoice=self.env['account.move'].sudo().search([('id','=',int(self.invoice_id))]) invoice.state='draft' @@ -195,24 +195,46 @@ class EventRegistration(models.Model): #invoice2.unlink() #raise Warning(invoice2) - if self.down_payment_invoice_id: + if self.down_payment_invoice_id and self.down_payment_invoice_state!='paid': + #si la facture d'acompte est payé, on le la supprime pas invoice=self.env['account.move'].sudo().search([('id','=',int(self.down_payment_invoice_id))]) invoice.state='draft' # self.env['account.move'].search([('id','=',int(self.down_payment_invoice_id))]).unlink() # self.down_payment_invoice_id=False - if self.balance_invoice_id: + if self.balance_invoice_id and self.balance_invoice_state!='paid': invoice=self.env['account.move'].sudo().search([('id','=',int(self.balance_invoice_id))]) invoice.state='draft' # self.env['account.move'].search([('id','=',int(self.balance_invoice_id))]).unlink() # self.balance_invoice_id=False - - #suppression des dons existants + return True + + def remove_donation(self): + #suppression des dons existants lié à l'inscription et aux options donation=self.env['donation.donation'].sudo().search([('id','in',self.donation_ids.ids)]) for d in donation: d.state='draft' self.env['donation.donation'].sudo().search([('id','in',self.donation_ids.ids)]).unlink() self.donation_ids=False + return True + + def action_event_registration_generate_end_of_stay_invoice(self): + return self.action_event_registration_generate_invoice(None,True,True) + + def action_event_registration_generate_invoice(self,id_registration=None,backoffice=True,end_of_stay_invoice=False): + + + if not end_of_stay_invoice: + #suppression des factures existantes + #si les factures sont payés on les supprime pas + self.remove_invoice() + #suppression des dons existants lié aux options de l'inscription + self.remove_donation() + else: + invoice=self.env['account.move'].sudo().search([('id','=',int(self.end_of_stay_invoice_id))]) + invoice.state='draft' + + if id_registration:reg=self.env['event.registration'].search([('id','=',int(id_registration))]) else : reg=self @@ -248,11 +270,11 @@ class EventRegistration(models.Model): if self.payment_adjustement!=0: product_price=product_price+self.payment_adjustement #calcul du montant total à régler - + if end_of_stay_invoice:product_price=0 #création du devis sans accompte - if not reg.down_payment: + if (not reg.down_payment and reg.invoice_state!='paid') or (end_of_stay_invoice): #création de la facture vals={} @@ -320,7 +342,7 @@ class EventRegistration(models.Model): #prix à appliquer aux options en fonction du statut ou de la présence de l'option d'adhesion event_option=self.env['booking.option'].sudo().search(['&',('event_id','=',int(reg.event_id)),('booking_option_id','=',int(option.booking_option_id.id))],limit=1) - + price_unit=0 if event_option: if status=="super member":price_unit=event_option.booking_option_super_member_price if status=="member":price_unit=event_option.booking_option_member_price @@ -329,23 +351,29 @@ class EventRegistration(models.Model): if backoffice: if option.booking_option_id.booking_option_product_backoffice: price_unit=option.booking_option_price - + vals={} vals['move_id']=invoice.id #ajout du produit vals['product_id']=int(option.booking_option_id.id) vals['quantity']=1 vals['price_unit']=price_unit - vals['name']=prd.name + vals['name']=prd.name vals['account_id']=int(account_credit.id) + invoice_line=self.env['account.move.line'].with_context(check_move_validity=False).sudo().create(vals) #debit_line vals_d={} vals_d['move_id']=invoice.id - vals_d['debit']=price_unit - vals_d['credit']=0 + if price_unit>=0: + vals_d['debit']=price_unit + vals_d['credit']=0 + if price_unit<0: + vals_d['debit']=0 + vals_d['credit']=-price_unit + vals_d['date']=datetime.now() vals_d['partner_id']=int(reg.partner_id) vals_d['product_id']=int(option.booking_option_id.id) @@ -364,176 +392,184 @@ class EventRegistration(models.Model): if prd.donation: self.sudo().create_donation(reg.id,reg.partner_id,vals['product_id'],vals['price_unit']) - reg.invoice_id=invoice.id + if not end_of_stay_invoice: + reg.invoice_id=invoice.id + else: + reg.end_of_stay_invoice_id=invoice.id + return invoice #2 factures si paiement avec acompte else: - #création de la 1ère facture d'acompte - vals={} - - vals['partner_id']=int(reg.partner_id) - vals['invoice_date']=datetime.now() + if reg.down_payment_invoice_state!='paid' and reg.down_payment and not end_of_stay_invoice: + #création de la 1ère facture d'acompte + vals={} + + vals['partner_id']=int(reg.partner_id) + vals['invoice_date']=datetime.now() + + #mode de paiement CB par defaut + electronic_method=self.env['account.payment.method'].sudo().search([('code','=','electronic')],limit=1) + if electronic_method: + cb_mode=self.env['account.payment.mode'].sudo().search([('payment_method_id','=',int(electronic_method.id))],limit=1) + if cb_mode: + vals['payment_mode_id']=cb_mode.id + else: + raise Warning('please configure credit card mode') + + vals['move_type']='out_invoice' + vals['state']='draft' + #vals['currency_id']=self.currency_id.id + invoice=self.env['account.move'].sudo().create(vals) + invoice.state='posted' + invoice.name='REC'+str(invoice.id) + invoice.payment_reference=invoice.name + + vals={} + account_credit=self.env['account.account'].sudo().search([('code','=','707100')]) + account_debit=self.env['account.account'].sudo().search([('code','=','411100')]) + + vals['move_id']=invoice.id + vals['product_id']=int(event.booking_product_id) + vals['quantity']=1 + vals['price_unit']=event.booking_down_payment + vals['name']='Acompte '+event.booking_product_id.name + + vals['account_id']=int(account_credit.id) - #mode de paiement CB par defaut - electronic_method=self.env['account.payment.method'].sudo().search([('code','=','electronic')],limit=1) - if electronic_method: - cb_mode=self.env['account.payment.mode'].sudo().search([('payment_method_id','=',int(electronic_method.id))],limit=1) - if cb_mode: - vals['payment_mode_id']=cb_mode.id - else: - raise Warning('please configure credit card mode') + invoice_line=self.env['account.move.line'].with_context(check_move_validity=False).sudo().create(vals) - vals['move_type']='out_invoice' - vals['state']='draft' - #vals['currency_id']=self.currency_id.id - invoice=self.env['account.move'].sudo().create(vals) - invoice.state='posted' - invoice.name='REC'+str(invoice.id) - invoice.payment_reference=invoice.name - - vals={} - account_credit=self.env['account.account'].sudo().search([('code','=','707100')]) - account_debit=self.env['account.account'].sudo().search([('code','=','411100')]) - - vals['move_id']=invoice.id - vals['product_id']=int(event.booking_product_id) - vals['quantity']=1 - vals['price_unit']=event.booking_down_payment - vals['name']='Acompte '+event.booking_product_id.name + + # #debit_line + vals_d={} + vals_d['move_id']=invoice.id + vals_d['debit']=event.booking_down_payment + vals_d['credit']=0 + vals_d['date']=datetime.now() + vals_d['partner_id']=int(reg.partner_id) + vals_d['product_id']=int(event.booking_product_id) + vals_d['name']='Acompte '+event.booking_product_id.name + vals_d['account_id']=int(account_debit.id) + vals_d['quantity']=1 + vals_d['price_unit']=event.booking_down_payment + vals_d['exclude_from_invoice_tab']=True + + + invoice_line=self.env['account.move.line'].with_context(check_move_validity=False).sudo().create(vals_d) + l=self.env['account.move.line'].sudo().search([('move_id','=',invoice.id),('balance','<',0)]) + l.partner_id=int(reg.partner_id) + + reg.down_payment_invoice_id=invoice.id - vals['account_id']=int(account_credit.id) + if reg.balance_invoice_state!='paid' and reg.down_payment and not end_of_stay_invoice: + #création 2ème facture de solde + paiement des options + vals={} + + vals['partner_id']=int(reg.partner_id) + vals['invoice_date']=datetime.now() - invoice_line=self.env['account.move.line'].with_context(check_move_validity=False).sudo().create(vals) - - # #debit_line - vals_d={} - vals_d['move_id']=invoice.id - vals_d['debit']=event.booking_down_payment - vals_d['credit']=0 - vals_d['date']=datetime.now() - vals_d['partner_id']=int(reg.partner_id) - vals_d['product_id']=int(event.booking_product_id) - vals_d['name']='Acompte '+event.booking_product_id.name - vals_d['account_id']=int(account_debit.id) - vals_d['quantity']=1 - vals_d['price_unit']=event.booking_down_payment - vals_d['exclude_from_invoice_tab']=True + vals['move_type']='out_invoice' + vals['state']='draft' + #vals['currency_id']=self.currency_id.id + invoice=self.env['account.move'].sudo().create(vals) + + invoice.state='posted' + invoice.name='REC'+str(invoice.id) + invoice.payment_reference=invoice.name + vals={} - invoice_line=self.env['account.move.line'].with_context(check_move_validity=False).sudo().create(vals_d) - l=self.env['account.move.line'].sudo().search([('move_id','=',invoice.id),('balance','<',0)]) - l.partner_id=int(reg.partner_id) - - reg.down_payment_invoice_id=invoice.id - - #création 2ème facture de solde + paiement des options - vals={} - - vals['partner_id']=int(reg.partner_id) - vals['invoice_date']=datetime.now() - - - vals['move_type']='out_invoice' - vals['state']='draft' - #vals['currency_id']=self.currency_id.id - invoice=self.env['account.move'].sudo().create(vals) - - invoice.state='posted' - invoice.name='REC'+str(invoice.id) - invoice.payment_reference=invoice.name - - vals={} - - vals['move_id']=invoice.id - vals['product_id']=int(event.booking_product_id) - vals['quantity']=1 - vals['price_unit']=product_price-event.booking_down_payment - vals['name']='solde '+event.booking_product_id.name - - vals['account_id']=int(account_credit.id) - - invoice_line=self.env['account.move.line'].with_context(check_move_validity=False).sudo().create(vals) + vals['move_id']=invoice.id + vals['product_id']=int(event.booking_product_id) + vals['quantity']=1 + vals['price_unit']=product_price-event.booking_down_payment + vals['name']='solde '+event.booking_product_id.name + + vals['account_id']=int(account_credit.id) - - # #debit_line - vals_d={} - vals_d['move_id']=invoice.id - vals_d['debit']=product_price-event.booking_down_payment - vals_d['credit']=0 - vals_d['date']=datetime.now() - vals_d['partner_id']=int(reg.partner_id) - vals_d['product_id']=int(event.booking_product_id) - vals_d['name']='solde '+event.booking_product_id.name - vals_d['account_id']=int(account_debit.id) - vals_d['quantity']=1 - vals_d['price_unit']=product_price-event.booking_down_payment - vals_d['exclude_from_invoice_tab']=True + invoice_line=self.env['account.move.line'].with_context(check_move_validity=False).sudo().create(vals) + + # #debit_line + vals_d={} + vals_d['move_id']=invoice.id + vals_d['debit']=product_price-event.booking_down_payment + vals_d['credit']=0 + vals_d['date']=datetime.now() + vals_d['partner_id']=int(reg.partner_id) + vals_d['product_id']=int(event.booking_product_id) + vals_d['name']='solde '+event.booking_product_id.name + vals_d['account_id']=int(account_debit.id) + vals_d['quantity']=1 + vals_d['price_unit']=product_price-event.booking_down_payment + vals_d['exclude_from_invoice_tab']=True + + + invoice_line=self.env['account.move.line'].with_context(check_move_validity=False).sudo().create(vals_d) + l=self.env['account.move.line'].sudo().search([('move_id','=',invoice.id),('balance','<',0)]) + l.partner_id=int(reg.partner_id) + + + #ajout des options + if selected_registrant_options: + for option in selected_registrant_options: + + prd=self.env['product.product'].sudo().search([('id','=',int(option.booking_option_id.id))]) + + #prix à appliquer aux options en fonction du statut ou de la présence de l'option d'adhesion + event_option=self.env['booking.option'].search(['&',('event_id','=',int(reg.event_id)),('booking_option_id','=',int(option.booking_option_id.id))]) + price_unit=0 + if event_option: + if status=="super member":price_unit=event_option.booking_option_super_member_price + if status=="member":price_unit=event_option.booking_option_member_price + if status=="not member" and membership_option:price_unit=event_option.booking_option_member_price + if status=="not member" and not membership_option:price_unit=event_option.booking_option_price + if backoffice: + if option.booking_option_id.booking_option_product_backoffice: + price_unit=option.booking_option_price - invoice_line=self.env['account.move.line'].with_context(check_move_validity=False).sudo().create(vals_d) - l=self.env['account.move.line'].sudo().search([('move_id','=',invoice.id),('balance','<',0)]) - l.partner_id=int(reg.partner_id) - - #ajout des options - if selected_registrant_options: - for option in selected_registrant_options: - - prd=self.env['product.product'].sudo().search([('id','=',int(option.booking_option_id.id))]) - - #prix à appliquer aux options en fonction du statut ou de la présence de l'option d'adhesion - event_option=self.env['booking.option'].search(['&',('event_id','=',int(reg.event_id)),('booking_option_id','=',int(option.booking_option_id.id))]) - - if event_option: - if status=="super member":price_unit=event_option.booking_option_super_member_price - if status=="member":price_unit=event_option.booking_option_member_price - if status=="not member" and membership_option:price_unit=event_option.booking_option_member_price - if status=="not member" and not membership_option:price_unit=event_option.booking_option_price + vals={} + vals['move_id']=invoice.id + #ajout du produit + vals['product_id']=int(event.booking_product_id) + vals['quantity']=1 + vals['price_unit']=price_unit + vals['name']=prd.name + vals['account_id']=int(account_credit.id) + invoice_line=self.env['account.move.line'].with_context(check_move_validity=False).sudo().create(vals) - #calcul du prix en fonction du sejour,nuité, ou jour - # if prd.price_per=='day': - # price_unit=price_unit*event.duration - # if prd.price_per=='night': - # price_unit=price_unit*event.duration-1 - - vals={} - vals['move_id']=invoice.id - #ajout du produit - vals['product_id']=int(event.booking_product_id) - vals['quantity']=1 - vals['price_unit']=price_unit - vals['name']=prd.name - vals['account_id']=int(account_credit.id) - invoice_line=self.env['account.move.line'].with_context(check_move_validity=False).sudo().create(vals) - - #debit_line - vals_d={} - vals_d['move_id']=invoice.id - vals_d['debit']=price_unit - vals_d['credit']=0 - vals_d['date']=datetime.now() - vals_d['partner_id']=int(reg.partner_id) - vals_d['product_id']=int(option.booking_option_id.id) - vals_d['name']=prd.name - vals_d['account_id']=int(account_debit.id) - vals_d['quantity']=1 - vals_d['price_unit']=price_unit - vals_d['exclude_from_invoice_tab']=True - - invoice_line=self.env['account.move.line'].with_context(check_move_validity=True).sudo().create([vals_d]) - l=self.env['account.move.line'].search([('move_id','=',invoice.id),('balance','<',0)]) - l.partner_id=int(reg.partner_id) - - - #si l'option est un produit de don on créé un don pour la personne - if prd.donation: self.sudo().create_donation(reg.id,reg.partner_id,vals['product_id'],vals['price_unit']) - - reg.balance_invoice_id=invoice.id + #debit_line + vals_d={} + vals_d['move_id']=invoice.id + if price_unit>=0: + vals_d['debit']=price_unit + vals_d['credit']=0 + if price_unit<0: + vals_d['debit']=0 + vals_d['credit']=-price_unit + vals_d['date']=datetime.now() + vals_d['partner_id']=int(reg.partner_id) + vals_d['product_id']=int(option.booking_option_id.id) + vals_d['name']=prd.name + vals_d['account_id']=int(account_debit.id) + vals_d['quantity']=1 + vals_d['price_unit']=price_unit + vals_d['exclude_from_invoice_tab']=True + + invoice_line=self.env['account.move.line'].with_context(check_move_validity=True).sudo().create([vals_d]) + l=self.env['account.move.line'].search([('move_id','=',invoice.id),('balance','<',0)]) + l.partner_id=int(reg.partner_id) + + + #si l'option est un produit de don on créé un don pour la personne + if prd.donation: self.sudo().create_donation(reg.id,reg.partner_id,vals['product_id'],vals['price_unit']) + + reg.balance_invoice_id=invoice.id return invoice.id def info_objet(self,model_id,objet_id): diff --git a/models/membership.py b/models/membership.py index 6811fb4..9320add 100644 --- a/models/membership.py +++ b/models/membership.py @@ -1,6 +1,6 @@ from odoo import models, fields, api from dateutil.relativedelta import relativedelta -from datetime import datetime +from datetime import datetime,timedelta class kalachakra_membership(models.Model): _name = 'kalachakra.membership' @@ -31,11 +31,12 @@ class kalachakra_membership(models.Model): rec.payment_state='paid' rec.state='done' - def _default_end_date(self): - - return datetime.now()+relativedelta(years=1) + + + + end_date=fields.Date('end date') + - end_date=fields.Date('end date',required=True,default=_default_end_date) state=fields.Selection(string='state',selection=[('draft', 'draft'), ('done', 'done')],default='draft') currency_id = fields.Many2one( "res.currency", @@ -129,24 +130,26 @@ class kalachakra_membership(models.Model): return transaction - # @api.model - # def create(self,vals): - - # res=super(kalachakra_membership, self).create(vals) - - # #on ajoute l'étiquette membre au contact - # #si l'étiquette membre n'existe pas on l'a créé ! - # label_member=self.env['res.partner.category'].search([('name','=','member')]) - # id_label_member=label_member.id - # if not label_member: - # vals={} - # vals['name']='member' - # res=self.env['res.partner.category'].create(vals) - # id_label_member=res.id - # partner=self.env['res.partner'].search([('id','=',int(self.partner_id))]) - # if partner: - # if id_label_member not in partner.category_id: - # partner.write({category_id:(4, id_label_member)}) + def update_membership(self): + if self.end_date>=datetime.now().date() and self.payment_state=='paid': + member_status='member' + else: + member_status='not member' + + partner=self.env['res.partner'].search([('id','=',int(self.partner_id))]) + + if partner.super_member==False: + partner.member_status=member_status + def write(self,vals): + + res=super(kalachakra_membership, self).write(vals) + self.update_membership() + + def create(self,vals): + + res=super(kalachakra_membership, self).create(vals) + res.update_membership() + diff --git a/models/membership_import.py b/models/membership_import.py new file mode 100644 index 0000000..17af555 --- /dev/null +++ b/models/membership_import.py @@ -0,0 +1,78 @@ +from odoo import models, fields, api +from odoo.exceptions import UserError, ValidationError, Warning +from psycopg2 import sql, DatabaseError +from odoo.tools.safe_eval import safe_eval +from datetime import date, datetime, time,timedelta +from dateutil.relativedelta import relativedelta +from odoo import fields, http, SUPERUSER_ID, tools, _ +from werkzeug import utils +import csv +import base64 +import io +import json +import re + + + +class membershipimport(models.Model): + _name = 'kalachakra.membershipimport' + _description = 'import memberships from csv' + + + + def import_membership_csv_files(self): + + files= self.env["opendons.partnerdraftfile"].search([('source_name','=','membership')]) + + for f in files: + + decrypted = base64.b64decode(f.file).decode('utf-8-sig') + source_name=f.source_name + membership_product=self.env['product.product'].sudo().search([('membership_product','=',True)],limit=1) + + with io.StringIO(decrypted) as fp: + reader = csv.DictReader(fp, delimiter=",", quotechar='"') + for row in reader: + vals={} + vals['partner_id']=False + vals['product_id']=membership_product.id + vals['start_date']=False + vals['state']='done' + vals['payment_state']='paid' + type_rec='' + for key, value in row.items(): + #on cherche le contact + + + if key=='id_contact': + partner=self.env['res.partner'].search([('external_id','=',value)]) + if partner: + vals['partner_id']=partner.id + if key=='type': + type_rec=value + if key=='debut_adhesion': + if value!='0000-00-00': + year_m=value[0:4] + month_m=value[5:7] + day_m=value[8:10] + if year_m=='2021': + start_date=datetime.strptime(year_m+'-'+month_m+'-'+day_m, '%Y-%m-%d') + ref_date=datetime.strptime('2021-08-15', '%Y-%m-%d') + + if start_date>=ref_date: + vals['start_date']=start_date + vals['end_date']=start_date+relativedelta(years=1) + # field_map=self.env['opendons.partnerdraftfile_mapping'].search([('external_field','=',key)]) + # if field_map: + # odoo_field=field_map.odoo_field + # vals[odoo_field]=str(value) + + # else: raise Warning('champ '+str(key)+' non trouvé') + + if vals['partner_id'] and vals['start_date']: + self.env['kalachakra.membership'].create(vals) + + + return True + + \ No newline at end of file diff --git a/models/partner.py b/models/partner.py index 66dbb99..308b956 100644 --- a/models/partner.py +++ b/models/partner.py @@ -61,8 +61,10 @@ class ResPartner(models.Model): date_adhesion=fields.Char(string='Date adhesion', readonly=True) + @api.depends('super_member') def _compute_member_status(self): for rec in self: + member=rec.env['kalachakra.membership'].search([('partner_id','=',rec.id),('end_date','>=',datetime.now()),('payment_state','=','paid')]) if member : rec.member_status='member' else :rec.member_status='not member' diff --git a/security/ir.model.access.csv b/security/ir.model.access.csv index 85f0d0b..67ebc52 100644 --- a/security/ir.model.access.csv +++ b/security/ir.model.access.csv @@ -1,6 +1,7 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink access_kalachakra_membership,kalachakra.membership,model_kalachakra_membership,base.group_user,1,1,1,1 +access_kalachakra_membership_import,kalachakra.membership_import,model_kalachakra_membershipimport,base.group_user,1,1,1,1 access_booking_booking_option,booking.booking_option,model_booking_option,base.group_user,1,1,1,1 access_booking_location,booking.booking_location,model_booking_location,base.group_user,1,1,1,1 @@ -18,6 +19,7 @@ access_event_registration_option,event.registration_option,model_event_registrat access_event_partner_category,event.partner_category,model_event_partner_category,base.group_user,1,1,1,1 access_event_membership_product,event.membership_product,model_event_membership_product,base.group_user,1,1,1,1 + access_event_media_link,event_media_link,model_event_media_link,base.group_user,1,1,1,1 access_event_media_link_public,event_media_link_public,model_event_media_link,base.group_public,1,0,0,0 access_event_media_link_portal,event_media_link_portal,model_event_media_link,base.group_portal,1,0,0,0 diff --git a/static/js/booking.js b/static/js/booking.js index 4385006..0cae968 100644 --- a/static/js/booking.js +++ b/static/js/booking.js @@ -61,6 +61,13 @@ odoo.define('booking.main', function (require) { $('#validation_message').show() + } + else if ($('#city').val()=='') + { + $('#validation_message').text('merci de saisir la ville du participant') + $('#validation_message').show() + + } else { diff --git a/views/booking_event_registration.xml b/views/booking_event_registration.xml index ca08dcc..a211ac5 100644 --- a/views/booking_event_registration.xml +++ b/views/booking_event_registration.xml @@ -108,6 +108,9 @@ + @@ -119,6 +122,7 @@ + diff --git a/views/partner.xml b/views/partner.xml index 7347f10..6ad9a96 100644 --- a/views/partner.xml +++ b/views/partner.xml @@ -31,6 +31,23 @@ + + + + kalachakra.res.partner.tree + res.partner + + + + + + + + + + + +