updates in fleet

This commit is contained in:
esraa 2024-10-09 10:15:15 +03:00
parent ba04ee81e5
commit 91e1f44db4
6 changed files with 31 additions and 32 deletions

View File

@ -1709,7 +1709,7 @@ msgstr "تقرير الفاتورة"
#: model:ir.model.fields.selection,name:odex_fleet.selection__fleet_vehicle_log_fuel__state__invoiced
#: model:ir.model.fields.selection,name:odex_fleet.selection__fleet_vehicle_log_services__status__invoiced
msgid "Invoiced"
msgstr ""
msgstr "مفوتر"
#. module: odex_fleet
#: model:ir.model.fields,field_description:odex_fleet.field_hr_employee__driver
@ -2412,7 +2412,7 @@ msgstr "بيانات تعبئة الوقود"
#: model_terms:ir.ui.view,arch_db:odex_fleet.odex_fleet_vehicle_log_services_view_form
#: model_terms:ir.ui.view,arch_db:odex_fleet.vehicle_infraction_view_form
msgid "Refuse"
msgstr ""
msgstr "رفض"
#. module: odex_fleet
#: model:ir.model.fields.selection,name:odex_fleet.selection__fleet_vehicle_log_fuel__state__refused
@ -2421,7 +2421,7 @@ msgstr ""
#: model:ir.model.fields.selection,name:odex_fleet.selection__vehicle_delegation__state__refused
#: model:ir.model.fields.selection,name:odex_fleet.selection__vehicle_infraction__state__refused
msgid "Refused"
msgstr "رفض"
msgstr "مرفوض"
#. module: odex_fleet
#: model_terms:ir.ui.view,arch_db:odex_fleet.fleet_request_maintenance_view_form

View File

@ -1,10 +1,14 @@
from odoo import models, fields, api, _
from odoo.api import returns
class FleetServiceType(models.Model):
_inherit = 'fleet.service.type'
_description = 'Fleet Service Type'
category = fields.Selection([
('service', 'Service')
], 'Category', required=True, help='Choose whether the service refer to contracts, vehicle services or both')
category = fields.Selection(selection='get_new_category_selection', string='Category', required=True,
help='Choose whether the service refer to contracts, vehicle services or both')
def get_new_category_selection(self):
selection = [('service', 'Service')]
return selection

View File

