Skip to Content
Menu
This question has been flagged
1 Reply
2768 Views

Hi, 

I'm trying to make a custom module that sets a default property_account_payable_id to a new user every time i create a new supplier.

I tried adding an invisible field "supplier_rank" to check if the user thats going to be created is a supplier or not. 


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

                <field name="supplier_rank" invisible="1"/>

</xpath>


And through python i tried taking that fields value but it returns an empty string


@api.model

    def fields_view_get(self, view_id=None, view_type='form', toolbar=False,

                        submenu=False):

        res = super(ResPartner, self).fields_view_get(

            view_id=view_id, view_type=view_type, toolbar=toolbar,

            submenu=submenu,

        )


        if view_type == 'form':

            payable_xml = etree.XML(res['arch'])

            for node in payable_xml.xpath("//field[@name='supplier_rank']"):

                for i in node.getiterator():

                    print(i.text)

                res['arch'] = etree.tostring(payable_xml)

        return res

Avatar
Discard
Best Answer

Hi Ivan

You can set default accounts as follows:

1. Turn on the Developer mode

2. Go to the Purchase > Order > Vendor > Create (you can also do it through the contact app)

3. Under the Invoicing/Accounting tab, choose the respective accounts you want to set as "Default"

4. Open developer tools > Set Defaults > and configure the Default accounts/users and save.

BR

Ricardo
Avatar
Discard
Author

Isn't there a way to do it through code?

I'd like to keep it in my custom module if possible