تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
6703 أدوات العرض

Hello everyone. i have an issue. 

I want to override "type" field of original product.template model where original is :


type = fields.Selection([
('consu', 'Consumable'),
('service', 'Service')], string='Product Type', default='consu', required=True,
help='A storable product is a product for which you manage stock. The Inventory app has to be installed.\n'
'A consumable product is a product for which stock is not managed.
\n'
'A service is a non-material product you provide.'
)

I override field in my custom module by :

class ProductTemplate(models.Model):
_inherit = 'product.template'

type = fields.Selection([
('project', 'Project')], string='Product Type', default='proje', required=True,
help='Proje,hizmet,ürün')

But still  Consumable  and Service options are seen in list.  I also replaced view using xpath:

<record id="view_product_newcategory" model="ir.ui.view">
<field name="name">view.product.newcategory.sap.form.inherited</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_only_form_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='type']" position="replace">
<field name="type" ref="custome_fields.type"/>
<field name="type"/>
</xpath>
</field>
</record>


However problem isnt solved. How i should override a field entirely ?

الصورة الرمزية
إهمال
أفضل إجابة

Odoo is inheriting the field in other modules like Inventory to add the storable type by using the selection_add so even if you override it it the other options will remain .. I don't know what are you trying to do by removing them but i don't recommend doing that because you will brake other Odoo modules like project and rental the best solution is to hide the type field and make your own selection field.


Happy to help :) an upvote will be awesome

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
2
أغسطس 23
3137
3
أبريل 23
2250
3
ديسمبر 22
33763
1
مارس 15
4987
1
فبراير 23
7924