Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
3849 Visualizzazioni

i have created a custom field "designation" in 'stock.picking' , now i want to get the value of the description of the product (in purchase.order) in that field  automatically when user push in the button " Reception by item"  (in my custom field)

------------------------------------------------------------------------------

stock_view.xml

<?xml version="1.0" encoding="utf-8"?>

<openerp>

<data>

<record id="bl_stock_picking_tree" model="ir.ui.view">

<field name="name">bl.stock.picking.tree</field>

<field name="model">stock.picking</field>

<field name="inherit_id" ref="stock.vpicktree"/>

<field name="arch" type="xml">

<xpath expr="//field[@name='partner_id']" position="after">

<field name="num_bl"/>

<field name="designation"/>

</xpath>

</field>

</record>

<record id="bl_stock_picking_view_form" model="ir.ui.view">

<field name="name">bl.stock.picking.form</field>

<field name="model">stock.picking</field>

<field name="inherit_id" ref="stock.view_picking_form"/>

<field name="arch" type="xml">

<xpath expr="//field[@name='partner_id']" position="after">

<field name="num_bl"/>

<field name="designation"/>

</xpath>

</field>

        </record>

    </data>

</openerp>

---------------------------------------------------------------------------------------------

from openerp.osv import fields, osv

from openerp import tools

import openerp.addons.decimal_precision as dp

from openerp.tools.translate import _

class StockPicking(osv.osv):

_inherit = 'stock.picking'

def _get_designation(self,cr,uid,values,context=None):

designation=self.pool.get('purchase.order').browse(cr,uid,values.get('order_id')).product_uom.id

print StockQuantTreeDesignation

print values

return super (StockPicking,self).create(cr,uid,values,context)

_columns = {

'num_bl': fields.char( string="Numéro de BL fournisseur",required=True,select=True),

'designation': fields.char( string="Désignation",required=True,select=True,store=True, compute='_get_designation'),

}

-----------------------------------------------------------------------------------------------------

i have write this code but nothing is happened any help please

Avatar
Abbandona
Autore Risposta migliore

  thank you very much for your answer but always the field is not filled automatically    

Avatar
Abbandona
Risposta migliore

def _get_designation(self,cr,uid,values,context=None):         purchase_obj=self.pool.get('purchase.order').search[('name','=',self.origin)]

        for purchase in purchase_obj.order_line:

           self.designation = purchase.product_id.name

     

 

Avatar
Abbandona
Autore

thank you very much for your answer but always the field is not filled automatically

please add your origin all the time to match with purchase order name.(make origin required)