updates in fleet

This commit is contained in:
esraa 2024-10-09 11:54:01 +03:00
parent 91e1f44db4
commit 28de0484e9
5 changed files with 35 additions and 21 deletions

View File

@ -2574,7 +2574,15 @@ msgstr ""
msgid "Serial Number"
msgstr "الرقم المسلسل"
#. module: odex_fleet
#: code:addons/odex_fleet/models/fleet_service_type.py:0
#, python-format
msgid "service"
msgstr "الخدمة"
#. module: odex_fleet
#: code:addons/odex_fleet/models/fleet_service_type.py:0
#: model:ir.model.fields,field_description:odex_fleet.field_fleet_quotation_service__service_id
#: model:ir.model.fields,field_description:odex_fleet.field_fleet_service_line_config__service_ids
#: model:ir.model.fields,field_description:odex_fleet.field_fleet_vehicle_cost__service_id

View File

@ -10,5 +10,5 @@ class FleetServiceType(models.Model):
help='Choose whether the service refer to contracts, vehicle services or both')
def get_new_category_selection(self):
selection = [('service', 'Service')]
selection = [(_('service'), _('Service'))]
return selection

View File

@ -25,7 +25,7 @@ class FleetMaintenance(models.Model):
name = fields.Char(string="Name")
next_request_date = fields.Date(string="Next Request Date")
date = fields.Date(string=" Request Date", default=fields.Date.context_today)
next_odometer = fields.Float(string="Next Odometer")
next_odometer = fields.Float(string="Next Odometer", compute='get_old_odometer', store=True)
odometer = fields.Float(string="Odometer")
type = fields.Selection([('corrective', 'Corrective'), ('preventive', 'Preventive')], string='Maintenance Type',
default="corrective")
@ -53,6 +53,11 @@ class FleetMaintenance(models.Model):
user_id = fields.Many2one('res.users', string='Responsible', required=False, default=lambda self: self.env.user)
edit_access = fields.Boolean(compute="get_access", )
@api.onchange('vehicle_id')
def get_old_odometer(self):
for rec in self:
rec.next_odometer = rec.vehicle_id.odometer
def get_access(self):
for rec in self:
rec.edit_access = False
@ -65,7 +70,6 @@ class FleetMaintenance(models.Model):
if rec.service_ids:
rec.total1 = sum(rec.service_ids.mapped('qty'))
def create_invoice(self):
partner = self.quotation_ids.filtered(lambda r: r.approve == True).mapped('partner_id')
if not partner:
@ -115,13 +119,13 @@ class FleetMaintenance(models.Model):
def action_confirm(self):
for rec in self:
record = rec.quotation_ids.sudo().filtered(lambda r: r.approve == True)
if not record:
raise ValidationError(_("You Need Approve Quotation First"))
rec.sudo().state = 'confirm'
def action_approve(self):
for rec in self:
record = rec.quotation_ids.sudo().filtered(lambda r: r.approve == True)
if not record:
raise ValidationError(_("You Need Approve Quotation First"))
rec.state = 'approve'
rec.vehicle_id.next_request_date = rec.next_request_date
@ -142,6 +146,7 @@ class FleetMaintenance(models.Model):
for rec in self:
rec.state = 'cancel'
class FleetQuotation(models.Model):
_name = 'fleet.quotation'
_description = 'Fleet Quotation'
@ -182,6 +187,7 @@ class FleetQuotation(models.Model):
'context': {'default_request_id': self.id},
}
class FleetQuotationService(models.Model):
_name = 'fleet.quotation.service'
_description = 'Fleet Service'

View File

