Commits

Pablo Caro Revuelta committed 64f5689

Código del día 3 (no me funciona con la base de datos que tengo
actualmente)

Comments (0)

Files changed (4)

disc_management/author.py

 
     _columns = {
             'name': fields.char('Name', size=64),
+            'discs_ids': fields.many2many('discs', 'auth_disc_rel', 'author_id', 'discs_id', 'Discs'),
             'active': fields.boolean('Active'),
+            'song_ids': fields.one2many('song', 'author', 'Singing songs'),
         }
 
     _defaults = {
              'active': lambda *a: True,
     }
 
+    def button_ok(self, cr, uid, ids, *args):
+        print 'Botón ok pulsado!'
+        return True
+
 author()
+
+
+class discs(osv.osv):
+    _inherit = 'discs'
+    _colums = {
+        'author_ids': fields.many2many('author', 'auth_disc_rel', 'discs_id', 'author_id', 'Authors')
+    }
+
+discs()

disc_management/disc_management_view.xml

 						<field name="year" />
 						<field name="format" />
 						<field name="active" />
+						<field anme="author_ids" />
 					</group>
 					<separator string="Disc Description" />
 					<group colspan="4" col="6">
 						<group colspan="2">
 							<field name="description" nolabel="1" />
+							<group colspan="4" col="1">
+								<separator string="Song in the disc"/>
+								<field name="song_ids" nolabel="1" />
+							</group>
 						</group>
 					</group>
 				</form>
 			<field name="type">form</field>
 			<field name="arch" type="xml">
 				<form string="Authors">
-					<field name="name" />
-					<field name="active" />
+					<group colspan="4">
+						<field name="name" />
+						<field name="active" />
+					</group>
+					<separator string="Discography of the author"/>
+					<field name="discs_ids" colspan="4" nolabel="1"/>
 				</form>
 			</field>
 		</record>
 			<field name="view_type">form</field>
 			<field name="view_mode">tree,form</field>
 		</record>
-		
+
 		<!--  Vista search del autor -->
 		<record id="author_search_view" model="ir.ui.view">
 			<field name="name">author.search.view</field>
 					</group>
 				</search>
 			</field>
-			
+
 		</record>
-		
+
+
+		<!-- Vista tree de canciones (listado) -->
+		<record model="ir.ui.view" id="song_tree_view">
+			<field name="name">song.tree.view</field>
+			<field name="model">song</field>
+			<field name="type">tree</field>
+			<field name="arch" type="xml">
+				<tree string="Songs">
+					<field name="name" />
+				</tree>
+			</field>
+		</record>
+
+		<!-- Vista form de una canción -->
+		<record model="ir.ui.view" id="song_form_view">
+			<field name="name">song.form.view</field>
+			<field name="model">song</field>
+			<field name="type">form</field>
+			<field name="arch" type="xml">
+				<form string="Songs">
+						<field name="name" />
+						<field name="active" />
+						<field name="track" />
+						<group colspan="4">
+							<field name="discs_ids" colspan="4" nolabel="1" />
+						</group>
+				</form>
+			</field>
+		</record>
+
+		<!--  Vista search de la cancion -->
+		<record id="song_search_view" model="ir.ui.view">
+			<field name="name">song.search.view</field>
+			<field name="model">song</field>
+			<field name="type">search</field>
+			<field name="arch" type="xml">
+				<search string="Search for Songs">
+					<group col="15" colspan="4">
+						<filter string="inactive" icon="terp-gdu-smart-failing" domain="[('active','=', False)]" />
+						<separator orientation="vertical"/>
+						<field name="name" />
+					</group>
+				</search>
+			</field>
+		</record>
+
+		!-- Acción para la ventana de vistas -->
+		<record model="ir.actions.act_window" id="action_disc_management_songs">
+			<field name="name">Songs</field>
+			<field name="res_model">song</field>
+			<field name="view_type">form</field>
+			<field name="view_mode">tree,form</field>
+		</record>
+
 
 		<!-- Diseño submenús -->
 		<menuitem id="discs_group_view" name="Disc Group" parent="disc_management_menu" />
 		<menuitem id="discs_menu_view" name="Disc" parent="discs_group_view" action="action_disc_management_discs"/>
 		<menuitem id="author_menu_view" name="Author" parent="discs_group_view" action="action_disc_management_authors"/>
+		<menuitem id="author_menu_view" name="Songs" parent="discs_group_view" action="action_disc_management_songs"/>
 
 	</data>
 </openerp>

disc_management/discs.py

     _description = 'Disc Library'
 
     _columns = {
-            'name': fields.char('Title', size=64),
+            'name': fields.char('Title', size=64, required=True),
             'description': fields.text("Description", size=256),
             'year': fields.date('Published'),
             'format': fields.selection([('vinyl', 'Vinyl'), ('cd', 'CD'), ('mp3', 'MP3'), ('mp4', 'MP4')], 'Format'),

disc_management/songs.py

 
     _columns = {
             'name': fields.char('Song Title', size=64),
+            'author': fields.many2one('author', string='Author who sings this song', select=True),
+            'discs_ids': fields.many2many('discs', 'song_disc_rel', 'song_id', 'disc_id', 'Discs where this song is'),
             'track': fields.time('Track Time', size=2),
             'active': fields.boolean('Active'),
         }
 
 song()
+
+
+class discs(osv.osv):
+    _inherits = 'discs'
+
+    _columns = {
+        'song_ids': fields.many2many('song', 'song_disc_rel', 'discs_id', 'song_id', 'Songs'),
+    }
+
+discs()