Skip to Content
Menu
This question has been flagged
1 Reply
4055 Views

class sales_auction(models.Model):

        _name = "sales.auction"

auction_id = fields.Char("Auction Number")

product_auc_id = fields.Many2one("product.product","Product")

start_auc_date = fields.Date("Auction Start Date")

end_auc_date = fields.Date("Auction End Date")

product_auc_id = fields.Many2one("product.product","Product")

initial_price = fields.Float("Minimum Price")

buy_now_price = fields.Float("Maximum Price")

no_of_bids = fields.Integer("No. of Bids Receive")

seller_name = fields.Char("Seller Name")

bid_multiples = fields.Integer("Bid Multiples")

state= fields.Selection([('draft','Draft'), ('confirm','Confirm'), ('done','Done') ],'Status',readonly=True,copy=False,select=True) customer_bid_id = fields.One2many("customer.auction","product_id","Customer")

@api.model def create(self, vals):

        vals['auction_id'] = self.env['ir.sequence'].get('sales.auction')

 return super(sales_auction, self).create(vals)



here i want to create auction_id it's auto increment field when create a record

id like =  AUC00001 , AUC00002. in this order


Avatar
Discard
Best Answer

Check this example sequence generator

1.

@api.model

def create(self, vals):
        if vals.get('name', 'New') == 'New':
            vals['name'] = self.env['ir.sequence'].next_by_code('purchase.order') or '/'

            return super(PurchaseOrder, self).create(vals)

2.

@api.one
def _create_check_sequence(self):
""" Create a check sequence for the journal """
 self.check_sequence_id = self.env['ir.sequence'].sudo().create({
 'name': self.name + _(" : Check Number Sequence"),
 'implementation': 'no_gap',
 'padding': 5,
 'number_increment': 1,
 'company_id': self.company_id.id,
 })
Avatar
Discard