api.services.model_sheet

An Airtable Model as the commercial team reviews it: everything its sheet says (identity, descriptions, dimensions, photos, documents, its variations with their specifications and units in stock), and the fields they may correct from the app (specifications included).

Edits are explicit (one “Enregistrer” in the app) and checked against the values the app showed: a field changed in Airtable meanwhile is refused (409), never overwritten.

Attributes

Functions

read_sheet(at, model_id, variation_id, options[, ...]) → dict[str, Any]

The Model's sheet; options is catalog_lookup.load_options() (names

clean_value(key, value) → Any

The value to write, or ValueError with a message for the user.

update_model(at, model_id, changes, expected) → dict[str, Any]

Write changes (app keys) when Airtable still holds expected

attach_pdf(at, model_id, data, filename) → dict[str, Any]

Upload a PDF file to the Model's « Documentation » (Airtable's content

attach_document(at, model_id, field_key, url, filename) → dict[str, Any]

Add a document (by URL: Airtable downloads it) to one of the Model's

add_spec(at, variation_id, spec_type_id, valeur, unite) → dict[str, Any]

A new specification (an existing key) on the variation.

update_spec(at, spec_id, valeur, unite) → dict[str, Any]

delete_spec(at, spec_id) → None

Refused (409 variant_axis) for the spec that tells a variant apart.

Module Contents

api.services.model_sheet.MODEL_TABLE = 'Model'
api.services.model_sheet.VARIATION_TABLE = 'Variation'
api.services.model_sheet.SPEC_TABLE = 'Specification'
api.services.model_sheet.TEXT_FIELDS
api.services.model_sheet.NUMBER_FIELDS
api.services.model_sheet.FLAG_FIELDS
api.services.model_sheet.CHOICE_FIELDS
api.services.model_sheet.EDITABLE
api.services.model_sheet.DOCUMENT_FIELDS
api.services.model_sheet.MAX_ATTACHMENT_BYTES = 5242880
api.services.model_sheet.VERIFIED_FIELD = 'Vérification pour site'
api.services.model_sheet.STOCK_FORMULA = '{Statut commercial} != "Vendu"'
api.services.model_sheet.UNIT_PHOTOS_FIELD = 'Photos interne'
api.services.model_sheet.UNIT_CHUNK = 50
api.services.model_sheet.read_sheet(at: api.services.catalog_sync.AirtableGateway, model_id: str, variation_id: str | None, options: dict[str, Any], all_variations: bool = False) → dict[str, Any]

The Model’s sheet; options is catalog_lookup.load_options() (names of brands, types and specification keys). all_variations adds every variation with its specifications and its units in stock (the review).

api.services.model_sheet.clean_value(key: str, value: Any) → Any

The value to write, or ValueError with a message for the user.

api.services.model_sheet.update_model(at: api.services.catalog_sync.AirtableGateway, model_id: str, changes: dict[str, Any], expected: dict[str, Any]) → dict[str, Any]

Write changes (app keys) when Airtable still holds expected (the values the app showed) for each of them.

api.services.model_sheet.attach_pdf(at: api.services.catalog_sync.AttachmentGateway, model_id: str, data: bytes, filename: str) → dict[str, Any]

Upload a PDF file to the Model’s « Documentation » (Airtable’s content API: 5 MB max), unless a file of the same name is already there.

api.services.model_sheet.attach_document(at: api.services.catalog_sync.AirtableGateway, model_id: str, field_key: str, url: str, filename: str) → dict[str, Any]

Add a document (by URL: Airtable downloads it) to one of the Model’s document fields, keeping those already there; a file of the same name is not added twice.

api.services.model_sheet.add_spec(at: api.services.catalog_sync.AirtableGateway, variation_id: str, spec_type_id: str, valeur: Any, unite: Any) → dict[str, Any]

A new specification (an existing key) on the variation.

api.services.model_sheet.update_spec(at: api.services.catalog_sync.AirtableGateway, spec_id: str, valeur: Any, unite: Any) → dict[str, Any]
api.services.model_sheet.delete_spec(at: api.services.catalog_sync.AirtableGateway, spec_id: str) → None

Refused (409 variant_axis) for the spec that tells a variant apart.