@ -53,8 +53,8 @@ fleet.fleet_vehicle_log_contract_access_right_user,fleet_vehicle_log_contract_ac
fleet_vehicle_log_contract_access_right_user_hr,fleet_vehicle_log_contract_access_right_hr,fleet.model_fleet_vehicle_log_contract,fleet_group_hr,1,1,1,1
fleet_vehicle_log_contract_access_right_user_hr_off,fleet_vehicle_log_contract_access_right_hr_off,fleet.model_fleet_vehicle_log_contract,fleet_group_hr_officer,1,0,1,0
fleet_vehicle_log_line,fleet_vehicle_log_line,model_fleet_service_line_config,,1,1,1,0
fleet_vehicle_log_line_quotation,fleet_vehicle_log_line_quotation,model_fleet_quotation,,1,1,1,0
fleet_vehicle_log_line_quotation_ser,fleet_vehicle_log_line_quotation_ser,model_fleet_quotation_service,,1,1,1,0
fleet_vehicle_log_line_quotation,fleet_vehicle_log_line_quotation,model_fleet_quotation,,1,1,1,1
fleet_vehicle_log_line_quotation_ser,fleet_vehicle_log_line_quotation_ser,model_fleet_quotation_service,,1,1,1,1
fleet_vehicle_access_right_general,fleet_vehicle_access_right_general,fleet.model_fleet_vehicle,,1,0,0,0
fleet_vehicle_access_right_acc,fleet_vehicle_access_right_general,fleet.model_fleet_vehicle,fleet_group_account,1,1,0,0
fleet_vehicle_access_right_hr_off,fleet_vehicle_access_right_general,fleet.model_fleet_vehicle,fleet_group_hr_officer,1,1,0,0

1 id name model_id/id group_id/id perm_read perm_write perm_create perm_unlink
53 fleet_vehicle_log_contract_access_right_user_hr fleet_vehicle_log_contract_access_right_hr fleet.model_fleet_vehicle_log_contract fleet_group_hr 1 1 1 1
54 fleet_vehicle_log_contract_access_right_user_hr_off fleet_vehicle_log_contract_access_right_hr_off fleet.model_fleet_vehicle_log_contract fleet_group_hr_officer 1 0 1 0
55 fleet_vehicle_log_line fleet_vehicle_log_line model_fleet_service_line_config 1 1 1 0
56 fleet_vehicle_log_line_quotation fleet_vehicle_log_line_quotation model_fleet_quotation 1 1 1 0 1
57 fleet_vehicle_log_line_quotation_ser fleet_vehicle_log_line_quotation_ser model_fleet_quotation_service 1 1 1 0 1
58 fleet_vehicle_access_right_general fleet_vehicle_access_right_general fleet.model_fleet_vehicle 1 0 0 0
59 fleet_vehicle_access_right_acc fleet_vehicle_access_right_general fleet.model_fleet_vehicle fleet_group_account 1 1 0 0
60 fleet_vehicle_access_right_hr_off fleet_vehicle_access_right_general fleet.model_fleet_vehicle fleet_group_hr_officer 1 1 0 0

View File

@ -56,13 +56,13 @@
</page>
<page string="Quotations">
<field name="quotation_ids" nolabel="1" attrs="{'readonly': [('state', '!=', 'draft'),('edit_access', '!=', True)]}">
<tree editable="bottom">
<tree editable="bottom" delete="1">
<field name="partner_id" required="1"/>
<field name="cost" required="1"/>
<field name="offer" required="1"/>
<field name="reason" attrs="{'invisible': [('approve', '=',True)],'readonly':True}" force_save="1"/>
<button name="action_approve" string="Approve" type="object" class="oe_highlight" attrs="{'invisible': ['|',('approve', '=', True),('edit_access', '!=', True),('state','!=','confirm')]}"/>
<button name="action_reject" string="Reject" type="object" class="oe_highlight" attrs="{'invisible': ['|',('approve', '=', False),('edit_access', '!=', True),('state','!=','confirm')]}"/>
<button name="action_approve" string="Approve" type="object" class="oe_highlight" attrs="{'invisible': ['|',('approve', '=', True),('edit_access', '!=', True),('state','!=','draft')]}"/>
<button name="action_reject" string="Reject" type="object" class="oe_highlight" attrs="{'invisible': ['|',('approve', '=', False),('edit_access', '!=', True),('state','!=','draft')]}"/>
<field name="approve" invisible="1"/>
<field name="state" invisible="1"/>
<field name="edit_access" invisible="1"/>