<commit_before>from openerp.osv import osv, fields
class add_bed_qty(osv.TransientModel):
    _name = "add.bed.qty"
    _description = "Add The Bed Qty"

    def _check_avi_bed_type(self, cr, uid, ids, context=None):
        total_avi_bed=0
        for avi_bed in self.browse(cr, uid, ids):
            list_bed_types=self.pool.get("hotel.bed.type").search(cr, uid, [('id', '=', avi_bed.bed_type.id)],context=None)
            for list_bed_type_value in self.pool.get("hotel.bed.type").read(cr, uid, list_bed_types, ['available_stock'], context=context):
                total_avi_bed=total_avi_bed+list_bed_type_value['available_stock']
        if total_avi_bed >= avi_bed.qty:
            return True
        else:
            return False


    _columns = {
        'bed_type': fields.many2one('hotel.bed.type', 'Bed Type', required=True),
        'qty': fields.integer('Quantity'),
    }
    _constraints = [
        (_check_avi_bed_type, 'We cant add beds more than available stock', ['bed_type'])
    ]

    def add_bed_qty(self, cr, uid, ids, context=None):<commit_msg>rooms - add room- qty must be non zero<commit_after>from openerp.osv import osv, fields
class add_bed_qty(osv.TransientModel):
    _name = "add.bed.qty"
    _description = "Add The Bed Qty"

    def _check_avi_bed_type(self, cr, uid, ids, context=None):
        total_avi_bed=0
        for avi_bed in self.browse(cr, uid, ids):
            list_bed_types=self.pool.get("hotel.bed.type").search(cr, uid, [('id', '=', avi_bed.bed_type.id)],context=None)
            for list_bed_type_value in self.pool.get("hotel.bed.type").read(cr, uid, list_bed_types, ['available_stock'], context=context):
                total_avi_bed=total_avi_bed+list_bed_type_value['available_stock']
        if total_avi_bed >= avi_bed.qty:
            return True
        else:
            return False

    def _constraints_quantity_nonzero(self, cr, uid, ids, context=None):
        result =True
        for current_rec in self.browse(cr, uid, ids):
            if current_rec.qty <= 0:
                result = False
        return result


    _columns = {
        'bed_type': fields.many2one('hotel.bed.type', 'Bed Type', required=True),
        'qty': fields.integer('Quantity'),
    }
    _constraints = [
        (_check_avi_bed_type, 'We cant add beds more than available stock', ['bed_type']),
        (_constraints_quantity_nonzero, 'Quantity must be greater than zero.', ['Quantity']),
    ]

    def add_bed_qty(self, cr, uid, ids, context=None):
{'fraction_non_alphanumeric': 0.1270410195141378, 'fraction_numerical': 0.001991238550378335, 'mean_word_length': 2.9873015873015873, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1562538', 'n_tokens_mistral': 867, 'n_tokens_neox': 838, 'n_words': 181}