Hello,
UPDATE 2013.09.12: Iâll re-write the question(and split the code in different files), since looks like it got really confusing to follow..Basically I have the coding below at the moment. I've uploaded whole addon also to pavel-pavlov.com/share/openerp/help/30816/z_fivesol.zip
I've just added DEBUG trace and it shows up... I get in the console
"DEBUG oerpv8_dev1 openerp.addons.z_fivesol.z_fivesol_sale: Successfully set res['value']['zCodeFiveSol']: 'FS012345'."
=> So the problem is not in the .py code...
Current Question: What may be the reason that res['value'] is set properly, but not visible in the sale order line layout, via field name="zCodeFiveSol" ? Maybe I did something wrong in my view?
__init__.py
import z_fivesol_account
import z_fivesol_product
import z_fivesol_sale
__openerp__.py
{
'name': 'Z_FiveSol Customisations',
'version': '0.2',
'category': 'Tools',
'description': """This module contains custom Mods. Changelog:
In version 0.1: -Additional Product fields for internal ref code and external ref code
In version 0.2: -Additional Sale Order Line fields for internal ref code and external ref code""",
'author': 'FiveSol',
'depends': ['product', 'sale', 'stock', 'purchase', 'account'],
'data': [
'z_fivesol_account_view.xml',
'z_fivesol_product_view.xml',
'z_fivesol_sale_view.xml'
],
'demo': [],
'test': [],
'installable': True,
'auto_install': False,
'images': [],
'css': [],
}
z_fivesol_sale.py
from openerp import tools
from openerp.osv import fields, osv
from openerp.tools.translate import _
import logging
_logger = logging.getLogger(__name__)
class sale_order_line(osv.osv):
_inherit = 'sale.order.line'
_columns = {
'zCodeFiveSol': fields.many2one('product.product', 'zCodeFiveSol'),
'zBaumCode': fields.many2one('product.product', 'zBaumCode'),
}
def product_id_change(self, cr, uid, ids, pricelist, product, qty=0,
uom=False, qty_uos=0, uos=False, name='', partner_id=False,
lang=False, update_tax=True, date_order=False, packaging=False,
fiscal_position=False, flag=False, context=None):
res=super(sale_order_line, self).product_id_change(cr, uid, ids,
pricelist, product, qty, uom, qty_uos, uos, name, partner_id, lang,
update_tax, date_order, packaging=packaging,
fiscal_position=fiscal_position, flag=flag, context=context)
res['value']['zCodeFiveSol'] = "1234555"
res['value']['zBaumCode'] = "6789"
_logger.debug('Successfully set res[\'value\'][\'zCodeFiveSol\']: %r.', res['value']['zCodeFiveSol'])
return res
sale_order_line()
z_fivesol_sale_view.xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="zview_order_form" model="ir.ui.view">
<field name="name">sale.order.form.inherited</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='order_line']/tree/field[@name='name']" position="replace">
<field name="zCodeFiveSol"/>
</xpath>
</field>
</record>
</data>
</openerp>