コンテンツへスキップ
メニュー
この質問にフラグが付けられました
6 返信
7381 ビュー

i want to display only the products that has as a status = 'qualifid' when i am creating a new sales order in the sales.order.lines form 

for this i added the new selection field in the product.template model 

_inherit = "product.template"

    state = fields.Selection([
        ('scratch', 'Brouillion'),
        ('qualifid', 'Qualifié'),
        ('valide', 'Validé'),
        ], setting='State', readonly=True, default='scratch')

i added the field to the correspanding view 

<record id="view_product_template_tech_inherit" model="ir.ui.view">
<field name="name">product.template.form.inherit</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_only_form_view"/>
<field name="arch" type="xml">
<xpath expr="/form/header/button" position="after">
<field name="state" widget="statusbar"/>
</xpath>
</field>
</record>

and then i try to set the product_id in with this domaine 

<record id="view_sale_order_tech_inherit" model="ir.ui.view">
<field name="name">tech.order.form.inherit</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath
expr="//page[@name='order_lines']/field/form/group/group/field[@name='product_id']" position="replace">
<field name="product_id" domain="[('sale_ok', '=', True), '|', ('company_id', '=', False), ('company_id', '=', parent.company_id), ('state', '!=', 'scratch')]"/>
</xpath>
</field>
</record>

but it seems something still missing 

アバター
破棄
最善の回答

Hi,

Please try Below Code.

<xpath expr="/form/sheet/notebook/page/field[@name='order_line']/tree/field[@name='product_id']" position="attributes">
<attribute name="domain">['&amp;',('state', '=', 'scratch'),('sale_ok', '=', True), '|', ('company_id', '=', False), ('company_id', '=', parent.company_id)]</attribute>

</xpath>


アバター
破棄
著作者

hi, i tried your suggestion and it seems somthing wrong

File "src/lxml/parser.pxi", line 600, in lxml.etree._ParserContext._handleParseResultDoc

File "src/lxml/parser.pxi", line 710, in lxml.etree._handleParseResult

File "src/lxml/parser.pxi", line 639, in lxml.etree._raiseParseError

File "/usr/lib/python3/dist-packages/odoo/addons/tech_sale/views/tech_sale.xml", line 22

lxml.etree.XMLSyntaxError: xmlParseEntityRef: no name, line 22, column 29

Sorry forgot to specify '&' to '&amp;' , answer updated , Try it.

著作者

yes, the error occured due to a syntax error, thanks, i'll mark it as a best answer

最善の回答

Hi,

If there is no errors in installation of the module, make sure that the given domain for the field is correct, just ensure that the OR statement is placed correctly.


Also checking the code, it seems you are applying domain by xpath the one2many form view, so are you checking from the one2many form itself ? If not apply the same domain in the one2many tree view also, or you can directly apply the domain inheriting the sale.order.line in python file itself.


Sample xpath of sale order line view,

<xpath expr="/form/sheet/notebook/page/field[@name='order_line']/tree/field[@name='name']" position="after">
<field name="field_name"/>
</xpath>


Thanks

アバター
破棄
著作者

i tried to change the order of the domain conditions, by setting the ('state', '!=', 'scratch') first i had this error

odoo.tools.convert.ParseError: "unexpected EOF while parsing

('<unknown>', 1, 123, "('state', '=', 'scratch'), '|', ('company_id', '=', False), ('company_id', '=', parent.company_id), ('sale_ok', '=', True)]")" while parsing /usr/lib/python3/dist-packages/odoo/addons/tech_sale/views/tech_sale.xml:2, near

<odoo>

odoo.tools.convert.ParseError: "unexpected EOF while parsing

('<unknown>', 1, 123, "('state', '=', 'scratch'), '|', ('company_id', '=', False), ('company_id', '=', parent.company_id), ('sale_ok', '=', True)]")" while parsing /usr/lib/python3/dist-packages/odoo/addons/tech_sale/views/tech_sale.xml:2, near

<odoo>

it could be just the syntaxe ?

著作者

any suggestion please ?

関連投稿 返信 ビュー 活動
0
2月 25
18
1
10月 20
3289
2
3月 15
6779
0
3月 15
3748
1
3月 15
3650