[IMP] Change aseet type view, Sale wizard calculation and screenshot
This commit is contained in:
parent
9f0bc3ca6d
commit
57de0cd91d
@ -64,6 +64,7 @@
|
|||||||
vals = {
|
vals = {
|
||||||
'journal_id': journal_id,
|
'journal_id': journal_id,
|
||||||
'name': 'Electronics',
|
'name': 'Electronics',
|
||||||
|
'method_period': 12,
|
||||||
'method_number': 6,
|
'method_number': 6,
|
||||||
'account_asset_id': xfa_account_id,
|
'account_asset_id': xfa_account_id,
|
||||||
'account_depreciation_id': xfa_account_id,
|
'account_depreciation_id': xfa_account_id,
|
||||||
|
@ -153,12 +153,11 @@ class AccountAssetAsset(models.Model):
|
|||||||
date = datetime.strptime(date, DF).date()
|
date = datetime.strptime(date, DF).date()
|
||||||
else:
|
else:
|
||||||
date = datetime.now()
|
date = datetime.now()
|
||||||
if date.month <= 3 and date.day < 31:
|
|
||||||
year = date.year
|
year = date.year
|
||||||
else:
|
fiscal_date = date.replace(month=last_month, day=last_day, year=year)
|
||||||
year = date.year + 1
|
if fiscal_date < date:
|
||||||
date = date.replace(month=last_month, day=last_day, year=year)
|
fiscal_date = date.replace(month=last_month, day=last_day, year=year + 1)
|
||||||
return datetime.strftime(date, '%Y-%m-%d')
|
return datetime.strftime(fiscal_date, '%Y-%m-%d')
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def count_invoice(self):
|
def count_invoice(self):
|
||||||
@ -250,7 +249,6 @@ class AccountAssetAsset(models.Model):
|
|||||||
fiscal_date = datetime.strptime(self.date or fields.Datetime.today(), '%Y-%m-%d')
|
fiscal_date = datetime.strptime(self.date or fields.Datetime.today(), '%Y-%m-%d')
|
||||||
days = (self.company_id.compute_fiscalyear_dates(depreciation_date)['date_to'] - fiscal_date.date()).days
|
days = (self.company_id.compute_fiscalyear_dates(depreciation_date)['date_to'] - fiscal_date.date()).days
|
||||||
amount = (amount_to_depr / self.method_number) / total_days * days
|
amount = (amount_to_depr / self.method_number) / total_days * days
|
||||||
|
|
||||||
elif self.method == 'degressive':
|
elif self.method == 'degressive':
|
||||||
amount = residual_amount * self.method_progress_factor
|
amount = residual_amount * self.method_progress_factor
|
||||||
if self.prorata == 'purchase_date':
|
if self.prorata == 'purchase_date':
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 101 KiB After Width: | Height: | Size: 106 KiB |
@ -10,6 +10,7 @@
|
|||||||
<field name="model">account.asset.category</field>
|
<field name="model">account.asset.category</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="Asset category">
|
<form string="Asset category">
|
||||||
|
<sheet>
|
||||||
<group>
|
<group>
|
||||||
<div class="oe_title">
|
<div class="oe_title">
|
||||||
<label for="name" string="Asset Type" class="oe_edit_only" attrs="{'invisible': [('type','!=','purchase')]}"/>
|
<label for="name" string="Asset Type" class="oe_edit_only" attrs="{'invisible': [('type','!=','purchase')]}"/>
|
||||||
@ -23,24 +24,31 @@
|
|||||||
<field name="company_id" options="{'no_create': True}" groups="base.group_multi_company"/>
|
<field name="company_id" options="{'no_create': True}" groups="base.group_multi_company"/>
|
||||||
</group>
|
</group>
|
||||||
<group string="Journal Entries">
|
<group string="Journal Entries">
|
||||||
<field name="journal_id"/>
|
|
||||||
<div>
|
<div>
|
||||||
<label for="account_asset_id" attrs="{'invisible': [('type','!=','purchase')]}"/>
|
<label for="journal_id" style="font-weight: bold;" string="Journal"/>
|
||||||
<label for="account_asset_id" string="Deferred Revenue Account" attrs="{'invisible': [('type','!=','sale')]}"/>
|
</div>
|
||||||
|
<field name="journal_id" nolabel="1"/>
|
||||||
|
<div>
|
||||||
|
<label for="account_asset_id" style="font-weight: bold;" attrs="{'invisible': [('type','!=','purchase')]}"/>
|
||||||
|
<label for="account_asset_id" style="font-weight: bold;" string="Deferred Revenue Account" attrs="{'invisible': [('type','!=','sale')]}"/>
|
||||||
</div>
|
</div>
|
||||||
<field name="account_asset_id" nolabel="1" attrs="{'invisible': [('type','=', False)]}"/>
|
<field name="account_asset_id" nolabel="1" attrs="{'invisible': [('type','=', False)]}"/>
|
||||||
<div>
|
<div>
|
||||||
<label for="account_depreciation_id" attrs="{'invisible': [('type','!=','purchase')]}"/>
|
<label for="account_depreciation_id" style="font-weight: bold;" attrs="{'invisible': [('type','!=','purchase')]}"/>
|
||||||
<label for="account_depreciation_id" string="Recognition Income Account" attrs="{'invisible': [('type','!=','sale')]}"/>
|
<label for="account_depreciation_id" style="font-weight: bold;" string="Recognition Income Account" attrs="{'invisible': [('type','!=','sale')]}"/>
|
||||||
</div>
|
</div>
|
||||||
<field name="account_depreciation_id" nolabel="1"/>
|
<field name="account_depreciation_id" nolabel="1"/>
|
||||||
<div>
|
<div>
|
||||||
<label for="account_depreciation_expense_id" attrs="{'invisible': [('type','!=','purchase')]}"/>
|
<label for="account_depreciation_expense_id" style="font-weight: bold;" attrs="{'invisible': [('type','!=','purchase')]}"/>
|
||||||
<label for="account_depreciation_expense_id" string="Recognition Account" attrs="{'invisible': [('type','!=','sale')]}"/>
|
<label for="account_depreciation_expense_id" style="font-weight: bold;" string="Recognition Account" attrs="{'invisible': [('type','!=','sale')]}"/>
|
||||||
</div>
|
</div>
|
||||||
<field name="account_depreciation_expense_id" nolabel="1"/>
|
<field name="account_depreciation_expense_id" nolabel="1"/>
|
||||||
<field name="account_analytic_id" groups="analytic.group_analytic_accounting"/>
|
<field name="account_analytic_id" groups="analytic.group_analytic_accounting"/>
|
||||||
</group>
|
</group>
|
||||||
|
</group>
|
||||||
|
<notebook>
|
||||||
|
<page string="Other Information">
|
||||||
|
<group>
|
||||||
<group string="Periodicity">
|
<group string="Periodicity">
|
||||||
<field name="method_time" string="Time Method Based On" widget="radio" attrs="{'invisible': [('type','!=','purchase')]}"/>
|
<field name="method_time" string="Time Method Based On" widget="radio" attrs="{'invisible': [('type','!=','purchase')]}"/>
|
||||||
<field name="method_number" attrs="{'invisible':['|',('method_time','!=','number'),'&',('type','=', False)], 'required':[('method_time','=','number')]}"/>
|
<field name="method_number" attrs="{'invisible':['|',('method_time','!=','number'),'&',('type','=', False)], 'required':[('method_time','=','number')]}"/>
|
||||||
@ -51,16 +59,19 @@
|
|||||||
</div>
|
</div>
|
||||||
<field name="method_end" attrs="{'required': [('method_time','=','end')], 'invisible':[('method_time','!=','end')]}"/>
|
<field name="method_end" attrs="{'required': [('method_time','=','end')], 'invisible':[('method_time','!=','end')]}"/>
|
||||||
</group>
|
</group>
|
||||||
<group string="Additional Options">
|
|
||||||
<field name="open_asset"/>
|
|
||||||
<field name="group_entries"/>
|
|
||||||
</group>
|
|
||||||
<group attrs="{'invisible': [('type','=','sale')]}" string="Depreciation Method">
|
<group attrs="{'invisible': [('type','=','sale')]}" string="Depreciation Method">
|
||||||
<field name="method" widget="radio"/>
|
<field name="method" widget="radio"/>
|
||||||
<field name="method_progress_factor" attrs="{'invisible':[('method','=','linear')], 'required':[('method','=','degressive')]}"/>
|
<field name="method_progress_factor" attrs="{'invisible':[('method','=','linear')], 'required':[('method','=','degressive')]}"/>
|
||||||
<field name="prorata" attrs="{'invisible': [('method_time','=','end')]}"/>
|
<field name="prorata" attrs="{'invisible': [('method_time','=','end')]}"/>
|
||||||
</group>
|
</group>
|
||||||
|
<group string="Additional Options">
|
||||||
|
<field name="open_asset"/>
|
||||||
|
<field name="group_entries"/>
|
||||||
</group>
|
</group>
|
||||||
|
</group>
|
||||||
|
</page>
|
||||||
|
</notebook>
|
||||||
|
</sheet>
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
@ -22,6 +22,16 @@ class SaleAssetWizard(models.TransientModel):
|
|||||||
string="Date", default=lambda self: datetime.today(),
|
string="Date", default=lambda self: datetime.today(),
|
||||||
required=True)
|
required=True)
|
||||||
|
|
||||||
|
@api.onchange('product_id')
|
||||||
|
def onchange_product_id(self):
|
||||||
|
date = False
|
||||||
|
for line in self.asset_id.depreciation_line_ids:
|
||||||
|
if line.move_check:
|
||||||
|
date = line.depreciation_date
|
||||||
|
if not date:
|
||||||
|
date = self.asset_id.depreciation_line_ids and self.asset_id.depreciation_line_ids[0].depreciation_date or self.asset_id.date
|
||||||
|
self.sale_date = date
|
||||||
|
|
||||||
@api.onchange('sale_date')
|
@api.onchange('sale_date')
|
||||||
def onchange_sale_date(self):
|
def onchange_sale_date(self):
|
||||||
if self.sale_date:
|
if self.sale_date:
|
||||||
@ -32,17 +42,16 @@ class SaleAssetWizard(models.TransientModel):
|
|||||||
amount += line.amount
|
amount += line.amount
|
||||||
last_date = line.depreciation_date
|
last_date = line.depreciation_date
|
||||||
else:
|
else:
|
||||||
if not last_date and line.sequence != 1:
|
if not last_date:
|
||||||
last_date = line.depreciation_date
|
last_date = line.depreciation_date
|
||||||
|
if line.sequence == 1:
|
||||||
|
last_date = self.asset_id.date
|
||||||
days, total_days = \
|
days, total_days = \
|
||||||
self.get_days(last_date, self.sale_date)
|
self.get_days(last_date, self.sale_date)
|
||||||
else:
|
|
||||||
days, total_days = \
|
|
||||||
self.get_days(self.asset_id.date, self.sale_date)
|
|
||||||
amount += (line.amount * days) / total_days
|
amount += (line.amount * days) / total_days
|
||||||
break
|
break
|
||||||
self.depreciated_amount = amount
|
self.depreciated_amount = amount
|
||||||
self.sale_value = self.asset_id.value_residual - amount
|
self.sale_value = self.asset_id.value - amount
|
||||||
|
|
||||||
@api.constrains('sale_date')
|
@api.constrains('sale_date')
|
||||||
def _check_sale_date(self):
|
def _check_sale_date(self):
|
||||||
@ -58,6 +67,9 @@ class SaleAssetWizard(models.TransientModel):
|
|||||||
if self.sale_date < str(last_depreciation_date):
|
if self.sale_date < str(last_depreciation_date):
|
||||||
raise ValueError(_("Sale date must be greater than last "
|
raise ValueError(_("Sale date must be greater than last "
|
||||||
"Depreciated date!"))
|
"Depreciated date!"))
|
||||||
|
if self.sale_date < self.asset_id.date:
|
||||||
|
raise ValueError(_("Sale date must be greater than "
|
||||||
|
"Date of Asset!"))
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def get_days(self, last_date, sale_date):
|
def get_days(self, last_date, sale_date):
|
||||||
@ -66,6 +78,12 @@ class SaleAssetWizard(models.TransientModel):
|
|||||||
delta = sale_date - last_depreciation_date
|
delta = sale_date - last_depreciation_date
|
||||||
year = last_depreciation_date.year
|
year = last_depreciation_date.year
|
||||||
total_days = (year % 4) and 365 or 366
|
total_days = (year % 4) and 365 or 366
|
||||||
|
if self.asset_id.depreciation_line_ids and self.asset_id.depreciation_line_ids[0].depreciation_date > str(sale_date):
|
||||||
|
depreciation_date = datetime.strptime(self.asset_id.depreciation_line_ids[0].depreciation_date, DF).date()
|
||||||
|
asset_date = datetime.strptime(self.asset_id.date, DF).date()
|
||||||
|
delta_day = depreciation_date - asset_date
|
||||||
|
total_days = delta_day.days
|
||||||
|
delta = sale_date - asset_date
|
||||||
return delta.days, total_days
|
return delta.days, total_days
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
@ -80,9 +98,9 @@ class SaleAssetWizard(models.TransientModel):
|
|||||||
last_line = line
|
last_line = line
|
||||||
else:
|
else:
|
||||||
last_line = line
|
last_line = line
|
||||||
if not last_date and line.sequence != 1:
|
if not last_date:
|
||||||
last_date = line.depreciation_date
|
last_date = line.depreciation_date
|
||||||
else:
|
if line.sequence == 1:
|
||||||
last_date = self.asset_id.date
|
last_date = self.asset_id.date
|
||||||
break
|
break
|
||||||
days, total_days = self.get_days(last_date, sale_date)
|
days, total_days = self.get_days(last_date, sale_date)
|
||||||
@ -96,7 +114,7 @@ class SaleAssetWizard(models.TransientModel):
|
|||||||
'sale_date': self.sale_date,
|
'sale_date': self.sale_date,
|
||||||
})
|
})
|
||||||
last_line, amount = self.last_line_info()
|
last_line, amount = self.last_line_info()
|
||||||
if last_line:
|
if last_line and amount:
|
||||||
depreciated_value = \
|
depreciated_value = \
|
||||||
(last_line.depreciated_value - last_line.amount) + amount
|
(last_line.depreciated_value - last_line.amount) + amount
|
||||||
last_line.update({
|
last_line.update({
|
||||||
|
Loading…
Reference in New Issue
Block a user