2025年2月17日 星期一

Odoo 訂製品-產品變體/Product variant 及 屬性/attribute

為單一產品提供多種不同的屬性及選項,例如尺寸、顏色。

例如,服裝公司可對 T 恤設定以下變體/variant:

顏色:藍、紅、白、黑

尺碼:S、M、L、XL、XXL

屬性/attribute

在 Odoo 中,「T 恤」是產品範本,「顏色」及「尺碼」是屬性/attribute ,如此有 20 種不同產品變體:4 款 顏色 選項乘以 5 款 尺碼 選項。

每種款式變體 Odoo 系統都會記錄獨立的庫存數、銷售總額。


變體建立模式/Variant Creation Mode

何時建立新的產品變體?

  • 即時/Instantly:在產品範本新增屬性時,立即建立變體。
  • 動態/Dynamically: 有此變體產品的銷售訂單建立時,才會建立此產品變體。
  • 永不/Never:需自行手動建立產品變體。

產品變體一旦使用,建立模式便不能修改。

變體的影響

  • 條碼:每個變體可有獨立條碼、 SKU(庫存單位)。
  • 價格:每個變體可有獨立價格,為範本產品價格 加上 此變數屬性的各種額外收費。
    如:紅色襯衫的銷售價格為 $23,即:範本襯衫價格 $20,加紅色款式的 $3。
    可在價目表規則中設定計算方式,套用至產品範本或產品變體。
  • 庫存:庫存是每種單獨的產品變體進行盤點計數。範本產品的庫存反映的是所有變體的總和,但實際庫存數量是按各個變體計算的。
  • 圖片:每種產品變體都可以有自己的專屬圖片。
  • 產品範本的變更會自動套用至該產品的每種變體。

電子商務篩選器

客戶在網上商店購物時,是否要在前端看到這些屬性選項。


2024年12月30日 星期一

計量單位

計量單位類別

類別如下,每個類別有一個基準單位,如"長度和距離"是 m。


每類下可再細分,如"長度和距離"下可再分為毫米、公里等。也可自訂如: roll 250m。


類別若是"大於基準單位"則是基準單位乘上"比例",若是"小於基準單位"則是基準單位除以"比例"。
 


2024年12月25日 星期三

採購、訂單 交貨時間/Purchase lead times

每個商品的採購頁籤中可設定多個供應商,每個供應商的供貨價格及交貨時間,如下:


也可設定對客戶訂單的前置時間:

如此在 "報價單" 中便可自動推算廠商到貨時間:


及對客戶的訂單交貨時間:


2024年12月23日 星期一

Dropshipping

賣家不囤貨、不經手商品物流,只當中間人賺取差價。

每當客人下單,賣家就把訂單和發貨細節轉交批發商,直接發送給客戶。

啟用 Dropshipping

設定 Dropshipping 產品

可有多個供應商,清單順序在前面的優先供貨。





2022年5月18日 星期三

CKAN Route(2.9): add_ckan_admin_tab

https://github.com/ckan/ckan/blob/2.9/ckanext/example_iconfigurer/plugin.py

參考 CKAN Extensions Tutorial(v2.9):一個空的 CKAN extension,建立 ckanext-example_iconfigurer 擴充套件。

建立:ckanext-example_iconfigurer  

  1. 進入Python Virtual Environment:
    . /usr/lib/ckan/default/bin/activate
  2. 切換目錄
    cd /usr/lib/ckan/default/src 
  3. 執行 ckan generate extension,輸入:ckanext-example_iconfigurer。

撰寫 plugin 類別:ExampleIConfigurerPlugin

修改 ckanext-example_iconfigurer/ckanext/example_iconfigurer/plugin.py。參考完整程式,主要內容如下:

略...
import ckanext.example_iconfigurer.blueprint as blueprint

class ExampleIConfigurerPlugin(plugins.SingletonPlugin):
    略...

    plugins.implements(plugins.IConfigurer)
    plugins.implements(plugins.IBlueprint)

    # IConfigurer

    def update_config(self, config):
        # Add extension templates directory

        toolkit.add_template_directory(config, u'templates')
        # Add a new ckan-admin tabs for our extension
        toolkit.add_ckan_admin_tab(
            config, u'example_iconfigurer.config_one',
            u'My First Custom Config Tab'
        )
        toolkit.add_ckan_admin_tab(
            config, u'example_iconfigurer.config_two',
            u'My Second Custom Config Tab'
        )

撰寫 blueprint.py

參考完整程式,主要內容如下:

# encoding: utf-8

import ckan.lib.base as base
import ckan.lib.helpers as helpers
from flask import Blueprint
render = base.render

example_iconfigurer = Blueprint(u'example_iconfigurer', __name__)


