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

Does the payment view for CUSTOMER and SUPPLIER shares in one view for PAYMENT? Thanks in advance (SOLVED)

By
Alcaline
on 12/3/14, 12:55 AM 745 views

How will I going to required the OR number for Customer and required Checque number for Supplier?

 

In XML:

 <record id="account_voucher_receipt_dialog_form_view_inherit_sale" model="ir.ui.view">
            <field name="name">account.voucher.payment.form</field>
            <field name="model">account.voucher</field>
            <field name="inherit_id" ref="account_voucher.view_vendor_receipt_dialog_form" />
            <field name="priority" eval="30"/>
            <field name="arch" type="xml">
                <data>
                    <xpath expr="//field[@name='reference']" position="after">
                        <field name="pr_num" string="P.R. Number" placeholder="e.g. PR003/10"/>
                        <field name="or_num" domain="[('partner_id', '=', partner_id)]" invisible="context.get('hide_track',False)" attrs="{'required':('tracking','=',True)}" string="O.R. Number" placeholder="e.g. OR003/10"/>
                        <field name="cv_num"  string="C.V.Number" placeholder="e.g. CV003/10"/>
                        <field name="cheque_num"   domain="[('partner_id', '=', partner_id)]" invisible="context.get('hide_track',False)" attrs="{'required':('tracking','=',True)}" string="Checque Number" placeholder="e.g. Checque003/10"/>
                        <field name="tracking" invisible="1"/>
                    </xpath>
                </data>
            </field>
        </record>

 

In PY:

 

class account_voucher(osv.osv):
    _inherit = 'account.voucher'
    
    def _tracking(self, cursor, user, ids, name, arg, context=None):
        res = {}
        for tracklot in self.browse(cursor, user, ids, context=context):
            tracking = False
            if (tracklot.move_id.picking_id.type == 'in' and tracklot.product_id.track_incoming == True) or \
                (tracklot.move_id.picking_id.type == 'out' and tracklot.product_id.track_outgoing == True):
                tracking = True
            res[tracklot.id] = tracking
        return res
    
    def _hide_tracking(self, cursor, user, ids, name, arg, context=None):
        res = {}
        for wizard in self.browse(cursor, user, ids, context=context):
            res[wizard.id] = any([not(x.tracking) for x in wizard.move_ids])
        return res

    _columns ={
               'or_num': fields.char('O.R. Number', size=50),
               'cheque_num': fields.char('Cheque Number', size=50),
               'pr_num': fields.char('P.R. Number', size=50),
               'cv_num': fields.char('C.V. Number', size=50),
               'name':fields.char('Memo', size=256, readonly=True, states={'draft':[('readonly',False)]}),
               'type':fields.selection([('sale','Sale'),('purchase','Purchase'),('payment','Payment'),('receipt','Receipt'),],'Default Type'),
               'tracking': fields.function(_tracking, string='Tracking', type='boolean'),
               'hide_track':fields.function(_hide_tracking, string='Tracking', type='boolean'),

               }
   

account_voucher() 

1

Ivan

--Ivan--
3210
| 5 3 6
Jakarta, Indonesia
--Ivan--
Ivan
On 12/3/14, 1:24 AM

If you do it from Pay button yes, it use the same view.  See odoo/odoo/addons/account_voucher/invoice.py

Is there any way to required fields for 2 different payment for CUSTOMER and SUPPLIER

Alcaline
on 12/3/14, 1:29 AM

Yes there is. You can set the required attributes according to certain fields' value. If you look at the file that I've mentioned, you'll see that the invoice_type context will be different for Supplier Invoice (out_invoice), Customer Invoice (in_invoice), Supplier Refund (in_refund), and Customer Refund (out_refund). So you can change the required attribute based on the invoice_type context. Example can be found in addons/stock/wizard/stock_partial_picking_view.xml. Search for context.get.

Ivan
on 12/3/14, 3:01 AM

Do i need to create 2 views for this?

Alcaline
on 12/3/14, 3:37 AM

No.

Ivan
on 12/3/14, 3:49 AM
account.voucher.payment.form account.voucher <xpath expr="//field[@name='reference']" position="after">
Alcaline
on 12/3/14, 4:00 AM

Hi Sir I've Followed the instruction that you gave me but when i click the button an error occured Error: Unknown field undefined in domain ["tracking","=",true]

Alcaline
on 12/3/14, 4:03 AM

