skilld-labs / go-odoo

Golang wrapper for Odoo API
Apache License 2.0
86 stars 62 forks source link

go generate not generating anything #29

Closed sivan-koren closed 3 years ago

sivan-koren commented 3 years ago

It does not appear that "go generate" is working as expected. No files are being generated and no output is received on stderr or stdout. I may be missing something.

Please let me know if I can provide more information.

user@Computer:~/$
go version go1.16 linux/amd64

user@Computer:~/$echo $ODOO_ADMIN
user@contoso.com

user@Computer:~/$echo $ODOO_PASSWORD
Apassword123!

user@Computer:~/$echo $ODOO_DATABASE
odoo

user@Computer:~/$echo $ODOO_URL
http://odoo.contoso.com:8069

user@Computer:~/$echo $ODOO_REPO_PATH
/home/user/go/src/github.com/skilld-labs/go-odoo

user@Computer:~/$cd $ODOO_REPO_PATH

user@Computer:~/go/src/github.com/skilld-labs/go-odoo$ ls | grep -v "conversion.go\|generator\|go.mod\|go-odoo-generator\|go.sum\|ir_model_fields.go\|ir_model.go\|LICENSE\|odoo.go\|README.md\|types.go\|version.go"
account_account.go
account_analytic_account.go
account_analytic_line.go
account_analytic_tag.go
account_invoice.go
account_invoice_line.go
account_journal.go
crm_lead.go
crm_lead_tag.go
product_product.go
product_supplierinfo.go
project_project.go
project_task.go
res_company.go
res_partner.go
res_partner_category.go
res_users.go

user@Computer:~/go/src/github.com/skilld-labs/go-odoo$ ls | grep -v "conversion.go\|generator\|go.mod\|go-odoo-generator\|go.sum\|ir_model_fields.go\|ir_model.go\|LICENSE\|odoo.go\|README.md\|types.go\|version.go" | xargs rm

user@Computer:~/go/src/github.com/skilld-labs/go-odoo$ ls
LICENSE  README.md  conversion.go  generator  go.mod  go.sum  ir_model.go  ir_model_fields.go  odoo.go  types.go  version.go

user@Computer:~/go/src/github.com/skilld-labs/go-odoo$ go generate

user@Computer:~/go/src/github.com/skilld-labs/go-odoo$ ls
LICENSE  README.md  conversion.go  generator  go.mod  go.sum  ir_model.go  ir_model_fields.go  odoo.go  types.go  version.go

user@Computer:~/go/src/github.com/skilld-labs/go-odoo$ ls -la ../
total 0
drwxr-xr-x 1 user user 512 Feb 18 20:15 .
drwxr-xr-x 1 user user 512 Feb 18 20:15 ..
drwxr-xr-x 1 user user 512 Feb 18 20:17 go-odoo
ahuret commented 3 years ago

Hi @sivan-koren !

I think it's probably an ACL's issue, maybe the user hasn't sufficient permissions. I've try to run go generate using a basic user (not admin) and as you, no error prompt, but no model generated.

I've check the odoo server logs and can find Access Denied by ACLs for operation: read, uid: 8, model: ir.model.access. Note that this log is INFO so that's why no error reported on go-odoo generator side.

We probably could add lines here https://github.com/skilld-labs/go-odoo/blob/master/generator/cmd/generator.go#L35 that check for 0 model found and explain that ACL's stuff + linked this issue ? Contribution welcomed :-) . What do you think ?

Can you give a try with admin account and tell if it fixed ?

sivan-koren commented 3 years ago

I confirmed the user has full access to the IR stuff in Odoo.

Also tried chmod -R 777 * on src\github.com\skilld-labs\go-odoo.

Still nothing happens.

Let me know if there is more I can try.

I'm running Ubuntu 20 on WSL. I did also try running as root in an elevated prompt and still had no luck.

If I run your example code in go, however, it does create an opportunity. This is very promising. I just can't get the models to generate.

Can you maybe generate more of the stock models that come with Odoo community? Would that work? I need to import sales orders, customers, invoices, purchase orders etc...

ahuret commented 3 years ago

Have you try to run directly ./generator/generator -u $user -d $database -p $password --url $url -o /the/path/for/generated/models ? (Basicaly this is what go generate do using env variables) If same result, you can debug directly in code ./generator/cmd, rebuild generator binary to get what step is wrong (client connection / no models found etc...).

Can you maybe generate more of the stock models that come with Odoo community? Would that work? I need to import sales orders, customers, invoices, purchase orders etc...

Could be a good idea to create a "Community Repository" that contains basic/default models

sivan-koren commented 3 years ago

I tried hard coding my credentials into root.go and rebuilding it. Still no output, still no files.

What version of Odoo are you using this on? I'm running 14.0.

I'm pretty sure it's connecting because if I pass a different URL I get: Post "http://localhost:8069/xmlrpc/2/common": dial tcp 127.0.0.1:8069: connect: connection refused

ahuret commented 3 years ago

can you add some debug (fmt.Println) inside this func https://github.com/skilld-labs/go-odoo/blob/master/generator/cmd/generator.go#L34 (that's the first method called by the generator), check if it gets models etc... I bet https://github.com/skilld-labs/go-odoo/blob/master/generator/cmd/generator.go#L35 returns no models.

Btw have you check for odoo server's logs ?

sivan-koren commented 3 years ago

I played with it for a while but I didn't succeed in pulling the models.

I ended up using: https://pkg.go.dev/github.com/ausuwardi/godooj@v0.1.1

I'm going to continue with that for now, just because it's working at this point.

ahuret commented 3 years ago

I'd be happy to help you with models generation if you have some time. You can contact me at huret.antoine@yahoo.fr, we can plan a call or so. Closing it !