[UPD] property_management: add fields contract_type and taxt_amount and total_amount_with_tax && fix calculations
This commit is contained in:
parent
fad1674863
commit
bd30d6f808
|
|
@ -451,6 +451,11 @@ msgstr "تاريخ بداية العقد"
|
|||
msgid "Contract Transfer"
|
||||
msgstr "نقل العقد"
|
||||
|
||||
#. module: property_management
|
||||
#: model:ir.model.fields,field_description:property_management.field_rental_contract__contract_type
|
||||
msgid "Contract Type"
|
||||
msgstr "نوع العقد"
|
||||
|
||||
#. module: property_management
|
||||
#: model:ir.model.fields,field_description:property_management.field_re_unit__contract_counts
|
||||
#: model_terms:ir.ui.view,arch_db:property_management.contract_unit_view
|
||||
|
|
@ -2049,6 +2054,7 @@ msgstr "الضريبة"
|
|||
|
||||
#. module: property_management
|
||||
#: model:ir.model.fields,field_description:property_management.field_rent_payment__tax_amount
|
||||
#: model:ir.model.fields,field_description:property_management.field_rental_contract__tax_amount
|
||||
#: model_terms:ir.ui.view,arch_db:property_management.rental_contract_form_view
|
||||
msgid "Tax Amount"
|
||||
msgstr "قيمة الضريبة"
|
||||
|
|
@ -2119,6 +2125,11 @@ msgstr "الإجمالي"
|
|||
msgid "Total Amount"
|
||||
msgstr "القيمة الإجمالية"
|
||||
|
||||
#. module: property_management
|
||||
#: model:ir.model.fields,field_description:property_management.field_rental_contract__total_amount_with_tax
|
||||
msgid "Total Amount With Tax"
|
||||
msgstr "القيمة الإجمالية مع الضريبة"
|
||||
|
||||
#. module: property_management
|
||||
#: model_terms:ir.ui.view,arch_db:property_management.rent_payment_list_view
|
||||
msgid "Total Commission"
|
||||
|
|
|
|||
|
|
@ -127,6 +127,10 @@ class RentalContract(models.Model):
|
|||
('unit', 'Unit')], string="Rent Method")
|
||||
property_id = fields.Many2one('internal.property', string="Property", tracking=True,)
|
||||
unit_ids = fields.Many2many('re.unit', string="Units", tracking=True)
|
||||
contract_type = fields.Selection(
|
||||
[('residential', 'Residential'), ('commercial', 'Commercial'), ('lands', 'Lands')],
|
||||
default=lambda self: self._get_default_contract_type()
|
||||
)
|
||||
partner_id = fields.Many2one('res.partner', string="Renter", domain=[('is_tenant', '=', True)])
|
||||
identification_type = fields.Selection(related="partner_id.identification_type", string='Identification Type')
|
||||
identification_number = fields.Char(related="partner_id.identification_number", string='Identification NUmber')
|
||||
|
|
@ -221,11 +225,33 @@ class RentalContract(models.Model):
|
|||
annual_raise_on_type = fields.Selection([('meter', _('Meter')), ('rent_amount', _('Rent amount'))],
|
||||
_('الزيادة علي'), default='rent_amount')
|
||||
# Add Sales Tax Field
|
||||
tax_id = fields.Many2one('account.tax', string="Tax", domain=[('type_tax_use', '=', 'sale')],compute='compute_tax_id')
|
||||
tax_id = fields.Many2one(
|
||||
'account.tax',
|
||||
string="Tax",
|
||||
domain=[('type_tax_use', '=', 'sale')],
|
||||
# compute='compute_tax_id'
|
||||
default=lambda self: self._get_default_tax_id()
|
||||
)
|
||||
tax_amount = fields.Float(compute="_compute_amounts")
|
||||
total_amount_with_tax = fields.Float(compute="_compute_amounts")
|
||||
|
||||
|
||||
@api.depends('tax_id', 'cal_rent_amount')
|
||||
def _compute_amounts(self):
|
||||
for rec in self:
|
||||
rec.tax_amount = rec.tax_id._compute_amount(rec.cal_rent_amount, rec.cal_rent_amount) if rec.tax_id else 0.0
|
||||
rec.total_amount_with_tax = rec.cal_rent_amount + rec.tax_amount
|
||||
|
||||
def _get_default_contract_type(self):
|
||||
self.contract_type = self.unit_ids[0].unit_category if self.unit_ids else False
|
||||
|
||||
def _get_default_tax_id(self):
|
||||
self.tax_id = self.unit_ids[0].tax_id if self.unit_ids else False
|
||||
|
||||
# @api.onchange('unit_ids')
|
||||
# def compute_tax_id(self):
|
||||
# self.tax_id = self.unit_ids[0].tax_id if self.unit_ids else False
|
||||
|
||||
@api.onchange('unit_ids')
|
||||
def compute_tax_id(self):
|
||||
self.tax_id = self.unit_ids.tax_id
|
||||
@api.onchange('tax_id')
|
||||
def _onchange_sales_tax_id(self):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@
|
|||
('state','=','available'),
|
||||
('action_type', '=', 'rent')]" widget="many2many_tags" attrs="{'readonly':[('state','!=','draft')], 'invisible':[('rent_method','in',['property', False])],
|
||||
'required':[('rent_method','not in',['property', False])]}"/>
|
||||
<field name="contract_type" attrs="{'readonly': [('state', '!=', 'draft')]}" />
|
||||
<field name="user_id" readonly="1"/>
|
||||
<field name="company_id" readonly="1"/>
|
||||
</group>
|
||||
|
|
@ -138,6 +139,8 @@
|
|||
<field name="sanitation_cost"/>
|
||||
<field name="water_cost"/>
|
||||
<field name="tax_id"/>
|
||||
<field name="tax_amount" />
|
||||
<field name="total_amount_with_tax" />
|
||||
<div attrs="{'invisible': [('management_type', '!=', 'included')]}">
|
||||
<field name="company_profit"
|
||||
attrs="{'readonly':[('state','not in',['draft','register'])],'required': [('management_type', 'in',('included'))]}"
|
||||
|
|
@ -299,7 +302,10 @@
|
|||
<field name="rent_type"/>
|
||||
<field name="date_from"/>
|
||||
<field name="date_to"/>
|
||||
<field name="cal_rent_amount"/>
|
||||
<field name="contract_type" optional="show"/>
|
||||
<field name="cal_rent_amount" optional="show"/>
|
||||
<field name="tax_amount" optional="show"/>
|
||||
<field name="total_amount_with_tax" optional="show"/>
|
||||
<field name="service_amount"/>
|
||||
<field name="state"/>
|
||||
</tree>
|
||||
|
|
|
|||
Loading…
Reference in New Issue