diff --git a/models/booking_event_registration.py b/models/booking_event_registration.py
index 8d7c20e..7e99f08 100644
--- a/models/booking_event_registration.py
+++ b/models/booking_event_registration.py
@@ -96,10 +96,18 @@ class EventRegistration(models.Model):
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_status=fields.Selection(string='payment status',selection=[('paid','Paid'),('not paid','Not paid'),('down payment not paid','down payment not paid'),('down payment paid','down payment paid')],compute='_compute_payment_status',translate=True)
+ to_be_paid_amount=fields.Monetary('to be paid amount',compute='_compute_to_be_paid_amount',currency_field='currency_id')
payment_adjustement=fields.Monetary('payment adjustement',currency_field='currency_id')
-
+ def _compute_to_be_paid_amount(self):
+ for rec in self:
+ rec.to_be_paid_amount=0
+ if rec.invoice_id : rec.to_be_paid_amount=rec.invoice_id.amount_residual
+ else:
+ if rec.down_payment_invoice_id and balance_invoice_id:
+ rec.to_be_paid_amount=rec.down_payment_invoice_id.amount_residual+rec.balance_invoice_id.amount_residual
+
def _compute_payment_status(self):
for rec in self:
rec.payment_status='not paid'
@@ -127,8 +135,8 @@ class EventRegistration(models.Model):
def _compute_kanban_color(self):
for rec in self:
rec.kanban_color=''
- if rec.gender=='male':rec.kanban_color="d0e0e3"
- if rec.gender=='femelle':rec.kanban_color="eebbcc"
+ if rec.gender=='male':rec.kanban_color="50aaf3"
+ if rec.gender=='femelle':rec.kanban_color="ffffff"
@api.model
def _read_group_room_ids(self, stages, domain, order):
return self.env['booking.room'].search([])
@@ -281,15 +289,23 @@ class EventRegistration(models.Model):
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')
+ #mode de paiement CB par defaut si frontoffice
+ if not backoffice:
+ 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')
+ else:
+ check_mode=self.env['account.payment.mode'].sudo().search([('name','=','chèque')])
+ if check_mode:
+ vals['payment_mode_id']=check_mode.id
+ else:
+ raise Warning('please configure check mode')
+
vals['move_type']='out_invoice'
vals['state']='draft'
#vals['currency_id']=self.currency_id.id
@@ -411,13 +427,20 @@ class EventRegistration(models.Model):
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')
+ if not backoffice:
+ 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')
+ else:
+ check_mode=self.env['account.payment.mode'].sudo().search([('name','=','chèque')])
+ if check_mode:
+ vals['payment_mode_id']=check_mode.id
+ else:
+ raise Warning('please configure check mode')
vals['move_type']='out_invoice'
vals['state']='draft'
@@ -490,6 +513,22 @@ class EventRegistration(models.Model):
vals['account_id']=int(account_credit.id)
+ #mode de paiement CB par defaut
+ if not backoffice:
+ 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')
+ else:
+ check_mode=self.env['account.payment.mode'].sudo().search([('name','=','chèque')])
+ if check_mode:
+ vals['payment_mode_id']=check_mode.id
+ else:
+ raise Warning('please configure check mode')
+
invoice_line=self.env['account.move.line'].with_context(check_move_validity=False).sudo().create(vals)
diff --git a/views/booking_event_registration.xml b/views/booking_event_registration.xml
index a211ac5..79f78fb 100644
--- a/views/booking_event_registration.xml
+++ b/views/booking_event_registration.xml
@@ -235,6 +235,8 @@
+
+
diff --git a/views/event_templates_page_registration.xml b/views/event_templates_page_registration.xml
index 8ab545d..090ed7d 100644
--- a/views/event_templates_page_registration.xml
+++ b/views/event_templates_page_registration.xml
@@ -105,7 +105,7 @@
-