Skip to Content
Menu
This question has been flagged
2 Replies
17845 Views

Hello ,

this is my code xml:

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

<openerp>

<data noupdate="1">

<!-- Product Sequences -->

<record id="seq_type_ean13_sequence" model="ir.sequence.type">

<field name="name">EAN13 code</field>

<field name="code">product.ean13.code</field>

</record>

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

<field name="name">Ean13 code</field>

<field name="code">product.ean13.code</field>

<field name="prefix">000000</field>

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

<field name="number_next">1</field>

</record>

</data>

</openerp>

and my code python:

class product_product(orm.Model):

_inherit = 'product.product'

_columns = {

'ean_sequence_id': fields.many2one('ir.sequence', 'Ean Sequence'),

}


 my question is :

how can i get the ID of ean_sequence_id from ID XML( seq_type_ean13_sequence)?

Avatar
Discard

7.0, 8.0 ?

Author

hello Temur, i want exectly to get a default value to ean_sequence_id by use id xml : class product_product(orm.Model): _inherit = 'product.product' _columns = { 'ean_sequence_id': fields.many2one('ir.sequence', 'Ean Sequence'), } _defaults = { 'ean_sequence_id': the default value }

Best Answer

seq_type_ean13_sequence is an ID as it may referred inside the same xml. from refer this ID externally, you'll need external ID. it means you've to prefix this id with it's module name and add a single dot, between module name and ID. then external id will become somthing like: module_name.seq_type_ean13_sequence

in v8.0 you lookup for a record corresponding of this xml id as follows: 

xml_record = self.env.ref("module_name.seq_type_ean13_sequence")

then xml_record.id should be database id.


Avatar
Discard