Hi,
Can anybody tell me how to inherit an auto generated sequence(model : ir.sequence) pattern through xml?
Thanks in advance
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hi,
Can anybody tell me how to inherit an auto generated sequence(model : ir.sequence) pattern through xml?
Thanks in advance
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!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
3
Oct 20
|
5065 | ||
|
1
Jul 19
|
5135 | ||
|
3
Aug 15
|
6964 | ||
|
2
Oct 23
|
1766 | ||
|
0
Dec 16
|
3267 |