Odoo-bin 在 PowerShell 的表达式或语句中给出意外的标记 "Scaffold"

Odoo-bin give Unexpected token "Scaffold" in expression or statement in PowerShell

我刚开始学习 Odoo,当我阅读他们的文档时,他们说有一个名为 odoo-bin 的命令,但是当我 运行 PowerShell 中的命令时,它给我一个错误:

At line:1 char:54
+ ... python.exe' 'C:\Program Files (x86)\Odoo 12.0\server\odoo-bin' scaffo ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unexpected token ''C:\Program Files (x86)\Odoo 12.0\server\odoo-bin'' in expression or statement.
At line:1 char:105
+ ... ' 'C:\Program Files (x86)\Odoo 12.0\server\odoo-bin' scaffold custom_ ...
+                                                          ~~~~~~~~
Unexpected token 'scaffold' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken

这是什么意思?我错过了什么?下面是我如何 运行 命令:

"c:\Program Files (x86)\Odoo 12.0\python\python.exe" "C:\Program Files (x86)\Odoo 12.0\server\odoo-bin" scaffold custom_salesorder "C:\Program Files (x86)\Odoo 12.0\server\odoo\addons"

python.exe位置是对的,odoo-bin文件在那个文件夹里,还是报错。我使用 odoo 12.

默认情况下,PowerShell 回显字符串而不是执行它们。您需要 call operator (&) 来告诉 PowerShell 将给定的字符串作为命令执行。

示范:

PS C:\> "C:\Windows\System32\PING.EXE"
C:\Windows\System32\PING.EXE
PS C:\> "C:\Windows\System32\PING.EXE" "127.0.0.1"
At line:1 char:32
+ "C:\Windows\System32\PING.EXE" "127.0.0.1"
+                                ~~~~~~~~~~~
Unexpected token '"127.0.0.1"' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken

PS C:\> & "C:\Windows\System32\PING.EXE" "127.0.0.1"

Pinging 127.0.0.1 with 32 bytes of data:
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128

Ping statistics for 127.0.0.1:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

将您的命令行更改为此,问题就会消失:

& "c:\Program Files (x86)\Odoo 12.0\python\python.exe" "C:\Program Files (x86)\Odoo 12.0\server\odoo-bin" scaffold custom_salesorder "C:\Program Files (x86)\Odoo 12.0\server\odoo\addons"