Skip to Content
Menu
This question has been flagged
2422 Views

This is for any smart button I've found,however currently I'm unable to find example for something that comes with base Odoo since they all conveniently avoid this problem (read below).


Let's say I have a project and to its form view I add a smart button 'Test Invoice' that opens a tree view with all invoices tied to this project (this is just an example, can be a tree view for anything).


Now the breadcrumb would be 'project/invoices' for example

Now when I create a new invoice from that view it will open a form view for invoice, now the breadcrumb will be  'project/invoices/new' and when I finish creating it and click save I am still at the same breadcrumb 'project/invoices/some_invoice_name' 


So far so good, problem is if I try to go from that view back to 'project/invoices' , one would expect that my new invoice would be shown there but it is not, even after refreshing. I have to go to project again and click smart button 'Test Invoice' and then it will show.


My current code:

smart button just calls a function which is something  like this:


def action_open_invoices(self):
self.ensure_one()
invoice_domain = [("project", "=", self.id)]
 invoices = self.env["account.move"].search(invoice_domain)
ctx = dict(self.env.context)

action = {
"name": "invoices",
"type": "ir.actions.act_window",
"res_model": "account.move",
"views": [[False, "tree"], [False, "form"]],
"domain": [("id", "in", invoices.ids)],
"context": ctx,
} return action


Now previously I said that existing addons avoid this problem conveniently. All of them are adding the new records in the tree view itself, so their breadcrumb is for example 'project/invoices' which is a editable tree , this bypasses the problem since only thing you can return to is the project itself and everything you add is displayed right away since you're editing the tree itself, However I have far too much fields I need to modify for it to be easy to add it directly in the tree, I need to open a form when creating since it's easier to view all the fields.


I think this is a Odoo bug?


Avatar
Discard
Related Posts Replies Views Activity
1
Jun 22
11302
2
Feb 20
8487
1
Jan 24
12763
2
Mar 18
3866
0
Jan 18
2159