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