I have question about Vendor Bill.
When we create vendor bill, there is a journal items tab that the data will be generated when we choose Receipts.
I have requirement that user want to reformat the journal item, let say to add 1 account item of debit and credit.
Im looking the sourcode, and the journal items generated from this line :
moves_lines = self.env['stock.move'].browse([rec.id for rec in picking_ids.move_ids_without_package])
new_lines = self.env['account.move.line']
for line in moves_lines:
new_line = new_lines.new(line._prepare_picking_account_move_line(self))
# if i comment the above line, the journal items will not generate
new_line.account_id = new_line._get_computed_account()
new_line.stock_move_id = line.id
new_line._onchange_price_subtotal()
new_lines += new_line
My questions are :
How can i modify the journal items account format ? If i comment the new_lines.new() it will not generate the journal items. But i don't know how to modify the journal items generation. For information the code is created by previous programmer but currently its not possible to contact them.
Thank you before
According to your piece of code, you "just" need to create a new account move line and add it to your record set (new_lines).
You will probably have to do it this way:
Another way of doing that is to gather account_move_lines you want to create and to write them directly on your account_move.
regarding the "cryptic" (0, 0, values), it corresponds to that: (ORM_METHOD_NUMBER, ID_OF_RECORD, VALUES_OF_RECORD) I let you have a look at the ORM methods: (don't forget to change the link for the version you are developing in) https://www.odoo.com/documentation/14.0/developer/reference/addons/orm.html#common-orm-methods
Note that the AccountMove model has a lot of constraint and that you have to balance the account_move_line together for the global balance of the account_move to be 0. (basic accounting stuff)
By the way, the variable names are highly unclear and there are rooms for confusion here. You should rename those to match what they are.
moves_lines
andline
are stock_move ->stock_moves
andstock_move
new_lines
andnew_line
are account_move_line ->account_move_lines
andaccount_move_line
(or aml if it's too long)