Fix service and link to equipment
This commit is contained in:
parent
bd9b834bda
commit
afb8abe283
|
@ -32,7 +32,6 @@ def register():
|
|||
stock.ShipmentOut,
|
||||
stock.ShipmentOutReturn,
|
||||
stock.Move,
|
||||
equipment.EquipmentModel,
|
||||
equipment.RentalEquipment,
|
||||
module='rental', type_='model')
|
||||
Pool.register(
|
||||
|
|
|
@ -21,7 +21,7 @@ class Booking(Workflow, ModelSQL, ModelView):
|
|||
__name__ = 'rental.booking'
|
||||
_rec_name = 'number'
|
||||
number = fields.Char('Number', readonly=True, select=True)
|
||||
equipment = fields.Many2One('rental.equipment', 'Equipment', states=STATES)
|
||||
equipment = fields.Many2One('maintenance.equipment', 'Equipment', states=STATES)
|
||||
type_document = fields.Selection([
|
||||
('', ''),
|
||||
('passport', 'Passport'),
|
||||
|
@ -48,10 +48,7 @@ class Booking(Workflow, ModelSQL, ModelView):
|
|||
product = fields.Many2One('product.product', 'Product', domain=[
|
||||
('template.type', '=', 'assets')
|
||||
], states=STATES)
|
||||
category = fields.Many2One('product.category', 'Product Category',
|
||||
domain=[
|
||||
('leasable', '=', True)
|
||||
], states=STATES)
|
||||
brand = fields.Many2One('maintenance.equipment.brand', 'Brand')
|
||||
lapse_time = fields.Integer('Lapse Time', states=STATES)
|
||||
booking_date = fields.Date('Booking Date', states=STATES)
|
||||
start_date = fields.DateTime('Start Date', states=STATES)
|
||||
|
@ -263,7 +260,7 @@ class Booking(Workflow, ModelSQL, ModelView):
|
|||
Party = pool.get('party.party')
|
||||
Rental = pool.get('rental.service')
|
||||
Config = pool.get('rental.configuration')
|
||||
Equipment = pool.get('rental.equipment')
|
||||
Equipment = pool.get('maintenance.equipment')
|
||||
Item = pool.get('product.check_list_item')
|
||||
ProductCheckList = pool.get('rental.service.product_check_list')
|
||||
config = Config(1)
|
||||
|
|
45
equipment.py
45
equipment.py
|
@ -1,47 +1,30 @@
|
|||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from trytond.model import ModelView, ModelSQL, fields, Unique
|
||||
from trytond.pool import Pool
|
||||
from trytond.model import fields, Unique
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
|
||||
__all__ = [
|
||||
'RentalEquipment', 'EquipmentModel'
|
||||
]
|
||||
__all__ = ['RentalEquipment']
|
||||
|
||||
|
||||
class EquipmentModel(ModelSQL, ModelView):
|
||||
'Equipment Model'
|
||||
__name__ = 'rental.equipment.model'
|
||||
name = fields.Char('Name', required=True)
|
||||
|
||||
|
||||
class RentalEquipment(ModelSQL, ModelView):
|
||||
'Rental Equipment'
|
||||
__name__ = 'rental.equipment'
|
||||
_rec_name = 'product'
|
||||
product = fields.Many2One('product.product', 'Product', required=True,
|
||||
domain=[('template.type', '=', 'assets')])
|
||||
class RentalEquipment(metaclass=PoolMeta):
|
||||
__name__ = 'maintenance.equipment'
|
||||
status = fields.Selection([
|
||||
('available', 'Available'),
|
||||
('maintenance', 'Maintenance'),
|
||||
('not_available', 'Not Available'),
|
||||
], 'Status', readonly=False)
|
||||
('available', 'Available'),
|
||||
('maintenance', 'Maintenance'),
|
||||
('not_available', 'Not Available'),
|
||||
('stolen', 'Stolen'),
|
||||
], 'Status')
|
||||
issues = fields.Text('issues')
|
||||
gps_id = fields.Char('GPS Id')
|
||||
gps_passwd = fields.Char('GPS Password')
|
||||
gps_link = fields.Char('GPS Link')
|
||||
date_return = fields.Function(fields.Date('Date Return'),
|
||||
'get_return_date')
|
||||
date_return = fields.Function(fields.Date('Date Return'), 'get_return_date')
|
||||
current_service = fields.Function(fields.Many2One(
|
||||
'rental.service', 'Contract Service'), 'get_service')
|
||||
model = fields.Many2One('rental.equipment.model', 'Model')
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(RentalEquipment, cls).__setup__()
|
||||
table = cls.__table__()
|
||||
cls._order = [
|
||||
('product.name', 'ASC'),
|
||||
]
|
||||
cls._sql_constraints += [
|
||||
('product_uniq', Unique(table, table.product),
|
||||
'Product already exists!'),
|
||||
|
@ -68,8 +51,9 @@ class RentalEquipment(ModelSQL, ModelView):
|
|||
|
||||
def get_rec_name(self, name):
|
||||
product_name = self.product.name or ''
|
||||
self._rec_name = product_name
|
||||
return (self._rec_name)
|
||||
if self.vin:
|
||||
product_name = '[' + self.vin + ']' + product_name
|
||||
return product_name
|
||||
|
||||
@classmethod
|
||||
def search_rec_name(cls, name, clause):
|
||||
|
@ -81,4 +65,5 @@ class RentalEquipment(ModelSQL, ModelView):
|
|||
bool_op,
|
||||
('product.code',) + tuple(clause[1:]),
|
||||
('product.name',) + tuple(clause[1:]),
|
||||
('vin',) + tuple(clause[1:]),
|
||||
]
|
||||
|
|
|
@ -4,58 +4,19 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<tryton>
|
||||
<data>
|
||||
|
||||
<!-- <record model="ir.action.report" id="report_rental">
|
||||
<field name="name">Equipment</field>
|
||||
<field name="model">rental.equipment</field>
|
||||
<field name="report_name">rental.equipment.report</field>
|
||||
<field name="report">rental/rental.odt</field>
|
||||
</record>
|
||||
<record model="ir.action.keyword" id="report_rental_keyword">
|
||||
<field name="keyword">form_print</field>
|
||||
<field name="model">rental.service,-1</field>
|
||||
<field name="action" ref="report_rental"/>
|
||||
</record> -->
|
||||
|
||||
<record model="ir.ui.view" id="model_view_form">
|
||||
<field name="model">rental.equipment.model</field>
|
||||
<field name="type">form</field>
|
||||
<field name="name">model_view_form</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="model_view_tree">
|
||||
<field name="model">rental.equipment.model</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="name">model_view_tree</field>
|
||||
</record>
|
||||
<record model="ir.action.act_window" id="act_equipment_model">
|
||||
<field name="name">Model</field>
|
||||
<field name="res_model">rental.equipment.model</field>
|
||||
</record>
|
||||
<record model="ir.action.act_window.view" id="act_model_tree">
|
||||
<field name="sequence" eval="1"/>
|
||||
<field name="view" ref="model_view_tree"/>
|
||||
<field name="act_window" ref="act_equipment_model"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.view" id="act_model_form">
|
||||
<field name="sequence" eval="2"/>
|
||||
<field name="view" ref="model_view_form"/>
|
||||
<field name="act_window" ref="act_equipment_model"/>
|
||||
</record>
|
||||
<menuitem parent="menu_configuration" sequence="30"
|
||||
action="act_equipment_model" id="menu_equipment_model"/>
|
||||
|
||||
<record model="ir.ui.view" id="rental_equipment_view_form">
|
||||
<field name="model">rental.equipment</field>
|
||||
<field name="model">maintenance.equipment</field>
|
||||
<field name="type">form</field>
|
||||
<field name="name">equipment_view_form</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="rental_equipment_view_tree">
|
||||
<field name="model">rental.equipment</field>
|
||||
<field name="model">maintenance.equipment</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="name">equipment_view_tree</field>
|
||||
</record>
|
||||
<record model="ir.action.act_window" id="act_rental_equipment">
|
||||
<field name="name">Equipment</field>
|
||||
<field name="res_model">rental.equipment</field>
|
||||
<field name="res_model">maintenance.equipment</field>
|
||||
</record>
|
||||
<record model="ir.action.act_window.view" id="act_rental_equipment_tree">
|
||||
<field name="sequence" eval="1"/>
|
||||
|
|
25
service.py
25
service.py
|
@ -36,7 +36,7 @@ class Service(Workflow, ModelSQL, ModelView):
|
|||
], states={
|
||||
'readonly': Eval('state').in_(['done', 'cancelled']),
|
||||
})
|
||||
equipment = fields.Many2One('rental.equipment', 'Equipment', states={
|
||||
equipment = fields.Many2One('maintenance.equipment', 'Equipment', states={
|
||||
'readonly': Eval('state').in_(['done', 'cancelled']),
|
||||
})
|
||||
service_product = fields.Many2One('product.product', 'Service',
|
||||
|
@ -63,7 +63,6 @@ class Service(Workflow, ModelSQL, ModelView):
|
|||
states={
|
||||
'readonly': (Eval('state') != 'draft') | Eval('currency', 0),
|
||||
}, depends=['state'])
|
||||
deposit_paid = fields.Boolean('Deposit Paid', select=True)
|
||||
balance = fields.Function(fields.Numeric('Balance', digits=(16, 2),
|
||||
readonly=True), 'get_balance')
|
||||
comment = fields.Text('Comment', states=STATES)
|
||||
|
@ -79,7 +78,6 @@ class Service(Workflow, ModelSQL, ModelView):
|
|||
state = fields.Selection([
|
||||
('draft', 'Draft'),
|
||||
('confirmed', 'Confirmed'),
|
||||
('pickup', 'Pick Up'),
|
||||
('renewed', 'Renewed'),
|
||||
('done', 'Done'),
|
||||
('cancelled', 'Cancelled'),
|
||||
|
@ -133,11 +131,16 @@ class Service(Workflow, ModelSQL, ModelView):
|
|||
address = fields.Function(fields.Char('Address'), 'get_party_info')
|
||||
email = fields.Function(fields.Char('Email'), 'get_party_info')
|
||||
pickup_user = fields.Many2One('res.user', 'Pickup User')
|
||||
payment_state = fields.Selection([
|
||||
deposit_state = fields.Selection([
|
||||
('', ''),
|
||||
('pending', 'Pending'),
|
||||
('paid', 'Paid'),
|
||||
('returned', 'Returned'),
|
||||
('partial_paid', 'Partial Paid'),
|
||||
('kept', 'Kept'),
|
||||
], 'Payment State')
|
||||
deposit_amount = fields.Numeric('Deposit Amount', digits=(16, 2))
|
||||
deposit_kept = fields.Numeric('Deposit Kept Amount', digits=(16, 2))
|
||||
deposit_balance = fields.Function(fields.Numeric('Deposit Balance',
|
||||
digits=(16, 2)), 'get_deposit_balance')
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
|
@ -173,6 +176,9 @@ class Service(Workflow, ModelSQL, ModelView):
|
|||
'pay_advance': {
|
||||
'invisible': Eval('state').in_(['done']),
|
||||
},
|
||||
'notification_expiration': {
|
||||
'invisible': ~Eval('state').in_(['done', 'draft']),
|
||||
},
|
||||
})
|
||||
cls._error_messages.update({
|
||||
'invalid_dates': ('Error in Date Start Service!'),
|
||||
|
@ -267,6 +273,7 @@ class Service(Workflow, ModelSQL, ModelView):
|
|||
def renew(cls, records):
|
||||
for rec in records:
|
||||
rec.equipment.write([rec.equipment], {'status': 'not_available'})
|
||||
rec.send_rental_emails()
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
|
@ -292,7 +299,7 @@ class Service(Workflow, ModelSQL, ModelView):
|
|||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
def expire_notification(cls, records):
|
||||
def notification_expiration(cls, records):
|
||||
for rec in records:
|
||||
rec.send_expire_emails()
|
||||
|
||||
|
@ -435,6 +442,10 @@ class Service(Workflow, ModelSQL, ModelView):
|
|||
amount_to_pay += config[0].value_early_return
|
||||
return amount_to_pay
|
||||
|
||||
def get_deposit_balance(self, name):
|
||||
if self.deposit_amount and self.deposit_kept:
|
||||
return (self.deposit_amount - self.deposit_kept)
|
||||
|
||||
def get_days_expiration(self, name):
|
||||
if self.end_date:
|
||||
days = (self.end_date - date.today()).days
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[tryton]
|
||||
version=5.0.2
|
||||
version=5.0.3
|
||||
depends:
|
||||
party
|
||||
company
|
||||
|
@ -8,6 +8,7 @@ depends:
|
|||
email
|
||||
sms
|
||||
account_voucher
|
||||
maintenance
|
||||
xml:
|
||||
rental.xml
|
||||
configuration.xml
|
||||
|
|
|
@ -1,24 +1,34 @@
|
|||
<?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. -->
|
||||
<form>
|
||||
<form col="6">
|
||||
<label name="product"/>
|
||||
<field name="product"/>
|
||||
<label name="code"/>
|
||||
<field name="code"/>
|
||||
<label name="active"/>
|
||||
<field name="active"/>
|
||||
<label name="vin"/>
|
||||
<field name="vin"/>
|
||||
<label name="current_service"/>
|
||||
<field name="current_service"/>
|
||||
<label name="model"/>
|
||||
<field name="model"/>
|
||||
<label name="brand"/>
|
||||
<field name="brand"/>
|
||||
<label name="serial"/>
|
||||
<field name="serial"/>
|
||||
<label name="date_return"/>
|
||||
<field name="date_return"/>
|
||||
<label name="status"/>
|
||||
<field name="status"/>
|
||||
<label name="gps_id"/>
|
||||
<field name="gps_id"/>
|
||||
<label name="gps_serial"/>
|
||||
<field name="gps_serial"/>
|
||||
<label name="gps_passwd"/>
|
||||
<field name="gps_passwd"/>
|
||||
<label name="gps_link"/>
|
||||
<field name="gps_link"/>
|
||||
<notebook colspan="4">
|
||||
<label name="photo"/>
|
||||
<field name="photo" colspan="4"/>
|
||||
<notebook colspan="6">
|
||||
<page string="General" id="general">
|
||||
<separator string="issues" colspan="4" id="issues"/>
|
||||
<field name="issues" colspan="4"/>
|
||||
|
|
|
@ -2,8 +2,10 @@
|
|||
<!-- 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="code"/>
|
||||
<field name="product"/>
|
||||
<field name="model"/>
|
||||
<field name="brand"/>
|
||||
<field name="vin"/>
|
||||
<field name="status"/>
|
||||
<field name="current_service"/>
|
||||
<field name="date_return"/>
|
||||
|
|
|
@ -38,8 +38,8 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="lapse_time"/>
|
||||
<label name="end_date"/>
|
||||
<field name="end_date"/>
|
||||
<label name="category"/>
|
||||
<field name="category" widget="selection"/>
|
||||
<label name="brand"/>
|
||||
<field name="brand" widget="selection"/>
|
||||
<button name="send_notification_pickup" string="Send SMS Notification"
|
||||
icon="tryton-forward" colspan="2"/>
|
||||
<notebook colspan="4">
|
||||
|
|
|
@ -10,7 +10,7 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="last_name"/>
|
||||
<field name="mobile"/>
|
||||
<field name="product"/>
|
||||
<field name="category"/>
|
||||
<field name="brand"/>
|
||||
<field name="booking_date"/>
|
||||
<field name="lapse_time"/>
|
||||
<field name="start_date" widget="date" string="Start Date"/>
|
||||
|
|
|
@ -30,10 +30,18 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="days_expiration"/>
|
||||
<label name="balance"/>
|
||||
<field name="balance"/>
|
||||
<label name="deposit_paid"/>
|
||||
<field name="deposit_paid"/>
|
||||
<group col="6" colspan="4" id="deposit_status">
|
||||
<label name="deposit_amount"/>
|
||||
<field name="deposit_amount"/>
|
||||
<label name="deposit_kept"/>
|
||||
<field name="deposit_kept"/>
|
||||
<label name="deposit_balance"/>
|
||||
<field name="deposit_balance"/>
|
||||
</group>
|
||||
<label name="extra_charges"/>
|
||||
<field name="extra_charges"/>
|
||||
<button name="notification_expiration" string="Notification Expiration"
|
||||
colspan="2"/>
|
||||
<notebook colspan="4">
|
||||
<page string="Check List" id="check_list">
|
||||
<field name="check_list" colspan="4"/>
|
||||
|
@ -102,8 +110,8 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<group col="10" colspan="4" id="state_buttons">
|
||||
<label name="state"/>
|
||||
<field name="state"/>
|
||||
<label name="payment_state"/>
|
||||
<field name="payment_state"/>
|
||||
<label name="deposit_state"/>
|
||||
<field name="deposit_state"/>
|
||||
<group col="6" colspan="4" id="buttons">
|
||||
<button name="pay_advance" string="Add Advance" icon="tryton-open"
|
||||
colspan="2"/>
|
||||
|
|
|
@ -12,5 +12,6 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="end_date"/>
|
||||
<field name="days_expiration"/>
|
||||
<field name="pickup_user"/>
|
||||
<field name="deposit_state"/>
|
||||
<field name="state"/>
|
||||
</tree>
|
||||
|
|
Loading…
Reference in New Issue