Navigation

    Odoo 中文社区

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • Popular
    • Users
    • Groups

    Odoo中文社区可以通过以下两个域名访问:shine-it.net , odoo.net.cn

    由于系统升迁的原因,本论坛部分较早期的内容存在格式和链接损坏失效的问题,并非本论坛系统本身的缺陷,望谅解

    本社区没有维护任何QQ群讨论组,任何与本社区同名的QQ群讨论组的言论与本社区无关!

    开发人员可以登录gitter讨论组: http://gitter.im/odoo-china/Talk, 需要github账号

    如果您登录系统碰到问题,请在微信公众号留言:

    Odoo 10 JAVA api?

    Odoo 开发与实施交流
    2
    9
    4265
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      tetsu last edited by

      各位好,我想请问一下有没有java能用的api?我查了一下好像很多人都直接写sql,感觉这样也许会出现数据不一致的问题,不知道还有没有别的好办法?我的版本是odoo 10,谢谢各位。

      1 Reply Last reply Reply Quote 0
      • digitalsatori
        digitalsatori 管理员 last edited by

        看这里:https://www.odoo.com/documentation/10.0/api_integration.html

        1 Reply Last reply Reply Quote 0
        • T
          tetsu last edited by

          感谢回复!这个我看过了,感觉还是在做数据库table的操作,我想知道有没有类似business function这种封装好的方法可以调用,比如我想建立一个sales order,直接把所需的参数传进去之后就直接可以在相应的数据库table里插入数据(sales,inventory还有invoice之类),不用再自己做数据库级别的操作了,我是odoo新手,多谢各位大神指点。

          1 Reply Last reply Reply Quote 0
          • digitalsatori
            digitalsatori 管理员 last edited by

            你理解错了,除了基本的对象的CRUD操作,Odoo所有的业务逻辑都可以通过xml-rpc/json-rpc来调用,包括报表,工作流等。如果你愿意完全可以用java写一个自己的客户端。

            1 Reply Last reply Reply Quote 0
            • T
              tetsu last edited by

              能否提供一个xml-rpc/json-rpc调用odoo业务逻辑的例子呢?比如生成一个最简单的sales order?

              因为我有Oracle JD Edwards的开发经验,Oracle提供很多business functions来实现业务逻辑,不知道odoo是不是也提供类似的function,不用自己写table IO。

              谢谢!

              1 Reply Last reply Reply Quote 0
              • digitalsatori
                digitalsatori 管理员 last edited by digitalsatori

                #创建rpc客户端对象models,所有的api调用都要通过models,url是你的Odoo host地址
                final XmlRpcClient models = new XmlRpcClient() {{
                    setConfig(new XmlRpcClientConfigImpl() {{
                        setServerURL(new URL(String.format("%s/xmlrpc/2/object", url)));
                    }});
                }};
                #所有的远程函数调用都是通过 `execute_kw`调用接口 , 后面都是其调用参数,而实际的
                #效果是execute_kw将远程客户端的调用分派(dispatch)并最终执行对象为"sale.order"的“create”函数,并将之后的列表作为参数传递给create函数
                final Integer id = (Integer)models.execute("execute_kw", asList(
                    db, uid, password,
                    "sale.order", "create",
                    asList(new HashMap() {{ put("partner_id", 1); }})
                ));
                

                请参见代码中的说明,上面的java代码远程创建了一个空的销售订单。你可以改变操作对象(当前是‘sale.order'),改变调用的函数(比如用action_confirm 用来确认订单,对象上所有的非私有函数都可以远程调用),或者改变调用函数中所传递的参数,这样就可以执行你希望执行的任何操作了。

                希望对你有帮助。

                1 Reply Last reply Reply Quote 0
                • T
                  tetsu last edited by

                  代码调通了,非常感谢

                  1 Reply Last reply Reply Quote 0
                  • T
                    tetsu last edited by

                    再向您请教一个问题,order_line里面的信息我应该怎么送进去呢?比如我想建一个有两个item的order,按下面的格式送进去好像不对,谢谢

                    final Integer id = (Integer) models.execute("execute_kw", asList(
                    db, Integer.parseInt(uid), password,
                    "sale.order", "create",
                    asList(new HashMap() {
                    {
                    put("origin", 0);
                    put("message_follower_ids", 0);
                    put("order_line", asList(new HashMap() {
                    {
                    put("product_id",7);
                    put("product_uom",7);
                    put("price_unit",100);
                    put("product_uom_qty",1);
                    }
                    {
                    put("product_id",4);
                    put("product_uom",1);
                    put("price_unit",50);
                    put("product_uom_qty",1);
                    }
                    }));
                    put("partner_id", 1);
                    put("carrier_id", 1);
                    put("team_id", 1);
                    put("client_order_ref", 0);
                    }
                    })
                    ));

                    digitalsatori 1 Reply Last reply Reply Quote 0
                    • digitalsatori
                      digitalsatori 管理员 @tetsu last edited by digitalsatori

                      @tetsu
                      代码中的说明,应该能看得懂吧:

                      ~odoo.fields.One2many and ~odoo.fields.Many2many use a special "commands" format to manipulate the set of records stored in/associated with the field.

                      This format is a list of triplets executed sequentially, where each triplet is a command to execute on the set of records. Not all commands apply in all situations. Possible commands are:

                      (0, _, values)
                      adds a new record created from the provided value dict.

                      (1, id, values)
                      updates an existing record of id id with the values in values. Can not be used in :meth:~.create.

                      (2, id, _)
                      removes the record of id id from the set, then deletes it (from the database). Can not be used in :meth:~.create.

                      (3, id, _)
                      removes the record of id id from the set, but does not delete it. Can not be used on ~odoo.fields.One2many. Can not be used in :meth:~.create.

                      (4, id, _)
                      adds an existing record of id id to the set. Can not be used on :class:~odoo.fields.One2many.

                      (5, _, _)
                      removes all records from the set, equivalent to using the command 3 on every record explicitly. Can not be used on :class:~odoo.fields.One2many. Can not be used in :meth:~.create.

                      (6, _, ids)
                      replaces all existing records in the set by the ids list, equivalent to using the command 5 followed by a command 4 for each id in ids.

                      Note: Values marked as _ in the list above are ignored and can be anything, generally 0 or False.

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post