我是odoo的新手。我创建了一个学生模型,我需要在单独的树视图中查看男孩。
当我在插入女孩或男孩后点击保存按钮时,我需要在同一视图下的单独标签中查看所有男生..
你有什么想法吗?
答案 0 :(得分:0)
如果您需要在同一视图中分隔男孩和女孩,请为性别添加默认的group_by。将其放在树视图操作上下文中(将性别替换为您用于识别男孩和女孩的任何字段):
<field name="domain">[('gender', '=', 'male')]</field>
对于男孩的单独树视图,请创建另一个操作并添加域,例如:
<field name="domain">[('is_boy', '=', True)]</field>
或
<?php
if (isset($_GET["w1"]) && isset($_GET["w2"])) {
$lt = $_GET["w1"];
$ln = $_GET["w2"];
$GLOBALS['id']= "";
}
$servername = "localhost";
$username = "root";
$password = "";
try {
$conn = new PDO("mysql:host=$servername;dbname=dbname", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $e){
echo "Connection failed: " . $e->getMessage();
}
function getAddress($lt, $ln) {
$result = json_decode(file_get_contents("https://maps.google.com/maps/api/geocode/json?key=". API_KEY ."&latlng=$lt,$ln"));
if ($result->status == 'OK') {
return $result->results[0]->formatted_address;
}
return 'Error';
}
try{
$db = $conn->prepare("Select ID from Table");
$db->execute();
echo "<div class='row'>";
while($row=$db->fetch(PDO::FETCH_OBJ)) {
$GLOBALS['id'] = $row->ID;
echo "<div class='col-sm-6 col-md-4'>";
echo "<h4 class='media-heading'>", $GLOBALS['id'] ,"</h4>";
echo "<span class='fa fa-map-pin'></span> ", getAddress($lt,$ln);
echo "</div>";
}
echo "</div>";
} catch (PDOException $e) {
echo "Error: ".$e;
}
?>
<!--Pagination-->
<div class="row">
<div class="col-xs-12">
<nav aria-label="Page navigation" class="text-center">
<ul class="pagination pagination-lrr">
<li>
<a href="#" aria-label="Previous">
<span aria-hidden="true">«</span>
</a>
</li>
<li class="active"><a href="#">1</a></li>
<li><a href="#">2</a></li>
<li><a href="#">3</a></li>
<li><a href="#">4</a></li>
<li><a href="#">5</a></li>
<li>
<a href="#" aria-label="Next">
<span aria-hidden="true">»</span>
</a>
</li>
</ul>
</nav>
</div>
</div>