It's because the domain is not correct. Anyway, if you use context you don't need to use any domain. Let me quote from stock_partial_picking_view.xml: (cut the rest for clarity). So in your case, try to add invisible="context.get('invoice_type') in ['out_invoice']". Change ['out_invoice'] with the list of invoice types in which you want the field to be invisible. You can also try to do the reverse: invisible="context.get('invoice_type') not in ['in_invoice']". This time the list need to be those types that you want the field to be visible.

Ivan
on 12/3/14, 4:45 AM

Sorry, the XML got cut. Let me re-comment below.

Ivan
on 12/3/14, 4:46 AM

It's because the domain is not correct. Anyway, if you use context you don't need to use any domain. Let me quote from stock_partial_picking_view.xml: <field name="prodlot_id" domain="[('product_id', '=', product_id)]" invisible="context.get('hide_tracking',False)"...> (cut the rest for clarity). So in your case, try to add invisible="context.get('invoice_type') in ['out_invoice']". Change ['out_invoice'] with the list of invoice types in which you want the field to be invisible. You can also try to do the reverse: invisible="context.get('invoice_type') not in ['in_invoice']". This time the list need to be those types that you want the field to be visible.

Ivan
on 12/3/14, 4:47 AM
1

Emipro Technologies Pvt. Ltd.

--Emipro Technologies Pvt. Ltd.--
Tiny ERP Pvt Ltd
http://www.odoo.com
5975
| 6 7 8
Rajkot, India
--Emipro Technologies Pvt. Ltd.--

Being an emerging leader in IT market since 2011, Emipro Technologies Pvt. Ltd. has been providing a wide range of business solutions in Odoo & Magento. We are pleased to have a large pool of contented customers with our meticulous work in the domain of ERP & e-Commerce. A ray of relief & satisfaction to  our customers heart by our successful deployment in their organization, purely represents our success in Odoo platform. Hence, we take pride for being an Odoo partner with a vision of expanding our strategic alliances with our customers to offer them high value-added, trustworthy & cost effective solutions.

 

Since establishment, our business has span across 11 countries of the world. Our customers are companies of all sizes ranging from start-ups to large enterprises, who realize that they need a professional business solutions to generate revenue streams, establish proper communication channels or streamline business operations. Standing with strong determination of customer satisfaction, observing each minute detail of their business processes, providing proper guidance and moving forth to develop product accordingly adds our value and reliability among our customers. 

 

We are blessed with efficient, passionate & eclectic young developers who have come across almost all kinds of business profiles, working with full dedication, applying creativity & new features in existing modules and completing customer's projects successfully on predefined target. Our in-depth knowledge while giving business solutions in Odoo allows us to offer following services to our customers :

 

  • Consulting
  • Installation, Configuration & Customization
  • Training & Support
  • Maintenance
  • Upgradation
  • Documentation
  • Crafting community modules
  • Drafting videos on demand
  • Smart Apps development

We will be :) to welcome you @ www.emiprotechnologies.com to solve any kind of your business needs around Odoo. However we are just an inch away from you by email info@emiprotechnologies.com or a tweet to @EmiproTech

Emipro Technologies Pvt. Ltd.
On 12/3/14, 1:35 AM

Hello Alcaline

 

You can use the 'type' field of account.voucher, which includes sale, purchase, payment, receipt. It is there on the view but is invisible. You can define attrs based on this field as per your requirement.

OR

You can bring the 'customer' and 'supplier' fields as related from partner screen in this pop-up form and based on that you can define the attrs on your fields.

Hope this helps

Can you please give me an example for attrs?

Alcaline
on 12/3/14, 2:23 AM

First you need to confirm what value of field 'type' comes up when you are doing the customer or supplier payments and then you can apply the attrs. Following is just the example for customer i think this will be the value ---- attrs="{'required':[('type','=','reciept')]}" for supplier i think following will be the value ----- attrs="{'required':[('type','=','payment')]}"

Emipro Technologies Pvt. Ltd.
on 12/3/14, 3:23 AM

do i need to display the "type" field??

Alcaline
on 12/3/14, 4:29 AM

@alcaline No you don't need to display the file 'type'. Just the appropriate attrs in appropriate field which you mentioned in your image. Just make sure that 'type' field remains on the form visible or invisible.

Emipro Technologies Pvt. Ltd.
on 12/3/14, 7:05 AM

do i need to create 2 views??

Alcaline
on 12/4/14, 1:00 AM

thanks Empiro. It works..

Alcaline
on 12/4/14, 3:14 AM

@Empiro Technologies what if i want to hide the or number in supplier? Do you know how to add invisible in the existing attrs??

Alcaline
on 12/4/14, 9:02 PM

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: 12/3/14, 12:55 AM
Seen: 745 times
Last updated: 3/16/15, 8:10 AM