Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
13383 Vistas

Hi, First of all I had a new parameter to the product. Then I need that new parameter in Sales Order Lines for each product in the sales order.

I've tried to add but I had some problems regarding to being inheriting a view from sales.order and adding a parameter from products.

I've done this:

<record id="view_order_form_inherit" model="ir.ui.view">
  <field name="name">sale.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="/form/sheet/notebook/page/field[@name='order_line']/tree/field[@name='price_unit']" position="before">
         <field name="new_field_from_product"/> 
     </xpath>
  </field>
</record>

Thanks, sorry my English.

Avatar
Descartar
Mejor respuesta

First, The code you posted is trying to insert your new field into the view_ORDER_form, you need to insert it on the view_ORDER_LINE_form.

Second, the python code must also inherit and add the new field, if you are not doing that, there is no way your XML will work right.

Third, when you ask for help, please include the error message. Without the error message those trying to help you are flying blind.

Avatar
Descartar
Autor

I've changed the code to: <record id="view_order_line_form_inherit" model="ir.ui.view"> <field name="name">sale.order.line.form.inherit</field> <field name="model">sale.order.line</field> <field name="inherit_id" ref="sale.view_order_line_form2"/> <field name="arch" type="xml"> <xpath expr="/form/sheet/group/group/field[@name='price_unit']" position="before"> <field name="vi_adr"/> </xpath> </field> </record>

Autor

In the second point you said that I've to inherit and and the new field, class product_product(osv.osv): _inherit = "product.product" _name = "product.product" _columns = { 'vi_adr': fields.boolean('ADR', help="Check this box if the product needs ADR (Accord europeen relatif au transport international des marchandises Dangereuses par Route)"), } product_product() Is this that you mean or is to add the new field in the sale.order.line?

Autor

And the error that I've with the new code is: Can't find field 'vi_adr' in the following view parts composing the view of object model 'sale.order.line': * sale.order.line.form.inherit Either you wrongly customized this view, or some modules bringing those views are not compatible with your current data model openerp.addons.base.ir.ir_ui_view: Can't render view mutante.view_order_line_form_inherit for model: sale.order.line

you must upload your code, then stop and start your server to get openERP to recognize the new fields you added in your python file.

Autor

I'm stoping and starting the server by doing this : ./openerp-server -c install/openerp-server.conf --update=mynewmodule, but the error that I've mentioned is always there..

that is wrong, you must FIRST stop the server. ./openerp-server stop SECOND run the command to confirm the server has stopped - ps aux | grep openerp THIRD kill any other running processes FINALLY start the server again ./openerp-server start capitals are for readability because you cannot put new lines in the comments.

Autor

I've this error doing like you told me to: ./openerp-server start No handlers could be found for logger "openerp.addons.google_docs.google_docs" Traceback (most recent call last): File "./openerp-server", line 5, in <module> openerp.cli.main() File "/opt/openerp-7.0/openerp/cli/__init__.py", line 51, in main __import__(m) File "/opt/openerp-7.0/openerp/modules/module.py", line 133, in load_module mod = imp.load_module('openerp.addons.' + module_part, f, path, descr)

Autor

File "/opt/openerp-7.0/openerp/addons/base_action_rule/__init__.py", line 23, in <module> import test_models File "/opt/openerp-7.0/openerp/addons/base_action_rule/test_models.py", line 1, in <module> from osv import osv, fields

Autor

I've put this working but the error is still here: " Can't find field 'vi_adr' ..."

you must add the attribute to class sale_order_line(osv.osv): if you want to record that information in an order line. If you have a product that is or is not ADR it would be much easier for you to just create 2 different products. I do not know what ADR is, so i cannot adivse you.

Autor

So if I had a field to products and if I want that field to appear in the sale_order_line I have to add this field to the class sale_order_line(osv.osv)? ADR - "Accord europeen relatif au transport international des marchandises Dangereuses par Route" Thanks

Yes, but it would probably be easier for you to create a product ADR, and add that to orders that require ADR. Or create 2 product entries - one with ADR and one without, for each of your products. That would remove the need for you to do any custom coding.

Hi, please share all module, tnks

Mejor respuesta

Here is .py

class SaleOrderLine(models.Model):
_inherit = "sale.order.line"

secondary_uom_qty = fields.Float(
string="Secondary Qty", digits="Product Unit of Measure"
)

Here is your XML


Sale Order Secondary Unit
sale.order



expr="//field[@name='order_line']/form//field[@name='price_subtotal']"
position="after"
>
name="secondary_uom_qty"
class="oe_inline oe_no_button"
attrs="{'readonly': [('state', 'in', ('done', 'cancel'))]}"
/>

I hope this will give you a good idea about how to do it. Just inherit sale.order.line in py and specify your field and in xml while specifying model you will write sale.order as both views are linked together.

Thanks

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
1
jun 19
2335
2
mar 23
2382
2
mar 24
1951
1
mar 20
3474
12
dic 23
44098