Hello World :D
please help, I want to filter values from fields that are in many2one.
I have tried various ways, but still have difficulties in understanding.
so this my code;
zona_parkir=fields.Char('Zona Parkir', related='location_id.zone_id.name', readonly='True')location_id=fields.Many2one('parking_location', string='Lokasi', required='True')
class ParkingLocation(models.Model): #parking_location
_name='parking_location'
_rec_name='name'
name=fields.Char('Lokasi')
zone_id=fields.Many2one('parking_zone', string='Zona')
class ParkingZone(models.Model):
_name='parking_zone' #parking zone
_rec_name='name'
name=fields.Char('Zona Parkir') billing=fields.Float('Tarif')
information=fields.Text('Keterangan')
parking_log_ids=fields.One2many('parking_log','parking_log_id',string='Log Parkir')class ParkingLog(models.Model):
_name='parking_log'
_rec_name='vehicle_id'
vehicle_id=fields.Many2one('vehicle',string='Nomor Kendaraan')
vehicle_type_id=fields.Char(string='Jenis Kendaraan', related='vehicle_id.vehicle_type.name', readonly='True')
rate_id=fields.Float('Tarif / Jam', related='vehicle_id.vehicle_type.billing')
user_id=fields.Many2one('res.users',string='Juru Parkir', default=lambda self: self.env.user, readonly='true')
parking_log_id=fields.Many2one('parking_session', string='Sesi Parkir', readonly='True')
total_rate=fields.Float(string='Total Biaya Parkir',states={'in' : [('readonly', 'False')], 'paid' : [('readonly', 'False')]}, store='True', readonly='True', compute='action_close', track_visibility='onchange')
parking_point_id=fields.Many2one('parking_point',string='Titik Parkir')
parking_location_id=fields.Char('Lokasi Parkir', related='parking_log_id.location_id.name',readonly='True')
parking_zone_rate_id=fields.Char('Zona Parkir', related='parking_log_id.zona_parkir',readonly='True')
parking_hours=fields.Float('Lama Parkir', store='True', readonly='True', compute='action_close', track_visibility='onchange')
class Vehicle(models.Model): _name='vehicle' _rec_name='vehicle_number' vehicle_type=fields.Many2one('vehicle_type',string='Jenis Kendaraan',ondelete='cascade')
vehicle_number=fields.Char(string='Nomor Kendaraan'
class VehicleType(models.Model): _name='vehicle_type'
name=fields.Char('Jenis Kendaraan')
billing=fields.Float('Tarif')
so the point is, when I select ('location_id')
suppose I make 3 zones in that field,
zone X = B = 2 and C = 3
zone Y = B = 1.5 and C = 2.5
zone Z = B = 1 and C = 2
then the value I previously inputted has been recorded in the "billing" field and when I "add item" in the o2m field, the value in it is the filter result from the zone of one of the zones I selected
What do I think I should do?
maybe there is my code that is not supposed to exist / is not suitable.
also ask for advice :D
I will appreciate all forms of answers, thank you very much :-D
try this: https://learnopenerp.blogspot.com/2020/09/domain-filter-many2one-field-odoo13.html