first push message
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
from . import controllers
|
||||
from . import models
|
||||
@@ -0,0 +1,33 @@
|
||||
{
|
||||
'name': "address_kh",
|
||||
|
||||
'summary': "Short (1 phrase/line) summary of the module's purpose",
|
||||
|
||||
'description': """
|
||||
Long description of module's purpose
|
||||
""",
|
||||
|
||||
'author': "My Company",
|
||||
'website': "https://www.yourcompany.com",
|
||||
|
||||
# Categories can be used to filter modules in modules listing
|
||||
# Check https://github.com/odoo/odoo/blob/15.0/odoo/addons/base/data/ir_module_category_data.xml
|
||||
# for the full list
|
||||
'category': 'Uncategorized',
|
||||
'version': '0.1',
|
||||
|
||||
# any module necessary for this one to work correctly
|
||||
'depends': ['base'],
|
||||
|
||||
# always loaded
|
||||
'data': [
|
||||
# 'security/ir.model.access.csv',
|
||||
'views/views.xml',
|
||||
'views/templates.xml',
|
||||
],
|
||||
# only loaded in demonstration mode
|
||||
'demo': [
|
||||
'demo/demo.xml',
|
||||
],
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
from . import controllers
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,21 @@
|
||||
# from odoo import http
|
||||
|
||||
|
||||
# class AddressKh(http.Controller):
|
||||
# @http.route('/address_kh/address_kh', auth='public')
|
||||
# def index(self, **kw):
|
||||
# return "Hello, world"
|
||||
|
||||
# @http.route('/address_kh/address_kh/objects', auth='public')
|
||||
# def list(self, **kw):
|
||||
# return http.request.render('address_kh.listing', {
|
||||
# 'root': '/address_kh/address_kh',
|
||||
# 'objects': http.request.env['address_kh.address_kh'].search([]),
|
||||
# })
|
||||
|
||||
# @http.route('/address_kh/address_kh/objects/<model("address_kh.address_kh"):obj>', auth='public')
|
||||
# def object(self, obj, **kw):
|
||||
# return http.request.render('address_kh.object', {
|
||||
# 'object': obj
|
||||
# })
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<odoo>
|
||||
<data>
|
||||
<!--
|
||||
<record id="object0" model="address_kh.address_kh">
|
||||
<field name="name">Object 0</field>
|
||||
<field name="value">0</field>
|
||||
</record>
|
||||
|
||||
<record id="object1" model="address_kh.address_kh">
|
||||
<field name="name">Object 1</field>
|
||||
<field name="value">10</field>
|
||||
</record>
|
||||
|
||||
<record id="object2" model="address_kh.address_kh">
|
||||
<field name="name">Object 2</field>
|
||||
<field name="value">20</field>
|
||||
</record>
|
||||
|
||||
<record id="object3" model="address_kh.address_kh">
|
||||
<field name="name">Object 3</field>
|
||||
<field name="value">30</field>
|
||||
</record>
|
||||
|
||||
<record id="object4" model="address_kh.address_kh">
|
||||
<field name="name">Object 4</field>
|
||||
<field name="value">40</field>
|
||||
</record>
|
||||
-->
|
||||
</data>
|
||||
</odoo>
|
||||
@@ -0,0 +1 @@
|
||||
from . import models
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,68 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from odoo import models, fields, api
|
||||
|
||||
class AddressAddress(models.Model):
|
||||
_name = 'address.address'
|
||||
# loc_code = fields.Char()
|
||||
_rec_name = "location_name"
|
||||
_description = "Address_Add"
|
||||
location_name = fields.Char(string='ឈ្មោះទីតាំង', required=True)
|
||||
parent_location = fields.Many2one('address.address', string='ទីកន្លែងមេ')
|
||||
children_ids = fields.One2many('address.address', 'parent_location', 'Children', copy=True)
|
||||
loc_code = fields.Selection([('1', 'រាជធានី/ខេត្ត'),
|
||||
('2', 'ស្រុក/ខ័ណ្ឌ/ក្រុង'),
|
||||
('3', 'ឃុំ/សង្កាត់'),
|
||||
('4', 'ភូមិ')], string='ជា')
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
# Helper Methods for Portal
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
@api.model
|
||||
def get_locations_by_level(self, level_code, parent_id=None):
|
||||
"""
|
||||
Get locations filtered by level and optional parent
|
||||
@param level_code: '1', '2', '3', or '4'
|
||||
@param parent_id: ID of parent location (for levels 2-4)
|
||||
@return: recordset of address.address
|
||||
"""
|
||||
domain = [('loc_code', '=', level_code)]
|
||||
if parent_id and level_code != '1':
|
||||
domain.append(('parent_location', '=', parent_id))
|
||||
return self.sudo().search(domain, order='location_name')
|
||||
|
||||
@api.model
|
||||
def get_location_path(self, location_id):
|
||||
"""
|
||||
Get full path string for a location
|
||||
@return: "Province > District > Commune > Village"
|
||||
"""
|
||||
location = self.browse(location_id)
|
||||
if not location.exists():
|
||||
return ''
|
||||
|
||||
path = []
|
||||
current = location
|
||||
while current:
|
||||
path.insert(0, current.location_name)
|
||||
current = current.parent_location
|
||||
|
||||
return ' > '.join(path)
|
||||
|
||||
@api.model
|
||||
def get_cascading_options(self, parent_id=None):
|
||||
"""
|
||||
Get all child options for cascading dropdowns
|
||||
Useful for pre-loading in form context
|
||||
@return: dict of {loc_code: [{id, name}]}
|
||||
"""
|
||||
result = {}
|
||||
for code in ['2', '3', '4']: # District, Commune, Village
|
||||
domain = [('loc_code', '=', code)]
|
||||
if parent_id:
|
||||
# Get children of this parent at any level
|
||||
domain.append(('parent_location', '=', parent_id))
|
||||
items = self.sudo().search(domain, order='location_name')
|
||||
result[code] = [{'id': i.id, 'name': i.location_name} for i in items]
|
||||
return result
|
||||
@@ -0,0 +1,2 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_address_kh_address_kh,address_kh.address_kh,model_address_kh_address_kh,base.group_user,1,1,1,1
|
||||
|
@@ -0,0 +1,24 @@
|
||||
<odoo>
|
||||
<data>
|
||||
<!--
|
||||
<template id="listing">
|
||||
<ul>
|
||||
<li t-foreach="objects" t-as="object">
|
||||
<a t-attf-href="#{ root }/objects/#{ object.id }">
|
||||
<t t-esc="object.display_name"/>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
<template id="object">
|
||||
<h1><t t-esc="object.display_name"/></h1>
|
||||
<dl>
|
||||
<t t-foreach="object._fields" t-as="field">
|
||||
<dt><t t-esc="field"/></dt>
|
||||
<dd><t t-esc="object[field]"/></dd>
|
||||
</t>
|
||||
</dl>
|
||||
</template>
|
||||
-->
|
||||
</data>
|
||||
</odoo>
|
||||
@@ -0,0 +1,60 @@
|
||||
<odoo>
|
||||
<data>
|
||||
<!-- explicit list view definition -->
|
||||
<!--
|
||||
<record model="ir.ui.view" id="address_kh.list">
|
||||
<field name="name">address_kh list</field>
|
||||
<field name="model">address_kh.address_kh</field>
|
||||
<field name="arch" type="xml">
|
||||
<list>
|
||||
<field name="name"/>
|
||||
<field name="value"/>
|
||||
<field name="value2"/>
|
||||
</list>
|
||||
</field>
|
||||
</record>
|
||||
-->
|
||||
|
||||
<!-- actions opening views on models -->
|
||||
<!--
|
||||
<record model="ir.actions.act_window" id="address_kh.action_window">
|
||||
<field name="name">address_kh window</field>
|
||||
<field name="res_model">address_kh.address_kh</field>
|
||||
<field name="view_mode">list,form</field>
|
||||
</record>
|
||||
-->
|
||||
|
||||
<!-- server action to the one above -->
|
||||
<!--
|
||||
<record model="ir.actions.server" id="address_kh.action_server">
|
||||
<field name="name">address_kh server</field>
|
||||
<field name="model_id" ref="model_address_kh_address_kh"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code">
|
||||
action = {
|
||||
"type": "ir.actions.act_window",
|
||||
"view_mode": "list,form",
|
||||
"res_model": model._name,
|
||||
}
|
||||
</field>
|
||||
</record>
|
||||
-->
|
||||
|
||||
<!-- Top menu item -->
|
||||
<!--
|
||||
<menuitem name="address_kh" id="address_kh.menu_root"/>
|
||||
-->
|
||||
<!-- menu categories -->
|
||||
<!--
|
||||
<menuitem name="Menu 1" id="address_kh.menu_1" parent="address_kh.menu_root"/>
|
||||
<menuitem name="Menu 2" id="address_kh.menu_2" parent="address_kh.menu_root"/>
|
||||
-->
|
||||
<!-- actions -->
|
||||
<!--
|
||||
<menuitem name="List" id="address_kh.menu_1_list" parent="address_kh.menu_1"
|
||||
action="address_kh.action_window"/>
|
||||
<menuitem name="Server to list" id="address_kh" parent="address_kh.menu_2"
|
||||
action="address_kh.action_server"/>
|
||||
-->
|
||||
</data>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user