Explorar el Código

[ADD]新添加‘宿舍’视图子菜单列表,更新视图,添加宿舍描述。编写一个临时储存数据的模型,暂未为其编写视图,暂未在模块中引用

longyuan hace 1 mes
padre
commit
dcc486624f
Se han modificado 6 ficheros con 178 adiciones y 13 borrados
  1. 1 1
      models/hostel.py
  2. 0 7
      models/hostel_room.py
  3. 25 5
      views/hostel_views.xml
  4. 113 0
      views/trade_views.xml
  5. 1 0
      wizards/__init__.py
  6. 38 0
      wizards/hostel_room.py

+ 1 - 1
models/hostel.py

@@ -34,7 +34,7 @@ class Hostel(models.Model):
     )
     other_info = fields.Text(string="其他信息", help="输入更多信息")
     description = fields.Html(string="描述")
-    hostel_rating = fields.Float('宿舍平均评分', digits="rating value")
+    hostel_rating = fields.Float('宿舍平均排名', digits="rating value")
 
     @api.depends('hostel_code')
     def _compute_display_name(self):

+ 0 - 7
models/hostel_room.py

@@ -1,7 +0,0 @@
-from odoo import models, fields, api
-
-class HostelRoom(models.Model):
-    _name = 'hostel.room'
-    currency_id = fields.Many2one('res.currency', string='Currency')
-    rent_amount = fields.Monetary("Rnet Amount", help="Enter rent amount per month")
-    # optional attribute: currency_field='currency_id' incase currency field have another name then 'currency_id'

+ 25 - 5
views/hostel_views.xml

@@ -29,9 +29,11 @@
                                     <field name="street" placeholder="街道..." class="o_address_street"/>
                                     <field name="street2" placeholder="街道2..." class="o_address_street"/>
                                     <field name="city" placeholder="城市" class="o_address_city"/>
-                                    <field name="state_id" class="o_address_state" placeholder="省份" options='{"no_open": True}'/>
+                                    <field name="state_id" class="o_address_state" placeholder="省份"
+                                           options='{"no_open": True}'/>
                                     <field name="zip" placeholder="邮编" class="o_address_zip"/>
-                                    <field name="country_id" placeholder="国家" class="o_address_country" options='{"no_open": True, "no_create": True}'/>
+                                    <field name="country_id" placeholder="国家" class="o_address_country"
+                                           options='{"no_open": True, "no_create": True}'/>
                                 </div>
                             </group>
                             <group>
@@ -46,6 +48,9 @@
                             <field name="mobile" widget="phone" string="手机"/>
                             <field name="email" widget="email" context="{'gravatar_image': True}" string="邮箱"/>
                         </group>
+                        <group>
+                            <field name="description" />
+                        </group>
                     </sheet>
                 </form>
             </field>
@@ -63,6 +68,18 @@
             </field>
         </record>
 
+        <!-- Hostel Search View -->
+        <record id="view_hostel_search" model="ir.ui.view">
+            <field name="name">hostel.hostel.search</field>
+            <field name="model">hostel.hostel</field>
+            <field name="arch" type="xml">
+                <search>
+                    <field name="name"/>
+                    <field name="hostel_code"/>
+                </search>
+            </field>
+        </record>
+
         <!-- Hostel Action -->
         <record id="action_hostel" model="ir.actions.act_window">
             <field name="name">宿舍</field>
@@ -75,8 +92,11 @@
                 </p>
             </field>
         </record>
-
-        <!-- Hostel Menu -->
-        <menuitem id="menu_hostel" name="宿舍列表" action="action_hostel"/>
+        <!-- 添加主菜单项 -->
+        <menuitem id="hostel_main_menu" name="宿舍管理" sequence="50"/>
+        <!-- Hostel 子列表 -->
+        <menuitem id="menu_hostel" name="宿舍列表" action="action_hostel" parent="hostel_main_menu"/>
+        <menuitem id="hostel_type_menu" name="宿舍" parent="hostel_main_menu" action="my_hostel.action_hostel"
+                  groups="my_hostel.group_hostel_manager" sequence="1"/>
     </data>
 </odoo>

+ 113 - 0
views/trade_views.xml

