dtg-base
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDTG Base Skill
DTG Base Skill
Complete reference for DTG Base module utilities and helpers in Odoo 18.
Odoo 18中DTG Base模块实用工具与助手的完整参考。
What is DTG Base?
什么是DTG Base?
DTG Base is a custom abstract model () that provides common utility methods for Odoo development. It's designed to be inherited by other models to gain access to helpful utilities.
dtg_base.DTGBaseDTG Base是一个自定义抽象模型(),为Odoo开发提供常用实用方法。它设计为可被其他模型继承,以获取各类实用工具的访问权限。
dtg_base.DTGBaseQuick Reference
快速参考
| Utility | Description |
|---|---|
| Date & Period | Find first/last date of period, period iteration |
| Timezone | Convert local to UTC, UTC to local |
| Barcode | Check barcode exists, generate EAN13 |
| Batch Processing | Split large recordsets into batches |
| after_commit | Execute code after transaction commit |
| Vietnamese Text | Strip accents, convert to non-accent |
| File Utilities | Zip directories, get file size |
| Number Utilities | Round to decimal places |
Main Guide
主要指南
File:
odoo-18-dtg-base-guide.md文件:
odoo-18-dtg-base-guide.mdWhen to use this skill
何时使用该Skill
- Working with DTG Odoo codebase
- Need date/period calculations
- Timezone conversions
- Barcode validation
- Batch processing large recordsets
- Vietnamese text processing
- File zipping utilities
- 处理DTG Odoo代码库
- 需要日期/周期计算
- 时区转换
- 条形码验证
- 大型记录集的批量处理
- 越南语文本处理
- 文件压缩工具
DTGBase Abstract Model
DTGBase抽象模型
Inherit from DTGBase
继承DTGBase
Location:
addons_customs/erp/dtg_base/models/dtg_base.pypython
from odoo import models
class MyModel(models.Model):
_name = 'my.model'
_inherit = ['dtg_base.dtg_base']
def my_method(self):
# Now you have access to all DTGBase utilities
first_date = self.find_first_date_of_period('2024-01-15', 'month')
utc_date = self.convert_local_to_utc('2024-01-15 10:00:00')位置:
addons_customs/erp/dtg_base/models/dtg_base.pypython
from odoo import models
class MyModel(models.Model):
_name = 'my.model'
_inherit = ['dtg_base.dtg_base']
def my_method(self):
# 现在你可以访问所有DTGBase实用工具
first_date = self.find_first_date_of_period('2024-01-15', 'month')
utc_date = self.convert_local_to_utc('2024-01-15 10:00:00')File Structure
文件结构
agent-skills/skills/dtg-base/
├── SKILL.md # This file - master index
├── odoo-18-dtg-base-guide.md # Complete DTG Base utilities reference
└── README.md # Skill overviewagent-skills/skills/dtg-base/
├── SKILL.md # 本文件 - 主索引
├── odoo-18-dtg-base-guide.md # DTG Base实用工具完整参考
└── README.md # Skill概述Utilities Overview
实用工具概述
Date & Period Utilities
日期与周期实用工具
- - Get first date of period
find_first_date_of_period(date, period_type) - - Get last date of period
find_last_date_of_period(date, period_type) - - Iterate over periods
period_iter(start_date, end_date, period_type)
- - 获取周期的首日期
find_first_date_of_period(date, period_type) - - 获取周期的末日期
find_last_date_of_period(date, period_type) - - 遍历周期
period_iter(start_date, end_date, period_type)
Timezone Conversion
时区转换
- - Convert local datetime to UTC
convert_local_to_utc(local_dt, tz=None) - - Convert UTC datetime to local
convert_utc_to_local(utc_dt, tz=None)
- - 将本地日期时间转换为UTC
convert_local_to_utc(local_dt, tz=None) - - 将UTC日期时间转换为本地时间
convert_utc_to_local(utc_dt, tz=None)
Barcode Utilities
条形码实用工具
- - Check if barcode already exists
barcode_exists(barcode, exclude_id=0) - - Generate/check EAN13 barcode
get_ean13 barcode)
- - 检查条形码是否已存在
barcode_exists(barcode, exclude_id=0) - - 生成/检查EAN13条形码
get_ean13(barcode)
Batch Processing
批量处理
- - Split recordset into batches for processing
splittor(limit=None)
- - 将记录集拆分为批次进行处理
splittor(limit=None)
String & Text Utilities
字符串与文本实用工具
- - Remove Vietnamese accents
strip_accents(text) - - Convert Vietnamese text
_no_accent_vietnamese(text)
- - 去除越南语重音
strip_accents(text) - - 转换越南语文本
_no_accent_vietnamese(text)
File Utilities
文件实用工具
- - Zip a directory
zip_dir(source_dir, output_file) - - Zip multiple directories
zip_dirs(dirs, output_file) - - Get human-readable file size
_get_file_size(file_path)
- - 压缩目录
zip_dir(source_dir, output_file) - - 压缩多个目录
zip_dirs(dirs, output_file) - - 获取易读格式的文件大小
_get_file_size(file_path)
Number Utilities
数字实用工具
- - Round to specific decimal places
round_decimal(value, decimal_places)
For detailed documentation, see odoo-18-dtg-base-guide.md
- - 四舍五入到指定小数位
round_decimal(value, decimal_places)
如需详细文档,请查看 odoo-18-dtg-base-guide.md