Skip to Content
Menu
This question has been flagged
5 Replies
16641 Views

Hi,

How to customize the PO number by adding the Company name/ Purchase location/ Project name/ Financial Year /PO number.

Eg: Heutech/India/Project-1/2018-19/PO0001

In the above i want customize the PO number , is there any possibility to fetch the field details that i defined in the app or i need to explicitly define new fields,

Thanks in Advance


Allen.. 

Avatar
Discard
Best Answer

Hi Prashanth Kumar,

Settings -> Technical -> Sequences and Identifiers -> Sequences

In the search bar, type "Purchase" Select the first one.


You can add prefix and suffixes.

Prefix: Fixed or date/ time-based prefix characters (Basic Odoo feature does not provide the project name and location)
Suffix: Fixed or date/ time-based suffix characters after the character.
Sequence Size: The total number of numerals in the number (padding) ie: 001 or 000001

Step: The increment used for the next number in the sequence

Next Number: The next number used for the numeric part of the sequence

Use subsequences per date_range: Allow to add the Data/time range.


UPDATED:-

you can override the CREATE function of the purchase order. and add the location and project name etc in the reference.

    @api.model
    def create(self, vals):
        if vals.get('name', 'New') == 'New':
            vals['name'] = self.env['ir.sequence'].next_by_code('purchase.order') or '/'
# Inherit this fuction and add project name and location and company name as a string before the sequence. # then change the new PO reference to the vals['name']. last return the vals, you can recreate the complete reference.
return super(PurchaseOrder, self).create(vals)

Thank you

..

Avatar
Discard
Author

Thanks Nikhil for the response,

The above configuration i did but my requirement is that to fetch the information automatically , The example i mentioned can be defined as prefix , but if the purchasing is done from different location and for different projects what should i do , and more over the customized PO is applicable for all the projects, i want this format for a single project and the location. .... is there any way that we can fetch the project name info and Location info from the fields in coding

Thanks in Advance

HI, I just update the answer it will help you.

Best Answer
do this in py

@api.model def create(self, vals): if vals.get('name', 'New') == 'New':
            if location == "location_1":      vals['name'] = self.env['ir.sequence'].next_by_code('purchase.order')
            if location == 'location_2'
                vals['name'] = self.env['ir.sequence'].next_by_code('purchase.order.location') 

return super(PurchaseOrder, self).create(vals)

class purchaseorderlocation(models.Model):
    _inherit = 'purchase.order'
    _name = purchase.order.location

    seq = fields.Char('')

put this purchase/data/purchase_data.xml
<record id="sequence_PO" model="ir.sequence">
<field name="name">purchase order</field>
<field name="code">purchase.order.location</field>
<field name="prefix">PO or Purchase order</field> #prefix of the doc
<field name="padding">5</field>
<field name="number_next">1</field>
<field name="number_increment">1</field>
</record>

Avatar
Discard
Author

Thanks Rakesh,

But After editing all the above on Purchse.py it is showing "The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application"

Can explain what might be the problem...... an moreover unable to login to the home screen. This i installed locally.

Thanks in advance.

Best Answer

Hello Prashanth, 

          To Change Sequences goto settings and update with your required pattern:

                    Settings -> Technical -> Sequences & Identifiers -> Sequences

 For more details, please visit:  

https://www.odoo.com/en_US/forum/aide-1/question/how-do-i-change-the-format-of-purchase-order-numbers-ie-poxxxxx -to- something- else- 129797

Hope it helps you.
Thanks,
Mayank Gosai


Avatar
Discard