|
|
@ -102,7 +102,87 @@ class EventRegistration(models.Model): |
|
|
|
individual_room=fields.Boolean('Individual room',compute='compute_individual_room') |
|
|
|
start_day_individual_booking=fields.Date('Start day individual booking') |
|
|
|
end_day_individual_booking=fields.Date('End day individual booking') |
|
|
|
|
|
|
|
#pour rapport |
|
|
|
# member_status=fields.Char('member status', compute='_compute_member_status') |
|
|
|
# invoice_options_amount=fields.Float('invoice options amount',compute='_compute_invoice_options_amount') |
|
|
|
# membership_amount=fields.Float('membership amount',compute='_compute_membership_amount') |
|
|
|
# booking_amount=fields.Float('booking amount',compute='_compute_booking_amount') |
|
|
|
# amount_to_be_paid=fields.Float('booking amount to be paid',compute='_compute_amount_to_be_paid') |
|
|
|
# amount_paid=fields.Float('booking amount paid',compute='_compute_amount_paid') |
|
|
|
# invoice_options=fields.Char('invoice options',compute='_compute_invoice_options') |
|
|
|
# payment_mode=fields.Char('invoice options',compute='_compute_payment_mode') |
|
|
|
|
|
|
|
def _compute_payment_mode(self): |
|
|
|
for rec in self: |
|
|
|
rec.payment_mode='' |
|
|
|
if rec.invoice_id: |
|
|
|
rec.payment_mode=rec.invoice_id.payment_mode_id.name |
|
|
|
if rec.down_payment_invoice_id: |
|
|
|
rec.payment_mode=rec.down_payment_invoice_id.payment_mode_id.name |
|
|
|
|
|
|
|
def _compute_amount_paid(self): |
|
|
|
for rec in self: |
|
|
|
rec.amount_paid=0 |
|
|
|
if rec.invoice_id: |
|
|
|
rec.amount_paid=rec.invoice_id.amount_total-rec.invoice_id.amount_residual |
|
|
|
if rec.down_payment_invoice_id: |
|
|
|
rec.amount_paid=rec.amount_paid+rec.down_payment_invoice_id.amount_total-rec.down_payment_invoice_id.amount_residual |
|
|
|
if rec.balance_invoice_id: |
|
|
|
rec.amount_paid=rec.amount_paid+rec.balance_invoice_id.amount_total-rec.balance_invoice_id.amount_residual |
|
|
|
if rec.end_of_stay_invoice_id: |
|
|
|
rec.amount_paid=rec.amount_paid+rec.end_of_stay_invoice_id.amount_total-rec.end_of_stay_invoice_id.amount_residual |
|
|
|
|
|
|
|
def _compute_amount_to_be_paid(self): |
|
|
|
for rec in self: |
|
|
|
rec.amount_to_be_paid=0 |
|
|
|
if rec.invoice_id: |
|
|
|
rec.amount_to_be_paid=rec.invoice_id.amount_residual |
|
|
|
if rec.down_payment_invoice_id: |
|
|
|
rec.amount_to_be_paid=rec.amount_to_be_paid+rec.down_payment_invoice_id.amount_residual |
|
|
|
if rec.balance_invoice_id: |
|
|
|
rec.amount_to_be_paid=rec.amount_to_be_paid+rec.balance_invoice_id.amount_residual |
|
|
|
if rec.end_of_stay_invoice_id: |
|
|
|
rec.amount_to_be_paid=rec.amount_to_be_paid+rec.end_of_stay_invoice_id.amount_residual |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _compute_invoice_options_amount(self): |
|
|
|
membership_product=self.env['product.product'].sudo().search([('membership_product','=',True)],limit=1) |
|
|
|
for rec in self: |
|
|
|
rec.invoice_options_amount=0 |
|
|
|
#si facture sans acompte: |
|
|
|
i=1 |
|
|
|
|
|
|
|
if rec.invoice_id: |
|
|
|
|
|
|
|
for line in rec.invoice_id.invoice_line_ids: |
|
|
|
if i>1: |
|
|
|
if line.name!=membership_product.name: |
|
|
|
rec.invoice_options_amount=rec.invoice_options_amount+line.price_subtotal |
|
|
|
i=i+1 |
|
|
|
#si facture avec acompte: |
|
|
|
i=1 |
|
|
|
|
|
|
|
if rec.balance_invoice_id: |
|
|
|
|
|
|
|
for line in rec.balance_invoice_id.invoice_line_ids: |
|
|
|
if i>1: |
|
|
|
if line.name!=membership_product.name: |
|
|
|
rec.invoice_options_amount=rec.invoice_options_amount+line.price_subtotal |
|
|
|
i=i+1 |
|
|
|
i=1 |
|
|
|
if rec.end_of_stay_invoice_id: |
|
|
|
for line in rec.end_of_stay_invoice_id.invoice_line_ids: |
|
|
|
if i>1: |
|
|
|
if line.name!=membership_product.name: |
|
|
|
rec.invoice_options_amount=rec.invoice_options_amount+line.price_subtotal |
|
|
|
|
|
|
|
i=i+1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def compute_individual_room(self): |
|
|
|
for rec in self: |
|
|
@ -539,7 +619,7 @@ class EventRegistration(models.Model): |
|
|
|
invoice.state='posted' |
|
|
|
invoice.name='REC'+str(invoice.id) |
|
|
|
invoice.payment_reference=invoice.name |
|
|
|
user=self.env['res.users'].search([('email','ilike',reg.partner_id.email)]) |
|
|
|
user=self.env['res.users'].search([('email','ilike',reg.partner_id.email)],limit=1) |
|
|
|
invoice.invoice_user_id=user.id |
|
|
|
invoice.user_id=user.id |
|
|
|
|
|
|
@ -595,7 +675,7 @@ class EventRegistration(models.Model): |
|
|
|
invoice.state='posted' |
|
|
|
invoice.name='REC'+str(invoice.id) |
|
|
|
invoice.payment_reference=invoice.name |
|
|
|
user=self.env['res.users'].search([('email','ilike',reg.partner_id.email)]) |
|
|
|
user=self.env['res.users'].search([('email','ilike',reg.partner_id.email)],limit=1) |
|
|
|
invoice.invoice_user_id=user.id |
|
|
|
invoice.user_id=user.id |
|
|
|
|
|
|
|