Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
1 Antworten
5164 Ansichten

I have create a class 'sale_order_section' in order to decompose a quotation into multiples sections. Here is a part of my code :

class sale_order_section(osv.osv):
    _name = 'sale.order.section'
    #_rec_name = 'number'
    _columns = {
               'order_id': fields.many2one('sale.order', 'Order Reference', ondelete='cascade', select=True, readonly=True),
               'order_line': fields.one2many('sale.order.line', 'section_id', 'Order Lines', readonly=False),
               'number': fields.integer('n° section')
    }

class sale_order_line(osv.osv):

_name = 'sale.order.line'
_inherit = 'sale.order.line'
_columns = {
    'section_id': fields.many2one('sale.order.section', 'n° section', required=True, ondelete='cascade', select=True, readonly=True, states={'draft':[('readonly',False)]}),
    'is_option': fields.boolean('option')
}
sale_order_line()


class sale_order(osv.osv):
_name = "sale.order"
_inherit = 'sale.order'
_columns = {
            'order_section': fields.one2many('sale.order.section', 'order_id', 'Order Sections', readonly=True, states={'draft': [('readonly', False)]})
    }

The problem is that when i create a new section in a view, the "order_id" relative to this section is not created, so i don't have a link between the sale order and the section which belongs to this sale order. How can i fix that ? Thanks

Avatar
Verwerfen
Beste Antwort

Normally, you should create sections from sale order view as order_section is a one2many field in sale.order model. The order_id field is automatically filled.

Avatar
Verwerfen
Autor

Maybe it doesnt work because i cannot have two one2many fields in the same table (order_line and order_section) ?

Autor

Also now i have a field "section_id" in the table "sale.order" in PostgreSQL : i am not supposed to have this becaus it's a one2many field...

Verknüpfte Beiträge Antworten Ansichten Aktivität
0
März 15
7713
1
Mai 16
5257
2
März 15
14497
2
März 15
8746
2
März 15
5445