Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
4 ตอบกลับ
4880 มุมมอง

I'm tying to get the field "next number (number_next_actual)"  of a product sequence and auto set it everytime i create a new product, i need to autofill the field before saving the new product.

 

something like this picture

https://drive.google.com/file/d/1UviCXw-3nRBdjNygOvMuLAaCsWfgYOCO/view?usp=sharing


i have  coded this, it fill the sequence when i save the new product,  but i need to load the sequence when i press the button create


@api.model

    def create(self, values):

        values['ref_sequence'] = self.env['ir.sequence'].next_by_code('ref.seq')

        return super(ProductTemplate, self).create(values)


do someone have any idea of how to achieve this, if is there any similar in odoo, or any method i could use to get it.


อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

Thanks all!!! 

I solved it using this function and using as default:

def _get_sequence(self):

next_seq = self.env['ir.sequence'].search([('code', '=', 'ref.seq')])

return next_seq.number_next_actual

print_next_seq = fields.Integer(string="sequence", required=False, default=_get_sequence)

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Have you seen https://www.odoo.com/forum/help-1/question/can-i-assign-a-custom-field-the-value-of-a-sequence-without-a-module-143107

 

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
Add products in attribute values? แก้ไขแล้ว
1
พ.ค. 19
5080
2
เม.ย. 25
3111
2
พ.ย. 22
6323
1
มิ.ย. 22
8297
1
ก.ย. 21
3212