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账号

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

    文件管理模块中的ftp目录文件夹改名

    Odoo 开发与实施交流
    2
    3
    4142
    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.
    • L
      linyaohui last edited by

      该模块下的ftp功能很强大,我有个疑问,因为默认的ftp目录(举个例子,产品目录下面的文件夹是命名是用product里面的name来命名的,想修改为命名是用product的code 字段来命名)

      解决方法:
      浏览ducpoment.py,有一段
        if len(obj.fields_get(self.cr, self.uid, ['dirname'])):
                      _dirname_field = 'dirname'

      原来oe的文件管理目录默认是用相应的object里面的dirname字段作为文件夹的名字的,如果该project没有dirname字段会用name名字
      所以,解决方法就是在product。product下增加一个dirname字段,然后让dirname的值和code 的值保持一直,这里用触发器处理


      CREATE OR REPLACE FUNCTION ftpdirname() RETURNS trigger AS $ftpdirname$
          BEGIN
              NEW.dirname := NEW.default_code;
              RETURN NEW;
          END;
      $ftpdirname$ LANGUAGE plpgsql;

      CREATE TRIGGER ftpdirname BEFORE INSERT OR UPDATE ON product_product
          FOR EACH ROW EXECUTE PROCEDURE ftpdirname();


      特别鸣谢shelly,jeff等兄的指导 (其实增加一个function字段的dirname来处理更方便,无奈暂时没通晓,所以在数据库段用触发器完成)

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

        可以试试酱紫写

        def _new_dirname(self, cr, uid, ids, field_name, arg, context):<br />&nbsp; &nbsp; &nbsp; &nbsp; res = {}<br />&nbsp; &nbsp; &nbsp; &nbsp; for product in self.browse(cr, uid, ids, context=context):<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; res[product.id] = product.name +&#039; &#039;+ product.default_code<br />&nbsp; &nbsp; &nbsp; &nbsp; return res<br />&nbsp; &nbsp; _columns = {<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;dirname&#039;:fields.function(_new_dirname, method=True, string=&#039;dirname&#039;,type=&#039;char&#039;,store=True)<br />&nbsp; &nbsp; }<br />
        


        想要更多还有
        [检测到链接无效,已移除]

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