def config_one():
    u'''Render the config template with the first custom title.'''

    return render(
        u'admin/myext_config.html',
        extra_vars={u'title': u'Custom Config Page A'}
    )


def config_two():
    u'''Render the config template with the second custom title.'''
    return render(
        u'admin/myext_config.html',
        extra_vars={u'title': u'Custom Config Page B'}
    )


def build_extra_admin_nav():
    u'''Return results of helpers.build_extra_admin_nav for testing.'''
    return helpers.build_extra_admin_nav()


example_iconfigurer.add_url_rule(
    u'/ckan-admin/myext_config_one', view_func=config_one
)
example_iconfigurer.add_url_rule(
    u'/ckan-admin/myext_config_two', view_func=config_two
)
example_iconfigurer.add_url_rule(
    u'/build_extra_admin_nav', view_func=build_extra_admin_nav
)

修改 setup.py:設定 entry_points

修改 ckanext-example_iconfigurer/setup.py 的 entry_points:

entry_points='''
        [ckan.plugins] 
        example_iconfigurer=ckanext.example_iconfigurer.plugin:ExampleIConfigurerPlugin

修改 ckan.ini:啟用 plugin

修改 /etc/ckan/default/ckan.ini。CKAN 的 extension plugins 必須加到 CKAN 設定檔的 ckan.plugins 中,CKAN 才會呼叫。

ckan.plugins = stats text_view 略... example_iconfigurer

安裝

  1. 進入Python Virtual Environment: 
    . /usr/lib/ckan/default/bin/activate
  2. 切換目錄:
    cd /usr/lib/ckan/default/src/example_iconfigurer
  3. 安裝 Plugin: 
    python setup.py develop
  4. 重啟 CKAN 服務:
    sudo supervisorctl restart ckan-uwsgi:*

測試

瀏覽 http://CKAN web site]/ckan-admin/ 可看到兩個新增的管理頁籤。




2022年5月17日 星期二

CKAN Route(2.9): Flask IBlueprint

參考 CKAN Extensions Tutorial(v2.9):一個空的 CKAN extension,建立 ckanext-example_flask_iblueprint 擴充套件。

建立:ckanext-example_flask_iblueprint  

  1. 進入Python Virtual Environment:
    . /usr/lib/ckan/default/bin/activate
  2. 切換目錄
    cd /usr/lib/ckan/default/src 
  3. 執行 ckan generate extension,輸入:ckanext-example_flask_iblueprint。

撰寫 plugin 類別:ExampleFlaskIBlueprintPlugin

修改 ckanext-example_flask_iblueprint/ckanext/example_flask_iblueprint/plugin.py。參考完整程式,主要內容如下:

class ExampleFlaskIBlueprintPlugin(p.SingletonPlugin):
    u'''
    An example IBlueprint plugin to demonstrate Flask routing from an
    extension.
    '''
    p.implements(p.IBlueprint)
    p.implements(p.IConfigurer)

    # IConfigurer

    def update_config(self, config):
        # Add extension templates directory
        p.toolkit.add_template_directory(config, u'templates')

    def get_blueprint(self):
        u'''Return a Flask Blueprint object to be registered by the app.'''

        # Create Blueprint for plugin
        blueprint = Blueprint(self.name, self.__module__)
        blueprint.template_folder = u'templates'
        # Add plugin url rules to Blueprint object
        rules = [
            (u'/hello_plugin', u'hello_plugin', hello_plugin),
            (u'/', u'home', override_flask_home),
            (u'/helper_not_here', u'helper_not_here', helper_not_here),
            (u'/helper', u'helper_here', helper_here),
            (u'/flask_request', u'flask_request', flask_request),
        ]
        for rule in rules:
            blueprint.add_url_rule(*rule)

        return blueprint

修改 setup.py:設定 entry_points

修改 ckanext-example_flask_iblueprint/setup.py 的 entry_points:

entry_points='''
        [ckan.plugins] 
        example_flask_iblueprint=ckanext.example_flask_iblueprint.plugin:ExampleFlaskIBlueprintPlugin

修改 ckan.ini:啟用 plugin

修改 /etc/ckan/default/ckan.ini。CKAN 的 extension plugins 必須加到 CKAN 設定檔的 ckan.plugins 中,CKAN 才會呼叫。

ckan.plugins = stats text_view 略... example_flask_iblueprint

安裝

  1. 進入Python Virtual Environment: 
    . /usr/lib/ckan/default/bin/activate
  2. 切換目錄:
    cd /usr/lib/ckan/default/src/example_flask_iblueprint
  3. 安裝 Plugin: 
    python setup.py develop
  4. 重啟 CKAN 服務:
    sudo supervisorctl restart ckan-uwsgi:*

測試

瀏覽 http://[CKAN web site] 下的 /, /hello_plugin, /helper, /helper_not_here, /flask_request 可看到對應的程式內容。