dtg-base

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

DTG 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 (
dtg_base.DTGBase
) 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是一个自定义抽象模型(
dtg_base.DTGBase
),为Odoo开发提供常用实用方法。它设计为可被其他模型继承,以获取各类实用工具的访问权限。

Quick Reference

快速参考

UtilityDescription
Date & PeriodFind first/last date of period, period iteration
TimezoneConvert local to UTC, UTC to local
BarcodeCheck barcode exists, generate EAN13
Batch ProcessingSplit large recordsets into batches
after_commitExecute code after transaction commit
Vietnamese TextStrip accents, convert to non-accent
File UtilitiesZip directories, get file size
Number UtilitiesRound to decimal places

实用工具描述
日期与周期查找周期的首/末日期、周期迭代
时区转换本地时间转UTC、UTC转本地时间
条形码工具检查条形码是否存在、生成EAN13码
批量处理将大型记录集拆分为批次
after_commit事务提交后执行代码
越南语文本去除重音、转换为非重音文本
文件工具压缩目录、获取文件大小
数字工具四舍五入到指定小数位

Main Guide

主要指南

File:
odoo-18-dtg-base-guide.md
文件
odoo-18-dtg-base-guide.md

When 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.py
python
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.py
python
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 overview

agent-skills/skills/dtg-base/
├── SKILL.md                       # 本文件 - 主索引
├── odoo-18-dtg-base-guide.md      # DTG Base实用工具完整参考
└── README.md                      # Skill概述

Utilities Overview

实用工具概述

Date & Period Utilities

日期与周期实用工具

  • find_first_date_of_period(date, period_type)
    - Get first date of period
  • find_last_date_of_period(date, period_type)
    - Get last date of period
  • period_iter(start_date, end_date, period_type)
    - Iterate over periods
  • 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_to_utc(local_dt, tz=None)
    - Convert local datetime to UTC
  • convert_utc_to_local(utc_dt, tz=None)
    - Convert UTC datetime to local
  • convert_local_to_utc(local_dt, tz=None)
    - 将本地日期时间转换为UTC
  • convert_utc_to_local(utc_dt, tz=None)
    - 将UTC日期时间转换为本地时间

Barcode Utilities

条形码实用工具

  • barcode_exists(barcode, exclude_id=0)
    - Check if barcode already exists
  • get_ean13 barcode)
    - Generate/check EAN13 barcode
  • barcode_exists(barcode, exclude_id=0)
    - 检查条形码是否已存在
  • get_ean13(barcode)
    - 生成/检查EAN13条形码

Batch Processing

批量处理

  • splittor(limit=None)
    - Split recordset into batches for processing
  • splittor(limit=None)
    - 将记录集拆分为批次进行处理

String & Text Utilities

字符串与文本实用工具

  • strip_accents(text)
    - Remove Vietnamese accents
  • _no_accent_vietnamese(text)
    - Convert Vietnamese text
  • strip_accents(text)
    - 去除越南语重音
  • _no_accent_vietnamese(text)
    - 转换越南语文本

File Utilities

文件实用工具

  • zip_dir(source_dir, output_file)
    - Zip a directory
  • zip_dirs(dirs, output_file)
    - Zip multiple directories
  • _get_file_size(file_path)
    - Get human-readable file size
  • zip_dir(source_dir, output_file)
    - 压缩目录
  • zip_dirs(dirs, output_file)
    - 压缩多个目录
  • _get_file_size(file_path)
    - 获取易读格式的文件大小

Number Utilities

数字实用工具

  • round_decimal(value, decimal_places)
    - Round to specific decimal places

For detailed documentation, see odoo-18-dtg-base-guide.md
  • round_decimal(value, decimal_places)
    - 四舍五入到指定小数位

如需详细文档,请查看 odoo-18-dtg-base-guide.md