Skip to content

ffl_core.item_options

Source: apps/ffl_core/ffl_core/item_options.py · 7 endpoint(s)

Generated by make api-docs — do not edit by hand.

create_item_with_options

POST /api/method/ffl_core.item_options.create_item_with_options

Auth (derived from code): Requires create permission on Item (Frappe DocType permission check).

Create an item that comes in options: the template Item, any missing options (Item

Attributes) and values, and one variant Item per included combination — all or nothing.

Each variant copies the template's shared fields once (group, brand, description, photos, tax and accounting defaults, flags) and has its own item code (its SKU), price (with the register's Item Price), cost and pre-order slots. The template keeps no price, cost, UPC or stock of its own.

arg type required default description
item — yes — The Item form's document (dict or JSON), as the form would save it. item_code is required.
options — yes — [{name, values: [value, ...]}] in order (1–3 options); values in the order the storefront lists them. Names and values are matched to existing ones ignoring case.
rows — yes — [{values: {option: value}, include, sku, price, cost, preorder, eta}] — one per combination; unticked rows (include 0) are skipped. An included row needs a SKU (letters, numbers and . _ / -, not an existing item code) and a price above 0.

Returns: {"template": the template's item code, "variants": [the variants' item codes]}.

Raises: ValidationError: Any row or option problem (all listed at once); nothing is written.

apps/ffl_core/ffl_core/item_options.py:393

group_items

POST /api/method/ffl_core.item_options.group_items

Auth (derived from code): Requires write permission on Item (Frappe DocType permission check).

Group existing Items under an item that comes in options, each with its option values,

keeping their item codes. Nothing is written when any Item fails a check.

arg type required default description
template string yes — The Item that comes in options.
variants — yes — {item_code: {option: value}} (dict or JSON); every option needs one of its existing values, and no two Items (nor an Item and an existing row) the same values.

Returns: {"ok", "errors": [one line per problem], "variants": [the item codes grouped]}.

apps/ffl_core/ffl_core/item_options.py:804

item_options_state

POST /api/method/ffl_core.item_options.item_options_state

Auth (derived from code): Requires read permission on Item (Frappe DocType permission check).

A saved item's options and one row per variant, for the Item form's panel.

arg type required default description
template string yes — The Item that comes in options.

Returns: {"template", "item_name", "preorder": whether pre-order fields exist, "options": [{name, values: [in storefront order], abbr: {value: abbreviation}}], "rows": [{item_code, item_name, values: {option: value}, disabled, price, cost, preorder, eta}]}.

apps/ffl_core/ffl_core/item_options.py:499

option_codes

POST /api/method/ffl_core.item_options.option_codes

Auth (derived from code): Requires read permission on Item (Frappe DocType permission check).

The short code each value of an option has, or will get when saved — what the Item form

builds default SKUs from.

arg type required default description
option string yes — The option (Item Attribute) name; it need not exist yet.
values — yes — The option's values in order (list or JSON).

Returns: {value: code} — an existing value's own code, a new value the code saving gives it.

apps/ffl_core/ffl_core/item_options.py:679

option_suggestions

POST /api/method/ffl_core.item_options.option_suggestions

Auth (derived from code): Requires read permission on Item (Frappe DocType permission check).

Existing option names, or one option's values, for the Item form's typeahead.

arg type required default description
option string | null no None An option (Item Attribute) name: its values are returned (in storefront order). Blank: option names.
txt string no '' What was typed (matched anywhere, ignoring case).
limit — no 20 At most this many (default 20, up to 500).

Returns: [{"value", "abbr"?}] — option names without abbreviations.

apps/ffl_core/ffl_core/item_options.py:650

taken_item_codes

POST /api/method/ffl_core.item_options.taken_item_codes

Auth (derived from code): Requires read permission on Item (Frappe DocType permission check).

Which of codes are already item codes (ignoring case) — the Item form's SKU check.

arg type required default description
codes — yes — Item codes (list or JSON), up to 500.

Returns: The ones that exist, as given.

apps/ffl_core/ffl_core/item_options.py:712

update_option_rows

POST /api/method/ffl_core.item_options.update_option_rows

Auth (derived from code): Requires write permission on Item (Frappe DocType permission check).

Save the panel of an item that comes in options: edits to existing rows, and new rows for

values added to its options — one transaction.

An existing row is saved through an ordinary Item save (so the website and GunBroker pushes run); a new price also becomes the register's price. Unticking a row disables that variant — never deletes it — and ticking it again enables it.

arg type required default description
template string yes — The Item that comes in options.
rows — yes — [{item_code, include?, price?, cost?, preorder?, eta?}] for existing rows (only the keys sent change), and [{values: {option: value}, include, sku, price, cost, preorder, eta}] for new combinations (created when included; same checks as :func:create_item_with_options).
options — no None [{name, values}] — the item's options in order with every value it shows, new ones included, in the order the storefront lists them (needed when new rows are sent; the option names can't change). Unused new values are kept on the option.

Returns: :func:item_options_state after the save, plus "created": the new variants' item codes.

apps/ffl_core/ffl_core/item_options.py:585