Odoo Help

0

how to inherit an auto generated sequence pattern through xml?

By
Vivekrajan
on 3/26/14, 10:21 AM 1,159 views

Hi,

Can anybody tell me how to inherit an auto generated sequence(model : ir.sequence) pattern through xml?

Thanks in advance

0
Spike Lee
On 6/21/17, 3:11 AM

Here is a solution. I think you already solve this problem though.


I guess there's no way to inherit a exists sequence record.


You can write a new sequence.xml below:

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

<openerp>

    <data noupdate="1">


        <record id="seq_new_sale_order" model="ir.sequence">

            <field name="name">Sales Order</field>

            <field name="code">new.sale.order</field>

            <field name="prefix">SO%(y)s</field>

            <field name="padding">5</field>

            <field name="company_id" eval="False"/>

        </record>


    </data>

</openerp>

See this line: <field name="code">new.sale.order</field>

I set field's value to new.sale.order

You should set a name as you want.


And override a create method in sale.order

from openerp import api, models, _


class SaleOrder(models.Model):

    _inherit = 'sale.order'


    @api.model

    def create(self, vals):

        record = super(SaleOrder, self).create(vals)

        record['name'] = self.env['ir.sequence'].next_by_code('kinder.sale.order') or _('New')

        return record

See : record['name'] = self.env['ir.sequence'].next_by_code('kinder.sale.order') or _('New')

You can input sequence new.sale.order by using next_by_code method.

I think there is no way to inherit a sequence xml files.

Instead, you can override a create method.


Have a nice day!

About This Community

This platform 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.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)

Stats

Asked: 3/26/14, 10:21 AM
Seen: 1159 times
Last updated: 6/21/17, 3:11 AM