Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
12835 Lượt xem

I would like to change the invoice sequence from INV/%(range_year)% to something else (say ABC/INV/%(range_year)%. 

This is my code:

.py file

class AccountMove(models.Model):

     _inherit = 'account.move'
    @api.model 

    def create(self, vals):

         if vals.get('name', ('New')) == ('New'): 

            vals['name'] = self.env['ir.sequence'].next_by_code('account.invoice.sequence') or                     ('New') 

            record = super(AccountMove, self).create(vals)

     return record

.xml file


Invoice Sequence
account.invoice.sequence
ABC/INV/%(y)s/




4


This changed the invoice sequence format but the problem is it keeps generating invoice number even in draft state. How to solve this?


Ảnh đại diện
Huỷ bỏ
Tác giả

I got the solution. Thank you all for the response


Câu trả lời hay nhất

Hello,

There is an option available in the front end to change the sequence.

Follow the steps.

1. Enable the debug mode

2. Goto Settings-> Technical-> Sequence and search for the Customer Invoice Sequence

3. Edit the record and change the sequence as required

4.Save


Ảnh đại diện
Huỷ bỏ
Tác giả

Ya I know about that but I want this by code

Hi Balagopal,

When looking at the solution your provide, the "customer invoice" sequence does not appeared in the list as the Sales Order sequence.

Even if i create a new sequence (e.g. Customer invoice) with the right pre fix and so on, i cannot properly apply this new created sequence.

Any idea on how to apply a new created sequence for customer invoice?

Many thanks
Michel

Hi Michel,

Check the "INV Sequence"

I can't see any INV Sequence there either. only hr.expense.invoice shows up when searching for inv

Câu trả lời hay nhất

Hi,

Instead of doing it in the create method, change it to the Confirm button of the invoice, so that the invoice number will not get generated for the draft invoice.

Override the action_post method and apply the changes.

Thanks

Ảnh đại diện
Huỷ bỏ
Tác giả

Hi,

do you have any references for this??

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 2 23
4750
0
thg 1 23
94
1
thg 10 22
4118
0
thg 4 22
2686
2
thg 3 25
2743