commit
b7daa7386e
|
|
@ -1218,6 +1218,11 @@ msgstr "أخرى"
|
|||
msgid "Paid"
|
||||
msgstr "مدفوع"
|
||||
|
||||
#. module: property_management
|
||||
#: model:ir.model.fields.selection,name:property_management.selection__rent_payment__state__invoice
|
||||
msgid "Invoice"
|
||||
msgstr "مفوتر"
|
||||
|
||||
#. module: property_management
|
||||
#: model:ir.model.fields,field_description:property_management.field_rent_payment__paid_date
|
||||
msgid "Paid Date"
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ class RentPayment(models.Model):
|
|||
amount_in_word = fields.Char(string="Amount In Word", compute="get_amount_in_word")
|
||||
state = fields.Selection([('draft', 'Not Due'),
|
||||
('due', 'Due'),
|
||||
('invoice', 'Invoice'),
|
||||
('paid', 'Paid'),
|
||||
('cancel', 'Canceled')], string="Status", default='draft')
|
||||
invoice_id = fields.Many2one('account.move', string="Invoice")
|
||||
|
|
@ -57,6 +58,8 @@ class RentPayment(models.Model):
|
|||
if rec.invoice_id:
|
||||
if rec.invoice_id.amount_residual == 0.0:
|
||||
rec.paid = True
|
||||
if rec.invoice_id.payment_state in ['paid','in_payment']:
|
||||
rec.write({'state': 'paid'})
|
||||
|
||||
|
||||
def _prepare_invoice_values(self, payment, amount):
|
||||
|
|
@ -83,7 +86,7 @@ class RentPayment(models.Model):
|
|||
invoice_vals = self._prepare_invoice_values(self, self.total_amount)
|
||||
invoice = self.env['account.move'].sudo().create(invoice_vals).with_user(self.env.uid)
|
||||
self.invoice_id = invoice.id
|
||||
self.write({'state': 'paid'})
|
||||
self.write({'state': 'invoice'})
|
||||
|
||||
@api.depends('total_amount')
|
||||
def get_amount_in_word(self):
|
||||
|
|
|
|||
|
|
@ -282,6 +282,7 @@ class RentalContract(models.Model):
|
|||
rec.insurance_paid = 0.0
|
||||
|
||||
def _prepare_invoice_values(self, contract, amount):
|
||||
self.partner_id.property_account_receivable_id = contract.debit_account_id.id
|
||||
invoice_vals = {
|
||||
'ref': _("Insurance payment for ") + contract.name,
|
||||
'move_type': 'out_invoice',
|
||||
|
|
@ -305,6 +306,10 @@ class RentalContract(models.Model):
|
|||
def action_confirm(self):
|
||||
invoice_vals = self._prepare_invoice_values(self, self.insurance_amount)
|
||||
invoice = self.env['account.move'].sudo().create(invoice_vals).with_user(self.env.uid)
|
||||
# Get the ID of the second line
|
||||
if invoice.invoice_line_ids[1]:
|
||||
line_id = invoice.invoice_line_ids[1].id
|
||||
commands = [(2, line_id, 0)]
|
||||
self.insurance_invoice_id = invoice.id
|
||||
if self.rent_method != 'property':
|
||||
for unit in self.unit_ids:
|
||||
|
|
|
|||
Loading…
Reference in New Issue