<record id="product_code_sequence" model="ir.sequence">@api.model
<field name='name'>Code Sequence </field>
<field name="code">product_code_new</field>
<field name="prefix"> %(code)</field> %%%%not workig this code
<field name='padding'>3</field>
</record>
def create(self,vals):
category=vals['categ_id']
categ_name=self.env['product.category'].browse(category)
name_details=str(categ_name.name)[:3]
product_name=str(vals['name'][:3])
code=product_name+name_details#######this field i want to add prefix in xml
vals.update({
'product_code':self.env['ir.sequence'].next_by_code('product_code_new')})
return super(ProductTemplate,self).create(vals)
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Contabilità
- Magazzino
- PoS
- Project
- MRP
La domanda è stata contrassegnata
2
Risposte
8871
Visualizzazioni
Hi,
You can inherit the compute function( if there any or else add a new compute function) and add some condition for specifying the name as below.
@api.depends('variable', 'operator', 'max_value', 'list_base_price', 'list_price', 'variable_factor') def _compute_name(self): for rule in self: name = 'if %s %s %.02f then' % (rule.variable, rule.operator, rule.max_value) if rule.list_base_price and not rule.list_price: name = '%s fixed price %.02f' % (name, rule.list_base_price) elif rule.list_price and not rule.list_base_price: name = '%s %.02f times %s' % (name, rule.list_price, rule.variable_factor) else: name = '%s fixed price %.02f plus %.02f times %s' % (name, rule.list_base_price, rule.list_price, rule.variable_factor) rule.name = name
Regards
you can simply do this:
on the XML:
<field name="prefix">ANY_KEY_WILL_DO</field> <!--- this will work -->
on Python:
product_code = self.env['ir.sequence'].next_by_code('product_code_new')
product_code = product_code.replace("ANY_KEY_WILL_DO", code)
vals["product_code"] = product_code
i know the question is long time ago, but hope it helps someone else in the future. thanks.
Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!
Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!
Registrati
Hello, have you found the way to do that?
thanks