[ADD]event_sale: Add event_items fields for product_ids and sales_ends fields.

bzr revid: atp@tinyerp.com-20120402062817-yjd1pay0kqolv8fe
This commit is contained in:
Atul Patel (OpenERP) 2012-04-02 11:58:17 +05:30
parent 1a65c7aceb
commit a85f78a48b
2 changed files with 74 additions and 1 deletions

View File

@ -92,4 +92,32 @@ class sale_order_line(osv.osv):
message = _("The registration %s has been created from the Sale Order %s.") % (registration_id, order_line.order_id.name)
registration_obj.log(cr, uid, registration_id, message)
return super(sale_order_line, self).button_confirm(cr, uid, ids, context=context)
class event_event(osv.osv):
_inherit = 'event.event'
_columns = {
'event_item_ids': fields.one2many('event.items','event_id', 'Event Items'),
}
class event_items(osv.osv):
_name = "event.items"
_columns = {
'product_id': fields.many2one('product.product', 'Product', required=True),
'qty': fields.integer('Quantity'),
'price': fields.integer('Price'),
'uom_id': fields.many2one('product.uom', 'Unit of Measure'),
'discount': fields.integer('Discount'),
'event_id': fields.many2one('event.event', 'Event'),
'sales_end_date': fields.date('Sales End')
}
def onchange_product_id(self, cr, uid, ids, product, context=None):
product_obj = self.pool.get('product.product')
data = {}
if not product:
return {'value': data}
price = product_obj.browse(cr, uid, product).list_price
uom = product_obj.browse(cr, uid, product).uom_id.id
data['price'] = price
data['uom_id'] = uom
return {'value': data}

View File

@ -29,5 +29,50 @@
</xpath>
</field>
</record>
<record model="ir.ui.view" id="view_event_form_inherit">
<field name="name">Events Inherit</field>
<field name="model">event.event</field>
<field name="type">form</field>
<field name="inherit_id" ref="event.view_event_form"/>
<field name="arch" type="xml">
<xpath expr="//notebook[last()]" position="inside">
<page string="Event Items">
<field name="event_item_ids" nolabel="1"/>
</page>
</xpath>
</field>
</record>
<record model="ir.ui.view" id="view_event_items_tree">
<field name="name">Event Items Tree</field>
<field name="model">event.items</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Event Items">
<field name="product_id"/>
<field name="price"/>
<field name="uom_id"/>
<field name="discount"/>
<field name="sales_end_date"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="view_event_items_form">
<field name="name">Event Items Form</field>
<field name="model">event.items</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Event Items">
<field name="product_id" domain="[('event_ok','=',True)]" on_change="onchange_product_id(product_id)"/>
<field name="price"/>
<field name="uom_id"/>
<field name="discount"/>
<field name="sales_end_date"/>
</form>
</field>
</record>
</data>
</openerp>