@ -27,36 +27,36 @@ class FleetMaintenance(models.Model):
date = fields.Date(string=" Request Date", default=fields.Date.context_today)
next_odometer = fields.Float(string="Next Odometer")
odometer = fields.Float(string="Odometer")
type = fields.Selection([('corrective', 'Corrective'), ('preventive', 'Preventive')], string='Maintenance Type', default="corrective")
state = fields.Selection([('draft', 'Draft'),
type = fields.Selection([('corrective', 'Corrective'), ('preventive', 'Preventive')], string='Maintenance Type',
default="corrective")
state = fields.Selection([('draft', 'Draft'),
('confirm', 'Confirm'),
('approve', 'Approve'),
('paid', 'Paid'),
('refused', 'Refuse'),
('cancel', 'Cancel'),
], string='state', default="draft")
], string='state', default="draft")
vehicle_id = fields.Many2one('fleet.vehicle', string="Vehicle")
license_plate = fields.Char(required=True, related='vehicle_id.license_plate', store=True,
)
employee_id = fields.Many2one('hr.employee', string="Driver" )
quotation_ids = fields.One2many('fleet.quotation','request_id',string="Quotations")
service_ids = fields.One2many('fleet.quotation.service','request_id',string="Quotations")
license_plate = fields.Char(required=True, related='vehicle_id.license_plate')
employee_id = fields.Many2one('hr.employee', string="Driver")
quotation_ids = fields.One2many('fleet.quotation', 'request_id', string="Quotations")
service_ids = fields.One2many('fleet.quotation.service', 'request_id', string="Quotations")
branch_id = fields.Many2one('hr.department', string="Branch")
# log_id = fields.Many2one('fleet.vehicle.log.services', string="Service Log")
total_cost = fields.Float( string="Total Cost", compute="get_cost",store=True )
total1 = fields.Float(string="Total",compute="get_total",store=True )
total_cost = fields.Float(string="Total Cost", compute="get_cost", store=True)
total1 = fields.Float(string="Total", compute="get_total", store=True)
account_id = fields.Many2one('account.account', string="Account")
invoice_id = fields.Many2one('account.move', string="Invoice", copy=False)
line_id = fields.Many2one('fleet.service.line.config', string="Line", copy=False)
reason = fields.Text(string="Reject Reason", tracking=True,)
reason = fields.Text(string="Reject Reason", tracking=True, )
tax_id = fields.Many2one('account.tax', string='Tax', ondelete='restrict')
user_id = fields.Many2one('res.users', string='Responsible', required=False, default=lambda self: self.env.user)
edit_access = fields.Boolean(compute="get_access",)
edit_access = fields.Boolean(compute="get_access", )
def get_access(self):
for rec in self:
rec.edit_access = False
if rec.state == 'approve' and self.env.user.has_group('odex_fleet.fleet_group_account'):
if rec.state == 'approve' and self.env.user.has_group('odex_fleet.fleet_group_account'):
rec.edit_access = True
@api.depends('service_ids')
@ -67,10 +67,10 @@ class FleetMaintenance(models.Model):
def create_invoice(self):
partner = self.quotation_ids.filtered(lambda r:r.approve == True).mapped('partner_id')
partner = self.quotation_ids.filtered(lambda r: r.approve == True).mapped('partner_id')
if not partner:
raise ValidationError(_("You NEED To ADD And Approve Quotation Lines"))
amount = sum(self.quotation_ids.filtered(lambda r:r.approve == True).mapped('cost'))
amount = sum(self.quotation_ids.filtered(lambda r: r.approve == True).mapped('cost'))
invoice = self.env['account.move'].sudo().create({
'partner_id': partner[0].id,
'currency_id': self.env.user.company_id.currency_id.id,
@ -125,7 +125,6 @@ class FleetMaintenance(models.Model):
rec.state = 'approve'
rec.vehicle_id.next_request_date = rec.next_request_date
def action_refuse(self):
for rec in self:
rec.state = 'refused'
@ -162,7 +161,6 @@ class FleetQuotation(models.Model):
if rec.state == 'approve' and self.env.user.has_group('odex_fleet.fleet_group_account'):
rec.edit_access = True
def action_approve(self):
rec = self.request_id.quotation_ids.filtered(lambda r: r.approve)
print("YYYYYYYYYYYY", rec)
@ -199,6 +197,3 @@ class FleetQuotationService(models.Model):
def _compute_total(self):
for r in self:
r.total = r.number * r.qty

View File

@ -12,7 +12,7 @@
<button name="action_refuse" groups="odex_fleet.fleet_group_account,odex_fleet.fleet_group_gm" string="Refuse" type="object" class="oe_highlight" states="confirm"/>
<button name="action_paid" groups="odex_fleet.fleet_group_account,odex_fleet.fleet_group_supervisor" string="Paid" type="object" class="oe_highlight" states="approve"/>
<button name="action_cancel" groups="odex_fleet.fleet_group_gm,odex_fleet.fleet_group_vice_gm" string="Cancel" type="object" class="oe_highlight" states="draft,confirm,approve"/>
<button name="set_to_draft" groups="odex_fleet.fleet_group_draft" type="object" states="refused" class="oe_highlight" string="Set To Draft"/>
<button name="set_to_draft" groups="odex_fleet.fleet_group_draft" type="object" states="refused,cancel" class="oe_highlight" string="Set To Draft"/>
<field name="state" widget="statusbar" />
</header>
<sheet>
@ -29,8 +29,8 @@
</div>
<group col="4" colspan="2" string="Vehicle Information">
<field name="branch_id" required="1"/>
<field name="account_id" readonly="1" force_save="1" required="1"/>
<field name="tax_id" readonly="1" force_save="1" required="1"/>
<field name="account_id" readonly="1" force_save="1" required="0"/>
<field name="tax_id" readonly="1" force_save="1" required="0"/>
<field name="employee_id" readonly="1" force_save="1"/>
<field name="total_cost"/>
<field name="license_plate" readonly="1" force_save="1"/>

View File

@ -11,7 +11,7 @@
<button name="action_approve" groups="odex_fleet.fleet_group_gm" type="object" states="confirm" class="oe_highlight" string="Approve"/>
<button name="action_cancel" groups="odex_fleet.fleet_group_supervisor" type="object" states="draft" class="oe_highlight" string="Cancel"/>
<button name="action_refuse" groups="odex_fleet.fleet_group_gm" type="object" states="confirm" class="oe_highlight" string="Refuse"/>
<button name="set_to_draft" groups="odex_fleet.fleet_group_draft" type="object" states="refused" class="oe_highlight" string="Set To Draft"/>
<button name="set_to_draft" groups="odex_fleet.fleet_group_draft" type="object" states="refused,cancel" class="oe_highlight" string="Set To Draft"/>
<field name="state" widget="statusbar" />
</header>
<sheet>

View File

@ -685,7 +685,7 @@
states="draft" class="oe_highlight" string="Cancel"/>
<button name="action_refuse" groups="odex_fleet.fleet_group_gm" type="object" states="confirm"
class="oe_highlight" string="Refuse"/>
<button name="set_to_draft" groups="odex_fleet.fleet_group_draft" type="object" states="refused"
<button name="set_to_draft" groups="odex_fleet.fleet_group_draft" type="object" states="refused,cancel"
class="oe_highlight" string="Set To Draft"/>
<field name="state" widget="statusbar" nolabel="1"/>
</header>
@ -811,7 +811,7 @@
<button name="action_refuse" groups="odex_fleet.fleet_group_gm" type="object"
states="confirm" class="oe_highlight" string="Refuse"/>
<button name="set_to_draft" groups="odex_fleet.fleet_group_draft" type="object"
states="refused" class="oe_highlight" string="Set To Draft"/>
states="refused,cancel" class="oe_highlight" string="Set To Draft"/>
<field name="status" widget="statusbar" nolabel="1"/>
</header>
<sheet>