Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
47502 Представления

Hello All,

I created a master table for estimated weight. For this master table i have two float fields 'min' and 'max'. Now i have 10 records and in every record there is 'min' and 'max' value. Now i want to show all 'min' and 'max' values from table to another place. For this i use search method, but not reached upto the mark. So, How can i do that?

Python Code:

Master Table code --

class est_weight(models.Model):
    _name = "est.weight"
    _rec_name = 'est_weight_pet'

    min = fields.Float("Min. Weight")
    max = fields.Float("Max. Weight")
    est_weight_price = fields.Integer(string="Price")


Here i want to search all min. and max. value:--

class RentalPackWizard(models.TransientModel):
    _name = "rental.pack.wizard"
    _description = "Rental Pack Wizard"
   
    @api.model
    def _get_min_max(self):
        mini = self.env['est.weight'].search([('min', '=', '')], limit=1)
        maxi = self.env['est.weight'].search([('max', '=', '')], limit=1)


Thanks in advance.

Аватар
Отменить
Лучший ответ

Hi,

To get the field value in all records of a table, you can try like this. This will return a list of the values in all fields

mini_rec = self.env['est.weight'].search([])
mini = mini_rec.mapped('min')
maxi_rec = self.env['est.weight'].search([])

maxi = maxi_rec.mapped('max')

Thanks

Аватар
Отменить
Автор

Thanks Niyas...!!

Автор

And also how to get 'min' and 'max' combinations id-wise??

Автор

Because i have i float value field(weight) in sale order and i want to apply condition that if that field value is greater than min value than it show related price. That's why i need to check all the min value one by one by that field. So, How apply condition between 'mini' list values?

Related Posts Ответы Просмотры Активность
2
авг. 22
11870
2
мая 21
8758
2
авг. 25
12214
5
сент. 20
6527
1
дек. 19
9865