This question has been flagged

What I need is to automatically write some quantities to a specific journal, read'em and write them on debit or credit fields, depending on the situation.

But, the whole point is, that I need to do this:

1.- Without creating invoices

2.- Depending on the state of class/table

3.- Without adding the function to any field, so as soon as it changes state, the quantites are written into the journal.

Ive tried this method, but I think this doesn't works because it should be on a computed Float or Integer field:

@api.multi
@api.depends('order_lines', 'order_lines.product_id', 'contract_work')
def accounting_scenarios(self):
    for record in self:
        if record.state == awaitingraw:
            record.product_id.printer_wip_account.debit = record.contract_work.total_
        elif record.state == work_in_progress:
            record.partner.transp_account.debit = record.contract_work.total_

So, it basically does nothing.

I need a behaviour like, when a purchase or sale is done, the debit or credit fieds are updated with the invoices generated. BUT in this case, the invoice isn't necessary, I just need to read, and copy some field (computed or not), and then "paste" this on the aforementioned fields of the selected journal.

I hope I've explained myself.

Any ideas?

Avatar
Discard

If you want this change to occur when sale state is changed to done, then override lock button function in sale.order.

Author

lock button on sale.order? don't remember one called like that, let me check, but this is another class though, nothing to do with sales