[UPDATE]
This commit is contained in:
parent
f2475cd33f
commit
466fadfc1e
|
|
@ -42,7 +42,7 @@ class EndOfRent(models.Model):
|
|||
invoice_id = fields.Many2one('account.move', string="Invoice")
|
||||
|
||||
def _prepare_out_refund_invoice_values(self, end, amount):
|
||||
self.contract_id.partner_id.property_account_receivable_id = end.contract_id.debit_account_id.id
|
||||
self.contract_id.partner_id.property_account_receivable_id = end.contract_id.accrued_account_id.id
|
||||
invoice_vals = {
|
||||
'ref': end.name,
|
||||
'move_type': 'out_refund',
|
||||
|
|
@ -55,19 +55,19 @@ class EndOfRent(models.Model):
|
|||
'name': end.name + ' - ' + str(end.date),
|
||||
'price_unit': amount,
|
||||
'quantity': 1.0,
|
||||
'account_id': end.contract_id.accrued_account_id.id,
|
||||
'account_id': end.contract_id.debit_account_id.id,
|
||||
|
||||
})],
|
||||
'line_ids': [(0, 0, {'account_id': end.contract_id.accrued_account_id.id, 'debit': 0.0, 'credit': amount,
|
||||
'line_ids': [(0, 0, {'account_id':end.contract_id.debit_account_id.id, 'debit': 0.0, 'credit': amount,
|
||||
'name': end.name + ' - ' + str(end.date),
|
||||
'quantity': 1}),
|
||||
(0, 0,
|
||||
{'account_id': end.contract_id.debit_account_id.id, 'debit': amount, 'credit': 0.0, 'quantity': 1})]
|
||||
{'account_id': end.contract_id.accrued_account_id.id , 'debit': amount, 'credit': 0.0, 'quantity': 1})]
|
||||
}
|
||||
return invoice_vals
|
||||
|
||||
def _prepare_invoice_values(self, end, amount):
|
||||
self.contract_id.partner_id.property_account_receivable_id = end.contract_id.revenue_account_id.id
|
||||
self.contract_id.partner_id.property_account_receivable_id = end.contract_id.debit_account_id.id
|
||||
invoice_vals = {
|
||||
'ref': end.name,
|
||||
'move_type': 'out_invoice',
|
||||
|
|
@ -80,13 +80,15 @@ class EndOfRent(models.Model):
|
|||
'name': end.name + ' - ' + str(end.date),
|
||||
'price_unit': amount,
|
||||
'quantity': 1.0,
|
||||
'account_id': end.contract_id.revenue_account_id.id,
|
||||
|
||||
|
||||
})],
|
||||
'line_ids': [(0, 0, {'account_id': end.contract_id.debit_account_id.id, 'debit': 0.0, 'credit': amount,
|
||||
'line_ids': [(0, 0, {'account_id':end.contract_id.revenue_account_id.id, 'debit': 0.0, 'credit': amount,
|
||||
'name': end.name + ' - ' + str(end.date),
|
||||
'quantity': 1}),
|
||||
(0, 0,
|
||||
{'account_id': end.contract_id.revenue_account_id.id, 'debit': amount, 'credit': 0.0, 'quantity': 1})]
|
||||
{'account_id': end.contract_id.debit_account_id.id, 'debit': amount, 'credit': 0.0, 'quantity': 1})]
|
||||
}
|
||||
return invoice_vals
|
||||
|
||||
|
|
@ -107,10 +109,10 @@ class EndOfRent(models.Model):
|
|||
if (rec.remain_amount > 0.0) or (rec.remain_amount > 0.0 and rec.maintenance):
|
||||
invoice_vals = rec._prepare_out_refund_invoice_values(rec, rec.remain_amount)
|
||||
invoice = self.env['account.move'].sudo().create(invoice_vals).with_user(self.env.uid)
|
||||
# Get the ID of the second line
|
||||
line_id = invoice.invoice_line_ids[1].id
|
||||
commands = [(2, line_id, 0)]
|
||||
invoice.write({'invoice_line_ids': commands})
|
||||
if len(invoice.invoice_line_ids) > 1:
|
||||
line_id = invoice.invoice_line_ids[1].id
|
||||
commands = [(2, line_id, 0)]
|
||||
invoice.write({'invoice_line_ids': commands})
|
||||
rec.invoice_id = invoice.id
|
||||
rec.write({'state': 'done'})
|
||||
elif (rec.insurance_amount == 0.0 or rec.remain_amount==0.0) and not rec.maintenance:
|
||||
|
|
@ -118,20 +120,20 @@ class EndOfRent(models.Model):
|
|||
elif (rec.insurance_amount == 0.0 or rec.remain_amount==0.0) and rec.maintenance:
|
||||
invoice_vals = rec._prepare_invoice_values(rec, abs(rec.remain_amount))
|
||||
invoice = self.env['account.move'].sudo().create(invoice_vals).with_user(self.env.uid)
|
||||
# Get the ID of the second line
|
||||
line_id = invoice.invoice_line_ids[1].id
|
||||
commands = [(2, line_id, 0)]
|
||||
invoice.write({'invoice_line_ids': commands})
|
||||
if len(invoice.invoice_line_ids) > 1:
|
||||
line_id = invoice.invoice_line_ids[1].id
|
||||
commands = [(2, line_id, 0)]
|
||||
invoice.write({'invoice_line_ids': commands})
|
||||
rec.invoice_id = invoice.id
|
||||
rec.write({'state': 'done'})
|
||||
|
||||
elif (rec.remain_amount < 0.0) or (rec.remain_amount<0.0 and rec.maintenance):
|
||||
invoice_vals = rec._prepare_invoice_values(rec, abs(rec.remain_amount))
|
||||
invoice = self.env['account.move'].sudo().create(invoice_vals).with_user(self.env.uid)
|
||||
# Get the ID of the second line
|
||||
line_id = invoice.invoice_line_ids[1].id
|
||||
commands = [(2, line_id, 0)]
|
||||
invoice.write({'invoice_line_ids': commands})
|
||||
if len(invoice.invoice_line_ids) > 1:
|
||||
line_id = invoice.invoice_line_ids[1].id
|
||||
commands = [(2, line_id, 0)]
|
||||
invoice.write({'invoice_line_ids': commands})
|
||||
rec.invoice_id = invoice.id
|
||||
rec.write({'state': 'done'})
|
||||
if rec.contract_state == 'before':
|
||||
|
|
@ -161,6 +163,8 @@ class EndOfRent(models.Model):
|
|||
'partner_id': rec.contract_id.partner_id.id,
|
||||
'end_rent_id': rec.id,
|
||||
'maintenance_type': 'end_contract',
|
||||
'hand_cost': rec.hand_cost,
|
||||
'total_amount': rec.hand_cost+rec.maintenance_cost,
|
||||
'date': rec.date,
|
||||
'state': 'draft', }
|
||||
maintenance_id = self.env['property.management.maintenance'].create(vals)
|
||||
|
|
@ -272,6 +276,15 @@ class PropertyManagementMaintenance(models.Model):
|
|||
'quantity': line.qty,
|
||||
'price_unit': line.cost,
|
||||
}))
|
||||
line_data.append((0, 0, {
|
||||
'name':_('Hand Cost') + maintenance.name + ' '+self.property_id.name+' ' +unit_name+' ' +maintenance.partner_id.name if maintenance.partner_id else \
|
||||
_('Hand Cost') + ' ' + maintenance.name +' '+self.property_id.name+' ' +unit_name+' ' + maintenance.vendor_id.name,
|
||||
'quantity': 1.0,
|
||||
'price_unit': self.hand_cost,
|
||||
'account_id': payment.contract_id.revenue_account_id.id,
|
||||
'analytic_account_id': payment.property_id.account_analy_id.id if payment.property_id.account_analy_id else False,
|
||||
'tax_ids': [(6, 0, [payment.tax_id.id])] if payment.tax_id else False, # Assigning tax_id to tax_ids
|
||||
}))
|
||||
invoice_vals = {
|
||||
'ref': maintenance.name,
|
||||
'move_type': 'in_invoice',
|
||||
|
|
@ -293,9 +306,9 @@ class PropertyManagementMaintenance(models.Model):
|
|||
invoice_vals = rec._prepare_invoice_values(rec, abs(rec.total_amount))
|
||||
if rec.end_rent_id and rec.end_rent_id.state != 'done':
|
||||
raise exceptions.ValidationError(_('Please confirm end of rent first '))
|
||||
if not rec.end_rent_id:
|
||||
invoice = self.env['account.move'].sudo().create(invoice_vals).with_user(self.env.uid)
|
||||
rec.invoice_id = invoice.id
|
||||
# if not rec.end_rent_id:
|
||||
invoice = self.env['account.move'].sudo().create(invoice_vals).with_user(self.env.uid)
|
||||
rec.invoice_id = invoice.id
|
||||
for line in rec.end_line_ids:
|
||||
line_ids.append((0, 0, {
|
||||
'product_id': line.product_id.id,
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ class RentPayment(models.Model):
|
|||
|
||||
if payment.amount>0.00:
|
||||
line_invoice.append((0, 0, {
|
||||
'name':'قيمة الإيجار ' + ' - ' + str(payment.contract_id.name or '') + ' - ' + str(self.property_id.name or '') + ' - ' + unit_name + ' - ' + str(self.name or '') + ' - ' + str(payment.code or '') + ' - ' + str(payment.due_date or ''),
|
||||
'name':_('Reant Amount ') + ' - ' + str(payment.contract_id.name or '') + ' - ' + str(self.property_id.name or '') + ' - ' + unit_name + ' - ' + str(self.name or '') + ' - ' + str(payment.code or '') + ' - ' + str(payment.due_date or ''),
|
||||
'quantity': 1.0,
|
||||
'price_unit': self.amount,
|
||||
'account_id': payment.contract_id.revenue_account_id.id,
|
||||
|
|
@ -122,7 +122,7 @@ class RentPayment(models.Model):
|
|||
}))
|
||||
if payment.water_cost>0.00:
|
||||
line_invoice.append((0, 0, {
|
||||
'name': 'تكلفة المياه'+ ' - ' + str(payment.contract_id.name or '') + ' - ' + str(self.property_id.name or '') + ' - ' + unit_name + ' - ' + str(self.name or '') + ' - ' + str(payment.code or '') + ' - ' + str(payment.due_date or ''),
|
||||
'name': _('Water Cost ')+ ' - ' + str(payment.contract_id.name or '') + ' - ' + str(self.property_id.name or '') + ' - ' + unit_name + ' - ' + str(self.name or '') + ' - ' + str(payment.code or '') + ' - ' + str(payment.due_date or ''),
|
||||
'price_unit':self.water_cost,
|
||||
'quantity': 1.0,
|
||||
'account_id': payment.contract_id.revenue_account_id.id,
|
||||
|
|
@ -131,7 +131,7 @@ class RentPayment(models.Model):
|
|||
}),)
|
||||
if payment.service_cost>0.00:
|
||||
line_invoice.append((0, 0, {
|
||||
'name': 'قيمة الخدمات' + ' - ' + str(payment.contract_id.name or '') + ' - ' + str(self.property_id.name or '') + ' - ' + unit_name + ' - ' + str(self.name or '') + ' - ' + str(payment.code or '') + ' - ' + str(payment.due_date or ''),
|
||||
'name': _('Serviecs Cost') + ' - ' + str(payment.contract_id.name or '') + ' - ' + str(self.property_id.name or '') + ' - ' + unit_name + ' - ' + str(self.name or '') + ' - ' + str(payment.code or '') + ' - ' + str(payment.due_date or ''),
|
||||
'price_unit': self.service_cost,
|
||||
'quantity': 1.0,
|
||||
'analytic_account_id': payment.property_id.account_analy_id.id if payment.property_id.account_analy_id else False,
|
||||
|
|
|
|||
|
|
@ -351,6 +351,7 @@ class RentalContract(models.Model):
|
|||
full = True
|
||||
if self.property_id.state in ['reserve', 'rent']:
|
||||
raise exceptions.ValidationError(_("Property is already reserved or rented"))
|
||||
#
|
||||
for units in self.property_id.unit_ids:
|
||||
if units.state in ['draft', 'available']:
|
||||
full = False
|
||||
|
|
|
|||
|
|
@ -66,9 +66,9 @@
|
|||
readonly="1"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="electric_meter" readonly="1"/>
|
||||
<field name="electric_amount" readonly="1"/>
|
||||
<field name="electric_payment_no" readonly="1"/>
|
||||
<field name="electric_meter" readonly="0"/>
|
||||
<field name="electric_amount" readonly="0"/>
|
||||
<field name="electric_payment_no" readonly="0"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
|
|
|
|||
|
|
@ -104,6 +104,8 @@
|
|||
<filter string="Paid" name="paid_payment" domain="[('state','=','paid')]"/>
|
||||
<filter string="Cancelled" name="cancel_payment" domain="[('state','=','cancel')]"/>
|
||||
<filter string="Collected From Company" name="collected_from_company" domain="[('collected_from_company','=',True)]"/>
|
||||
<filter string="Invoice Commission" name="invoice_commission_id" domain="[('collected_from_company','=',True),('invoice_commission_id','!=',False)]"/>
|
||||
<filter string="NOT Invoice Commission " name="no_invoice_commission_id" domain="[('collected_from_company','=',True),('invoice_commission_id','=',False)]"/>
|
||||
|
||||
<separator/>
|
||||
<filter name="payment_state" string="Not Canceled Payment" domain="[('state','!=','cancel')]"/>
|
||||
|
|
|
|||
Loading…
Reference in New Issue