[ADD] Default value for log type and function name for vehicles
bzr revid: dle@openerp.com-20120924090705-ndlk3uvn7tslggny
This commit is contained in:
+29
-3
@@ -45,10 +45,31 @@ class fleet_vehicle_model_brand(osv.Model):
|
||||
}
|
||||
|
||||
class fleet_vehicle(osv.Model):
|
||||
|
||||
def name_get(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
if not ids:
|
||||
return []
|
||||
reads = self.browse(cr, uid, ids, context=context)
|
||||
res = []
|
||||
for record in reads:
|
||||
if record.registration:
|
||||
name = record.registration
|
||||
if record.model_id:
|
||||
name = record.model_id.brand.name+' / '+record.model_id.modelname + ' / ' + name
|
||||
res.append((record.id, name))
|
||||
return res
|
||||
|
||||
def _vehicle_name_get_fnc(self, cr, uid, ids, prop, unknow_none, context=None):
|
||||
res = self.name_get(cr, uid, ids, context=context)
|
||||
return dict(res)
|
||||
|
||||
_name = 'fleet.vehicle'
|
||||
_description = 'Fleet Vehicle'
|
||||
|
||||
_columns = {
|
||||
'name' : fields.function(_vehicle_name_get_fnc, type="char", string='Name', store=True),
|
||||
'registration' : fields.char('Registration', size=32, required=False, help='Registration number of the vehicle (ie: plate number for a car)'),
|
||||
'vin_sn' : fields.char('Chassis Number', size=32, required=False, help='Unique number written on the vehicle motor (VIN/SN number)'),
|
||||
'driver' : fields.many2one('hr.employee', 'Driver',required=False, help='Driver of the vehicle'),
|
||||
@@ -113,9 +134,10 @@ class fleet_vehicle_log(osv.Model):
|
||||
'create_date' : fields.datetime('Creation Date'),
|
||||
|
||||
'description' : fields.text('Description'),
|
||||
'type' : fields.many2one('fleet.vehicle.log.type', 'Type', required=True),
|
||||
|
||||
|
||||
'type' : fields.char('Type', size=32, required=False),
|
||||
}
|
||||
_defaults = {
|
||||
'type' : 'Log',
|
||||
}
|
||||
|
||||
class fleet_vehicle_log_fuel(osv.Model):
|
||||
@@ -125,6 +147,10 @@ class fleet_vehicle_log_fuel(osv.Model):
|
||||
'description' : fields.text('Description'),
|
||||
'liter' : fields.integer('Liter'),
|
||||
'price_per_liter' : fields.float('Price per liter'),
|
||||
'type' : fields.char('Type', size=32, required=False),
|
||||
}
|
||||
_defaults = {
|
||||
'type' : 'Fuel',
|
||||
}
|
||||
|
||||
class fleet_vehicle_log_insurance(osv.Model):
|
||||
|
||||
@@ -96,14 +96,12 @@
|
||||
<field name="log_fuel">
|
||||
<tree string="Fuel Logs">
|
||||
<field name="create_date" />
|
||||
<field name="type"/>
|
||||
<field name="employee_id" />
|
||||
<field name="description" />
|
||||
</tree>
|
||||
<form string="Fuel Logs" version="7.0">
|
||||
<sheet>
|
||||
<group>
|
||||
<field name="type" default="Fuel"/>
|
||||
<field name="create_date" />
|
||||
<field name="employee_id" />
|
||||
<field name="liter" />
|
||||
|
||||
+10
-2
@@ -2300,7 +2300,11 @@ class stock_move(osv.osv):
|
||||
or move.location_id.company_id != move.location_dest_id.company_id):
|
||||
journal_id, acc_src, acc_dest, acc_valuation = self._get_accounting_data_for_valuation(cr, uid, move, src_company_ctx)
|
||||
reference_amount, reference_currency_id = self._get_reference_accounting_values_for_valuation(cr, uid, move, src_company_ctx)
|
||||
account_moves += [(journal_id, self._create_account_move_line(cr, uid, move, acc_valuation, acc_dest, reference_amount, reference_currency_id, context))]
|
||||
#returning goods to supplier
|
||||
if move.location_dest_id.usage == 'supplier':
|
||||
account_moves += [(journal_id, self._create_account_move_line(cr, uid, move, acc_valuation, acc_src, reference_amount, reference_currency_id, context))]
|
||||
else:
|
||||
account_moves += [(journal_id, self._create_account_move_line(cr, uid, move, acc_valuation, acc_dest, reference_amount, reference_currency_id, context))]
|
||||
|
||||
# Incoming moves (or cross-company input part)
|
||||
if move.location_dest_id.company_id \
|
||||
@@ -2308,7 +2312,11 @@ class stock_move(osv.osv):
|
||||
or move.location_id.company_id != move.location_dest_id.company_id):
|
||||
journal_id, acc_src, acc_dest, acc_valuation = self._get_accounting_data_for_valuation(cr, uid, move, dest_company_ctx)
|
||||
reference_amount, reference_currency_id = self._get_reference_accounting_values_for_valuation(cr, uid, move, src_company_ctx)
|
||||
account_moves += [(journal_id, self._create_account_move_line(cr, uid, move, acc_src, acc_valuation, reference_amount, reference_currency_id, context))]
|
||||
#goods return from customer
|
||||
if move.location_id.usage == 'customer':
|
||||
account_moves += [(journal_id, self._create_account_move_line(cr, uid, move, acc_dest, acc_valuation, reference_amount, reference_currency_id, context))]
|
||||
else:
|
||||
account_moves += [(journal_id, self._create_account_move_line(cr, uid, move, acc_src, acc_valuation, reference_amount, reference_currency_id, context))]
|
||||
|
||||
move_obj = self.pool.get('account.move')
|
||||
for j_id, move_lines in account_moves:
|
||||
|
||||
Reference in New Issue
Block a user