@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="utf-8"?>
+<odoo>
+    <!-- 贸易系统主视图 -->
+    <record id="trade_system_view_tree" model="ir.ui.view">
+        <field name="name">trade.system.tree</field>
+        <field name="model">trade.system</field>
+        <field name="arch" type="xml">
+            <tree>
+                <field name="name"/>
+                <field name="purchase_ids" widget="many2many_tags"/>
+                <field name="warehouse_ids" widget="many2many_tags"/>
+            </tree>
+        </field>
+    </record>
+
+    <record id="trade_system_view_form" model="ir.ui.view">
+        <field name="name">trade.system.form</field>
+        <field name="model">trade.system</field>
+        <field name="arch" type="xml">
+            <form>
+                <sheet>
+                    <group>
+                        <field name="name"/>
+                    </group>
+                    <notebook>
+                        <page string="采购记录">
+                            <field name="purchase_ids" mode="tree,form">
+                                <tree>
+                                    <field name="name"/>
+                                    <field name="product_id"/>
+                                    <field name="quantity"/>
+                                    <field name="price"/>
+                                    <field name="total"/>
+                                </tree>
+                            </field>
+                        </page>
+                        <page string="仓储记录">
+                            <field name="warehouse_ids" mode="tree,form">
+                                <tree>
+                                    <field name="name"/>
+                                    <field name="location"/>
+                                    <field name="capacity"/>
+                                    <field name="current_stock"/>
+                                </tree>
+                            </field>
+                        </page>
+                        <page string="人员配置">
+                            <field name="staff_ids" mode="tree,form">
+                                <tree>
+                                    <field name="name"/>
+                                    <field name="position"/>
+                                    <field name="department"/>
+                                </tree>
+                            </field>
+                        </page>
+                        <page string="进货渠道">
+                            <field name="supplier_ids" widget="many2many_tags"/>
+                        </page>
+                        <page string="出货去向">
+                            <field name="customer_ids" widget="many2many_tags"/>
+                        </page>
+                    </notebook>
+                </sheet>
+            </form>
+        </field>
+    </record>
+
+    <!-- 采购管理视图 -->
+    <record id="trade_purchase_view_tree" model="ir.ui.view">
+        <field name="name">trade.purchase.tree</field>
+        <field name="model">trade.purchase</field>
+        <field name="arch" type="xml">
+            <tree>
+                <field name="name"/>
+                <field name="product_id"/>
+                <field name="quantity"/>
+                <field name="price"/>
+                <field name="total"/>
+            </tree>
+        </field>
+    </record>
+
+    <record id="trade_purchase_view_form" model="ir.ui.view">
+        <field name="name">trade.purchase.form</field>
+        <field name="model">trade.purchase</field>
+        <field name="arch" type="xml">
+            <form>
+                <sheet>
+                    <group>
+                        <field name="name"/>
+                        <field name="product_id"/>
+                        <field name="quantity"/>
+                        <field name="price"/>
+                        <field name="total"/>
+                    </group>
+                </sheet>
+            </form>
+        </field>
+    </record>
+
+    <!-- 菜单和动作 -->
+    <menuitem id="menu_trade_root" name="贸易系统" sequence="10"/>
+    <menuitem id="menu_trade_config" name="贸易配置" parent="menu_trade_root"/>
+    <menuitem id="menu_trade_main" name="贸易管理" parent="menu_trade_root" sequence="20"/>
+
+    <record id="action_trade_system" model="ir.actions.act_window">
+        <field name="name">贸易系统</field>
+        <field name="res_model">trade.system</field>
+        <field name="view_mode">tree,form</field>
+    </record>
+
+    <menuitem id="menu_trade_system" name="贸易系统" parent="menu_trade_main" action="action_trade_system"/>
+</odoo>

+ 1 - 0
wizards/__init__.py

@@ -0,0 +1 @@
+from . import hostel_room

+ 38 - 0
wizards/hostel_room.py

@@ -0,0 +1,38 @@
+from odoo import models, fields, api
+
+class HostelRoom(models.Model):
+    _name = 'hostel.room'
+    currency_id = fields.Many2one('res.currency', string='Currency')
+    rent_amount = fields.Monetary("Rnet Amount", help="Enter rent amount per month")
+    # optional attribute: currency_field='currency_id' incase currency field have another name then 'currency_id'
+
+class TempClean(models.TransientModel):
+    # Transient model模型用于临时存储数据,通常用于Wizard,Form视图等
+    # 创建一个没有任何表的模型
+    _table = None
+    # 如果_auto为True,则模型使用SQL表名
+    _sequence = None
+    # 用于ID字段的SQL序列
+    _sql_constraints = []
+    # SQL约束[(名称, sql定义, 消息)]
+    _register = True
+    # 在ORM注册表中不可见
+    _name = "房间清扫记录"
+    # 模型名称
+    _description = "房间清扫记录,每隔两个小时自动清理一次,可以自定义时间间隔"
+    # 模型描述
+    _inherit = []
+    # 继承的模型
+    fields.Char(string="清扫日期", required=True, readonly=True, help="自动生成清扫时间")
+    fields.Char(string="房间号", required=True, readonly=True, help="清扫的房间号")
+    fields.Boolean(string="是否清扫", default=False)
+    fields.Char(sting="清扫人", required=True, groups="my_hostel.group_hostel_manager")
+
+    @api.model
+    def _is_clean(self):
+        return []
+
+
+
+
+