Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to get fields and values of one module also in an other module?

By
Zeus
on 5/26/14, 1:02 PM 869 views

Need help, tips and advice:

I created my own custom module to add more fields to the purchase-module.

Now I need the same fields (as readonly) in the stock-module (Incoming Shipments - stock.picking.in) with the corresponding values for each order. I tried a lot and browsed for days but I don't get it to work.

I try to give an example: Field x_ebay_id has the value "123" in purchase.order for the Order PO00006. Now the same/new field x_ebay_id in stock.picking.in should show the same value "123" for the Incoming Shipment of Order PO00006 (IN/00001). The intention is that the warehouse workers get the information of the Purchase Order for checking the delivery. 

Can anyone give me an advice how-to?

 

purchase_ebay_project.py

 

from openerp.osv import fields, osv

class purchase_ebay(osv.osv)

_name = 'purchase.order'

_inherit = 'purchase.order'

_columns = {

        'x_ebay_id': fields.char('ebay-Auktionsnummer', size=10, readonly=False, ondelete="set null", select=1),
        'x_ebay_title': fields.char('ebay-Titel', size=64, readonly=False, ondelete="set null", select=1),
        'x_ebay_date': fields.date('ebay-Auktionsende'),
        'x_ebay_sum': fields.char('ebay-Auktionsbetrag', size=10, readonly=False, ondelete="set null", select=1),
        'x_ebay_seller_username': fields.char('ebay-Verkäuferaccount', size=10, readonly=False, ondelete="set null", select=1),
        'x_ebay_seller_realname': fields.char('ebay-Verkäufername', size=10, readonly=False, ondelete="set null", select=1),
        'x_ebay_seller_email': fields.char('ebay-Verkäufer-Mailadresse', size=10, readonly=False, ondelete="set null", select=1),
        'x_ebay_purchaser': fields.char('ebay-Einkäufer-ID', size=10, readonly=False, ondelete="set null", select=1),
        'x_ebay_payment_check': fields.boolean('bezahlt'),
        'x_ebay_payment_methode': fields.selection(
                (('ueberweisung','Überweisung'),
                ('paypal','PayPal'),
                ('bar','Barzahlung'),
                ('sonstige','sonstige'),
                ),'Zahlungsart'),
        'x_ebay_payment_date': fields.date('Zahlungsdatum'),
        'x_ebay_feedback_check': fields.boolean('ebay-Bewertung abgegeben'),
        'x_ebay_link': fields.text('ebay-Auktions-Link', readonly=False, ondelete="set null", select=1),
        'x_ebay_shipped_in_date': fields.date('Wareneingangsdatum'),
        'x_ebay_packer_id': fields.char('Verpackt durch', size=3, readonly=False, ondelete="set null", select=1),
        'x_ebay_storage_id': fields.char('Lagerort', size=6, readonly=False, ondelete="set null", select=1),
        'x_ebay_palett_id': fields.char('Verpackt in Palette', size=3, readonly=False, ondelete="set null", select=False),
        'x_ebay_shipped_out_date': fields.date('Versanddatum'),
        'x_ebay_shipped_out_customs_id': fields.char('Zollnummer', size=10, readonly=False, ondelete="set null", select=1),
        'x_ebay_logistics_company': fields.char('Versandunternehmen', size=10, readonly=False, ondelete="set null", select=False),
        'x_ebay_logistics_company_id': fields.char('Versandauftragsnummer', size=10, readonly=False, ondelete="set null", select=False),
        'x_ebay_comment': fields.text('Kommentar', readonly=False, ondelete="set null", select=False),
        'x_ebay_packer_comment': fields.text('Lager-Kommentar', readonly=False, ondelete="set null", select=False),
    }


purchase_ebay()

 

purchase_ebay_project_form.xml

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


<openerp>
    <data>
        <record model="ir.ui.view" id="purchase_ebay_project_form" >
            <field name="name">purchase_ebay_purchase.order.form</field>
            <field name="model">purchase.order</field>
            <field name="inherit_id" ref="purchase.purchase_order_form"/>
            <field name="arch" type="xml">     
                <xpath expr="//field[@name='partner_ref']" position="after">
                    <field name="x_ebay_id"/> 
                    <field name="x_ebay_title"/>
                </xpath>
                <xpath expr="//field[@name='date_order']" position="after">
                    <field name="x_ebay_date"/>
                    <field name="x_ebay_sum"/>
                </xpath>
            </field>
        </record>


        <record model="ir.ui.view" id="purchase_ebay_project_form2" >
            <field name="name">purchase_ebay_purchase.order.form2</field>
            <field name="model">purchase.order</field>
            <field name="inherit_id" ref="purchase.purchase_order_form"/>
            <field name="arch" type="xml">
                <xpath expr="//page[@string='Incoming Shipments &amp; Invoices']" position="after">
                    <page string="ebay-Details">
                        <group>
                            <group>
                            <field name="x_ebay_seller_username"/>
                            <field name="x_ebay_seller_realname"/>
                            <field name="x_ebay_seller_email"/>
                            <field name="x_ebay_feedback_check"/>
                            <field name="x_ebay_link"/>
                            <field name="x_ebay_comment"/>
                            </group>
                            <group>
                            <field name="x_ebay_purchaser"/>
                            <field name="x_ebay_payment_check"/>
                            <field name="x_ebay_payment_methode"/>
                            <field name="x_ebay_seller_realname"/>
                            <field name="x_ebay_payment_date"/>
                            </group>
                        </group>
                    </page>
                </xpath>
            </field>
        </record>

 

        <record model="ir.ui.view" id="purchase_ebay_project_form3" >
            <field name="name">purchase_ebay_purchase.order.form3</field>
            <field name="model">purchase.order</field>
            <field name="inherit_id" ref="purchase.purchase_order_form"/>
            <field name="arch" type="xml">
                <xpath expr="//page[@string='Incoming Shipments &amp; Invoices']" position="after">
                    <page string="Logistik">
                        <group>
                            <group>
                            <field name="x_ebay_shipped_in_date"/> 
                            <field name="x_ebay_packer_id"/>
                            <field name="x_ebay_storage_id"/>
                            <field name="x_ebay_packer_comment"/>
                            </group>
                            <group>
                            <field name="x_ebay_palett_id"/>
                            <field name="x_ebay_shipped_out_date"/>
                            <field name="x_ebay_logistics_company"/>
                            <field name="x_ebay_logistics_company_id"/>
                            <field name="x_ebay_shipped_out_customs_id"/>
                            </group>
                        </group>
                    </page>
                </xpath>
            </field>
        </record>
</data>
</openerp>

0

Daniel Reis

--Daniel Reis--
3436
| 6 7 9
Lisbon, Portugal
--Daniel Reis--

Author of the "Odoo Development Essentials" book.

Applications Manager at Securitas Portugal

Github: https://github.com/dreispt

Twitter; @reis_pt


Daniel Reis
On 5/26/14, 1:19 PM

On your "purchase_ebay" model, use "related" fields for that.

Something similar to this:

'x_ebay_date': fields.related(

    'sale_order_id', 'date_closed',   # <= follow dot-notation

    string='ebay-Auktionsende', type='date', readonly=True ),

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 5/26/14, 1:02 PM
Seen: 869 times
Last updated: 3/16/15, 8:10 AM