fixes, kind is added as a class

This commit is contained in:
Elvis 2022-07-12 10:42:11 -05:00
parent 081237b91b
commit ddb863364c
8 changed files with 76 additions and 22 deletions

View File

@ -34,6 +34,7 @@ def register():
account.Cashflow,
asset.Asset,
asset.AssetLocation,
asset.DepreciationKind,
account.Account,
move.Move,
move.Line,

View File

@ -4,22 +4,22 @@ from trytond.model import ModelView, ModelSQL, fields
from datetime import timedelta
KINDLIST = {
'1': {'name': 'Constructions and buildings', 'days': 16425},
'2': {'name': 'Aqueduct, plant and networks', 'days': 14600},
'3': {'name': 'Communication channels', 'days': 14600},
'5': {'name': 'Fleet and air equipment', 'days': 10950},
'6': {'name': 'Fleet and railway equipment', 'days': 7300},
'7': {'name': 'Fleet and river equipment', 'days': 5475},
'8': {'name': 'Weapons and surveillance equipment', 'days': 3650},
'9': {'name': 'Electric equipment', 'days': 3650},
'10': {'name': 'Fleet and ground transportation equipment', 'days': 3650},
'11': {'name': 'Machinery, equipment', 'days': 3650},
'12': {'name': 'Furniture and fixtures', 'days': 3650},
'13': {'name': 'Scientific medical equipment', 'days': 2920},
'14': {'name': 'Containers, packaging and tools', 'days': 1825},
'15': {'name': 'Computer equipment', 'days': 1825},
'16': {'name': 'Data processing networks', 'days': 1825},
'17': {'name': 'Communication equipment', 'days': 1825},
'construccion': {'name': 'Constructions and buildings, blablablablab', 'days': 16425},
'aqueduct': {'name': 'Aqueduct, plant and networks', 'days': 14600},
'communication': {'name': 'Communication channels', 'days': 14600},
'fleet_air': {'name': 'Fleet and air equipment', 'days': 10950},
'fleet_railway': {'name': 'Fleet and railway equipment', 'days': 7300},
'fleet_river': {'name': 'Fleet and river equipment', 'days': 5475},
'weapons': {'name': 'Weapons and surveillance equipment', 'days': 3650},
'electric': {'name': 'Electric equipment', 'days': 3650},
'fleet_transportation': {'name': 'Fleet and ground transportation equipment', 'days': 3650},
'machinery': {'name': 'Machinery, equipment', 'days': 3650},
'furniture': {'name': 'Furniture and fixtures', 'days': 3650},
'scientific': {'name': 'Scientific medical equipment', 'days': 2920},
'containers': {'name': 'Containers, packaging and tools', 'days': 1825},
'computer': {'name': 'Computer equipment', 'days': 1825},
'data': {'name': 'Data processing networks', 'days': 1825},
'communication': {'name': 'Communication equipment', 'days': 1825},
}
@ -31,24 +31,32 @@ class AssetLocation(ModelView, ModelSQL):
address = fields.Char('address')
class DepreciationKind(ModelView, ModelSQL):
'Depreciation Kind'
__name__ = 'account_col.depreciation_kind'
name = fields.Char('Name')
years = fields.Integer('Years Depreciation')
class Asset(metaclass=PoolMeta):
__name__ = 'account.asset'
kind = fields.Selection('get_kind_list','Kind')
#kind = fields.Selection('get_kind_list','Kind')
kind = fields.Many2One('account_col.depreciation_kind', 'Kind', required=True)
location = fields.Many2One('account_col.asset_location', "Location")
type = fields.Selection([
('AFP' ,'Activo fijo propios'),
('CD', 'Comodato'),
('AC', 'Activo Controlado'),], 'Type')
('AC', 'Activo Controlado'),], 'Type', required=True)
code = fields.Char('Code')
@fields.depends('kind')
def on_change_with_end_date(self, name=None):
if self.kind:
print(self.kind)
days = KINDLIST[self.kind]['days']
print(self.kind.name)
#days = KINDLIST[self.kind]['days']
days = 365 * self.kind.years
return self.start_date + timedelta(days=days)
@ -70,7 +78,7 @@ class Asset(metaclass=PoolMeta):
@classmethod
def create_lines(cls, assets):
for asset in assets:
if asset.type == 'AC':
if asset.type == 'AC' or asset.type == 'CD':
continue
super(Asset, cls).create_lines([asset])

View File

@ -8,5 +8,11 @@
<field name="inherit" ref="account_asset.asset_view_form"/>
<field name="name">asset_form</field>
</record>
<record model="ir.ui.view" id="asset_view_tree">
<field name="model">account.asset</field>
<field name="inherit" ref="account_asset.asset_view_tree"/>
<field name="name">asset_tree</field>
</record>
</data>
</tryton>

20
depreciation_kind.xml Normal file
View File

@ -0,0 +1,20 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of this
repository contains the full copyright notices and license terms. -->
<tryton>
<data>
<record model="ir.ui.view" id="depreciation_kind_view_list">
<field name="model">account_col.asset_location</field>
<field name="type">tree</field>
<field name="priority" eval="10"/>
<field name="name">Depreciation kind list</field>
</record>
<record model="ir.ui.view" id="depreciation_kind_view_form">
<field name="model">depreciation_kind.asset_location</field>
<field name="type">form</field>
<field name="priority" eval="10"/>
<field name="name">Depreciation kind form</field>
</record>
</data>
</tryton>

View File

@ -4248,7 +4248,7 @@ msgstr "Muebles y enseres"
msgctxt "selection:account.asset,kind:"
msgid "Machinery, equipment"
msgstr "Maquinaria, equipos"
msgstr "Equipo de comunicación"
msgctxt "selection:account.asset,kind:"
msgid "Weapons and surveillance equipment"

6
view/asset_tree.xml Normal file
View File

@ -0,0 +1,6 @@
<data>
<xpath expr="/tree/field[@name='state']" position="after">
<field name="kind"/>
<field name="type"/>
</xpath>
</data>

View File

@ -0,0 +1,6 @@
<form>
<label name="name"/>
<field name="name"/>
<label name="years"/>
<field name="years"/>
</form>

View File

@ -0,0 +1,7 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tree>
<field name="name"/>
<field name="years"/>
</tree>